autumn-js 0.0.92-beta.1 → 0.0.92

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 (131) hide show
  1. package/dist/libraries/backend/better-auth.d.mts +33 -33
  2. package/dist/libraries/backend/better-auth.d.ts +33 -33
  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-ecz_wESO.d.mts → referralTypes-C_LRkLGP.d.mts} +18 -18
  6. package/dist/libraries/backend/{referralTypes-BAYl5TR1.d.ts → referralTypes-KJHGHDgD.d.ts} +18 -18
  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 +5 -5
  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 +9 -9
  15. package/dist/libraries/react/{ReactAutumnClient-BiipnfQn.d.mts → ReactAutumnClient-BmHGkNH1.d.mts} +5 -5
  16. package/dist/libraries/react/{ReactAutumnClient-BTNcA_3b.d.ts → ReactAutumnClient-PGnPqPkr.d.ts} +5 -5
  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 +10 -10
  20. package/dist/libraries/react/{chunk-TINC2IR4.mjs → chunk-6SDVW33H.mjs} +2 -2
  21. package/dist/libraries/react/{chunk-G3XBGOHR.mjs → chunk-DIJJCQ2N.mjs} +3 -3
  22. package/dist/libraries/react/{chunk-ITN754AD.mjs → chunk-HL4JNKWK.mjs} +1 -1
  23. package/dist/libraries/react/{chunk-67Y4DFV2.mjs → chunk-L3IZ2O3T.mjs} +3 -3
  24. package/dist/libraries/react/{chunk-TBKIB6DH.mjs → chunk-LPJSRHPQ.mjs} +1 -1
  25. package/dist/libraries/react/{chunk-SJAAUTL2.mjs → chunk-OGFFPM5T.mjs} +2 -2
  26. package/dist/libraries/react/{chunk-GK75OJJJ.mjs → chunk-PJK6OPCU.mjs} +2 -2
  27. package/dist/libraries/react/{chunk-3WP2MI55.mjs → chunk-RZW3QO6B.mjs} +2 -2
  28. package/dist/libraries/react/{chunk-6JOSRG5Z.mjs → chunk-SDZ5NW6G.mjs} +2 -2
  29. package/dist/libraries/react/{chunk-CHQRTGXF.mjs → chunk-TCCWWPEC.mjs} +2 -2
  30. package/dist/libraries/react/{chunk-4AYEAAQU.mjs → chunk-VH4FTCAC.mjs} +2 -2
  31. package/dist/libraries/react/{chunk-LKBUMRHE.mjs → chunk-Y6RO4AM2.mjs} +279 -279
  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 +4 -4
  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/client/types/clientGenTypes.d.mts +4 -4
  48. package/dist/libraries/react/client/types/clientGenTypes.d.ts +4 -4
  49. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.css +1271 -0
  50. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.mts +1 -1
  51. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.d.ts +1 -1
  52. package/dist/libraries/react/components/attach-dialog/attach-dialog-synced.mjs +20 -20
  53. package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.mts +1 -1
  54. package/dist/libraries/react/components/attach-dialog/lib/attach-content.d.ts +1 -1
  55. package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.mts +1 -1
  56. package/dist/libraries/react/components/check-dialog/check-dialog-synced.d.ts +1 -1
  57. package/dist/libraries/react/components/check-dialog/lib/check-content.d.mts +1 -1
  58. package/dist/libraries/react/components/check-dialog/lib/check-content.d.ts +1 -1
  59. package/dist/libraries/react/components/pricing-table/pricing-table-synced.css +1271 -0
  60. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
  61. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
  62. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +20 -20
  63. package/dist/libraries/react/{cusTypes-Bf1qr9iE.d.ts → cusTypes-WaPJKeAb.d.mts} +3 -3
  64. package/dist/libraries/react/{cusTypes-Bf1qr9iE.d.mts → cusTypes-WaPJKeAb.d.ts} +3 -3
  65. package/dist/libraries/react/{entTypes-O8YXxhrA.d.ts → entTypes-D01S8gFX.d.ts} +1 -1
  66. package/dist/libraries/react/{entTypes-CscyyE1A.d.mts → entTypes-aIV0QUCW.d.mts} +1 -1
  67. package/dist/libraries/react/hooks/handleAllowed.d.mts +2 -2
  68. package/dist/libraries/react/hooks/handleAllowed.d.ts +2 -2
  69. package/dist/libraries/react/hooks/useAutumn.d.mts +2 -2
  70. package/dist/libraries/react/hooks/useAutumn.d.ts +2 -2
  71. package/dist/libraries/react/hooks/useAutumn.mjs +8 -8
  72. package/dist/libraries/react/hooks/useAutumnBase.d.mts +4 -4
  73. package/dist/libraries/react/hooks/useAutumnBase.d.ts +4 -4
  74. package/dist/libraries/react/hooks/useAutumnBase.mjs +7 -7
  75. package/dist/libraries/react/hooks/useCustomer.d.mts +4 -4
  76. package/dist/libraries/react/hooks/useCustomer.d.ts +4 -4
  77. package/dist/libraries/react/hooks/useCustomer.mjs +9 -9
  78. package/dist/libraries/react/hooks/useCustomerBase.d.mts +4 -4
  79. package/dist/libraries/react/hooks/useCustomerBase.d.ts +4 -4
  80. package/dist/libraries/react/hooks/useCustomerBase.mjs +8 -8
  81. package/dist/libraries/react/hooks/useEntity.d.mts +3 -3
  82. package/dist/libraries/react/hooks/useEntity.d.ts +3 -3
  83. package/dist/libraries/react/hooks/useEntity.mjs +9 -9
  84. package/dist/libraries/react/hooks/useEntityBase.d.mts +4 -4
  85. package/dist/libraries/react/hooks/useEntityBase.d.ts +4 -4
  86. package/dist/libraries/react/hooks/useEntityBase.mjs +8 -8
  87. package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
  88. package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
  89. package/dist/libraries/react/hooks/usePricingTable.mjs +7 -7
  90. package/dist/libraries/react/hooks/usePricingTableBase.d.mts +4 -4
  91. package/dist/libraries/react/hooks/usePricingTableBase.d.ts +4 -4
  92. package/dist/libraries/react/hooks/usePricingTableBase.mjs +6 -6
  93. package/dist/libraries/react/hooks/useProductsBase.mjs +5 -5
  94. package/dist/libraries/react/index.js +25 -0
  95. package/dist/libraries/react/index.mjs +25 -0
  96. package/dist/libraries/react/{response-CDZ_R5pb.d.mts → response-Bt5OMm4y.d.mts} +1 -1
  97. package/dist/libraries/react/{response-BHqAAnND.d.ts → response-CvPzWrT9.d.ts} +1 -1
  98. package/dist/next/client/NextAutumnClient.d.mts +11 -11
  99. package/dist/next/client/NextAutumnClient.d.ts +11 -11
  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-B28imYzT.d.mts → clientGenTypes-BPjTbeG-.d.mts} +19 -19
  103. package/dist/next/client/{clientGenTypes-D46edNj5.d.ts → clientGenTypes-Bqecpl58.d.ts} +19 -19
  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/{entTypes-CJx3GLTt.d.mts → entTypes-B-2_9hzP.d.mts} +1 -1
  107. package/dist/next/client/{entTypes-qYfQsZ9u.d.ts → entTypes-Dq2mbehl.d.ts} +1 -1
  108. package/dist/next/client/hooks/useAutumn.d.mts +2 -2
  109. package/dist/next/client/hooks/useAutumn.d.ts +2 -2
  110. package/dist/next/client/hooks/useCustomer.d.mts +3 -3
  111. package/dist/next/client/hooks/useCustomer.d.ts +3 -3
  112. package/dist/next/client/hooks/useEntity.d.mts +3 -3
  113. package/dist/next/client/hooks/useEntity.d.ts +3 -3
  114. package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
  115. package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
  116. package/dist/next/client/types.d.mts +2 -2
  117. package/dist/next/client/types.d.ts +2 -2
  118. package/dist/next/server/auth/withNextAuth.d.mts +1 -1
  119. package/dist/next/server/auth/withNextAuth.d.ts +1 -1
  120. package/dist/next/server/componentActions.d.mts +1 -1
  121. package/dist/next/server/componentActions.d.ts +1 -1
  122. package/dist/next/server/cusActions.d.mts +5 -5
  123. package/dist/next/server/cusActions.d.ts +5 -5
  124. package/dist/next/server/genActions.d.mts +1 -1
  125. package/dist/next/server/genActions.d.ts +1 -1
  126. package/package.json +1 -1
  127. package/dist/libraries/react/{chunk-QAHVMSK4.mjs → chunk-NCPXL3J2.mjs} +13 -13
  128. package/dist/next/client/{cusTypes-CGXuXu_Y.d.mts → cusTypes-D8lhXGaX.d.mts} +2 -2
  129. package/dist/next/client/{cusTypes-CGXuXu_Y.d.ts → cusTypes-D8lhXGaX.d.ts} +2 -2
  130. package/dist/next/server/{cusTypes-H4mqijcm.d.mts → cusTypes-C86FOl99.d.mts} +2 -2
  131. package/dist/next/server/{cusTypes-H4mqijcm.d.ts → cusTypes-C86FOl99.d.ts} +2 -2
@@ -1,11 +1,18 @@
1
1
  "use client";
2
2
 
3
+ import {
4
+ Switch
5
+ } from "./chunk-CMO5LYYU.mjs";
3
6
  import {
4
7
  getPricingTableContent
5
8
  } from "./chunk-QBBE72EF.mjs";
6
9
  import {
7
10
  getAttachContent
8
11
  } from "./chunk-BCMBFJ7E.mjs";
12
+ import {
13
+ loadingStyles,
14
+ spinnerStyles
15
+ } from "./chunk-WVKYZYFT.mjs";
9
16
  import {
10
17
  Button
11
18
  } from "./chunk-P2O4LZFD.mjs";
@@ -18,252 +25,34 @@ import {
18
25
  DialogTitle,
19
26
  LoaderCircle
20
27
  } from "./chunk-5FZ7IV6P.mjs";
21
- import {
22
- Switch
23
- } from "./chunk-CMO5LYYU.mjs";
24
- import {
25
- loadingStyles,
26
- spinnerStyles
27
- } from "./chunk-WVKYZYFT.mjs";
28
- import {
29
- useCustomer
30
- } from "./chunk-4AYEAAQU.mjs";
31
28
  import {
32
29
  usePricingTable
33
- } from "./chunk-GK75OJJJ.mjs";
30
+ } from "./chunk-PJK6OPCU.mjs";
34
31
  import {
35
32
  cn
36
33
  } from "./chunk-4J6OC4ZQ.mjs";
37
-
38
- // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
39
- import React2 from "react";
34
+ import {
35
+ useCustomer
36
+ } from "./chunk-VH4FTCAC.mjs";
40
37
 
41
38
  // src/libraries/react/components/attach-dialog/attach-dialog-synced.tsx
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
- };
39
+ import { useEffect, useState as useState2 } from "react";
252
40
 
253
41
  // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
254
- import { createContext, useContext, useState as useState2 } from "react";
255
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
42
+ import React from "react";
43
+ import { createContext, useContext, useState } from "react";
44
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
256
45
  function PricingTable({
257
46
  productDetails
258
47
  }) {
259
48
  const { attach } = useCustomer();
260
- const [isAnnual, setIsAnnual] = useState2(false);
49
+ const [isAnnual, setIsAnnual] = useState(false);
261
50
  const { products, isLoading, error } = usePricingTable({ productDetails });
262
51
  if (isLoading) {
263
- return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
52
+ return /* @__PURE__ */ jsx("div", { style: loadingStyles, children: /* @__PURE__ */ jsx(LoaderCircle, { style: spinnerStyles }) });
264
53
  }
265
54
  if (error) {
266
- return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
55
+ return /* @__PURE__ */ jsx("div", { children: " Something went wrong..." });
267
56
  }
268
57
  const intervals = Array.from(
269
58
  new Set(
@@ -284,14 +73,14 @@ function PricingTable({
284
73
  }
285
74
  return true;
286
75
  };
287
- return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
76
+ return /* @__PURE__ */ jsx("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx(
288
77
  PricingTableContainer,
289
78
  {
290
79
  products,
291
80
  isAnnualToggle: isAnnual,
292
81
  setIsAnnualToggle: setIsAnnual,
293
82
  multiInterval,
294
- children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
83
+ children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx(
295
84
  PricingCard,
296
85
  {
297
86
  productId: product.id,
@@ -341,14 +130,14 @@ var PricingTableContainer = ({
341
130
  throw new Error("products is required in <PricingTable />");
342
131
  }
343
132
  if (products.length === 0) {
344
- return /* @__PURE__ */ jsx2(Fragment2, {});
133
+ return /* @__PURE__ */ jsx(Fragment, {});
345
134
  }
346
135
  const hasRecommended = products?.some((p) => p.display?.recommend_text);
347
- return /* @__PURE__ */ jsx2(
136
+ return /* @__PURE__ */ jsx(
348
137
  PricingTableContext.Provider,
349
138
  {
350
139
  value: { isAnnualToggle, setIsAnnualToggle, products, showFeatures },
351
- children: /* @__PURE__ */ jsxs2(
140
+ children: /* @__PURE__ */ jsxs(
352
141
  "div",
353
142
  {
354
143
  className: cn(
@@ -356,13 +145,13 @@ var PricingTableContainer = ({
356
145
  hasRecommended && "!au-py-10"
357
146
  ),
358
147
  children: [
359
- multiInterval && /* @__PURE__ */ jsx2(
148
+ multiInterval && /* @__PURE__ */ jsx(
360
149
  "div",
361
150
  {
362
151
  className: cn(
363
152
  products.some((p) => p.display?.recommend_text) && "au-mb-8"
364
153
  ),
365
- children: /* @__PURE__ */ jsx2(
154
+ children: /* @__PURE__ */ jsx(
366
155
  AnnualSwitch,
367
156
  {
368
157
  isAnnualToggle,
@@ -371,7 +160,7 @@ var PricingTableContainer = ({
371
160
  )
372
161
  }
373
162
  ),
374
- /* @__PURE__ */ jsx2(
163
+ /* @__PURE__ */ jsx(
375
164
  "div",
376
165
  {
377
166
  className: cn(
@@ -404,7 +193,7 @@ var PricingCard = ({
404
193
  primary_text: "Free"
405
194
  } : product.items[0].display;
406
195
  const featureItems = product.properties?.is_free ? product.items : product.items.slice(1);
407
- return /* @__PURE__ */ jsxs2(
196
+ return /* @__PURE__ */ jsxs(
408
197
  "div",
409
198
  {
410
199
  className: cn(
@@ -413,8 +202,8 @@ var PricingCard = ({
413
202
  className
414
203
  ),
415
204
  children: [
416
- productDisplay?.recommend_text && /* @__PURE__ */ jsx2(RecommendedBadge, { recommended: productDisplay?.recommend_text }),
417
- /* @__PURE__ */ jsxs2(
205
+ productDisplay?.recommend_text && /* @__PURE__ */ jsx(RecommendedBadge, { recommended: productDisplay?.recommend_text }),
206
+ /* @__PURE__ */ jsxs(
418
207
  "div",
419
208
  {
420
209
  className: cn(
@@ -422,19 +211,19 @@ var PricingCard = ({
422
211
  isRecommended && "lg:au-translate-y-6"
423
212
  ),
424
213
  children: [
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 }) })
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 }) })
430
219
  ] }),
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: [
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: [
432
221
  mainPriceDisplay?.primary_text,
433
222
  " ",
434
- mainPriceDisplay?.secondary_text && /* @__PURE__ */ jsx2("span", { className: "au-font-normal au-text-muted-foreground au-mt-1", children: mainPriceDisplay?.secondary_text })
223
+ mainPriceDisplay?.secondary_text && /* @__PURE__ */ jsx("span", { className: "au-font-normal au-text-muted-foreground au-mt-1", children: mainPriceDisplay?.secondary_text })
435
224
  ] }) }) })
436
225
  ] }),
437
- showFeatures && featureItems.length > 0 && /* @__PURE__ */ jsx2("div", { className: "au-flex-grow au-px-6 au-mb-6", children: /* @__PURE__ */ jsx2(
226
+ showFeatures && featureItems.length > 0 && /* @__PURE__ */ jsx("div", { className: "au-flex-grow au-px-6 au-mb-6", children: /* @__PURE__ */ jsx(
438
227
  PricingFeatureList,
439
228
  {
440
229
  items: featureItems,
@@ -443,11 +232,11 @@ var PricingCard = ({
443
232
  }
444
233
  ) })
445
234
  ] }),
446
- /* @__PURE__ */ jsx2(
235
+ /* @__PURE__ */ jsx(
447
236
  "div",
448
237
  {
449
238
  className: cn(" au-px-6 ", isRecommended && "lg:au--translate-y-12"),
450
- children: /* @__PURE__ */ jsx2(
239
+ children: /* @__PURE__ */ jsx(
451
240
  PricingCardButton,
452
241
  {
453
242
  recommended: productDisplay?.recommend_text ? true : false,
@@ -470,21 +259,21 @@ var PricingFeatureList = ({
470
259
  everythingFrom,
471
260
  className
472
261
  }) => {
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: [
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: [
475
264
  "Everything from ",
476
265
  everythingFrom,
477
266
  ", plus:"
478
267
  ] }),
479
- /* @__PURE__ */ jsx2("div", { className: "au-space-y-3", children: items.map((item, index) => /* @__PURE__ */ jsxs2(
268
+ /* @__PURE__ */ jsx("div", { className: "au-space-y-3", children: items.map((item, index) => /* @__PURE__ */ jsxs(
480
269
  "div",
481
270
  {
482
271
  className: "au-flex au-items-start au-gap-2 au-text-sm",
483
272
  children: [
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 })
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 })
488
277
  ] })
489
278
  ]
490
279
  },
@@ -492,8 +281,8 @@ var PricingFeatureList = ({
492
281
  )) })
493
282
  ] });
494
283
  };
495
- var PricingCardButton = React2.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
496
- const [loading, setLoading] = useState2(false);
284
+ var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
285
+ const [loading, setLoading] = useState(false);
497
286
  const handleClick = async (e) => {
498
287
  setLoading(true);
499
288
  try {
@@ -504,7 +293,7 @@ var PricingCardButton = React2.forwardRef(({ recommended, children, className, o
504
293
  setLoading(false);
505
294
  }
506
295
  };
507
- return /* @__PURE__ */ jsx2(
296
+ return /* @__PURE__ */ jsx(
508
297
  Button,
509
298
  {
510
299
  className: cn(
@@ -516,14 +305,14 @@ var PricingCardButton = React2.forwardRef(({ recommended, children, className, o
516
305
  ref,
517
306
  disabled: loading || props.disabled,
518
307
  onClick: handleClick,
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" })
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" })
523
312
  ] }),
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" })
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" })
527
316
  ] })
528
317
  ] })
529
318
  }
@@ -534,9 +323,9 @@ var AnnualSwitch = ({
534
323
  isAnnualToggle,
535
324
  setIsAnnualToggle
536
325
  }) => {
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(
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(
540
329
  Switch,
541
330
  {
542
331
  id: "annual-billing",
@@ -544,14 +333,231 @@ var AnnualSwitch = ({
544
333
  onCheckedChange: setIsAnnualToggle
545
334
  }
546
335
  ),
547
- /* @__PURE__ */ jsx2("span", { className: "au-text-sm au-text-muted-foreground", children: "Annual" })
336
+ /* @__PURE__ */ jsx("span", { className: "au-text-sm au-text-muted-foreground", children: "Annual" })
548
337
  ] });
549
338
  };
550
339
  var RecommendedBadge = ({ recommended }) => {
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 });
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
+ );
552
552
  };
553
553
 
554
554
  export {
555
+ AttachDialog,
556
+ PriceItem,
557
+ OptionsInput,
558
+ QuantityInput,
559
+ TotalPrice,
560
+ PricingDialogButton,
555
561
  PricingTable,
556
562
  usePricingTableContext,
557
563
  PricingTableContainer,
@@ -559,11 +565,5 @@ export {
559
565
  PricingFeatureList,
560
566
  PricingCardButton,
561
567
  AnnualSwitch,
562
- RecommendedBadge,
563
- AttachDialog,
564
- PriceItem,
565
- OptionsInput,
566
- QuantityInput,
567
- TotalPrice,
568
- PricingDialogButton
568
+ RecommendedBadge
569
569
  };