autumn-js 0.1.2 → 0.1.3

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 (228) hide show
  1. package/dist/libraries/backend/better-auth.js +2 -2
  2. package/dist/libraries/backend/better-auth.mjs +7 -7
  3. package/dist/libraries/backend/{chunk-KYMRM3HV.mjs → chunk-3HEVKGSY.mjs} +1 -1
  4. package/dist/libraries/backend/{chunk-JARFSM7F.mjs → chunk-7Z2OYXN4.mjs} +1 -1
  5. package/dist/libraries/backend/{chunk-F4A665AR.mjs → chunk-NTPYEOME.mjs} +1 -1
  6. package/dist/libraries/backend/{chunk-UZ7WFRWB.mjs → chunk-P6KFNVAM.mjs} +6 -6
  7. package/dist/libraries/backend/{chunk-GVPYJINB.mjs → chunk-QVLMREDB.mjs} +1 -1
  8. package/dist/libraries/backend/{chunk-LYDMLZB7.mjs → chunk-TTNUEXHB.mjs} +2 -2
  9. package/dist/libraries/backend/{chunk-IG3DW6CW.mjs → chunk-Y63QWBQ6.mjs} +1 -1
  10. package/dist/libraries/backend/convex.js +2 -2
  11. package/dist/libraries/backend/convex.mjs +7 -7
  12. package/dist/libraries/backend/elysia.js +2 -2
  13. package/dist/libraries/backend/elysia.mjs +7 -7
  14. package/dist/libraries/backend/express.d.mts +1 -1
  15. package/dist/libraries/backend/express.d.ts +1 -1
  16. package/dist/libraries/backend/express.js +2 -2
  17. package/dist/libraries/backend/express.mjs +7 -7
  18. package/dist/libraries/backend/fastify.js +2 -2
  19. package/dist/libraries/backend/fastify.mjs +7 -7
  20. package/dist/libraries/backend/hono.js +2 -2
  21. package/dist/libraries/backend/hono.mjs +7 -7
  22. package/dist/libraries/backend/index.d.mts +1 -1
  23. package/dist/libraries/backend/index.d.ts +1 -1
  24. package/dist/libraries/backend/index.js +2 -2
  25. package/dist/libraries/backend/index.mjs +7 -7
  26. package/dist/libraries/backend/next.js +2 -2
  27. package/dist/libraries/backend/next.mjs +7 -7
  28. package/dist/libraries/backend/react-router.js +2 -2
  29. package/dist/libraries/backend/react-router.mjs +7 -7
  30. package/dist/libraries/backend/{referralTypes-DA9Hp6Bm.d.mts → referralTypes-BfrNJ62q.d.mts} +6 -6
  31. package/dist/libraries/backend/{referralTypes-C4KG2r29.d.ts → referralTypes-Djyi4iGt.d.ts} +6 -6
  32. package/dist/libraries/backend/remix_dep.js +2 -2
  33. package/dist/libraries/backend/remix_dep.mjs +7 -7
  34. package/dist/libraries/backend/routes/backendRouter.js +2 -2
  35. package/dist/libraries/backend/routes/backendRouter.mjs +7 -7
  36. package/dist/libraries/backend/routes/entityRoutes.js +2 -2
  37. package/dist/libraries/backend/routes/entityRoutes.mjs +3 -3
  38. package/dist/libraries/backend/routes/genRoutes.js +2 -2
  39. package/dist/libraries/backend/routes/genRoutes.mjs +3 -3
  40. package/dist/libraries/backend/routes/productRoutes.js +2 -2
  41. package/dist/libraries/backend/routes/productRoutes.mjs +3 -3
  42. package/dist/libraries/backend/routes/referralRoutes.js +2 -2
  43. package/dist/libraries/backend/routes/referralRoutes.mjs +3 -3
  44. package/dist/libraries/backend/supabase.js +2 -2
  45. package/dist/libraries/backend/supabase.mjs +7 -7
  46. package/dist/libraries/backend/tanstack.js +2 -2
  47. package/dist/libraries/backend/tanstack.mjs +7 -7
  48. package/dist/libraries/backend/utils/backendRes.js +2 -2
  49. package/dist/libraries/backend/utils/backendRes.mjs +1 -1
  50. package/dist/libraries/backend/utils/withAuth.d.mts +1 -1
  51. package/dist/libraries/backend/utils/withAuth.d.ts +1 -1
  52. package/dist/libraries/backend/utils/withAuth.js +2 -2
  53. package/dist/libraries/backend/utils/withAuth.mjs +2 -2
  54. package/dist/libraries/react/AutumnContext.d.mts +6 -6
  55. package/dist/libraries/react/AutumnContext.d.ts +6 -6
  56. package/dist/libraries/react/AutumnContext.js +2 -2
  57. package/dist/libraries/react/AutumnContext.mjs +3 -3
  58. package/dist/libraries/react/BaseAutumnProvider.d.mts +6 -6
  59. package/dist/libraries/react/BaseAutumnProvider.d.ts +6 -6
  60. package/dist/libraries/react/BaseAutumnProvider.js +2 -2
  61. package/dist/libraries/react/BaseAutumnProvider.mjs +8 -8
  62. package/dist/libraries/react/{ReactAutumnClient-DM5ZRTfX.d.ts → ReactAutumnClient-1LBbQRfF.d.ts} +5 -5
  63. package/dist/libraries/react/{ReactAutumnClient-BHjd9Tw5.d.mts → ReactAutumnClient-MbC7QLTg.d.mts} +5 -5
  64. package/dist/libraries/react/ReactAutumnProvider.d.mts +2 -2
  65. package/dist/libraries/react/ReactAutumnProvider.d.ts +2 -2
  66. package/dist/libraries/react/ReactAutumnProvider.js +2 -2
  67. package/dist/libraries/react/ReactAutumnProvider.mjs +9 -9
  68. package/dist/libraries/react/{attachTypes-Bz1_JTvk.d.ts → attachTypes-CcB6xjSF.d.ts} +1 -1
  69. package/dist/{next/client/attachTypes-CAvqbMDV.d.mts → libraries/react/attachTypes-DqUN3q8s.d.mts} +5 -5
  70. package/dist/libraries/react/{chunk-KIKDDSHG.mjs → chunk-3LPB3X5R.mjs} +460 -462
  71. package/dist/libraries/react/{chunk-G2GXS74H.mjs → chunk-3VVUDAFB.mjs} +3 -3
  72. package/dist/libraries/react/{chunk-6D7DZEP5.mjs → chunk-AIOLZ3SJ.mjs} +2 -2
  73. package/dist/libraries/react/{chunk-JZQQJNF6.mjs → chunk-BNG6GVPA.mjs} +3 -3
  74. package/dist/libraries/react/{chunk-KVTXABQL.mjs → chunk-CSTUBIO7.mjs} +1 -1
  75. package/dist/libraries/react/{chunk-SRYI4NMF.mjs → chunk-EK2RMWXP.mjs} +2 -2
  76. package/dist/libraries/react/{chunk-5K2M3CQZ.mjs → chunk-FEISQQNM.mjs} +1 -1
  77. package/dist/libraries/react/{chunk-4V7CDINI.mjs → chunk-FEVS5X3L.mjs} +3 -3
  78. package/dist/libraries/react/{chunk-BXMZYHE7.mjs → chunk-FJWZPMWU.mjs} +3 -3
  79. package/dist/libraries/react/{chunk-WT5K3J2K.mjs → chunk-I2A7PK2L.mjs} +17 -17
  80. package/dist/libraries/react/{chunk-O2GKDKV5.mjs → chunk-J3JS4DDB.mjs} +1 -1
  81. package/dist/libraries/react/{chunk-YCDNQZT5.mjs → chunk-JGDTNJTR.mjs} +2 -2
  82. package/dist/libraries/react/{chunk-M7SUFZ42.mjs → chunk-KUS3X33V.mjs} +1 -1
  83. package/dist/libraries/react/{chunk-F52BIZ4N.mjs → chunk-KZVVSY52.mjs} +2 -2
  84. package/dist/libraries/react/{chunk-MN66ZM7X.mjs → chunk-OTZ65PCT.mjs} +6 -6
  85. package/dist/libraries/react/{chunk-YI6OTBFN.mjs → chunk-PGU4IXT7.mjs} +1 -1
  86. package/dist/libraries/react/{chunk-S75NZSTG.mjs → chunk-QV6Q2XXO.mjs} +1 -1
  87. package/dist/libraries/react/{chunk-C5OYITSR.mjs → chunk-S6UKPOYV.mjs} +1 -1
  88. package/dist/libraries/react/{chunk-B7RO2OAP.mjs → chunk-TJMYXANS.mjs} +1 -1
  89. package/dist/libraries/react/{chunk-GKHVCED5.mjs → chunk-V3S3AWOQ.mjs} +2 -2
  90. package/dist/libraries/react/{chunk-NOUNCJRC.mjs → chunk-VF6ARZ6T.mjs} +2 -2
  91. package/dist/libraries/react/{chunk-JOAOLY2Z.mjs → chunk-W5XUD2S6.mjs} +1 -1
  92. package/dist/libraries/react/{chunk-NHDZWWMZ.mjs → chunk-YWQTQ72B.mjs} +2 -2
  93. package/dist/libraries/react/client/ReactAutumnClient.d.mts +6 -6
  94. package/dist/libraries/react/client/ReactAutumnClient.d.ts +6 -6
  95. package/dist/libraries/react/client/ReactAutumnClient.js +2 -2
  96. package/dist/libraries/react/client/ReactAutumnClient.mjs +2 -2
  97. package/dist/libraries/react/client/clientCompMethods.d.mts +6 -6
  98. package/dist/libraries/react/client/clientCompMethods.d.ts +6 -6
  99. package/dist/libraries/react/client/clientCusMethods.d.mts +6 -6
  100. package/dist/libraries/react/client/clientCusMethods.d.ts +6 -6
  101. package/dist/libraries/react/client/clientEntityMethods.d.mts +6 -6
  102. package/dist/libraries/react/client/clientEntityMethods.d.ts +6 -6
  103. package/dist/libraries/react/client/clientGenMethods.d.mts +6 -6
  104. package/dist/libraries/react/client/clientGenMethods.d.ts +6 -6
  105. package/dist/libraries/react/client/clientProdMethods.d.mts +6 -6
  106. package/dist/libraries/react/client/clientProdMethods.d.ts +6 -6
  107. package/dist/libraries/react/client/clientReferralMethods.d.mts +6 -6
  108. package/dist/libraries/react/client/clientReferralMethods.d.ts +6 -6
  109. package/dist/libraries/react/client/types/clientGenTypes.js +2 -2
  110. package/dist/libraries/react/client/types/clientGenTypes.mjs +1 -1
  111. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.mts +2 -2
  112. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.d.ts +2 -2
  113. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.js +2 -2
  114. package/dist/libraries/react/components/checkout-dialog/checkout-dialog-synced.mjs +27 -27
  115. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.mts +2 -2
  116. package/dist/libraries/react/components/checkout-dialog/lib/checkout-content.d.ts +2 -2
  117. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.mts +1 -1
  118. package/dist/libraries/react/components/paywall-dialog/lib/paywall-content.d.ts +1 -1
  119. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.js +2 -2
  120. package/dist/libraries/react/components/paywall-dialog/paywall-dialog-synced.mjs +27 -27
  121. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.mts +1 -1
  122. package/dist/libraries/react/components/pricing-table/lib/pricing-table-content.d.ts +1 -1
  123. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.mts +1 -1
  124. package/dist/libraries/react/components/pricing-table/pricing-table-synced.d.ts +1 -1
  125. package/dist/libraries/react/components/pricing-table/pricing-table-synced.js +2 -2
  126. package/dist/libraries/react/components/pricing-table/pricing-table-synced.mjs +27 -27
  127. package/dist/libraries/react/components/ui/accordion.mjs +3 -3
  128. package/dist/libraries/react/components/ui/button.d.mts +1 -1
  129. package/dist/libraries/react/components/ui/button.d.ts +1 -1
  130. package/dist/libraries/react/components/ui/dialog.mjs +4 -4
  131. package/dist/libraries/react/components/ui/popover.mjs +5 -5
  132. package/dist/libraries/react/components/ui/switch.mjs +3 -3
  133. package/dist/libraries/react/{cusTypes-yJ0fSxbq.d.ts → cusTypes-BeSXIQ6P.d.ts} +3 -3
  134. package/dist/libraries/react/{cusTypes-DT-gAUL9.d.mts → cusTypes-DbCQV8Sj.d.mts} +3 -3
  135. package/dist/libraries/react/{entTypes-BPdjCunj.d.ts → entTypes-0CBBecul.d.ts} +1 -1
  136. package/dist/libraries/react/{entTypes-D79XPrxo.d.mts → entTypes-kVUQcah5.d.mts} +1 -1
  137. package/dist/libraries/react/{genTypes-DJUAkD36.d.ts → genTypes-DsiuvyWS.d.ts} +1 -1
  138. package/dist/libraries/react/{genTypes-BV-Jc6Q1.d.mts → genTypes-fEH_nqSm.d.mts} +1 -1
  139. package/dist/libraries/react/hooks/helpers/handleCheck.d.mts +6 -6
  140. package/dist/libraries/react/hooks/helpers/handleCheck.d.ts +6 -6
  141. package/dist/libraries/react/hooks/helpers/handleCheck.js +2 -2
  142. package/dist/libraries/react/hooks/helpers/handleCheck.mjs +2 -2
  143. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.mts +6 -6
  144. package/dist/libraries/react/hooks/helpers/useAutumnBase.d.ts +6 -6
  145. package/dist/libraries/react/hooks/helpers/useAutumnBase.js +2 -2
  146. package/dist/libraries/react/hooks/helpers/useAutumnBase.mjs +3 -3
  147. package/dist/libraries/react/hooks/useAnalytics.d.mts +2 -2
  148. package/dist/libraries/react/hooks/useAnalytics.d.ts +2 -2
  149. package/dist/libraries/react/hooks/useAnalytics.js +2 -2
  150. package/dist/libraries/react/hooks/useAnalytics.mjs +4 -4
  151. package/dist/libraries/react/hooks/useCustomer.d.mts +6 -6
  152. package/dist/libraries/react/hooks/useCustomer.d.ts +6 -6
  153. package/dist/libraries/react/hooks/useCustomer.js +2 -2
  154. package/dist/libraries/react/hooks/useCustomer.mjs +8 -8
  155. package/dist/libraries/react/hooks/useCustomerBase.d.mts +6 -6
  156. package/dist/libraries/react/hooks/useCustomerBase.d.ts +6 -6
  157. package/dist/libraries/react/hooks/useCustomerBase.js +2 -2
  158. package/dist/libraries/react/hooks/useCustomerBase.mjs +7 -7
  159. package/dist/libraries/react/hooks/useEntity.d.mts +6 -6
  160. package/dist/libraries/react/hooks/useEntity.d.ts +6 -6
  161. package/dist/libraries/react/hooks/useEntity.js +2 -2
  162. package/dist/libraries/react/hooks/useEntity.mjs +8 -8
  163. package/dist/libraries/react/hooks/useEntityBase.d.mts +8 -8
  164. package/dist/libraries/react/hooks/useEntityBase.d.ts +8 -8
  165. package/dist/libraries/react/hooks/useEntityBase.js +2 -2
  166. package/dist/libraries/react/hooks/useEntityBase.mjs +7 -7
  167. package/dist/libraries/react/hooks/usePaywall.d.mts +1 -1
  168. package/dist/libraries/react/hooks/usePaywall.d.ts +1 -1
  169. package/dist/libraries/react/hooks/usePaywall.js +2 -2
  170. package/dist/libraries/react/hooks/usePaywall.mjs +4 -4
  171. package/dist/libraries/react/hooks/usePricingTable.d.mts +1 -1
  172. package/dist/libraries/react/hooks/usePricingTable.d.ts +1 -1
  173. package/dist/libraries/react/hooks/usePricingTable.js +2 -2
  174. package/dist/libraries/react/hooks/usePricingTable.mjs +5 -5
  175. package/dist/libraries/react/hooks/usePricingTableBase.d.mts +6 -6
  176. package/dist/libraries/react/hooks/usePricingTableBase.d.ts +6 -6
  177. package/dist/libraries/react/hooks/usePricingTableBase.js +2 -2
  178. package/dist/libraries/react/hooks/usePricingTableBase.mjs +2 -2
  179. package/dist/libraries/react/hooks/useProductsBase.d.mts +6 -6
  180. package/dist/libraries/react/hooks/useProductsBase.d.ts +6 -6
  181. package/dist/libraries/react/index.js +2 -2
  182. package/dist/libraries/react/index.mjs +2 -2
  183. package/dist/libraries/react/{prodTypes-2tlu9Pyz.d.mts → prodTypes--VvnyGlN.d.mts} +1 -1
  184. package/dist/libraries/react/{prodTypes-2tlu9Pyz.d.ts → prodTypes--VvnyGlN.d.ts} +1 -1
  185. package/dist/next/client/NextAutumnClient.d.mts +7 -7
  186. package/dist/next/client/NextAutumnClient.d.ts +7 -7
  187. package/dist/next/client/NextAutumnProvider.d.mts +2 -2
  188. package/dist/next/client/NextAutumnProvider.d.ts +2 -2
  189. package/dist/{libraries/react/attachTypes-C9FJTCo6.d.mts → next/client/attachTypes-DZFtFEmv.d.mts} +3 -3
  190. package/dist/next/client/{attachTypes-zg5EhNcS.d.ts → attachTypes-DxJ0LCjT.d.ts} +3 -3
  191. package/dist/next/client/{clientAttachTypes-DLh_8bIG.d.ts → clientAttachTypes-BXtfXB4v.d.ts} +3 -3
  192. package/dist/next/client/{clientAttachTypes-B-zWythK.d.mts → clientAttachTypes-qsdoMt_B.d.mts} +3 -3
  193. package/dist/next/client/clientUtils.d.mts +3 -3
  194. package/dist/next/client/clientUtils.d.ts +3 -3
  195. package/dist/next/client/{cusTypes-Crh2qzWb.d.ts → cusTypes-BHYpk8bK.d.ts} +5 -5
  196. package/dist/next/client/{cusTypes-XE8bnuf2.d.mts → cusTypes-Q54uLNO5.d.mts} +5 -5
  197. package/dist/next/client/{entTypes-BcoGsNYC.d.mts → entTypes-CHHBdhBK.d.mts} +1 -1
  198. package/dist/next/client/{entTypes-sKOZyw0N.d.ts → entTypes-vjIG3B1G.d.ts} +1 -1
  199. package/dist/next/client/hooks/useAutumn.d.mts +4 -4
  200. package/dist/next/client/hooks/useAutumn.d.ts +4 -4
  201. package/dist/next/client/hooks/useCustomer.d.mts +5 -5
  202. package/dist/next/client/hooks/useCustomer.d.ts +5 -5
  203. package/dist/next/client/hooks/useEntity.d.mts +4 -4
  204. package/dist/next/client/hooks/useEntity.d.ts +4 -4
  205. package/dist/next/client/hooks/usePricingTable.d.mts +1 -1
  206. package/dist/next/client/hooks/usePricingTable.d.ts +1 -1
  207. package/dist/next/client/types.d.mts +3 -3
  208. package/dist/next/client/types.d.ts +3 -3
  209. package/dist/next/server/auth/withNextAuth.d.mts +1 -1
  210. package/dist/next/server/auth/withNextAuth.d.ts +1 -1
  211. package/dist/next/server/componentActions.d.mts +1 -1
  212. package/dist/next/server/componentActions.d.ts +1 -1
  213. package/dist/next/server/cusActions.d.mts +1 -1
  214. package/dist/next/server/cusActions.d.ts +1 -1
  215. package/dist/next/server/{cusTypes-DUjCLJ7f.d.ts → cusTypes-DgoOZMIt.d.mts} +6 -6
  216. package/dist/next/server/{cusTypes-DUjCLJ7f.d.mts → cusTypes-DgoOZMIt.d.ts} +6 -6
  217. package/dist/next/server/genActions.d.mts +1 -1
  218. package/dist/next/server/genActions.d.ts +1 -1
  219. package/dist/sdk/index.d.mts +6 -6
  220. package/dist/sdk/index.d.ts +6 -6
  221. package/dist/sdk/index.js +2 -2
  222. package/dist/sdk/index.mjs +2 -2
  223. package/dist/utils/encryptUtils.js +2 -2
  224. package/dist/utils/encryptUtils.mjs +2 -2
  225. package/package.json +1 -1
  226. package/dist/libraries/react/{chunk-KWNH6C27.mjs → chunk-7TYAAD2T.mjs} +11 -11
  227. package/dist/next/client/{prodTypes-CER0agHK.d.mts → prodTypes-CxvB1YY3.d.mts} +2 -2
  228. package/dist/next/client/{prodTypes-CER0agHK.d.ts → prodTypes-CxvB1YY3.d.ts} +2 -2
@@ -4,14 +4,11 @@ import {
4
4
  getPaywallContent
5
5
  } from "./chunk-I5ZGIAIX.mjs";
6
6
  import {
7
- Button
8
- } from "./chunk-EV5RNY5U.mjs";
7
+ getCheckoutContent
8
+ } from "./chunk-BLM4DAAR.mjs";
9
9
  import {
10
- Dialog,
11
- DialogContent,
12
- DialogFooter,
13
- DialogTitle
14
- } from "./chunk-BXMZYHE7.mjs";
10
+ getPricingTableContent
11
+ } from "./chunk-URQMBRFZ.mjs";
15
12
  import {
16
13
  Input
17
14
  } from "./chunk-GUM4HIGI.mjs";
@@ -19,177 +16,488 @@ import {
19
16
  Popover,
20
17
  PopoverContent,
21
18
  PopoverTrigger
22
- } from "./chunk-MN66ZM7X.mjs";
19
+ } from "./chunk-OTZ65PCT.mjs";
23
20
  import {
24
21
  Switch
25
- } from "./chunk-NHDZWWMZ.mjs";
26
- import {
27
- getCheckoutContent
28
- } from "./chunk-BLM4DAAR.mjs";
22
+ } from "./chunk-YWQTQ72B.mjs";
29
23
  import {
30
- getPricingTableContent
31
- } from "./chunk-URQMBRFZ.mjs";
24
+ loadingStyles,
25
+ spinnerStyles
26
+ } from "./chunk-WVKYZYFT.mjs";
32
27
  import {
33
28
  Accordion,
34
29
  AccordionContent,
35
30
  AccordionItem,
36
31
  Header,
37
32
  Trigger2
38
- } from "./chunk-YCDNQZT5.mjs";
33
+ } from "./chunk-JGDTNJTR.mjs";
34
+ import {
35
+ Button
36
+ } from "./chunk-EV5RNY5U.mjs";
37
+ import {
38
+ Dialog,
39
+ DialogContent,
40
+ DialogFooter,
41
+ DialogTitle
42
+ } from "./chunk-FJWZPMWU.mjs";
39
43
  import {
40
44
  ArrowRight,
41
45
  ChevronDown,
42
46
  LoaderCircle
43
47
  } from "./chunk-QJPZFEVW.mjs";
44
- import {
45
- cn
46
- } from "./chunk-4J6OC4ZQ.mjs";
47
48
  import {
48
49
  usePaywall
49
- } from "./chunk-YI6OTBFN.mjs";
50
+ } from "./chunk-PGU4IXT7.mjs";
50
51
  import {
51
52
  usePricingTable
52
- } from "./chunk-6D7DZEP5.mjs";
53
+ } from "./chunk-AIOLZ3SJ.mjs";
53
54
  import {
54
- loadingStyles,
55
- spinnerStyles
56
- } from "./chunk-WVKYZYFT.mjs";
55
+ cn
56
+ } from "./chunk-4J6OC4ZQ.mjs";
57
57
  import {
58
58
  useCustomer
59
- } from "./chunk-GKHVCED5.mjs";
59
+ } from "./chunk-V3S3AWOQ.mjs";
60
60
 
61
61
  // src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
62
- import { useEffect, useState as useState2 } from "react";
63
-
64
- // src/libraries/react/components/paywall-dialog/paywall-dialog-synced.tsx
62
+ import { useEffect, useState } from "react";
65
63
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
66
- function PaywallDialog(params) {
67
- const { data: preview } = usePaywall({
68
- featureId: params?.featureId,
69
- entityId: params?.entityId
70
- });
71
- if (!params || !preview) {
64
+ var formatCurrency = ({
65
+ amount,
66
+ currency
67
+ }) => {
68
+ return new Intl.NumberFormat("en-US", {
69
+ style: "currency",
70
+ currency
71
+ }).format(amount);
72
+ };
73
+ function CheckoutDialog(params) {
74
+ const { attach } = useCustomer();
75
+ const [checkoutResult, setCheckoutResult] = useState(params?.checkoutResult);
76
+ useEffect(() => {
77
+ if (params.checkoutResult) {
78
+ setCheckoutResult(params.checkoutResult);
79
+ }
80
+ }, [params.checkoutResult]);
81
+ const [loading, setLoading] = useState(false);
82
+ if (!checkoutResult) {
72
83
  return /* @__PURE__ */ jsx(Fragment, {});
73
84
  }
74
85
  const { open, setOpen } = params;
75
- const { title, message } = getPaywallContent(preview);
86
+ const { title, message } = getCheckoutContent(checkoutResult);
87
+ const isFree = checkoutResult?.product.properties?.is_free;
88
+ const isPaid = isFree === false;
76
89
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm", children: [
77
- /* @__PURE__ */ jsx(DialogTitle, { className: cn("au-font-bold au-text-xl au-px-6"), children: title }),
78
- /* @__PURE__ */ jsx("div", { className: "au-px-6 au-my-2", children: message }),
79
- /* @__PURE__ */ jsx(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-mt-4 au-pl-6 au-pr-3 au-bg-secondary au-border-t", children: /* @__PURE__ */ jsx(
90
+ /* @__PURE__ */ jsx(DialogTitle, { className: "au-px-6 au-mb-1", children: title }),
91
+ /* @__PURE__ */ jsx("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
92
+ isPaid && checkoutResult && /* @__PURE__ */ jsx(
93
+ PriceInformation,
94
+ {
95
+ checkoutResult,
96
+ setCheckoutResult
97
+ }
98
+ ),
99
+ /* @__PURE__ */ jsx(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: /* @__PURE__ */ jsx(
80
100
  Button,
81
101
  {
82
102
  size: "sm",
83
- className: "au-font-medium au-shadow au-transition au-min-w-20",
84
103
  onClick: async () => {
104
+ setLoading(true);
105
+ const options = checkoutResult.options.map((option) => {
106
+ return {
107
+ featureId: option.feature_id,
108
+ quantity: option.quantity
109
+ };
110
+ });
111
+ await attach({
112
+ productId: checkoutResult.product.id,
113
+ options
114
+ });
85
115
  setOpen(false);
116
+ setLoading(false);
86
117
  },
87
- children: "Confirm"
118
+ disabled: loading,
119
+ className: "au-min-w-16 au-flex au-items-center au-gap-2",
120
+ 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" }) })
88
121
  }
89
122
  ) })
90
123
  ] }) });
91
124
  }
92
-
93
- // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
94
- import React from "react";
95
- import { createContext, useContext, useState } from "react";
96
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
97
- function PricingTable({
98
- productDetails
125
+ function PriceInformation({
126
+ checkoutResult,
127
+ setCheckoutResult
99
128
  }) {
100
- const { checkout } = useCustomer();
101
- const [isAnnual, setIsAnnual] = useState(false);
102
- const { products, isLoading, error } = usePricingTable({ productDetails });
103
- if (isLoading) {
104
- return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
105
- }
106
- if (error) {
107
- return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
108
- }
109
- const intervals = Array.from(
110
- new Set(
111
- products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
112
- )
129
+ return /* @__PURE__ */ jsxs("div", { className: "au-px-6 au-mb-4 au-flex au-flex-col au-gap-4", children: [
130
+ /* @__PURE__ */ jsx(
131
+ ProductItems,
132
+ {
133
+ checkoutResult,
134
+ setCheckoutResult
135
+ }
136
+ ),
137
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-2", children: [
138
+ checkoutResult?.has_prorations && checkoutResult.lines.length > 0 && /* @__PURE__ */ jsx(CheckoutLines, { checkoutResult }),
139
+ /* @__PURE__ */ jsx(DueAmounts, { checkoutResult })
140
+ ] })
141
+ ] });
142
+ }
143
+ function DueAmounts({ checkoutResult }) {
144
+ const { next_cycle, product } = checkoutResult;
145
+ const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
146
+ const hasUsagePrice = product.items.some(
147
+ (item) => item.usage_model === "pay_per_use"
113
148
  );
114
- const multiInterval = intervals.length > 1;
115
- const intervalFilter = (product) => {
116
- if (!product.properties?.interval_group) {
117
- return true;
118
- }
119
- if (multiInterval) {
120
- if (isAnnual) {
121
- return product.properties?.interval_group === "year";
122
- } else {
123
- return product.properties?.interval_group === "month";
149
+ const showNextCycle = next_cycle && next_cycle.total !== checkoutResult.total;
150
+ return /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-1", children: [
151
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
152
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("p", { className: "au-font-medium au-text-md", children: "Total due today" }) }),
153
+ /* @__PURE__ */ jsx("p", { className: "au-font-medium au-text-md", children: formatCurrency({
154
+ amount: checkoutResult?.total,
155
+ currency: checkoutResult?.currency
156
+ }) })
157
+ ] }),
158
+ showNextCycle && /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-text-muted-foreground", children: [
159
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
160
+ "Due next cycle (",
161
+ nextCycleAtStr,
162
+ ")"
163
+ ] }) }),
164
+ /* @__PURE__ */ jsxs("p", { className: "au-text-md", children: [
165
+ formatCurrency({
166
+ amount: next_cycle.total,
167
+ currency: checkoutResult?.currency
168
+ }),
169
+ hasUsagePrice && /* @__PURE__ */ jsx("span", { children: " + usage prices" })
170
+ ] })
171
+ ] })
172
+ ] });
173
+ }
174
+ function ProductItems({
175
+ checkoutResult,
176
+ setCheckoutResult
177
+ }) {
178
+ const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
179
+ const isOneOff = checkoutResult?.product.properties.is_one_off;
180
+ return /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-2", children: [
181
+ /* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: "Price" }),
182
+ checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
183
+ if (item.usage_model == "prepaid") {
184
+ return /* @__PURE__ */ jsx(
185
+ PrepaidItem,
186
+ {
187
+ item,
188
+ checkoutResult,
189
+ setCheckoutResult
190
+ },
191
+ index
192
+ );
124
193
  }
125
- }
126
- return true;
127
- };
128
- return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
129
- PricingTableContainer,
130
- {
131
- products,
132
- isAnnualToggle: isAnnual,
133
- setIsAnnualToggle: setIsAnnual,
134
- multiInterval,
135
- children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
136
- PricingCard,
194
+ if (isUpdateQuantity) {
195
+ return null;
196
+ }
197
+ return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
198
+ /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: item.feature ? item.feature.name : isOneOff ? "Price" : "Subscription" }),
199
+ /* @__PURE__ */ jsxs("p", { children: [
200
+ item.display?.primary_text,
201
+ " ",
202
+ item.display?.secondary_text
203
+ ] })
204
+ ] }, index);
205
+ })
206
+ ] });
207
+ }
208
+ function CheckoutLines({ checkoutResult }) {
209
+ return /* @__PURE__ */ jsx(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs(AccordionItem, { value: "total", className: "au-border-b-0", children: [
210
+ /* @__PURE__ */ jsx(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
211
+ /* @__PURE__ */ jsx("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
212
+ /* @__PURE__ */ jsx(
213
+ ChevronDown,
137
214
  {
138
- productId: product.id,
139
- buttonProps: {
140
- disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
141
- onClick: async () => {
142
- if (product.id) {
143
- await checkout({
144
- productId: product.id,
145
- dialog: CheckoutDialog
146
- });
147
- } else if (product.display?.button_url) {
148
- window.open(product.display?.button_url, "_blank");
149
- }
150
- }
151
- }
152
- },
153
- index
154
- ))
155
- }
156
- ) });
215
+ className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
216
+ size: 14
217
+ }
218
+ )
219
+ ] }) }),
220
+ /* @__PURE__ */ jsx(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
221
+ return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
222
+ /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: line.description }),
223
+ /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
224
+ style: "currency",
225
+ currency: checkoutResult?.currency
226
+ }).format(line.amount) })
227
+ ] }, index);
228
+ }) })
229
+ ] }) });
157
230
  }
158
- var PricingTableContext = createContext({
159
- isAnnualToggle: false,
160
- setIsAnnualToggle: () => {
161
- },
162
- products: [],
163
- showFeatures: true
164
- });
165
- var usePricingTableContext = (componentName) => {
166
- const context = useContext(PricingTableContext);
167
- if (context === void 0) {
168
- throw new Error(`${componentName} must be used within <PricingTable />`);
169
- }
170
- return context;
171
- };
172
- var PricingTableContainer = ({
173
- children,
174
- products,
175
- showFeatures = true,
231
+ function CustomAccordionTrigger({
176
232
  className,
177
- isAnnualToggle,
178
- setIsAnnualToggle,
179
- multiInterval
180
- }) => {
181
- if (!products) {
182
- throw new Error("products is required in <PricingTable />");
183
- }
184
- if (products.length === 0) {
185
- return /* @__PURE__ */ jsx2(Fragment2, {});
186
- }
187
- const hasRecommended = products?.some((p) => p.display?.recommend_text);
188
- return /* @__PURE__ */ jsx2(
189
- PricingTableContext.Provider,
233
+ children,
234
+ ...props
235
+ }) {
236
+ return /* @__PURE__ */ jsx(Header, { className: "au-flex", children: /* @__PURE__ */ jsx(
237
+ Trigger2,
190
238
  {
191
- value: { isAnnualToggle, setIsAnnualToggle, products, showFeatures },
192
- children: /* @__PURE__ */ jsxs2(
239
+ "data-slot": "accordion-trigger",
240
+ className: cn(
241
+ "focus-visible:au-border-ring focus-visible:au-ring-ring/50 au-flex au-flex-1 au-items-start au-justify-between au-gap-4 au-rounded-md au-py-4 au-text-left au-text-sm au-font-medium au-transition-all au-outline-none focus-visible:au-ring-[3px] disabled:au-pointer-events-none disabled:au-opacity-50 [&[data-state=open]_svg]:au-rotate-0",
242
+ className
243
+ ),
244
+ ...props,
245
+ children
246
+ }
247
+ ) });
248
+ }
249
+ var PrepaidItem = ({
250
+ item,
251
+ checkoutResult,
252
+ setCheckoutResult
253
+ }) => {
254
+ const { quantity = 0, billing_units: billingUnits = 1 } = item;
255
+ const [quantityInput, setQuantityInput] = useState(
256
+ (quantity / billingUnits).toString()
257
+ );
258
+ const { checkout } = useCustomer();
259
+ const [loading, setLoading] = useState(false);
260
+ const [open, setOpen] = useState(false);
261
+ const scenario = checkoutResult.product.scenario;
262
+ const handleSave = async () => {
263
+ setLoading(true);
264
+ try {
265
+ const newOptions = checkoutResult.options.filter((option) => option.feature_id !== item.feature_id).map((option) => {
266
+ return {
267
+ featureId: option.feature_id,
268
+ quantity: option.quantity
269
+ };
270
+ });
271
+ newOptions.push({
272
+ featureId: item.feature_id,
273
+ quantity: Number(quantityInput) * billingUnits
274
+ });
275
+ const { data, error } = await checkout({
276
+ productId: checkoutResult.product.id,
277
+ options: newOptions
278
+ });
279
+ if (error) {
280
+ console.error(error);
281
+ return;
282
+ }
283
+ setCheckoutResult(data);
284
+ } catch (error) {
285
+ console.error(error);
286
+ } finally {
287
+ setLoading(false);
288
+ setOpen(false);
289
+ }
290
+ };
291
+ const disableSelection = scenario === "renew";
292
+ return /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between", children: [
293
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2", children: [
294
+ /* @__PURE__ */ jsx("p", { className: "au-text-muted-foreground", children: item.feature?.name }),
295
+ /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
296
+ /* @__PURE__ */ jsxs(
297
+ PopoverTrigger,
298
+ {
299
+ className: cn(
300
+ "au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80",
301
+ disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
302
+ ),
303
+ disabled: disableSelection,
304
+ children: [
305
+ "Qty: ",
306
+ quantity,
307
+ /* @__PURE__ */ jsx(ChevronDown, { size: 12 })
308
+ ]
309
+ }
310
+ ),
311
+ /* @__PURE__ */ jsxs(
312
+ PopoverContent,
313
+ {
314
+ align: "start",
315
+ className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
316
+ children: [
317
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-flex-col au-gap-1", children: [
318
+ /* @__PURE__ */ jsx("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
319
+ /* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
320
+ item.display?.primary_text,
321
+ " ",
322
+ item.display?.secondary_text
323
+ ] })
324
+ ] }),
325
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-justify-between au-items-end", children: [
326
+ /* @__PURE__ */ jsxs("div", { className: "au-flex au-gap-2 au-items-center", children: [
327
+ /* @__PURE__ */ jsx(
328
+ Input,
329
+ {
330
+ className: "au-h-7 au-w-16 focus:!au-ring-2",
331
+ value: quantityInput,
332
+ onChange: (e) => setQuantityInput(e.target.value)
333
+ }
334
+ ),
335
+ /* @__PURE__ */ jsxs("p", { className: "au-text-muted-foreground", children: [
336
+ billingUnits > 1 && `x ${billingUnits} `,
337
+ item.feature?.name
338
+ ] })
339
+ ] }),
340
+ /* @__PURE__ */ jsx(
341
+ Button,
342
+ {
343
+ onClick: handleSave,
344
+ className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
345
+ disabled: loading,
346
+ children: loading ? /* @__PURE__ */ jsx(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
347
+ }
348
+ )
349
+ ] })
350
+ ]
351
+ }
352
+ )
353
+ ] })
354
+ ] }),
355
+ /* @__PURE__ */ jsxs("p", { children: [
356
+ item.display?.primary_text,
357
+ " ",
358
+ item.display?.secondary_text
359
+ ] })
360
+ ] });
361
+ };
362
+ var PriceItem = ({
363
+ children,
364
+ className,
365
+ ...props
366
+ }) => {
367
+ return /* @__PURE__ */ jsx(
368
+ "div",
369
+ {
370
+ className: cn(
371
+ "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",
372
+ className
373
+ ),
374
+ ...props,
375
+ children
376
+ }
377
+ );
378
+ };
379
+ var PricingDialogButton = ({
380
+ children,
381
+ size,
382
+ onClick,
383
+ disabled,
384
+ className
385
+ }) => {
386
+ return /* @__PURE__ */ jsxs(
387
+ Button,
388
+ {
389
+ onClick,
390
+ disabled,
391
+ size,
392
+ className: cn(className, "au-shadow-sm au-shadow-stone-400"),
393
+ children: [
394
+ children,
395
+ /* @__PURE__ */ jsx(ArrowRight, { className: "!au-h-3" })
396
+ ]
397
+ }
398
+ );
399
+ };
400
+
401
+ // src/libraries/react/components/pricing-table/pricing-table-synced.tsx
402
+ import React2 from "react";
403
+ import { createContext, useContext, useState as useState2 } from "react";
404
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
405
+ function PricingTable({
406
+ productDetails
407
+ }) {
408
+ const { checkout } = useCustomer();
409
+ const [isAnnual, setIsAnnual] = useState2(false);
410
+ const { products, isLoading, error } = usePricingTable({ productDetails });
411
+ if (isLoading) {
412
+ return /* @__PURE__ */ jsx2("div", { style: loadingStyles, children: /* @__PURE__ */ jsx2(LoaderCircle, { style: spinnerStyles }) });
413
+ }
414
+ if (error) {
415
+ return /* @__PURE__ */ jsx2("div", { children: " Something went wrong..." });
416
+ }
417
+ const intervals = Array.from(
418
+ new Set(
419
+ products?.map((p) => p.properties?.interval_group).filter((i) => !!i)
420
+ )
421
+ );
422
+ const multiInterval = intervals.length > 1;
423
+ const intervalFilter = (product) => {
424
+ if (!product.properties?.interval_group) {
425
+ return true;
426
+ }
427
+ if (multiInterval) {
428
+ if (isAnnual) {
429
+ return product.properties?.interval_group === "year";
430
+ } else {
431
+ return product.properties?.interval_group === "month";
432
+ }
433
+ }
434
+ return true;
435
+ };
436
+ return /* @__PURE__ */ jsx2("div", { className: cn("au-root"), children: products && /* @__PURE__ */ jsx2(
437
+ PricingTableContainer,
438
+ {
439
+ products,
440
+ isAnnualToggle: isAnnual,
441
+ setIsAnnualToggle: setIsAnnual,
442
+ multiInterval,
443
+ children: products.filter(intervalFilter).map((product, index) => /* @__PURE__ */ jsx2(
444
+ PricingCard,
445
+ {
446
+ productId: product.id,
447
+ buttonProps: {
448
+ disabled: product.scenario === "active" && !product.properties.updateable || product.scenario === "scheduled",
449
+ onClick: async () => {
450
+ if (product.id) {
451
+ await checkout({
452
+ productId: product.id,
453
+ dialog: CheckoutDialog
454
+ });
455
+ } else if (product.display?.button_url) {
456
+ window.open(product.display?.button_url, "_blank");
457
+ }
458
+ }
459
+ }
460
+ },
461
+ index
462
+ ))
463
+ }
464
+ ) });
465
+ }
466
+ var PricingTableContext = createContext({
467
+ isAnnualToggle: false,
468
+ setIsAnnualToggle: () => {
469
+ },
470
+ products: [],
471
+ showFeatures: true
472
+ });
473
+ var usePricingTableContext = (componentName) => {
474
+ const context = useContext(PricingTableContext);
475
+ if (context === void 0) {
476
+ throw new Error(`${componentName} must be used within <PricingTable />`);
477
+ }
478
+ return context;
479
+ };
480
+ var PricingTableContainer = ({
481
+ children,
482
+ products,
483
+ showFeatures = true,
484
+ className,
485
+ isAnnualToggle,
486
+ setIsAnnualToggle,
487
+ multiInterval
488
+ }) => {
489
+ if (!products) {
490
+ throw new Error("products is required in <PricingTable />");
491
+ }
492
+ if (products.length === 0) {
493
+ return /* @__PURE__ */ jsx2(Fragment2, {});
494
+ }
495
+ const hasRecommended = products?.some((p) => p.display?.recommend_text);
496
+ return /* @__PURE__ */ jsx2(
497
+ PricingTableContext.Provider,
498
+ {
499
+ value: { isAnnualToggle, setIsAnnualToggle, products, showFeatures },
500
+ children: /* @__PURE__ */ jsxs2(
193
501
  "div",
194
502
  {
195
503
  className: cn(
@@ -328,8 +636,8 @@ var PricingFeatureList = ({
328
636
  )) })
329
637
  ] });
330
638
  };
331
- var PricingCardButton = React.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
332
- const [loading, setLoading] = useState(false);
639
+ var PricingCardButton = React2.forwardRef(({ recommended, children, className, onClick, ...props }, ref) => {
640
+ const [loading, setLoading] = useState2(false);
333
641
  const handleClick = async (e) => {
334
642
  setLoading(true);
335
643
  try {
@@ -387,349 +695,37 @@ var RecommendedBadge = ({ recommended }) => {
387
695
  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 });
388
696
  };
389
697
 
390
- // src/libraries/react/components/checkout-dialog/checkout-dialog-synced.tsx
698
+ // src/libraries/react/components/paywall-dialog/paywall-dialog-synced.tsx
391
699
  import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
392
- var formatCurrency = ({
393
- amount,
394
- currency
395
- }) => {
396
- return new Intl.NumberFormat("en-US", {
397
- style: "currency",
398
- currency
399
- }).format(amount);
400
- };
401
- function CheckoutDialog(params) {
402
- const { attach } = useCustomer();
403
- const [checkoutResult, setCheckoutResult] = useState2(params?.checkoutResult);
404
- useEffect(() => {
405
- if (params.checkoutResult) {
406
- setCheckoutResult(params.checkoutResult);
407
- }
408
- }, [params.checkoutResult]);
409
- const [loading, setLoading] = useState2(false);
410
- if (!checkoutResult) {
700
+ function PaywallDialog(params) {
701
+ const { data: preview } = usePaywall({
702
+ featureId: params?.featureId,
703
+ entityId: params?.entityId
704
+ });
705
+ if (!params || !preview) {
411
706
  return /* @__PURE__ */ jsx3(Fragment3, {});
412
707
  }
413
708
  const { open, setOpen } = params;
414
- const { title, message } = getCheckoutContent(checkoutResult);
415
- const isFree = checkoutResult?.product.properties?.is_free;
416
- const isPaid = isFree === false;
709
+ const { title, message } = getPaywallContent(preview);
417
710
  return /* @__PURE__ */ jsx3(Dialog, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs3(DialogContent, { className: "au-p-0 au-pt-4 au-gap-0 au-text-foreground au-overflow-hidden au-text-sm", children: [
418
- /* @__PURE__ */ jsx3(DialogTitle, { className: "au-px-6 au-mb-1", children: title }),
419
- /* @__PURE__ */ jsx3("div", { className: "au-px-6 au-mt-1 au-mb-4 au-text-muted-foreground", children: message }),
420
- isPaid && checkoutResult && /* @__PURE__ */ jsx3(
421
- PriceInformation,
422
- {
423
- checkoutResult,
424
- setCheckoutResult
425
- }
426
- ),
427
- /* @__PURE__ */ jsx3(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: /* @__PURE__ */ jsx3(
711
+ /* @__PURE__ */ jsx3(DialogTitle, { className: cn("au-font-bold au-text-xl au-px-6"), children: title }),
712
+ /* @__PURE__ */ jsx3("div", { className: "au-px-6 au-my-2", children: message }),
713
+ /* @__PURE__ */ jsx3(DialogFooter, { className: "au-flex au-flex-col sm:au-flex-row au-justify-between au-gap-x-4 au-py-2 au-mt-4 au-pl-6 au-pr-3 au-bg-secondary au-border-t", children: /* @__PURE__ */ jsx3(
428
714
  Button,
429
715
  {
430
716
  size: "sm",
717
+ className: "au-font-medium au-shadow au-transition au-min-w-20",
431
718
  onClick: async () => {
432
- setLoading(true);
433
- const options = checkoutResult.options.map((option) => {
434
- return {
435
- featureId: option.feature_id,
436
- quantity: option.quantity
437
- };
438
- });
439
- await attach({
440
- productId: checkoutResult.product.id,
441
- options
442
- });
443
719
  setOpen(false);
444
- setLoading(false);
445
720
  },
446
- disabled: loading,
447
- className: "au-min-w-16 au-flex au-items-center au-gap-2",
448
- children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-w-4 au-h-4 au-animate-spin" }) : /* @__PURE__ */ jsx3(Fragment3, { children: /* @__PURE__ */ jsx3("span", { className: "au-whitespace-nowrap au-flex au-gap-1", children: "Confirm" }) })
721
+ children: "Confirm"
449
722
  }
450
723
  ) })
451
724
  ] }) });
452
725
  }
453
- function PriceInformation({
454
- checkoutResult,
455
- setCheckoutResult
456
- }) {
457
- return /* @__PURE__ */ jsxs3("div", { className: "au-px-6 au-mb-4 au-flex au-flex-col au-gap-4", children: [
458
- /* @__PURE__ */ jsx3(
459
- ProductItems,
460
- {
461
- checkoutResult,
462
- setCheckoutResult
463
- }
464
- ),
465
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
466
- checkoutResult?.has_prorations && checkoutResult.lines.length > 0 && /* @__PURE__ */ jsx3(CheckoutLines, { checkoutResult }),
467
- /* @__PURE__ */ jsx3(DueAmounts, { checkoutResult })
468
- ] })
469
- ] });
470
- }
471
- function DueAmounts({ checkoutResult }) {
472
- const { next_cycle, product } = checkoutResult;
473
- const nextCycleAtStr = next_cycle ? new Date(next_cycle.starts_at).toLocaleDateString() : void 0;
474
- const hasUsagePrice = product.items.some(
475
- (item) => item.usage_model === "pay_per_use"
476
- );
477
- const showNextCycle = next_cycle && next_cycle.total !== checkoutResult.total;
478
- return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
479
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
480
- /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: "Total due today" }) }),
481
- /* @__PURE__ */ jsx3("p", { className: "au-font-medium au-text-md", children: formatCurrency({
482
- amount: checkoutResult?.total,
483
- currency: checkoutResult?.currency
484
- }) })
485
- ] }),
486
- showNextCycle && /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-text-muted-foreground", children: [
487
- /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
488
- "Due next cycle (",
489
- nextCycleAtStr,
490
- ")"
491
- ] }) }),
492
- /* @__PURE__ */ jsxs3("p", { className: "au-text-md", children: [
493
- formatCurrency({
494
- amount: next_cycle.total,
495
- currency: checkoutResult?.currency
496
- }),
497
- hasUsagePrice && /* @__PURE__ */ jsx3("span", { children: " + usage prices" })
498
- ] })
499
- ] })
500
- ] });
501
- }
502
- function ProductItems({
503
- checkoutResult,
504
- setCheckoutResult
505
- }) {
506
- const isUpdateQuantity = checkoutResult?.product.scenario === "active" && checkoutResult.product.properties.updateable;
507
- const isOneOff = checkoutResult?.product.properties.is_one_off;
508
- return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-2", children: [
509
- /* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: "Price" }),
510
- checkoutResult?.product.items.filter((item) => item.type !== "feature").map((item, index) => {
511
- if (item.usage_model == "prepaid") {
512
- return /* @__PURE__ */ jsx3(
513
- PrepaidItem,
514
- {
515
- item,
516
- checkoutResult,
517
- setCheckoutResult
518
- },
519
- index
520
- );
521
- }
522
- if (isUpdateQuantity) {
523
- return null;
524
- }
525
- return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
526
- /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: item.feature ? item.feature.name : isOneOff ? "Price" : "Subscription" }),
527
- /* @__PURE__ */ jsxs3("p", { children: [
528
- item.display?.primary_text,
529
- " ",
530
- item.display?.secondary_text
531
- ] })
532
- ] }, index);
533
- })
534
- ] });
535
- }
536
- function CheckoutLines({ checkoutResult }) {
537
- return /* @__PURE__ */ jsx3(Accordion, { type: "single", collapsible: true, children: /* @__PURE__ */ jsxs3(AccordionItem, { value: "total", className: "au-border-b-0", children: [
538
- /* @__PURE__ */ jsx3(CustomAccordionTrigger, { className: "au-justify-between au-w-full au-my-0 au-py-0 au-border-none", children: /* @__PURE__ */ jsxs3("div", { className: "au-cursor-pointer au-flex au-items-center au-gap-1 au-w-full au-justify-end", children: [
539
- /* @__PURE__ */ jsx3("p", { className: "au-font-light au-text-muted-foreground", children: "View details" }),
540
- /* @__PURE__ */ jsx3(
541
- ChevronDown,
542
- {
543
- className: "au-text-muted-foreground au-mt-0.5 au-rotate-90 au-transition-transform au-duration-200 au-ease-in-out",
544
- size: 14
545
- }
546
- )
547
- ] }) }),
548
- /* @__PURE__ */ jsx3(AccordionContent, { className: "au-mt-2 au-mb-0 au-pb-2 au-flex au-flex-col au-gap-2", children: checkoutResult?.lines.filter((line) => line.amount != 0).map((line, index) => {
549
- return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
550
- /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: line.description }),
551
- /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: new Intl.NumberFormat("en-US", {
552
- style: "currency",
553
- currency: checkoutResult?.currency
554
- }).format(line.amount) })
555
- ] }, index);
556
- }) })
557
- ] }) });
558
- }
559
- function CustomAccordionTrigger({
560
- className,
561
- children,
562
- ...props
563
- }) {
564
- return /* @__PURE__ */ jsx3(Header, { className: "au-flex", children: /* @__PURE__ */ jsx3(
565
- Trigger2,
566
- {
567
- "data-slot": "accordion-trigger",
568
- className: cn(
569
- "focus-visible:au-border-ring focus-visible:au-ring-ring/50 au-flex au-flex-1 au-items-start au-justify-between au-gap-4 au-rounded-md au-py-4 au-text-left au-text-sm au-font-medium au-transition-all au-outline-none focus-visible:au-ring-[3px] disabled:au-pointer-events-none disabled:au-opacity-50 [&[data-state=open]_svg]:au-rotate-0",
570
- className
571
- ),
572
- ...props,
573
- children
574
- }
575
- ) });
576
- }
577
- var PrepaidItem = ({
578
- item,
579
- checkoutResult,
580
- setCheckoutResult
581
- }) => {
582
- const { quantity = 0, billing_units: billingUnits = 1 } = item;
583
- const [quantityInput, setQuantityInput] = useState2(
584
- (quantity / billingUnits).toString()
585
- );
586
- const { checkout } = useCustomer();
587
- const [loading, setLoading] = useState2(false);
588
- const [open, setOpen] = useState2(false);
589
- const scenario = checkoutResult.product.scenario;
590
- const handleSave = async () => {
591
- setLoading(true);
592
- try {
593
- const newOptions = checkoutResult.options.filter((option) => option.feature_id !== item.feature_id).map((option) => {
594
- return {
595
- featureId: option.feature_id,
596
- quantity: option.quantity
597
- };
598
- });
599
- newOptions.push({
600
- featureId: item.feature_id,
601
- quantity: Number(quantityInput) * billingUnits
602
- });
603
- const { data, error } = await checkout({
604
- productId: checkoutResult.product.id,
605
- options: newOptions
606
- });
607
- if (error) {
608
- console.error(error);
609
- return;
610
- }
611
- setCheckoutResult(data);
612
- } catch (error) {
613
- console.error(error);
614
- } finally {
615
- setLoading(false);
616
- setOpen(false);
617
- }
618
- };
619
- const disableSelection = scenario === "renew";
620
- return /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between", children: [
621
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2", children: [
622
- /* @__PURE__ */ jsx3("p", { className: "au-text-muted-foreground", children: item.feature?.name }),
623
- /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
624
- /* @__PURE__ */ jsxs3(
625
- PopoverTrigger,
626
- {
627
- className: cn(
628
- "au-text-muted-foreground au-text-xs au-px-1 au-py-0.5 au-rounded-md au-flex au-items-center au-gap-1 au-bg-accent/80",
629
- disableSelection !== true && "hover:au-bg-accent hover:au-text-foreground"
630
- ),
631
- disabled: disableSelection,
632
- children: [
633
- "Qty: ",
634
- quantity,
635
- /* @__PURE__ */ jsx3(ChevronDown, { size: 12 })
636
- ]
637
- }
638
- ),
639
- /* @__PURE__ */ jsxs3(
640
- PopoverContent,
641
- {
642
- align: "start",
643
- className: "au-w-80 au-text-sm au-p-4 au-pt-3 au-flex au-flex-col au-gap-4",
644
- children: [
645
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-flex-col au-gap-1", children: [
646
- /* @__PURE__ */ jsx3("p", { className: "au-text-sm au-font-medium", children: item.feature?.name }),
647
- /* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
648
- item.display?.primary_text,
649
- " ",
650
- item.display?.secondary_text
651
- ] })
652
- ] }),
653
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-justify-between au-items-end", children: [
654
- /* @__PURE__ */ jsxs3("div", { className: "au-flex au-gap-2 au-items-center", children: [
655
- /* @__PURE__ */ jsx3(
656
- Input,
657
- {
658
- className: "au-h-7 au-w-16 focus:!au-ring-2",
659
- value: quantityInput,
660
- onChange: (e) => setQuantityInput(e.target.value)
661
- }
662
- ),
663
- /* @__PURE__ */ jsxs3("p", { className: "au-text-muted-foreground", children: [
664
- billingUnits > 1 && `x ${billingUnits} `,
665
- item.feature?.name
666
- ] })
667
- ] }),
668
- /* @__PURE__ */ jsx3(
669
- Button,
670
- {
671
- onClick: handleSave,
672
- className: "au-w-14 !au-h-7 au-text-sm au-items-center au-bg-white au-text-foreground au-shadow-sm au-border au-border-zinc-200 hover:au-bg-zinc-100",
673
- disabled: loading,
674
- children: loading ? /* @__PURE__ */ jsx3(LoaderCircle, { className: "au-text-muted-foreground au-animate-spin !au-w-4 !au-h-4" }) : "Save"
675
- }
676
- )
677
- ] })
678
- ]
679
- }
680
- )
681
- ] })
682
- ] }),
683
- /* @__PURE__ */ jsxs3("p", { children: [
684
- item.display?.primary_text,
685
- " ",
686
- item.display?.secondary_text
687
- ] })
688
- ] });
689
- };
690
- var PriceItem = ({
691
- children,
692
- className,
693
- ...props
694
- }) => {
695
- return /* @__PURE__ */ jsx3(
696
- "div",
697
- {
698
- className: cn(
699
- "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",
700
- className
701
- ),
702
- ...props,
703
- children
704
- }
705
- );
706
- };
707
- var PricingDialogButton = ({
708
- children,
709
- size,
710
- onClick,
711
- disabled,
712
- className
713
- }) => {
714
- return /* @__PURE__ */ jsxs3(
715
- Button,
716
- {
717
- onClick,
718
- disabled,
719
- size,
720
- className: cn(className, "au-shadow-sm au-shadow-stone-400"),
721
- children: [
722
- children,
723
- /* @__PURE__ */ jsx3(ArrowRight, { className: "!au-h-3" })
724
- ]
725
- }
726
- );
727
- };
728
726
 
729
727
  export {
730
- CheckoutDialog,
731
- PriceItem,
732
- PricingDialogButton,
728
+ PaywallDialog,
733
729
  PricingTable,
734
730
  usePricingTableContext,
735
731
  PricingTableContainer,
@@ -738,5 +734,7 @@ export {
738
734
  PricingCardButton,
739
735
  AnnualSwitch,
740
736
  RecommendedBadge,
741
- PaywallDialog
737
+ CheckoutDialog,
738
+ PriceItem,
739
+ PricingDialogButton
742
740
  };