ghost 6.60.0 → 6.61.0

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 (399) hide show
  1. package/components/tryghost-adapter-base-scheduling-0.2.3.tgz +0 -0
  2. package/components/tryghost-adapter-base-sso-0.1.3.tgz +0 -0
  3. package/components/tryghost-custom-field-types-0.0.0.tgz +0 -0
  4. package/components/tryghost-kg-default-cards-10.3.5.tgz +0 -0
  5. package/core/boot.js +13 -4
  6. package/core/built/admin/assets/{Combination-gnJO3vIw.js → Combination-5fYEzgbs.js} +1 -1
  7. package/core/built/admin/assets/{PolarAngleAxis-C4qtHy1B.js → PolarAngleAxis-pkMyqz8g.js} +1 -1
  8. package/core/built/admin/assets/{RadialBarChart-Bh09Stsj.js → RadialBarChart-JAKoS4KT.js} +1 -1
  9. package/core/built/admin/assets/{about-BgpmhCuM.js → about-Bve7IJS2.js} +1 -1
  10. package/core/built/admin/assets/{account-migration-8qTEI1i1.js → account-migration-DRhAehfw.js} +1 -1
  11. package/core/built/admin/assets/{action-list-lGzZLHc8.js → action-list-C4v0-du8.js} +1 -1
  12. package/core/built/admin/assets/activitypub/{account-migration-DMHuPnJn.js → account-migration-C-aej4x_.js} +7 -7
  13. package/core/built/admin/assets/activitypub/activitypub.js +3 -4
  14. package/core/built/admin/assets/activitypub/{avatar-DhTo5D1B.js → avatar-DLPL3Abs.js} +59 -68
  15. package/core/built/admin/assets/activitypub/{avatar-flipboard-DnVgbEfa.js → avatar-flipboard-C9iDY-QV.js} +2 -2
  16. package/core/built/admin/assets/activitypub/{bluesky-sharing-BT4zAlW7.js → bluesky-sharing-BXkA5mqV.js} +8 -8
  17. package/core/built/admin/assets/activitypub/{content-formatters-BeDZ-DIa.js → content-formatters-CHcyMFk4.js} +17 -17
  18. package/core/built/admin/assets/activitypub/{copy-8sqxUuNd.js → copy-DIAOQoCZ.js} +2 -2
  19. package/core/built/admin/assets/activitypub/{domain-xQDDu1CS.js → domain-B3ihkPde.js} +8 -8
  20. package/core/built/admin/assets/activitypub/{edit-profile-BXdF_r2G.js → edit-profile-DsZM3rTX.js} +5 -5
  21. package/core/built/admin/assets/activitypub/{explore-CMt7gKlL.js → explore-BodNrZgR.js} +8 -8
  22. package/core/built/admin/assets/activitypub/{feed-Bwqdddp_.js → feed-PwH1iJ84.js} +9 -9
  23. package/core/built/admin/assets/activitypub/{field-4co_8FVg.js → field-D06-kmOJ.js} +3 -3
  24. package/core/built/admin/assets/activitypub/{hash-DwakMs4X.js → hash-Bm3WxYN4.js} +2 -2
  25. package/core/built/admin/assets/activitypub/{inbox-DQ5CwLma.js → inbox-BluD2ucT.js} +16 -16
  26. package/core/built/admin/assets/activitypub/{inbox-ckD4wo_r.js → inbox-d8oJRTf4.js} +2 -2
  27. package/core/built/admin/assets/activitypub/{label-B72sfvEU.js → label-FHSh6ZAw.js} +3 -3
  28. package/core/built/admin/assets/activitypub/layout-Cq4NG0Xr.js +1 -0
  29. package/core/built/admin/assets/activitypub/{moderation-KCCO7L2J.js → moderation-D1Yapsod.js} +9 -9
  30. package/core/built/admin/assets/activitypub/{note-BX_Bz5A0.js → note-C5zjqq5C.js} +8 -8
  31. package/core/built/admin/assets/activitypub/{notifications-BQOYGvRv.js → notifications-B9p8eCHD.js} +9 -9
  32. package/core/built/admin/assets/activitypub/{preferences-6h43G9_q.js → preferences-BCqUdC3v.js} +9 -9
  33. package/core/built/admin/assets/activitypub/{profile-BMN9VVZ2.js → profile-BRCWoFem.js} +178 -178
  34. package/core/built/admin/assets/activitypub/{reply-ZNo04xsO.js → reply-DYK5vVqb.js} +2 -2
  35. package/core/built/admin/assets/activitypub/{routes-3B9mUQ7i.js → routes-BSXT992i.js} +81 -84
  36. package/core/built/admin/assets/activitypub/{separator-D9taVCCa.js → separator-BbQqTm-p.js} +3 -3
  37. package/core/built/admin/assets/activitypub/{settings-71gCm3SO.js → settings-DQDkr06X.js} +6 -6
  38. package/core/built/admin/assets/activitypub/{step-1-BsGGnBuT.js → step-1-B-YfsVeO.js} +5 -5
  39. package/core/built/admin/assets/activitypub/{step-2-teosIS0k.js → step-2-DtPQzlTH.js} +6 -6
  40. package/core/built/admin/assets/activitypub/{step-3-BjD5TokC.js → step-3-D6BFMXL_.js} +10 -10
  41. package/core/built/admin/assets/activitypub/{tabs-Cvwl1wXU.js → tabs-GpNecvfB.js} +6 -6
  42. package/core/built/admin/assets/activitypub/{topic-filter-C3LZJc2X.js → topic-filter-BPDeQQys.js} +3 -3
  43. package/core/built/admin/assets/activitypub/{use-activity-pub-queries-Dp9f0gov.js → use-activity-pub-queries-BoVOxXkV.js} +2 -2
  44. package/core/built/admin/assets/activitypub/{use-navigate-with-base-path-C4RI0sa9.js → use-navigate-with-base-path-Bmk5h4lW.js} +220 -220
  45. package/core/built/admin/assets/activitypub/{use-reply-chain-data-C2oNDMUH.js → use-reply-chain-data-wVBX7swM.js} +5 -5
  46. package/core/built/admin/assets/activitypub/{x-Dxm6pV9X.js → x-DbQZOLiI.js} +2 -2
  47. package/core/built/admin/assets/{add-integration-modal--YpTq3c0.js → add-integration-modal-BC0jExDZ.js} +1 -1
  48. package/core/built/admin/assets/{add-newsletter-modal-C8Ix2hol.js → add-newsletter-modal-DchTkA7l.js} +1 -1
  49. package/core/built/admin/assets/{add-recommendation-modal-CScuNFz4.js → add-recommendation-modal-DMvaJZKp.js} +1 -1
  50. package/core/built/admin/assets/alert-dialog-QhXzdHfc.js +1 -0
  51. package/core/built/admin/assets/{analytics-Cnji45H5.js → analytics-No1DDY3A.js} +1 -1
  52. package/core/built/admin/assets/{announcement-bar-modal-BTHiy1ZO.js → announcement-bar-modal-DM3cYOpo.js} +1 -1
  53. package/core/built/admin/assets/{api-keys-Boy5pLbD.js → api-keys-BLm2NDBh.js} +1 -1
  54. package/core/built/admin/assets/audience-9mwU5TW6.js +1 -0
  55. package/core/built/admin/assets/{automations-BWpRCZ_f.js → automations-DpUNUdcZ.js} +1 -1
  56. package/core/built/admin/assets/{bluesky-sharing-DHOpQxff.js → bluesky-sharing-Cjrv_f62.js} +1 -1
  57. package/core/built/admin/assets/{box-By_EgGtm.js → box-CdfQAP_F.js} +1 -1
  58. package/core/built/admin/assets/{brand-icon-09YqFZjV.js → brand-icon-CrIGOA3Z.js} +1 -1
  59. package/core/built/admin/assets/{breadcrumb-CcFr_ltt.js → breadcrumb-DLiqCyFc.js} +1 -1
  60. package/core/built/admin/assets/{button-BshWPHvn.js → button-B2jcu6bk.js} +1 -1
  61. package/core/built/admin/assets/{card-CiiE7QfM.js → card--VNbfgo3.js} +1 -1
  62. package/core/built/admin/assets/{chart-BnXyfH11.js → chart-BrhA41Zi.js} +1 -1
  63. package/core/built/admin/assets/chart-helpers-Fo3bUL3K.js +1 -0
  64. package/core/built/admin/assets/{checkbox-Dwwr_3Py.js → checkbox-BfKktMph.js} +1 -1
  65. package/core/built/admin/assets/{chunk.524.91ecb33e6afc3bd8949b.js → chunk.524.60ca4692d91c6022042f.js} +4 -4
  66. package/core/built/admin/assets/{chunk.582.512549909741883f960c.js → chunk.582.525c7617c2d9e94c940a.js} +6 -6
  67. package/core/built/admin/assets/{chunk.16.f76a6314082d813d67e0.js → chunk.896.435fe0637944d4a69810.js} +3 -3
  68. package/core/built/admin/assets/{code-editor-view-BwIdPy_k.js → code-editor-view-CYVu4EW6.js} +1 -1
  69. package/core/built/admin/assets/{code-editor-view-CtkF82Fv.js → code-editor-view-DCQJxsfU.js} +1 -1
  70. package/core/built/admin/assets/{color-picker-Bmo1r9Fc.js → color-picker-BTY_NdEm.js} +1 -1
  71. package/core/built/admin/assets/{color-picker-field-DywowPhF.js → color-picker-field-CPlkzOH0.js} +1 -1
  72. package/core/built/admin/assets/{combobox-C4QCh6Yw.js → combobox-DrMtv_4P.js} +1 -1
  73. package/core/built/admin/assets/command-ZdgYJpoI.js +1 -0
  74. package/core/built/admin/assets/comments-kidj60-h.js +1 -0
  75. package/core/built/admin/assets/{confirmation-context-CLFHhyyH.js → confirmation-context-BhbmQQEl.js} +1 -1
  76. package/core/built/admin/assets/{container-LiZf3XdY.js → container-BuQG1wuP.js} +1 -1
  77. package/core/built/admin/assets/{content-api-modal-BtpNI92-.js → content-api-modal-CyQEC3fr.js} +1 -1
  78. package/core/built/admin/assets/{copy-field-CglgRZyG.js → copy-field-B3M1s78L.js} +1 -1
  79. package/core/built/admin/assets/{custom-field-type-option-D0PXoSnP.js → custom-field-type-option-CsGIZk1J.js} +1 -1
  80. package/core/built/admin/assets/{custom-integration-modal-DCIHKN33.js → custom-integration-modal-BY37O_9X.js} +1 -1
  81. package/core/built/admin/assets/{data-list-CupF7bjM.js → data-list-CA2jYGPq.js} +1 -1
  82. package/core/built/admin/assets/{date-range-select-JPwM0yUj.js → date-range-select-DD2RKkgB.js} +1 -1
  83. package/core/built/admin/assets/design-and-theme-modal-DUSKM4uC.js +22 -0
  84. package/core/built/admin/assets/{detail-page-D8lx2SdP.js → detail-page-Dnv-CdR1.js} +1 -1
  85. package/core/built/admin/assets/dialog-B44iRwlc.js +1 -0
  86. package/core/built/admin/assets/{dirty-confirm-dialog-CmARpZQS.js → dirty-confirm-dialog-BxgQgQ6H.js} +1 -1
  87. package/core/built/admin/assets/{disabled-sources-indicator-BTJ2ClQu.js → disabled-sources-indicator-Cvy47bE2.js} +1 -1
  88. package/core/built/admin/assets/{dist-DzcfoDJ3.js → dist-8YJUlf3B.js} +1 -1
  89. package/core/built/admin/assets/{dist-Cb5RSHSg.js → dist-B3keLvjj.js} +1 -1
  90. package/core/built/admin/assets/{dist-QLZuGq7o2.js → dist-Cy8tfrp_.js} +1 -1
  91. package/core/built/admin/assets/{dist-BT_Z-eCn.js → dist-Dgt2cr6a.js} +1 -1
  92. package/core/built/admin/assets/{domain-D0SAtc-T.js → domain-Ca6KhoQt.js} +1 -1
  93. package/core/built/admin/assets/{dropzone-CaPOeDRZ.js → dropzone-Bb-5zQTk.js} +1 -1
  94. package/core/built/admin/assets/edit-profile-BdupLlus.js +1 -0
  95. package/core/built/admin/assets/{editor-COXn4Atu.js → editor-BP883Lpn.js} +3 -3
  96. package/core/built/admin/assets/{embed-signup-form-modal-BFTPf04i.js → embed-signup-form-modal-DeBMLxlL.js} +1 -1
  97. package/core/built/admin/assets/{empty-indicator-WB1WgT9h.js → empty-indicator-D9QdpuNX.js} +1 -1
  98. package/core/built/admin/assets/{explore-BsNYrubV.js → explore-FB-CimXw.js} +1 -1
  99. package/core/built/admin/assets/{feed-8RR1O1bK.js → feed-C1GxsmI2.js} +1 -1
  100. package/core/built/admin/assets/{field-LmNk7wZh.js → field-Cj8lmDOo.js} +1 -1
  101. package/core/built/admin/assets/{filter-sources-4C0kF1NU.js → filter-sources-D5n5bFA2.js} +1 -1
  102. package/core/built/admin/assets/{filters-CV5jCb9n.js → filters-DJEzkMUK.js} +1 -1
  103. package/core/built/admin/assets/{filters-Dmr0PoqU.js → filters-MZXvdH5D.js} +1 -1
  104. package/core/built/admin/assets/{first-promoter-modal-OCzSaL3B.js → first-promoter-modal-CGTGLCr5.js} +1 -1
  105. package/core/built/admin/assets/{ghost-403cb39badad3df411fc0ba27d220047.js → ghost-3894eedcc6968f658578c0abfe942aab.js} +2 -2
  106. package/core/built/admin/assets/{gift-link-modal-0mzjn5oF.js → gift-link-modal-B6v0tnRN.js} +1 -1
  107. package/core/built/admin/assets/{grid-CUciBfjf.js → grid-Dj29PY05.js} +1 -1
  108. package/core/built/admin/assets/growth-BGAJD1rs.js +3 -0
  109. package/core/built/admin/assets/growth-D6mhcx3q.js +1 -0
  110. package/core/built/admin/assets/{heading-CRZZ2FUe.js → heading-Dh5SFVjL.js} +1 -1
  111. package/core/built/admin/assets/history-modal-iKwUY3XR.js +1 -0
  112. package/core/built/admin/assets/html-field-C8qVGGC1.js +1 -0
  113. package/core/built/admin/assets/{images-C0XvUYMb.js → images-h8VZEQ9k.js} +1 -1
  114. package/core/built/admin/assets/{inbox-DZXDUt4s.js → inbox-BYd1M06Q.js} +13 -13
  115. package/core/built/admin/assets/index-DjQe-e5s.js +4 -0
  116. package/core/built/admin/assets/{index.es-BMUCj9TR.js → index.es-VihPwfeH.js} +1 -1
  117. package/core/built/admin/assets/{inline-Cw-gigDW.js → inline-BWSs_VzR.js} +1 -1
  118. package/core/built/admin/assets/{input-UHrKuvBT.js → input--W-rCTrX.js} +1 -1
  119. package/core/built/admin/assets/{input-group-BPAxETpQ.js → input-group-D8sCXRF5.js} +1 -1
  120. package/core/built/admin/assets/{input-surface-BdOe4KzO.js → input-surface-BsrIZeSF.js} +1 -1
  121. package/core/built/admin/assets/{integration-header-B4DyXV06.js → integration-header-Bm6IDb1A.js} +1 -1
  122. package/core/built/admin/assets/{invite-user-modal-BrAkxEO3.js → invite-user-modal-MdImLCaJ.js} +1 -1
  123. package/core/built/admin/assets/{koenig-lexical-60O_8aiO.js → koenig-lexical-_-IsVI7E.js} +1 -1
  124. package/core/built/admin/assets/koenig-loader-DYZpm6El.js +2 -0
  125. package/core/built/admin/assets/{kpi-card-fUHZlzBX.js → kpi-card-DW_2y3ug.js} +1 -1
  126. package/core/built/admin/assets/kpi-card-DZQk_0W8.js +1 -0
  127. package/core/built/admin/assets/kpi-helpers-PueTKuA6.js +1 -0
  128. package/core/built/admin/assets/kpi-tabs-CojDs-Qz.js +1 -0
  129. package/core/built/admin/assets/{label-VIG969IC.js → label-DjbT91GM.js} +1 -1
  130. package/core/built/admin/assets/{label-picker-BBWykUeA.js → label-picker-cB51xl1r.js} +1 -1
  131. package/core/built/admin/assets/layout-c_B_1hax.js +1 -0
  132. package/core/built/admin/assets/{link-helpers-Dtq9fxQg.js → link-helpers-MVDdnFCY.js} +1 -1
  133. package/core/built/admin/assets/{list-page-CdsnQR9N.js → list-page-BucXJ0hi.js} +1 -1
  134. package/core/built/admin/assets/{loading-indicator-SFTqyYVE.js → loading-indicator-BpFWTVgh.js} +1 -1
  135. package/core/built/admin/assets/{member-custom-fields-gOv6Hoh3.js → member-custom-fields-qs0dIkxM.js} +1 -1
  136. package/core/built/admin/assets/member-detail-B6uec2a6.js +1 -0
  137. package/core/built/admin/assets/members-BQF3CqhI.js +2 -0
  138. package/core/built/admin/assets/{modal-page-BMTzFHVO.js → modal-page-xCivTMvI.js} +1 -1
  139. package/core/built/admin/assets/{moderation-DzzPLDyl.js → moderation-DY4wF1Q3.js} +1 -1
  140. package/core/built/admin/assets/{multi-select-combobox-CGohnsxJ.js → multi-select-combobox-B6LiRzDO.js} +1 -1
  141. package/core/built/admin/assets/navigation-modal-DX-gNF3X.js +1 -0
  142. package/core/built/admin/assets/newsletter-CyQA7m3m.js +1 -0
  143. package/core/built/admin/assets/{newsletter-detail-modal-DQU3r4g2.js → newsletter-detail-modal-BDrptuxn.js} +1 -1
  144. package/core/built/admin/assets/{newsletter-emails-D5ql1rud.js → newsletter-emails-CFeLlt4z.js} +1 -1
  145. package/core/built/admin/assets/newsletters-DXuNmC42.js +1 -0
  146. package/core/built/admin/assets/{note-i8k6pjaw.js → note-Cgo2LCJ6.js} +1 -1
  147. package/core/built/admin/assets/notifications-BC50AMku.js +1 -0
  148. package/core/built/admin/assets/{offers-container-modal-BWfjSdyg.js → offers-container-modal-DWycIMzT.js} +1 -1
  149. package/core/built/admin/assets/{onboarding-route-Cu_ROWPn.js → onboarding-route-Dmc4IPm3.js} +1 -1
  150. package/core/built/admin/assets/overview-CVbFtn-k.js +1 -0
  151. package/core/built/admin/assets/overview-YKj7SZaK.js +1 -0
  152. package/core/built/admin/assets/{page-header-Cfds8pCg.js → page-header-BR_nbIPp.js} +1 -1
  153. package/core/built/admin/assets/{pintura-modal-TDTrJ89x.js → pintura-modal-BR9hEvS8.js} +1 -1
  154. package/core/built/admin/assets/popover-CCy0h5rq.js +1 -0
  155. package/core/built/admin/assets/{portal-frame-DjBF-uy2.js → portal-frame-dc4XKr0e.js} +1 -1
  156. package/core/built/admin/assets/portal-modal-BvvdF_B9.js +1 -0
  157. package/core/built/admin/assets/{post-analytics-Buz1COoY.js → post-analytics-DX470WRG.js} +1 -1
  158. package/core/built/admin/assets/{post-analytics-header-B-P0eFnT.js → post-analytics-header-CXpJmdDv.js} +1 -1
  159. package/core/built/admin/assets/{post-analytics-provider-Cu3jNeFh.js → post-analytics-provider-CLfKGWZy.js} +1 -1
  160. package/core/built/admin/assets/{post-share-modal-P1_M6o-H.js → post-share-modal-Cl0NXRJr.js} +1 -1
  161. package/core/built/admin/assets/{preferences-Cq1aOiLy.js → preferences-DO0UUWFp.js} +2 -2
  162. package/core/built/admin/assets/{preview-chrome-BOVO6_PE.js → preview-chrome-BljUBlOk.js} +1 -1
  163. package/core/built/admin/assets/{preview-modal-MlTjP8UU.js → preview-modal-C-BL-F9k.js} +1 -1
  164. package/core/built/admin/assets/profile-CxT-0l4d.js +1 -0
  165. package/core/built/admin/assets/radio-group-Bgz60i81.js +1 -0
  166. package/core/built/admin/assets/{router-provider-CJC58zTy.js → router-provider-B0gZyiGJ.js} +1 -1
  167. package/core/built/admin/assets/{schemas-CRsC53ls.js → schemas-4UPic-oD.js} +2 -2
  168. package/core/built/admin/assets/select-DuDUFdPq.js +1 -0
  169. package/core/built/admin/assets/{settings-B5hJKZ5C.js → settings-BjCii7BM.js} +1 -1
  170. package/core/built/admin/assets/settings-b8kNzZSQ.js +4 -0
  171. package/core/built/admin/assets/{settings-breadcrumbs-sLDNedBW.js → settings-breadcrumbs-CyP_9zTo.js} +1 -1
  172. package/core/built/admin/assets/{shade-app-F7WxOyfk-nufqw1hd.js → shade-app-CcS3f8MZ-vwURazk8.js} +2 -2
  173. package/core/built/admin/assets/{share-modal-CLBfj377.js → share-modal-BV70mr9k.js} +1 -1
  174. package/core/built/admin/assets/{skeleton-D7hwjdry.js → skeleton-Ce9GgUpf.js} +1 -1
  175. package/core/built/admin/assets/{slack-modal-Bt9I_tEo.js → slack-modal-Be2_KK-z.js} +1 -1
  176. package/core/built/admin/assets/sort-button-Cc-Z96sA.js +1 -0
  177. package/core/built/admin/assets/{source-icon-BPsD5ees.js → source-icon-v6PUnmyM.js} +1 -1
  178. package/core/built/admin/assets/{stack-CIfOAAVf.js → stack-B2eszIiq.js} +1 -1
  179. package/core/built/admin/assets/{stats-B_YkF7bp.js → stats-C4reGh9O.js} +1 -1
  180. package/core/built/admin/assets/{stats-view-BOCp9RG8.js → stats-view-DP9pQ62k.js} +1 -1
  181. package/core/built/admin/assets/{step-1-CMta6YFO.js → step-1-DSRp2vBj.js} +1 -1
  182. package/core/built/admin/assets/{step-2-BG04nh5q.js → step-2-COqv2g0u.js} +1 -1
  183. package/core/built/admin/assets/{step-3-ZnMaVIPj.js → step-3-6W1NMVQc.js} +2 -2
  184. package/core/built/admin/assets/{stripe-button-DDoUKN5a.js → stripe-button-D2K42Uty.js} +1 -1
  185. package/core/built/admin/assets/{stripe-connect-modal-BeSukI8q.js → stripe-connect-modal-Z-UT_BGc.js} +1 -1
  186. package/core/built/admin/assets/{switch-C9djUIMO.js → switch-CI4gLWqb.js} +1 -1
  187. package/core/built/admin/assets/{table-CrqQtkR2.js → table-B2pIKjVh.js} +1 -1
  188. package/core/built/admin/assets/{tabs-CGisSbWq.js → tabs-SaW_UT-Q.js} +1 -1
  189. package/core/built/admin/assets/tag-detail-Dc0nTOtU.js +2 -0
  190. package/core/built/admin/assets/tags-BLaXBwnb.js +1 -0
  191. package/core/built/admin/assets/testimonials-modal-sFwRnNLh.js +1 -0
  192. package/core/built/admin/assets/{text-DU9Hv33_.js → text-BQDSDsKs.js} +1 -1
  193. package/core/built/admin/assets/{textarea-d9qEkMOP.js → textarea-DJ1Q5V39.js} +1 -1
  194. package/core/built/admin/assets/{tier-detail-modal-CxRwgTPR.js → tier-detail-modal-BCFpWwUS.js} +1 -1
  195. package/core/built/admin/assets/{toggle-group-CtKZURJd.js → toggle-group-EM9WpESu.js} +1 -1
  196. package/core/built/admin/assets/{topic-filter-D8JT8Tq1.js → topic-filter-DY4gNHn2.js} +1 -1
  197. package/core/built/admin/assets/{transistor-modal-6PUf0idx.js → transistor-modal-CpyPG-MH.js} +1 -1
  198. package/core/built/admin/assets/trend-badge-ByMkuAuH.js +1 -0
  199. package/core/built/admin/assets/{unsplash-modal-BPuDBPja.js → unsplash-modal-Cv2Q6GtY.js} +1 -1
  200. package/core/built/admin/assets/{use-analytics-data--opuzwcz.js → use-analytics-data-CHvjMYuT.js} +1 -1
  201. package/core/built/admin/assets/use-check-theme-limit-error-Qv4SVXqw.js +2 -0
  202. package/core/built/admin/assets/use-filter-params-CAvfDvf1.js +1 -0
  203. package/core/built/admin/assets/use-growth-stats-D6mZXGhK.js +1 -0
  204. package/core/built/admin/assets/{use-limiter-TDSNiHPB.js → use-limiter-cwJvsNBo.js} +1 -1
  205. package/core/built/admin/assets/{use-navigate-with-base-path-CK989MlC.js → use-navigate-with-base-path-BHPA228f.js} +1 -1
  206. package/core/built/admin/assets/{use-pintura-config-CnCGrDFk.js → use-pintura-config-CzTfnufz.js} +1 -1
  207. package/core/built/admin/assets/{use-pintura-editor-ntphvtUd.js → use-pintura-editor-BDBXWUYq.js} +1 -1
  208. package/core/built/admin/assets/{use-post-referrers-CbXLFIex.js → use-post-referrers-DbY-mzci.js} +1 -1
  209. package/core/built/admin/assets/{use-reply-chain-data-JYFKSO83.js → use-reply-chain-data-BeQwz8oF.js} +1 -1
  210. package/core/built/admin/assets/{use-router-history-entry-BwfQS2mq.js → use-router-history-entry-Bg6BhBQQ.js} +1 -1
  211. package/core/built/admin/assets/{use-setting-group-DQxV42-O.js → use-setting-group-VM7FQwMY.js} +1 -1
  212. package/core/built/admin/assets/{use-settings-navigation-BBzro2-V.js → use-settings-navigation-BbrSUVcf.js} +1 -1
  213. package/core/built/admin/assets/{use-simple-pagination-B2TdNX67.js → use-simple-pagination-Dum6Irbs.js} +1 -1
  214. package/core/built/admin/assets/{use-staff-users-QrR9voeC.js → use-staff-users-cZg4ugOF.js} +1 -1
  215. package/core/built/admin/assets/{use-tinybird-query-D2Aeoty5.js → use-tinybird-query-B1IMyAcv.js} +1 -1
  216. package/core/built/admin/assets/{use-tinybird-token-DBuwMmln.js → use-tinybird-token-Bow0Zwn8.js} +1 -1
  217. package/core/built/admin/assets/{use-unsaved-changes-guard-DpYJcj1d.js → use-unsaved-changes-guard-BAy0RANR.js} +1 -1
  218. package/core/built/admin/assets/{use-url-input-WnIqckzS.js → use-url-input-Df5QzNa7.js} +1 -1
  219. package/core/built/admin/assets/user-detail-modal-yipSoQfv.js +1 -0
  220. package/core/built/admin/assets/{virtual-list-D3MfPNOh.js → virtual-list-DEx8WgiO.js} +1 -1
  221. package/core/built/admin/assets/web-CKcXAu86.js +1 -0
  222. package/core/built/admin/assets/web-DR4TqM3E.js +2 -0
  223. package/core/built/admin/assets/{zapier-modal-BO6PS_Vd.js → zapier-modal-Cw3BTBUu.js} +1 -1
  224. package/core/built/admin/index.html +24 -25
  225. package/core/frontend/services/rendering/renderer.js +15 -0
  226. package/core/server/adapters/storage/LocalStorageBase.js +8 -5
  227. package/core/server/api/endpoints/db.js +19 -5
  228. package/core/server/api/endpoints/index.js +4 -0
  229. package/core/server/api/endpoints/member-custom-fields.js +4 -14
  230. package/core/server/api/endpoints/posts.js +1 -0
  231. package/core/server/api/endpoints/tiers-checkout-config.js +59 -0
  232. package/core/server/api/endpoints/utils/serializers/output/config.js +1 -0
  233. package/core/server/api/endpoints/utils/serializers/output/index.js +4 -0
  234. package/core/server/api/endpoints/utils/serializers/output/tiers-checkout-config.js +12 -0
  235. package/core/server/data/exporter/table-lists.js +3 -0
  236. package/core/server/data/importer/content-files.js +57 -0
  237. package/core/server/data/importer/handlers/image.js +2 -2
  238. package/core/server/data/importer/import-archive.js +131 -0
  239. package/core/server/data/importer/import-manager.js +18 -180
  240. package/core/server/data/importer/importers/content-file-importer.js +66 -4
  241. package/core/server/data/migrations/versions/6.61/2026-08-19-14-30-20-add-written-by-to-members-custom-field-values.js +42 -0
  242. package/core/server/data/migrations/versions/6.61/2026-08-19-14-38-53-add-members-custom-field-bindings-table.js +26 -0
  243. package/core/server/data/migrations/versions/6.61/2026-08-19-14-48-06-add-tier-checkout-field-tables.js +35 -0
  244. package/core/server/data/schema/schema.js +90 -0
  245. package/core/server/data/seeders/importers/automation-action-revisions-importer.js +3 -3
  246. package/core/server/data/seeders/importers/automation-actions-importer.js +3 -3
  247. package/core/server/data/seeders/importers/automation-run-steps-importer.js +3 -3
  248. package/core/server/data/seeders/importers/automation-runs-importer.js +5 -5
  249. package/core/server/data/seeders/importers/automations-importer.js +3 -3
  250. package/core/server/data/seeders/importers/comment-reports-importer.js +1 -1
  251. package/core/server/data/seeders/importers/comments-importer.js +1 -1
  252. package/core/server/data/seeders/importers/email-batches-importer.js +1 -1
  253. package/core/server/data/seeders/importers/email-recipients-importer.js +1 -1
  254. package/core/server/data/seeders/importers/emails-importer.js +1 -1
  255. package/core/server/data/seeders/importers/labels-importer.js +1 -1
  256. package/core/server/data/seeders/importers/members-click-events-importer.js +1 -1
  257. package/core/server/data/seeders/importers/members-created-events-importer.js +1 -1
  258. package/core/server/data/seeders/importers/members-feedback-importer.js +1 -1
  259. package/core/server/data/seeders/importers/members-importer.js +1 -1
  260. package/core/server/data/seeders/importers/members-login-events-importer.js +1 -1
  261. package/core/server/data/seeders/importers/members-products-importer.js +1 -1
  262. package/core/server/data/seeders/importers/members-status-events-importer.js +1 -1
  263. package/core/server/data/seeders/importers/members-stripe-customers-importer.js +1 -1
  264. package/core/server/data/seeders/importers/members-stripe-customers-subscriptions-importer.js +1 -1
  265. package/core/server/data/seeders/importers/members-subscribe-events-importer.js +1 -1
  266. package/core/server/data/seeders/importers/members-subscription-created-events-importer.js +1 -1
  267. package/core/server/data/seeders/importers/offer-redemptions-importer.js +1 -1
  268. package/core/server/data/seeders/importers/offers-importer.js +1 -1
  269. package/core/server/data/seeders/importers/posts-importer.js +1 -1
  270. package/core/server/data/seeders/importers/table-importer.js +2 -2
  271. package/core/server/data/seeders/importers/tags-importer.js +1 -1
  272. package/core/server/data/seeders/importers/users-importer.js +1 -1
  273. package/core/server/data/seeders/importers/web-mentions-importer.js +1 -1
  274. package/core/server/data/seeders/utils/random.js +3 -3
  275. package/core/server/ghost-server.js +3 -2
  276. package/core/server/lib/db-types/boolean.js +18 -0
  277. package/core/server/lib/promise-pool.js +31 -0
  278. package/core/server/services/automations/database-automations-repository.js +26 -26
  279. package/core/server/services/automations/poll.js +1 -0
  280. package/core/server/services/content-import/import/assets.js +74 -0
  281. package/core/server/services/content-import/import/importer.js +57 -14
  282. package/core/server/services/content-import/import/post-data.js +1 -0
  283. package/core/server/services/content-import/import/post-repository.js +78 -0
  284. package/core/server/services/content-import/import/relations.js +149 -0
  285. package/core/server/services/content-import/import/row.js +11 -0
  286. package/core/server/services/content-import/import/schema.js +29 -0
  287. package/core/server/services/content-import/import/source.js +125 -0
  288. package/core/server/services/content-import/index.js +6 -28
  289. package/core/server/services/email-analytics/email-analytics-service.js +8 -1
  290. package/core/server/services/email-analytics/lib/queries.js +7 -1
  291. package/core/server/services/gift-links/schema.js +3 -3
  292. package/core/server/services/gifts/CONTEXT.md +1 -1
  293. package/core/server/services/gifts/constants.js +1 -1
  294. package/core/server/services/gifts/gift-bookshelf-repository.js +2 -2
  295. package/core/server/services/gifts/gift-delivery-bookshelf-repository.js +18 -9
  296. package/core/server/services/gifts/gift-delivery-schema.js +5 -5
  297. package/core/server/services/gifts/gift-delivery-service.js +4 -0
  298. package/core/server/services/gifts/gift-schema.js +10 -10
  299. package/core/server/services/gifts/gift-service.js +4 -2
  300. package/core/server/services/jobs-service/register-job-handlers.js +5 -5
  301. package/core/server/services/lib/mailgun-client.js +44 -8
  302. package/core/server/services/media-inliner/external-media-inliner-job.js +12 -0
  303. package/core/server/services/media-inliner/external-media-inliner.js +103 -29
  304. package/core/server/services/media-inliner/service.js +13 -41
  305. package/core/server/services/media-inliner/types.js +2 -0
  306. package/core/server/services/members/import-export/export/exporter.js +4 -6
  307. package/core/server/services/members/import-export/import/importer.js +21 -5
  308. package/core/server/services/members/import-export/import/stripe-utils.js +6 -1
  309. package/core/server/services/members/import-export/index.js +6 -1
  310. package/core/server/services/members/members-api/members-api.js +5 -0
  311. package/core/server/services/members/members-api/services/member-bread-service.js +19 -1
  312. package/core/server/services/members/members-api/services/payments-service.js +47 -1
  313. package/core/server/services/members-custom-fields/actions.js +27 -1
  314. package/core/server/services/members-custom-fields/bindings-service.js +119 -0
  315. package/core/server/services/members-custom-fields/definitions-service.js +104 -13
  316. package/core/server/services/members-custom-fields/index.js +11 -4
  317. package/core/server/services/members-custom-fields/queries.js +5 -0
  318. package/core/server/services/members-custom-fields/schema.js +37 -6
  319. package/core/server/services/members-custom-fields/values-service.js +15 -3
  320. package/core/server/services/public-config/config.js +7 -0
  321. package/core/server/services/stripe/services/checkout/allowed-countries.js +267 -0
  322. package/core/server/services/stripe/services/checkout/completed-session.js +68 -0
  323. package/core/server/services/stripe/services/checkout/field-ports.js +34 -0
  324. package/core/server/services/stripe/services/checkout/session-options.js +97 -0
  325. package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +49 -0
  326. package/core/server/services/stripe/stripe-api.js +29 -0
  327. package/core/server/services/stripe/stripe-service.js +7 -0
  328. package/core/server/services/tier-checkout-config/codec.js +95 -0
  329. package/core/server/services/tier-checkout-config/destinations.js +17 -0
  330. package/core/server/services/tier-checkout-config/index.js +26 -0
  331. package/core/server/services/tier-checkout-config/models.js +57 -0
  332. package/core/server/services/tier-checkout-config/queries.js +80 -0
  333. package/core/server/services/tier-checkout-config/schema.js +33 -0
  334. package/core/server/services/tier-checkout-config/serializers.js +122 -0
  335. package/core/server/services/tier-checkout-config/service.js +303 -0
  336. package/core/server/services/tiers/service.js +21 -0
  337. package/core/server/web/api/endpoints/admin/routes.js +24 -13
  338. package/core/server/web/api/middleware/upload.js +2 -2
  339. package/core/server/web/parent/app.js +5 -0
  340. package/core/server/web/parent/middleware/filter-query-parameters.js +94 -0
  341. package/core/server/web/parent/middleware/index.js +1 -0
  342. package/core/server/web/query-parameter-policy/index.js +9 -0
  343. package/core/server/web/query-parameter-policy/policy.json +58 -0
  344. package/core/server/web/query-parameter-policy/schema.js +38 -0
  345. package/core/shared/config/defaults.json +3 -0
  346. package/core/shared/config/env/config.testing-mysql.json +3 -0
  347. package/core/shared/config/env/config.testing.json +3 -0
  348. package/core/shared/config/overrides.json +4 -2
  349. package/core/shared/labs.js +5 -14
  350. package/package.json +12 -13
  351. package/pnpm-lock.yaml +44 -46
  352. package/pnpm-workspace.yaml +6 -6
  353. package/tsconfig.json +2 -3
  354. package/core/built/admin/assets/activitypub/layout-CXajhRsL.js +0 -1
  355. package/core/built/admin/assets/alert-dialog-wEbVxANM.js +0 -1
  356. package/core/built/admin/assets/app-utils-D2Wp7ZSS.js +0 -1
  357. package/core/built/admin/assets/audience-DTLMXAFH.js +0 -1
  358. package/core/built/admin/assets/chart-helpers-B3OqQ6Ez.js +0 -1
  359. package/core/built/admin/assets/command-DcLbSifC.js +0 -1
  360. package/core/built/admin/assets/comments-Bxy_3WyE.js +0 -1
  361. package/core/built/admin/assets/design-and-theme-modal-CZ-PkW7o.js +0 -23
  362. package/core/built/admin/assets/dialog-Db7c164G.js +0 -1
  363. package/core/built/admin/assets/edit-profile-By7v5XW5.js +0 -1
  364. package/core/built/admin/assets/growth-55vWlGT_.js +0 -1
  365. package/core/built/admin/assets/growth-DA5AluYw.js +0 -3
  366. package/core/built/admin/assets/history-modal-G1s5hHz7.js +0 -1
  367. package/core/built/admin/assets/html-field-BegxsWpw.js +0 -1
  368. package/core/built/admin/assets/index-CDP9tIOk.js +0 -4
  369. package/core/built/admin/assets/koenig-loader-DwVY_V-H.js +0 -1
  370. package/core/built/admin/assets/kpi-card-LERqWBoY.js +0 -1
  371. package/core/built/admin/assets/kpi-helpers-DB3ouhYF.js +0 -1
  372. package/core/built/admin/assets/kpi-tabs-BGvtMD8S.js +0 -1
  373. package/core/built/admin/assets/layout-Di5K7doM.js +0 -1
  374. package/core/built/admin/assets/member-detail-D7mZDDp3.js +0 -1
  375. package/core/built/admin/assets/member-route-0Aa52Ntz.js +0 -1
  376. package/core/built/admin/assets/members-DvZG9t69.js +0 -2
  377. package/core/built/admin/assets/navigation-modal-CI8Bx5vn.js +0 -1
  378. package/core/built/admin/assets/newsletter-Bg3cq5U-.js +0 -1
  379. package/core/built/admin/assets/newsletters-DMDfZbMS.js +0 -1
  380. package/core/built/admin/assets/notifications-psA_2Ph4.js +0 -1
  381. package/core/built/admin/assets/overview-C-6xOLaf.js +0 -1
  382. package/core/built/admin/assets/overview-DaLhpRrC.js +0 -1
  383. package/core/built/admin/assets/popover-CFgqFDvC.js +0 -1
  384. package/core/built/admin/assets/portal-modal-Cf0pBAk8.js +0 -1
  385. package/core/built/admin/assets/profile-D6dHYf2o.js +0 -1
  386. package/core/built/admin/assets/radio-group-CjtmsCPl.js +0 -1
  387. package/core/built/admin/assets/select-D_RQaXgt.js +0 -1
  388. package/core/built/admin/assets/settings-DIo_F-MF.js +0 -4
  389. package/core/built/admin/assets/sort-button-DMBXF7tP.js +0 -1
  390. package/core/built/admin/assets/tag-detail-2a3BfzTW.js +0 -2
  391. package/core/built/admin/assets/tags-Dp2_8UzL.js +0 -1
  392. package/core/built/admin/assets/testimonials-modal-C9nrypNo.js +0 -1
  393. package/core/built/admin/assets/use-check-theme-limit-error-C9-QhGdV.js +0 -1
  394. package/core/built/admin/assets/use-filter-params-CSpAvgD2.js +0 -1
  395. package/core/built/admin/assets/use-growth-stats-BOmoPDHJ.js +0 -1
  396. package/core/built/admin/assets/user-detail-modal-59mBJqxN.js +0 -1
  397. package/core/built/admin/assets/web-DUuX7nE2.js +0 -2
  398. package/core/built/admin/assets/web-N8ucs2aG.js +0 -1
  399. /package/core/server/lib/{db-date.js → db-types/date.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{g as r,p as i}from"./hooks-CuEZV2-q.js";import{n as a}from"./dist-Ndy-PuGN.js";import{t as o}from"./use-form-vRjI0Kwk.js";import{a as s,i as c,r as l}from"./config-DOMQDZGZ.js";import{h as u}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{x as d}from"./dist-Cb5RSHSg.js";import{t as f}from"./inline-Cw-gigDW.js";import{t as p}from"./stack-CIfOAAVf.js";import{i as m,o as h,r as g}from"./shade-app-F7WxOyfk-nufqw1hd.js";import{A as _,H as v,Lt as y,N as b,P as x,S,U as C,Vn as w,X as T,fn as ee,fr as E,k as te,t as ne,x as re}from"./button-BshWPHvn.js";import{i as D,n as O,r as k,t as ie}from"./tabs-CGisSbWq.js";import{t as A}from"./switch-C9djUIMO.js";import{t as j}from"./input-UHrKuvBT.js";import{i as M,n as N,o as P,s as ae,t as F}from"./select-D_RQaXgt.js";import{t as I}from"./use-settings-navigation-BBzro2-V.js";import{a as L,c as R,i as z,n as B,o as V,r as oe,s as H,t as U}from"./field-LmNk7wZh.js";import{t as se}from"./textarea-d9qEkMOP.js";import{n as W,t as G}from"./toggle-group-CtKZURJd.js";import{r as ce}from"./components-CwL6a6As-B0E0-NBJ.js";import{t as le}from"./use-limiter-TDSNiHPB.js";import{i as ue,r as de}from"./newsletters-DhNigJUh.js";import{Pn as fe,Sr as K,t as pe,xr as me}from"./index-CDP9tIOk.js";import{t as he}from"./validator-Cr0sMKuW.js";import{n as ge}from"./confirmation-context-CLFHhyyH.js";import{n as q}from"./global-data-context-gAMDH9u1.js";import{t as _e}from"./use-upgrade-route-DhRSo7at.js";import{t as ve}from"./use-setting-group-DQxV42-O.js";import{t as J}from"./color-picker-field-DywowPhF.js";import{i as ye,r as be,t as Y}from"./newsletter-emails-D5ql1rud.js";import{t as xe}from"./html-field-BegxsWpw.js";import{t as X}from"./color-utils-Dzeeuj1F.js";import{t as Se}from"./preview-modal-MlTjP8UU.js";``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href,``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href,``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href,``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href;var Z=n(),Ce=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:s,showExcerpt:l,titleAlignment:u,titleFontCategory:f,titleFontWeight:p,bodyFontCategory:m,authorPlaceholder:h,showCommentCta:g,showFeatureImage:v,showFeedback:b,showShareButton:x,showLatestPosts:S,showSubscriptionDetails:C,siteTitle:w,footerContent:ee,showBadge:E,backgroundColor:ne,headerBackgroundColor:re,accentColor:D,textColor:O,secondaryTextColor:k,headerTextColor:ie,secondaryHeaderTextColor:A,postTitleColor:j,sectionTitleColor:M,dividerColor:N,buttonColor:P,buttonTextColor:ae,linkColor:F,buttonCorners:I,buttonStyle:L,imageCorners:R,linkStyle:z,dividerStyle:B})=>{let V=i||a,{config:oe}=q(),H=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),U=new Date().getFullYear(),se=ee?ee.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,W;W=c(oe)?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`From: `}),(0,Z.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`Reply-to: `}),n||t]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:e}),(0,Z.jsxs)(`span`,{children:[` `,t]})]}),(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let G=`mb-5 text-pretty leading-[1.7] text-black`;return G=f===`serif`&&m===`serif`?d(G,`mb-8 font-serif text-[2.0rem] leading-tight`):f!==`serif`&&m===`serif`?d(G,`mb-8 text-[1.7rem] leading-tight tracking-tight`):f===`serif`&&m!==`serif`?d(G,`mb-8 font-serif text-[2.0rem] leading-tight`):d(G,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(G=d(G,`text-center`)),(0,Z.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,Z.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,Z.jsxs)(`div`,{className:`mx-auto my-0 flex max-h-full w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm`,children:[(0,Z.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-grey-200 bg-white px-6 text-grey-700`,children:W}),(0,Z.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:ne},children:[(0,Z.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:re},children:[r&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),V&&(0,Z.jsxs)(`div`,{className:`py-3`,children:[i&&(0,Z.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,Z.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-grey-900 uppercase`,style:{color:ie},children:a}),o&&(0,Z.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-grey-700`,style:{color:A},children:o})]}),s&&(0,Z.jsxs)(`div`,{className:d(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,Z.jsx)(`h2`,{className:d(`text-4xl leading-supertight font-bold text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:j},children:`Your email newsletter`}),l&&(0,Z.jsx)(`p`,{className:G,style:{color:ie},children:`A subtitle to highlight key points and engage your readers.`}),(0,Z.jsxs)(`div`,{className:d(`flex w-full justify-between text-center text-md leading-none text-grey-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,Z.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:A},children:[`By `,h,(0,Z.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:H})]}),(0,Z.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:A},children:(0,Z.jsx)(`span`,{children:`View in browser`})})]})]}),v&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:d(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,s?``:`pt-6`),children:(0,Z.jsx)(`img`,{alt:`Feature`,className:d(`min-h-full min-w-full shrink-0`,R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,Z.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700`,style:{color:A},children:`Feature image caption`})]})]}),(0,Z.jsxs)(`div`,{className:d(`px-[7rem]`,re!==`transparent`&&`pt-10`),children:[(0,Z.jsxs)(`div`,{className:d(`max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`,m===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,v||s?``:`pt-8`),style:{borderColor:N},children:[(0,Z.jsx)(`p`,{className:`mb-6`,style:{color:O},children:`This is what your content will look like when you send one of your posts as an email newsletter to your subscribers.`}),(0,Z.jsx)(`p`,{className:`mb-6`,style:{color:O},children:`Over there on the right you'll see some settings that allow you to customize the look and feel of this template – from colors and typography to layout and buttons – to make it perfectly suited to your brand.`}),(0,Z.jsx)(`p`,{className:`mb-[52px]`,style:{color:O},children:`Email templates are exceptionally finnicky to make, but we've spent a long time optimising this one to make it work beautifully across devices, email clients and content types. So, you can trust that every email you send with Ghost will look great and work well. Just like the rest of your site.`}),(0,Z.jsx)(`hr`,{className:d(`my-[52px] border-[#e0e7eb]`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:N}}),(0,Z.jsx)(`h3`,{className:d(`mb-[13px] text-[2.6rem] leading-supertight`,f===`serif`&&`font-serif`,f===`sans_serif`&&`font-sans`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`Need inspiration?`}),(0,Z.jsxs)(`p`,{className:`mb-[27px]`,style:{color:O},children:[`We've put together a`,` `,(0,Z.jsx)(`a`,{className:d(z===`underline`&&`underline`,z===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:F||D},target:`_blank`,children:`quick guide`}),` `,`that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,Z.jsx)(`a`,{className:d(`inline-block border px-[18px] py-2 font-sans text-[15px]`,I===`rounded`&&`rounded-[6px]`,I===`pill`&&`rounded-full`,I===`square`&&`rounded-none`,L===`outline`?`bg-transparent`:`border-transparent text-white`,z===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:L===`outline`?{borderColor:P||D,color:P||D}:{backgroundColor:P||D,color:ae},target:`_blank`,children:`Learn more`})]}),(b||g||x)&&(0,Z.jsx)(`div`,{className:d(`grid gap-5 border-b border-grey-200 px-6 py-5`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:(0,Z.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(te,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`More like this`})]}),(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(_,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Less like this`})]})]}),g&&(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(y,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Comment`})]}),x&&(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(T,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Share`})]})]})}),S&&(0,Z.jsxs)(`div`,{className:d(`border-b border-grey-200 py-6`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:[(0,Z.jsx)(`h3`,{className:`mt-2 mb-4 pb-1 text-[1.2rem] font-semibold tracking-wide text-black uppercase`,style:{color:O},children:`Keep reading`}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`The three latest posts published on your site`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Posts sent as an email only will never be shown here.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`Displayed at the bottom of each newsletter`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Giving your readers one more place to discover your stories.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`To keep your work front and center`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Making sure that your audience stays engaged.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),C&&(0,Z.jsxs)(`div`,{className:d(`border-b border-grey-200 py-8`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:O},children:`Subscription details`}),(0,Z.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:O},children:[`You are receiving this because you are a paid subscriber to `,w,`. Your subscription will renew on 17 Jul 2024.`]}),(0,Z.jsxs)(`div`,{className:`flex`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,Z.jsx)(`p`,{style:{color:O},children:`Name: Jamie Larson`}),(0,Z.jsx)(`p`,{style:{color:O},children:`Email: jamie@example.com`}),(0,Z.jsx)(`p`,{style:{color:O},children:`Member since: 17 July 2023`})]}),(0,Z.jsx)(`span`,{className:d(`w-full self-end text-right text-base whitespace-nowrap`,z===`underline`&&`underline`,z===`bold`&&`font-bold`),style:{color:F||D},children:`Manage subscription`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,Z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:se||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-grey-700 [&_a]:underline`,style:{color:k}}),(0,Z.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-grey-700`,children:[(0,Z.jsxs)(`span`,{style:{color:k},children:[w,` © `,U,` —`,` `]}),(0,Z.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:k},children:`Unsubscribe`})]}),E&&(0,Z.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,Z.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-grey-900`,href:`https://ghost.org`,style:{color:O},children:[(0,Z.jsx)(ce,{className:`mr-[6px] size-4`}),(0,Z.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},Q=e(t(),1),we=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=q(),[a,o,s,c,l]=K(n,[`title`,`icon`,`comments_enabled`,`support_email_address`,`default_email_address`]),u=null;e.show_header_title?u=a||null:e.show_header_name&&(u=e.name);let d=e.show_header_title&&e.show_header_name?e.name:void 0,f=e.show_comment_cta&&s!==`off`,p=e.feedback_enabled,m=e.show_share_button,h=()=>{let t=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`#ffffff`},g=()=>{let t=e.header_background_color;return!t||t===`transparent`?`transparent`:/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`transparent`},_=()=>{let t=e.button_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===null?X(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return X(n).hex()},y=()=>{let t=e.link_color===void 0?`accent`:e.link_color;return t===`accent`?r.accent_color:/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:X(h()).hex()},b=()=>{let t=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(t||``))return t;if(t===`accent`)return r.accent_color;let n=g();return X(n===`transparent`?h():n).hex()},x=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:X(h()).hex()},S=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},C=X(h()).hex(),w=X(h()).alpha(.5).toString(),T=g()===`transparent`?C:X(g()).hex(),ee=g()===`transparent`?w:X(g()).alpha(.5).toString(),E={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:x()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:S()||void 0,textColor:C,secondaryTextColor:w,headerTextColor:T,secondaryHeaderTextColor:ee};return(0,Z.jsx)(Ce,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:E.backgroundColor||`#ffffff`,bodyFontCategory:e.body_font_category,buttonCorners:e.button_corners||`rounded`,buttonStyle:e.button_style||`fill`,dividerStyle:e.divider_style||`solid`,footerContent:e.footer_content,headerBackgroundColor:E.headerBackgroundColor||`transparent`,headerIcon:e.show_header_icon?o:void 0,headerImage:e.header_image,headerSubtitle:d,headerTitle:u,imageCorners:e.image_corners||`square`,linkStyle:e.link_style||`underline`,senderEmail:be(e,i,l),senderName:e.sender_name||a,senderReplyTo:Y(e,i,c,l),showBadge:e.show_badge,showCommentCta:f,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:p,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showShareButton:m,showSubscriptionDetails:e.show_subscription_details,siteTitle:a,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||`bold`,...E})},Te=e(he(),1),$=({label:e,value:t,options:n,onValueChange:r})=>(0,Z.jsx)(G,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,Z.jsxs)(g,{children:[(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsx)(W,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,Z.jsx)(m,{children:e.label})]},e.value))}),Ee=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=q(),[o,s]=K(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,Q.useState)(Y(e,a,s,o)||``),u=be(e,a,o),d=(0,Q.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,Z.jsxs)(U,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,Z.jsx)(j,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=Y(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,Z.jsx)(z,{children:n.sender_reply_to})]})},De=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:o,errors:s,clearError:u})=>{let{updateRoute:d}=I(),m=_e(),{mutateAsync:h}=ue(),g=le(),{settings:_,config:y,siteData:T}=q(),[te,W]=K(_,[`icon`,`default_email_address`]),[G,ce]=(0,Q.useState)(`generalSettings`),{localSettings:pe}=ve(),[he]=K(pe,[`title`]),Y=i(),{confirm:Se,showLimit:Ce}=ge(),{data:{newsletters:we}={}}=de(),Te=[`all`,`paid`].includes(me(_,`comments_enabled`)||``),De=be(e,y,W),[Oe,ke]=(0,Q.useState)(we||[]),Ae=Oe.filter(e=>e.status===`active`);(0,Q.useEffect)(()=>{ke(we||[])},[we]);let je=[{value:`serif`,label:`Elegant serif`,className:`font-serif`},{value:`sans_serif`,label:`Clean sans-serif`}],Me={sans_serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`medium`,label:`Medium`,className:`font-medium`},{value:`semibold`,label:`Semi-bold`,className:`font-semibold`},{value:`bold`,label:`Bold`,className:`font-bold`}]},serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`bold`,label:`Bold`,className:`font-bold`}],map:{medium:`normal`,semibold:`bold`}}},Ne=()=>e.background_color===`light`?!1:X(e.background_color).hex().toLowerCase()===`#ffffff`,Pe=async()=>{if(e.status===`active`)Se({title:`Archive newsletter`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,Z.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,Z.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await h({...e,status:`archived`}),t?.remove(),a.success(`Newsletter archived`)}catch(e){Y(e)}}});else{try{await g?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof r){Ce({prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>d({route:m,isExternal:!0})});return}else throw e}Se({title:`Reactivate newsletter`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[`Reactivating `,(0,Z.jsx)(`strong`,{children:e.name}),` will immediately make it visible to members and re-enable it as an option when publishing new posts.`]}),okLabel:`Reactivate`,onOk:async t=>{await h({...e,status:`active`}),t?.remove(),a.success(`Newsletter reactivated`)}})}},Fe=()=>{if(!c(y))return(0,Z.jsxs)(U,{"data-invalid":!!s.sender_email||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Z.jsx)(j,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,placeholder:De||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Z.jsx)(z,{children:s.sender_email})]});if(l(y))return(0,Z.jsxs)(U,{"data-invalid":!!s.sender_email||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Z.jsx)(j,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:W,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Z.jsx)(z,{children:s.sender_email})]})},Ie=Me[e.title_font_category||`sans_serif`].options,Le=[{id:`generalSettings`,title:`General`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{"data-invalid":!!s.name||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,Z.jsx)(j,{"aria-invalid":!!s.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>u(`name`)}),s.name&&(0,Z.jsx)(z,{children:s.name})]}),(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-description`,children:`Description`}),(0,Z.jsx)(se,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Email info`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,Z.jsx)(j,{id:`newsletter-sender-name`,maxLength:191,placeholder:he,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Fe(),(0,Z.jsx)(Ee,{clearError:u,errors:s,newsletter:e,updateNewsletter:n,validate:o})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,Z.jsx)(A,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,Z.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,Z.jsx)(ne,{className:`text-destructive hover:text-destructive`,disabled:Ae.length===1,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Archive newsletter`}):(0,Z.jsx)(ne,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Header`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(ye,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:Y}),(0,Z.jsxs)(p,{gap:`md`,children:[te&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,Z.jsx)(A,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,Z.jsx)(A,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,Z.jsx)(A,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Title section`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,Z.jsx)(A,{checked:!!e.show_post_title_section,id:`newsletter-show-post-title`,onCheckedChange:e=>n({show_post_title_section:e})})]}),e.show_post_title_section&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,Z.jsx)(A,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,Z.jsx)(A,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Footer`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(p,{gap:`lg`,children:[(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,Z.jsx)(A,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),Te&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,Z.jsx)(A,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,Z.jsx)(A,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,Z.jsx)(A,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,Z.jsx)(A,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,Z.jsx)(xe,{hint:`Any extra information or legal text`,nodes:`MINIMAL_NODES`,placeholder:` `,title:`Email footer`,value:e.footer_content||``,onChange:e=>n({footer_content:e})})]})]}),(0,Z.jsx)(fe,{className:`mt-8`}),(0,Z.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,Z.jsx)(`span`,{children:(0,Z.jsx)(ee,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,Z.jsx)(L,{className:`gap-8`,children:(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,Z.jsx)(oe,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,Z.jsx)(A,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Global`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{hex:`#ffffff`,value:`light`,title:`White`}],title:`Background color`,value:e.background_color||`light`,onChange:e=>n({background_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Heading font`}),(0,Z.jsxs)(F,{value:e.title_font_category,onValueChange:t=>{let r=e.title_font_weight,i=r;return Me[t].options.find(e=>e.value===r)||(i=Me[t].map?.[r]||`bold`),n({title_font_category:t,title_font_weight:i})},children:[(0,Z.jsx)(P,{"aria-label":`Heading font`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:je.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Heading weight`}),(0,Z.jsxs)(F,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Me[t].map,i=r&&r[n]||n;return Ie.find(e=>e.value===i)||Ie[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,Z.jsx)(P,{"aria-label":`Heading weight`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:Ie.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Body font`}),(0,Z.jsxs)(F,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,Z.jsx)(P,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:je.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Header`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`transparent`,title:`Transparent`,hex:`#00000000`}],title:`Header background color`,value:e.header_background_color||`transparent`,onChange:e=>n({header_background_color:e})})}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Title alignment`}),(0,Z.jsx)($,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,Z.jsx)(b,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,Z.jsx)(x,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Body`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Button style`}),(0,Z.jsx)($,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,Z.jsx)(v,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Button corners`}),(0,Z.jsx)($,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,Z.jsx)(C,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,Z.jsx)(w,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Link style`}),(0,Z.jsx)($,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,Z.jsx)(re,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,Z.jsx)(S,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,Z.jsx)(E,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Image corners`}),(0,Z.jsx)($,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,Z.jsx)(C,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,Z.jsx)(`div`,{className:`flex flex-col`,children:(0,Z.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,Z.jsxs)(ie,{value:G,variant:`underline`,onValueChange:e=>{ce(e)},children:[(0,Z.jsx)(k,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Le.map(e=>(0,Z.jsx)(D,{value:e.id,children:e.title},e.id))}),Le.map(e=>(0,Z.jsx)(O,{value:e.id,children:e.contents},e.id))]})})})},Oe=({newsletter:e,onlyOne:t})=>{let{config:n}=q(),{mutateAsync:r}=ue(),{updateRoute:c}=I(),u=pe(`automations`)?`emails`:`newsletters`,{formState:d,saveState:f,updateForm:p,setFormState:m,handleSave:h,validate:g,errors:_,clearError:v,okProps:y}=o({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await r(d),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,Z.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&a.info(t)},onSaveError:i(),onValidate:()=>{let e={};return d.name||(e.name=`A name is required for your newsletter`),d.sender_email&&!Te.default.isEmail(d.sender_email)?e.sender_email=`Enter a valid email address`:d.sender_email&&l(n)&&d.sender_email.split(`@`)[1]!==s(n)&&(e.sender_email=`Email address must end with @${s(n)}`),d.sender_reply_to&&!Te.default.isEmail(d.sender_reply_to)&&![`newsletter`,`support`].includes(d.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),b=e=>{p(t=>({...t,...e}))};(0,Q.useEffect)(()=>{m(()=>e)},[m,e]);let x=(0,Z.jsx)(we,{newsletter:d}),S=(0,Z.jsx)(De,{clearError:v,errors:_,newsletter:d,onlyOne:t,updateNewsletter:b,validate:g});return(0,Z.jsx)(Se,{buttonsDisabled:y.disabled,cancelLabel:`Close`,dirty:f===`unsaved`,okLabel:y.label||`Save`,okVariant:y.variant,preview:x,previewBgColor:`grey`,previewToolbar:!1,sidebar:S,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>c(u),onOk:async()=>{await h({fakeWhenUnchanged:!0})}})},ke=()=>{let{newsletterId:e}=u(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=de(),i=t?.find(({id:t})=>t===e);return(0,Q.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,Z.jsx)(Oe,{newsletter:i,onlyOne:t.length===1}):null};export{ke as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{g as r,p as i}from"./hooks-CuEZV2-q.js";import{n as a}from"./dist-Ndy-PuGN.js";import{t as o}from"./use-form-vRjI0Kwk.js";import{a as s,i as c,r as l}from"./config-DOMQDZGZ.js";import{h as u}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{w as d}from"./dist-B3keLvjj.js";import{t as f}from"./inline-BWSs_VzR.js";import{t as p}from"./stack-B2eszIiq.js";import{i as m,o as h,r as g}from"./shade-app-CcS3f8MZ-vwURazk8.js";import{A as _,H as v,Lt as y,N as b,P as x,S,U as C,Vn as w,X as T,fn as ee,fr as E,k as te,t as ne,x as re}from"./button-B2jcu6bk.js";import{i as D,n as O,r as k,t as ie}from"./tabs-SaW_UT-Q.js";import{t as A}from"./switch-CI4gLWqb.js";import{t as j}from"./input--W-rCTrX.js";import{i as M,n as N,o as P,s as ae,t as F}from"./select-DuDUFdPq.js";import{t as I}from"./use-settings-navigation-BbrSUVcf.js";import{a as L,c as R,i as z,n as B,o as V,r as oe,s as H,t as U}from"./field-Cj8lmDOo.js";import{t as se}from"./textarea-DJ1Q5V39.js";import{n as W,t as G}from"./toggle-group-EM9WpESu.js";import{r as ce}from"./components-CwL6a6As-B0E0-NBJ.js";import{t as le}from"./use-limiter-cwJvsNBo.js";import{i as ue,r as de}from"./newsletters-DhNigJUh.js";import{Er as K,Rn as fe,Tr as pe,t as me}from"./index-DjQe-e5s.js";import{t as he}from"./validator-Cr0sMKuW.js";import{n as ge}from"./confirmation-context-BhbmQQEl.js";import{n as q}from"./global-data-context-gAMDH9u1.js";import{t as _e}from"./use-upgrade-route-DhRSo7at.js";import{t as ve}from"./use-setting-group-VM7FQwMY.js";import{t as J}from"./color-picker-field-CPlkzOH0.js";import{i as ye,r as be,t as Y}from"./newsletter-emails-CFeLlt4z.js";import{t as xe}from"./html-field-C8qVGGC1.js";import{t as X}from"./color-utils-Dzeeuj1F.js";import{t as Se}from"./preview-modal-C-BL-F9k.js";``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href,``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href,``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href,``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href;var Z=n(),Ce=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:s,showExcerpt:l,titleAlignment:u,titleFontCategory:f,titleFontWeight:p,bodyFontCategory:m,authorPlaceholder:h,showCommentCta:g,showFeatureImage:v,showFeedback:b,showShareButton:x,showLatestPosts:S,showSubscriptionDetails:C,siteTitle:w,footerContent:ee,showBadge:E,backgroundColor:ne,headerBackgroundColor:re,accentColor:D,textColor:O,secondaryTextColor:k,headerTextColor:ie,secondaryHeaderTextColor:A,postTitleColor:j,sectionTitleColor:M,dividerColor:N,buttonColor:P,buttonTextColor:ae,linkColor:F,buttonCorners:I,buttonStyle:L,imageCorners:R,linkStyle:z,dividerStyle:B})=>{let V=i||a,{config:oe}=q(),H=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),U=new Date().getFullYear(),se=ee?ee.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,W;W=c(oe)?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`From: `}),(0,Z.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`Reply-to: `}),n||t]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:e}),(0,Z.jsxs)(`span`,{children:[` `,t]})]}),(0,Z.jsxs)(`p`,{className:`leading-normal`,children:[(0,Z.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let G=`mb-5 text-pretty leading-[1.7] text-black`;return G=f===`serif`&&m===`serif`?d(G,`mb-8 font-serif text-[2.0rem] leading-tight`):f!==`serif`&&m===`serif`?d(G,`mb-8 text-[1.7rem] leading-tight tracking-tight`):f===`serif`&&m!==`serif`?d(G,`mb-8 font-serif text-[2.0rem] leading-tight`):d(G,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(G=d(G,`text-center`)),(0,Z.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,Z.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,Z.jsxs)(`div`,{className:`mx-auto my-0 flex max-h-full w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm`,children:[(0,Z.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-grey-200 bg-white px-6 text-grey-700`,children:W}),(0,Z.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:ne},children:[(0,Z.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:re},children:[r&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),V&&(0,Z.jsxs)(`div`,{className:`py-3`,children:[i&&(0,Z.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,Z.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-grey-900 uppercase`,style:{color:ie},children:a}),o&&(0,Z.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-grey-700`,style:{color:A},children:o})]}),s&&(0,Z.jsxs)(`div`,{className:d(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,Z.jsx)(`h2`,{className:d(`text-4xl leading-supertight font-bold text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:j},children:`Your email newsletter`}),l&&(0,Z.jsx)(`p`,{className:G,style:{color:ie},children:`A subtitle to highlight key points and engage your readers.`}),(0,Z.jsxs)(`div`,{className:d(`flex w-full justify-between text-center text-md leading-none text-grey-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,Z.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:A},children:[`By `,h,(0,Z.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:H})]}),(0,Z.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:A},children:(0,Z.jsx)(`span`,{children:`View in browser`})})]})]}),v&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:d(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,s?``:`pt-6`),children:(0,Z.jsx)(`img`,{alt:`Feature`,className:d(`min-h-full min-w-full shrink-0`,R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,Z.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700`,style:{color:A},children:`Feature image caption`})]})]}),(0,Z.jsxs)(`div`,{className:d(`px-[7rem]`,re!==`transparent`&&`pt-10`),children:[(0,Z.jsxs)(`div`,{className:d(`max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`,m===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,v||s?``:`pt-8`),style:{borderColor:N},children:[(0,Z.jsx)(`p`,{className:`mb-6`,style:{color:O},children:`This is what your content will look like when you send one of your posts as an email newsletter to your subscribers.`}),(0,Z.jsx)(`p`,{className:`mb-6`,style:{color:O},children:`Over there on the right you'll see some settings that allow you to customize the look and feel of this template – from colors and typography to layout and buttons – to make it perfectly suited to your brand.`}),(0,Z.jsx)(`p`,{className:`mb-[52px]`,style:{color:O},children:`Email templates are exceptionally finnicky to make, but we've spent a long time optimising this one to make it work beautifully across devices, email clients and content types. So, you can trust that every email you send with Ghost will look great and work well. Just like the rest of your site.`}),(0,Z.jsx)(`hr`,{className:d(`my-[52px] border-[#e0e7eb]`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:N}}),(0,Z.jsx)(`h3`,{className:d(`mb-[13px] text-[2.6rem] leading-supertight`,f===`serif`&&`font-serif`,f===`sans_serif`&&`font-sans`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`Need inspiration?`}),(0,Z.jsxs)(`p`,{className:`mb-[27px]`,style:{color:O},children:[`We've put together a`,` `,(0,Z.jsx)(`a`,{className:d(z===`underline`&&`underline`,z===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:F||D},target:`_blank`,children:`quick guide`}),` `,`that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,Z.jsx)(`a`,{className:d(`inline-block border px-[18px] py-2 font-sans text-[15px]`,I===`rounded`&&`rounded-[6px]`,I===`pill`&&`rounded-full`,I===`square`&&`rounded-none`,L===`outline`?`bg-transparent`:`border-transparent text-white`,z===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:L===`outline`?{borderColor:P||D,color:P||D}:{backgroundColor:P||D,color:ae},target:`_blank`,children:`Learn more`})]}),(b||g||x)&&(0,Z.jsx)(`div`,{className:d(`grid gap-5 border-b border-grey-200 px-6 py-5`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:(0,Z.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(te,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`More like this`})]}),(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(_,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Less like this`})]})]}),g&&(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(y,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Comment`})]}),x&&(0,Z.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Z.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:N,color:O},children:(0,Z.jsx)(T,{className:`size-5`})}),(0,Z.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:O},children:`Share`})]})]})}),S&&(0,Z.jsxs)(`div`,{className:d(`border-b border-grey-200 py-6`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:[(0,Z.jsx)(`h3`,{className:`mt-2 mb-4 pb-1 text-[1.2rem] font-semibold tracking-wide text-black uppercase`,style:{color:O},children:`Keep reading`}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`The three latest posts published on your site`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Posts sent as an email only will never be shown here.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`Displayed at the bottom of each newsletter`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Giving your readers one more place to discover your stories.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,Z.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:M},children:`To keep your work front and center`}),(0,Z.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:k},children:`Making sure that your audience stays engaged.`})]}),(0,Z.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Z.jsx)(`img`,{alt:`Latest post`,className:d(R===`square`&&`rounded-none`,R===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),C&&(0,Z.jsxs)(`div`,{className:d(`border-b border-grey-200 py-8`,B===`dashed`&&`border-dashed`,B===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:N},children:[(0,Z.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:O},children:`Subscription details`}),(0,Z.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:O},children:[`You are receiving this because you are a paid subscriber to `,w,`. Your subscription will renew on 17 Jul 2024.`]}),(0,Z.jsxs)(`div`,{className:`flex`,children:[(0,Z.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,Z.jsx)(`p`,{style:{color:O},children:`Name: Jamie Larson`}),(0,Z.jsx)(`p`,{style:{color:O},children:`Email: jamie@example.com`}),(0,Z.jsx)(`p`,{style:{color:O},children:`Member since: 17 July 2023`})]}),(0,Z.jsx)(`span`,{className:d(`w-full self-end text-right text-base whitespace-nowrap`,z===`underline`&&`underline`,z===`bold`&&`font-bold`),style:{color:F||D},children:`Manage subscription`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,Z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:se||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-grey-700 [&_a]:underline`,style:{color:k}}),(0,Z.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-grey-700`,children:[(0,Z.jsxs)(`span`,{style:{color:k},children:[w,` © `,U,` —`,` `]}),(0,Z.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:k},children:`Unsubscribe`})]}),E&&(0,Z.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,Z.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-grey-900`,href:`https://ghost.org`,style:{color:O},children:[(0,Z.jsx)(ce,{className:`mr-[6px] size-4`}),(0,Z.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},Q=e(t(),1),we=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=q(),[a,o,s,c,l]=K(n,[`title`,`icon`,`comments_enabled`,`support_email_address`,`default_email_address`]),u=null;e.show_header_title?u=a||null:e.show_header_name&&(u=e.name);let d=e.show_header_title&&e.show_header_name?e.name:void 0,f=e.show_comment_cta&&s!==`off`,p=e.feedback_enabled,m=e.show_share_button,h=()=>{let t=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`#ffffff`},g=()=>{let t=e.header_background_color;return!t||t===`transparent`?`transparent`:/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`transparent`},_=()=>{let t=e.button_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===null?X(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return X(n).hex()},y=()=>{let t=e.link_color===void 0?`accent`:e.link_color;return t===`accent`?r.accent_color:/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:X(h()).hex()},b=()=>{let t=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(t||``))return t;if(t===`accent`)return r.accent_color;let n=g();return X(n===`transparent`?h():n).hex()},x=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:X(h()).hex()},S=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},C=X(h()).hex(),w=X(h()).alpha(.5).toString(),T=g()===`transparent`?C:X(g()).hex(),ee=g()===`transparent`?w:X(g()).alpha(.5).toString(),E={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:x()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:S()||void 0,textColor:C,secondaryTextColor:w,headerTextColor:T,secondaryHeaderTextColor:ee};return(0,Z.jsx)(Ce,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:E.backgroundColor||`#ffffff`,bodyFontCategory:e.body_font_category,buttonCorners:e.button_corners||`rounded`,buttonStyle:e.button_style||`fill`,dividerStyle:e.divider_style||`solid`,footerContent:e.footer_content,headerBackgroundColor:E.headerBackgroundColor||`transparent`,headerIcon:e.show_header_icon?o:void 0,headerImage:e.header_image,headerSubtitle:d,headerTitle:u,imageCorners:e.image_corners||`square`,linkStyle:e.link_style||`underline`,senderEmail:be(e,i,l),senderName:e.sender_name||a,senderReplyTo:Y(e,i,c,l),showBadge:e.show_badge,showCommentCta:f,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:p,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showShareButton:m,showSubscriptionDetails:e.show_subscription_details,siteTitle:a,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||`bold`,...E})},Te=e(he(),1),$=({label:e,value:t,options:n,onValueChange:r})=>(0,Z.jsx)(G,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,Z.jsxs)(g,{children:[(0,Z.jsx)(h,{asChild:!0,children:(0,Z.jsx)(W,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,Z.jsx)(m,{children:e.label})]},e.value))}),Ee=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=q(),[o,s]=K(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,Q.useState)(Y(e,a,s,o)||``),u=be(e,a,o),d=(0,Q.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,Z.jsxs)(U,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,Z.jsx)(j,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=Y(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,Z.jsx)(z,{children:n.sender_reply_to})]})},De=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:o,errors:s,clearError:u})=>{let{updateRoute:d}=I(),m=_e(),{mutateAsync:h}=ue(),g=le(),{settings:_,config:y,siteData:T}=q(),[te,W]=K(_,[`icon`,`default_email_address`]),[G,ce]=(0,Q.useState)(`generalSettings`),{localSettings:me}=ve(),[he]=K(me,[`title`]),Y=i(),{confirm:Se,showLimit:Ce}=ge(),{data:{newsletters:we}={}}=de(),Te=[`all`,`paid`].includes(pe(_,`comments_enabled`)||``),De=be(e,y,W),[Oe,ke]=(0,Q.useState)(we||[]),Ae=Oe.filter(e=>e.status===`active`);(0,Q.useEffect)(()=>{ke(we||[])},[we]);let je=[{value:`serif`,label:`Elegant serif`,className:`font-serif`},{value:`sans_serif`,label:`Clean sans-serif`}],Me={sans_serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`medium`,label:`Medium`,className:`font-medium`},{value:`semibold`,label:`Semi-bold`,className:`font-semibold`},{value:`bold`,label:`Bold`,className:`font-bold`}]},serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`bold`,label:`Bold`,className:`font-bold`}],map:{medium:`normal`,semibold:`bold`}}},Ne=()=>e.background_color===`light`?!1:X(e.background_color).hex().toLowerCase()===`#ffffff`,Pe=async()=>{if(e.status===`active`)Se({title:`Archive newsletter`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,Z.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,Z.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await h({...e,status:`archived`}),t?.remove(),a.success(`Newsletter archived`)}catch(e){Y(e)}}});else{try{await g?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof r){Ce({prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>d({route:m,isExternal:!0})});return}else throw e}Se({title:`Reactivate newsletter`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[`Reactivating `,(0,Z.jsx)(`strong`,{children:e.name}),` will immediately make it visible to members and re-enable it as an option when publishing new posts.`]}),okLabel:`Reactivate`,onOk:async t=>{await h({...e,status:`active`}),t?.remove(),a.success(`Newsletter reactivated`)}})}},Fe=()=>{if(!c(y))return(0,Z.jsxs)(U,{"data-invalid":!!s.sender_email||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Z.jsx)(j,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,placeholder:De||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Z.jsx)(z,{children:s.sender_email})]});if(l(y))return(0,Z.jsxs)(U,{"data-invalid":!!s.sender_email||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Z.jsx)(j,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:W,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Z.jsx)(z,{children:s.sender_email})]})},Ie=Me[e.title_font_category||`sans_serif`].options,Le=[{id:`generalSettings`,title:`General`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{"data-invalid":!!s.name||void 0,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,Z.jsx)(j,{"aria-invalid":!!s.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>u(`name`)}),s.name&&(0,Z.jsx)(z,{children:s.name})]}),(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-description`,children:`Description`}),(0,Z.jsx)(se,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Email info`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,Z.jsx)(j,{id:`newsletter-sender-name`,maxLength:191,placeholder:he,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Fe(),(0,Z.jsx)(Ee,{clearError:u,errors:s,newsletter:e,updateNewsletter:n,validate:o})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,Z.jsx)(L,{children:(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,Z.jsx)(A,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,Z.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,Z.jsx)(ne,{className:`text-destructive hover:text-destructive`,disabled:Ae.length===1,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Archive newsletter`}):(0,Z.jsx)(ne,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Header`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(ye,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:Y}),(0,Z.jsxs)(p,{gap:`md`,children:[te&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,Z.jsx)(A,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,Z.jsx)(A,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,Z.jsx)(A,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Title section`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,Z.jsx)(A,{checked:!!e.show_post_title_section,id:`newsletter-show-post-title`,onCheckedChange:e=>n({show_post_title_section:e})})]}),e.show_post_title_section&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,Z.jsx)(A,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,Z.jsx)(A,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Footer`}),(0,Z.jsxs)(L,{children:[(0,Z.jsxs)(p,{gap:`lg`,children:[(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,Z.jsx)(A,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),Te&&(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,Z.jsx)(A,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,Z.jsx)(A,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,Z.jsx)(A,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,Z.jsx)(A,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,Z.jsx)(xe,{hint:`Any extra information or legal text`,nodes:`MINIMAL_NODES`,placeholder:` `,title:`Email footer`,value:e.footer_content||``,onChange:e=>n({footer_content:e})})]})]}),(0,Z.jsx)(fe,{className:`mt-8`}),(0,Z.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,Z.jsx)(`span`,{children:(0,Z.jsx)(ee,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,Z.jsx)(L,{className:`gap-8`,children:(0,Z.jsxs)(U,{orientation:`horizontal`,children:[(0,Z.jsxs)(B,{children:[(0,Z.jsx)(V,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,Z.jsx)(oe,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,Z.jsx)(A,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Global`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{hex:`#ffffff`,value:`light`,title:`White`}],title:`Background color`,value:e.background_color||`light`,onChange:e=>n({background_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Heading font`}),(0,Z.jsxs)(F,{value:e.title_font_category,onValueChange:t=>{let r=e.title_font_weight,i=r;return Me[t].options.find(e=>e.value===r)||(i=Me[t].map?.[r]||`bold`),n({title_font_category:t,title_font_weight:i})},children:[(0,Z.jsx)(P,{"aria-label":`Heading font`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:je.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Heading weight`}),(0,Z.jsxs)(F,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Me[t].map,i=r&&r[n]||n;return Ie.find(e=>e.value===i)||Ie[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,Z.jsx)(P,{"aria-label":`Heading weight`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:Ie.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,Z.jsxs)(U,{className:`max-w-[200px]`,children:[(0,Z.jsx)(V,{className:`sr-only`,children:`Body font`}),(0,Z.jsxs)(F,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,Z.jsx)(P,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,Z.jsx)(ae,{})}),(0,Z.jsx)(N,{children:je.map(e=>(0,Z.jsx)(M,{value:e.value,children:(0,Z.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Header`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`transparent`,title:`Transparent`,hex:`#00000000`}],title:`Header background color`,value:e.header_background_color||`transparent`,onChange:e=>n({header_background_color:e})})}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Title alignment`}),(0,Z.jsx)($,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,Z.jsx)(b,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,Z.jsx)(x,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,Z.jsxs)(R,{className:`mt-8`,children:[(0,Z.jsx)(H,{className:`text-lg! font-semibold`,children:`Body`}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Button style`}),(0,Z.jsx)($,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,Z.jsx)(v,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Button corners`}),(0,Z.jsx)($,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,Z.jsx)(C,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,Z.jsx)(w,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:Ne()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Link style`}),(0,Z.jsx)($,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,Z.jsx)(re,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,Z.jsx)(S,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,Z.jsx)(E,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,Z.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Z.jsx)(`div`,{children:`Image corners`}),(0,Z.jsx)($,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,Z.jsx)(C,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Z.jsx)(v,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,Z.jsx)(`div`,{className:`mb-1`,children:(0,Z.jsx)(J,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,Z.jsx)(`div`,{className:`flex flex-col`,children:(0,Z.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,Z.jsxs)(ie,{value:G,variant:`underline`,onValueChange:e=>{ce(e)},children:[(0,Z.jsx)(k,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Le.map(e=>(0,Z.jsx)(D,{value:e.id,children:e.title},e.id))}),Le.map(e=>(0,Z.jsx)(O,{value:e.id,children:e.contents},e.id))]})})})},Oe=({newsletter:e,onlyOne:t})=>{let{config:n}=q(),{mutateAsync:r}=ue(),{updateRoute:c}=I(),u=me(`automations`)?`emails`:`newsletters`,{formState:d,saveState:f,updateForm:p,setFormState:m,handleSave:h,validate:g,errors:_,clearError:v,okProps:y}=o({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await r(d),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,Z.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&a.info(t)},onSaveError:i(),onValidate:()=>{let e={};return d.name||(e.name=`A name is required for your newsletter`),d.sender_email&&!Te.default.isEmail(d.sender_email)?e.sender_email=`Enter a valid email address`:d.sender_email&&l(n)&&d.sender_email.split(`@`)[1]!==s(n)&&(e.sender_email=`Email address must end with @${s(n)}`),d.sender_reply_to&&!Te.default.isEmail(d.sender_reply_to)&&![`newsletter`,`support`].includes(d.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),b=e=>{p(t=>({...t,...e}))};(0,Q.useEffect)(()=>{m(()=>e)},[m,e]);let x=(0,Z.jsx)(we,{newsletter:d}),S=(0,Z.jsx)(De,{clearError:v,errors:_,newsletter:d,onlyOne:t,updateNewsletter:b,validate:g});return(0,Z.jsx)(Se,{buttonsDisabled:y.disabled,cancelLabel:`Close`,dirty:f===`unsaved`,okLabel:y.label||`Save`,okVariant:y.variant,preview:x,previewBgColor:`grey`,previewToolbar:!1,sidebar:S,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>c(u),onOk:async()=>{await h({fakeWhenUnchanged:!0})}})},ke=()=>{let{newsletterId:e}=u(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=de(),i=t?.find(({id:t})=>t===e);return(0,Q.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,Z.jsx)(Oe,{newsletter:i,onlyOne:t.length===1}):null};export{ke as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{i as n,r}from"./config-DOMQDZGZ.js";import{f as i}from"./dist-Cb5RSHSg.js";import{D as a}from"./button-BshWPHvn.js";import{o,r as s,t as c}from"./field-LmNk7wZh.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./images-C0XvUYMb.js";e();var _=t(),v=({inputId:e=`welcome-email-header-image`,onUploadError:t,value:n,onChange:r})=>{let{mutateAsync:v}=f(),y=async e=>{try{r(g(await v({file:e})))}catch(e){if(t){t(e);return}throw e}};return(0,_.jsxs)(c,{"data-testid":`header-image-field`,children:[(0,_.jsx)(o,{htmlFor:e,children:`Header image`}),(0,_.jsx)(m,{className:`aspect-[2/1] w-full`,children:n?(0,_.jsxs)(u,{children:[(0,_.jsx)(h,{alt:`Header`,src:n}),(0,_.jsx)(l,{children:(0,_.jsx)(d,{"aria-label":`Remove header image`,type:`button`,onClick:()=>r(``),children:(0,_.jsx)(a,{})})})]}):(0,_.jsx)(p,{accept:{"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]},inputId:e,onDropAccepted:e=>e[0]&&void y(e[0]),children:(0,_.jsx)(`span`,{className:`text-control font-medium`,children:`Upload header image`})})}),(0,_.jsxs)(s,{children:[i(1200),`×`,i(600),` recommended. Use a transparent PNG for best results on any background.`]})]})},y=(e,t,i)=>n(t)&&!r(t)&&i?i:e.sender_email||i||``,b=(e,t,r,i)=>e.sender_reply_to===`newsletter`?n(t)?``:y(e,t,i):e.sender_reply_to===`support`?r||i||``:e.sender_reply_to,x=(e,t,n,r)=>b(e,t,n,r)||(e.sender_reply_to===`newsletter`?y(e,t,r)||n||r||``:n||r||``);export{v as i,x as n,y as r,b as t};
1
+ import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{i as n,r}from"./config-DOMQDZGZ.js";import{m as i}from"./dist-B3keLvjj.js";import{D as a}from"./button-B2jcu6bk.js";import{o,r as s,t as c}from"./field-Cj8lmDOo.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./images-h8VZEQ9k.js";e();var _=t(),v=({inputId:e=`welcome-email-header-image`,onUploadError:t,value:n,onChange:r})=>{let{mutateAsync:v}=f(),y=async e=>{try{r(g(await v({file:e})))}catch(e){if(t){t(e);return}throw e}};return(0,_.jsxs)(c,{"data-testid":`header-image-field`,children:[(0,_.jsx)(o,{htmlFor:e,children:`Header image`}),(0,_.jsx)(m,{className:`aspect-[2/1] w-full`,children:n?(0,_.jsxs)(u,{children:[(0,_.jsx)(h,{alt:`Header`,src:n}),(0,_.jsx)(l,{children:(0,_.jsx)(d,{"aria-label":`Remove header image`,type:`button`,onClick:()=>r(``),children:(0,_.jsx)(a,{})})})]}):(0,_.jsx)(p,{accept:{"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]},inputId:e,onDropAccepted:e=>e[0]&&void y(e[0]),children:(0,_.jsx)(`span`,{className:`text-control font-medium`,children:`Upload header image`})})}),(0,_.jsxs)(s,{children:[i(1200),`×`,i(600),` recommended. Use a transparent PNG for best results on any background.`]})]})},y=(e,t,i)=>n(t)&&!r(t)&&i?i:e.sender_email||i||``,b=(e,t,r,i)=>e.sender_reply_to===`newsletter`?n(t)?``:y(e,t,i):e.sender_reply_to===`support`?r||i||``:e.sender_reply_to,x=(e,t,n,r)=>b(e,t,n,r)||(e.sender_reply_to===`newsletter`?y(e,t,r)||n||r||``:n||r||``);export{v as i,x as n,y as r,b as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r,g as i,i as a,r as o}from"./stats-C4reGh9O.js";import{_ as s}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{a as c,t as l}from"./router-provider-B0gZyiGJ.js";import{c as u,h as d,m as f,u as p}from"./dist-B3keLvjj.js";import{Ht as m,Ut as h,t as g}from"./button-B2jcu6bk.js";import{g as _,n as v,o as y,r as b}from"./chart-BrhA41Zi.js";import{a as x,i as ee,o as te,r as ne}from"./trend-badge-ByMkuAuH.js";import{n as re,t as S}from"./sort-button-Cc-Z96sA.js";import{r as ie,t as ae}from"./tabs-SaW_UT-Q.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./select-DuDUFdPq.js";import{n as A}from"./skeleton-Ce9GgUpf.js";import{t as j}from"./loading-indicator-BpFWTVgh.js";import{a as M,n as N,o as P,r as F,t as I}from"./card--VNbfgo3.js";import{t as L}from"./empty-indicator-D9QdpuNX.js";import{a as R,c as z,n as B,r as V,s as oe,t as se}from"./table-B2pIKjVh.js";import{r as ce}from"./newsletters-DhNigJUh.js";import{Fr as le,Jn as ue,Kn as de,Mr as H,Nr as U,U as W,Xn as G,nr as fe}from"./index-DjQe-e5s.js";import{i as pe,n as me,r as he,t as ge}from"./stats-view-DP9pQ62k.js";import{a as K,c as _e,i as q,n as J,r as ve}from"./chart-helpers-Fo3bUL3K.js";import{n as Y,r as X,t as ye}from"./kpi-tabs-CojDs-Qz.js";import{t as be}from"./use-analytics-data-CHvjMYuT.js";import{t as xe}from"./get-site-timezone-HgL0jI_F.js";var Z=e(t(),1),Q=n(),Se=({active:e,payload:t})=>{if(!e||!t?.length)return null;let n=t[0].payload,r=typeof n.send_date==`string`?n.send_date:n.send_date.toISOString().split(`T`)[0];return(0,Q.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,Q.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,p(r)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,Q.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:f(n.sent_to)})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[f(n.total_opens),` / `]}),d(n.open_rate)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[f(n.total_clicks),` / `]}),d(n.click_rate)]})]})]})},Ce=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:i,initialTab:a=`total-subscribers`})=>{let[o,l]=(0,Z.useState)(a),[p,m]=(0,Z.useState)(!1),{range:g}=W(),S=c(),[C]=s(),w=H(),T=U(),{totalSubscribers:E,avgOpenRate:D,avgClickRate:O}=n,k=(0,Z.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=_e(e,g,`value`,`exact`),t.map(e=>({...e,formattedValue:f(e.value),label:`Total Subscribers`}))},[e,g]),A=(0,Z.useMemo)(()=>ve(g,e||[]),[e,g]),M=(0,Z.useMemo)(()=>{if(!k||k.length<=1)return{direction:`same`,value:`0%`};let e=k[0]?.value??0,t=k[k.length-1]?.value??0,n=`same`;t>e?n=`up`:t<e&&(n=`down`);let r;if(e===0)r=t===0?`0%`:`+100%`;else{let n=(t-e)/e*100,i=Math.round(n*10)/10;r=`${n>=0?`+`:``}${i}%`}return{direction:n,value:r}},[k]);(0,Z.useEffect)(()=>{l(a)},[a]);let N=e=>{l(e);let t=new URLSearchParams(C);t.set(`tab`,e),S(`?${t.toString()}`,{replace:!0})},P={open_rate:{label:`Open rate`}},F=(0,Z.useMemo)(()=>({"total-subscribers":{color:`var(--chart-darkblue)`,datakey:`value`},"avg-open-rate":{color:`var(--chart-blue)`,datakey:`open_rate`},"avg-click-rate":{color:`var(--chart-teal)`,datakey:`click_rate`}}),[]),{barDomain:I,barTicks:R}=(0,Z.useMemo)(()=>{if(!t||t.length===0||o===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=F[o]?.datakey;if(!e)return{barDomain:[0,1],barTicks:[0,1]};let n=t.map(t=>t[e]).filter(e=>typeof e==`number`);if(n.length===0)return{barDomain:[0,1],barTicks:[0,1]};let r=o===`avg-open-rate`?D:O,i=Math.max(Math.max(...n),r),a;return a=i<.01?.01:i<.1?(Math.floor(i*100)+1)/100:(Math.floor(i*10)+1)/10,{barDomain:[0,a],barTicks:[0,a]}},[t,o,F,D,O]);if(r)return(0,Q.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,Q.jsx)(j,{})});let z=`grid-cols-3`;(!w||!T)&&(z=`grid-cols-2`),!w&&!T&&(z=`grid-cols-1`);let B=o===`avg-open-rate`&&D>I[0]&&D<I[1]||o===`avg-click-rate`&&O>I[0]&&O<I[1],V=o===`avg-open-rate`?D:O;return(0,Q.jsxs)(ae,{defaultValue:a,variant:`kpis`,children:[(0,Q.jsxs)(ie,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${z}`,children:[(0,Q.jsx)(Y,{className:`${!T&&!w&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{N(`total-subscribers`)},children:(0,Q.jsx)(X,{color:F[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:M.direction,diffValue:M.value,label:`Total subscribers`,value:f(E)})}),T&&(0,Q.jsx)(Y,{value:`avg-open-rate`,onClick:()=>{N(`avg-open-rate`)},children:(0,Q.jsx)(X,{className:i?`opacity-50`:``,color:F[`avg-open-rate`].color,label:`Avg. open rate`,value:d(D)})}),w&&(0,Q.jsx)(Y,{value:`avg-click-rate`,onClick:()=>{N(`avg-click-rate`)},children:(0,Q.jsx)(X,{className:i?`opacity-50`:``,color:F[`avg-click-rate`].color,label:`Avg. click rate`,value:d(O)})})]}),(0,Q.jsxs)(de,{children:[(0,Q.jsx)(fe,{className:`md:hidden`,asChild:!0,children:(0,Q.jsxs)(ye,{children:[o===`total-subscribers`&&(0,Q.jsx)(X,{color:F[`total-subscribers`].color,label:`Total subscribers`,value:f(E)}),o===`avg-open-rate`&&T&&(0,Q.jsx)(X,{className:i?`opacity-50`:``,color:F[`avg-open-rate`].color,label:`Avg. open rate`,value:d(D)}),o===`avg-click-rate`&&w&&(0,Q.jsx)(X,{className:i?`opacity-50`:``,color:F[`avg-click-rate`].color,label:`Avg. click rate`,value:d(O)})]})}),(0,Q.jsxs)(ue,{align:`end`,className:`w-56`,children:[(0,Q.jsx)(G,{onClick:()=>N(`total-subscribers`),children:`Total subscribers`}),T&&(0,Q.jsx)(G,{onClick:()=>N(`avg-open-rate`),children:`Avg. open rate`}),w&&(0,Q.jsx)(G,{onClick:()=>N(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,Q.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[o===`total-subscribers`&&(0,Q.jsx)(ne,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:F[`total-subscribers`].color,data:k,id:`mrr`,range:A}),(o===`avg-open-rate`&&T||o===`avg-click-rate`&&w)&&(0,Q.jsx)(Q.Fragment,{children:i?(0,Q.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,Q.jsx)(j,{})}):t&&t.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(v,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:P,children:(0,Q.jsxs)(re,{className:p?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&S(`/posts/analytics/${t}`)},onMouseLeave:()=>m(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;m(!!t)},children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:F[o].color,stopOpacity:.8}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:F[o].color,stopOpacity:.6})]})}),(0,Q.jsx)(te,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,Q.jsx)(x,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,Q.jsx)(ee,{axisLine:!1,domain:I,tickFormatter:e=>d(e),tickLine:!1,ticks:R,width:u(R,e=>d(e))}),(0,Q.jsx)(b,{content:(0,Q.jsx)(Se,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),B&&(0,Q.jsx)(y,{label:{value:`${d(V)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:V}),(0,Q.jsx)(_,{activeBar:{fillOpacity:1},dataKey:F[o].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,Q.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,o===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,Q.jsx)(L,{className:`size-full py-20`,title:`No newsletters ${q(g)}`,children:(0,Q.jsx)(h,{strokeWidth:1.5})})})]})]})},we=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=W(),r=(0,Z.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Z.useEffect)(()=>{if(r.length>0&&!t){let e=r.find(e=>e.sort_order===0);n(e?e.id:r[0].id)}},[r,t,n]),r.length<=1?null:(0,Q.jsxs)(k,{value:t||``,onValueChange:e=>{n(e)},children:[(0,Q.jsxs)(E,{className:`w-auto`,children:[(0,Q.jsx)(m,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,Q.jsx)(O,{placeholder:`Select a newsletter`})]}),(0,Q.jsx)(T,{align:`end`,children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(C,{children:`Newsletters`}),r.map(e=>(0,Q.jsx)(w,{value:e.id,children:e.name},e.id))]})})]})},Te=(e,t,n=!0)=>{let i=e??30,{startDate:a,endDate:o}=(0,Z.useMemo)(()=>K(i),[i]),s=r({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(a),date_to:J(o)};return t&&(e.newsletter_id=t),e},[a,o,t]),enabled:n});return n?s:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:s.refetch}},Ee=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:s,endDate:c}=(0,Z.useMemo)(()=>K(i),[i]),l=o({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(s),date_to:J(c),order:a};return n&&(e.newsletter_id=n),e},[s,c,a,n]),enabled:r});return r?l:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:l.refetch}},De=(e,t=[],n=!0)=>{let r=a({searchParams:(0,Z.useMemo)(()=>{let n={};return e&&(n.newsletter_id=e),t.length>0&&(n.post_ids=t.join(`,`)),n},[e,t]),enabled:n});return n?r:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:r.refetch}},Oe=(e,t,n,r=!0)=>{let i=Ee(e,t,n,r),a=(0,Z.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=De(n,a,r&&a.length>0);return{data:(0,Z.useMemo)(()=>{if(!i.data?.stats)return;let e=i.data.stats,t=o.data?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...i.data,stats:r}},[i.data,o.data]),isLoading:i.isLoading,isClicksLoading:o.isLoading,error:i.error||o.error,isError:i.isError||o.isError,refetch:()=>{i.refetch(),o.refetch()}}},ke=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=c(),{settings:a}=be(),o=xe(a),{data:s,isLoading:l,isClicksLoading:u}=Oe(e,r,t||void 0,!!n),m=H(),_=U(),v=(0,Z.useMemo)(()=>s?.stats||[],[s]),y=_&&m?5:_||m?4:3,b=(0,Z.useMemo)(()=>(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(z,{className:`last:border-none [&>td]:py-2.5`,children:(0,Q.jsx)(V,{className:`font-medium`,colSpan:y,children:(0,Q.jsx)(A,{className:`mt-5`})})})}),[y]),x=(0,Z.useMemo)(()=>v.length>0?(0,Q.jsx)(Q.Fragment,{children:v.map(e=>(0,Q.jsxs)(z,{className:`last:border-none [&>td]:py-2.5`,children:[(0,Q.jsx)(V,{className:`font-medium`,children:(0,Q.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,Q.jsx)(g,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`)},children:e.post_title}):(0,Q.jsx)(Q.Fragment,{children:e.post_title})})}),(0,Q.jsx)(V,{className:`text-sm whitespace-nowrap`,children:p(e.send_date,o)}),(0,Q.jsx)(V,{className:`text-right font-mono text-sm`,children:f(e.sent_to)}),_&&(0,Q.jsxs)(V,{className:`text-right font-mono text-sm`,children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:d(e.open_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:f(e.total_opens)})]}),m&&(0,Q.jsx)(V,{className:`text-right font-mono text-sm`,children:u?(0,Q.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:d(e.click_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:f(e.total_clicks)})]})})]},e.post_id))}):(0,Q.jsx)(z,{className:`border-none hover:bg-transparent`,children:(0,Q.jsx)(V,{className:`text-center group-hover:bg-transparent!`,colSpan:y,children:(0,Q.jsx)(L,{className:`size-full py-20`,title:`No newsletters ${q(e)}`,children:(0,Q.jsx)(h,{strokeWidth:1.5})})})}),[v,u,i,m,_,e,o]);return l||!s?b:x});ke.displayName=`NewsletterTableRows`;var Ae=Z.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Z.useMemo)(()=>(0,Q.jsxs)(M,{children:[(0,Q.jsx)(P,{children:`Top newsletters`}),(0,Q.jsxs)(F,{children:[` Your best performing newsletters `,q(n)]})]}),[n]),i=H(),a=U();return(0,Q.jsx)(oe,{children:(0,Q.jsxs)(z,{children:[(0,Q.jsx)(R,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,Q.jsx)(R,{className:`w-[65px]`,children:(0,Q.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,Q.jsx)(R,{className:`w-[90px] text-right`,children:(0,Q.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),a&&(0,Q.jsx)(R,{className:`w-[90px] text-right`,children:(0,Q.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),i&&(0,Q.jsx)(R,{className:`w-[90px] text-right`,children:(0,Q.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ae.displayName=`NewsletterTableHeader`;var $=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Z.useState)(`open_rate desc`);return(0,Q.jsx)(I,{className:`w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,"data-testid":`top-newsletters-card`,children:(0,Q.jsx)(N,{children:(0,Q.jsxs)(se,{children:[(0,Q.jsx)(Ae,{range:e,setSortBy:i,sortBy:r}),(0,Q.jsx)(B,{children:(0,Q.jsx)(ke,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});$.displayName=`TopNewslettersTable`;var je=()=>{let{range:e,selectedNewsletterId:t}=W(),[n]=s(),r=le(),a=n.get(`tab`)||`total-subscribers`,{data:o,isLoading:c}=ce({searchParams:{limit:`50`}}),u=!c&&o&&o.newsletters.length>0&&!!t,{data:d,isLoading:f}=Te(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=Oe(e,`date asc`,t||void 0,u||!1),g=(0,Z.useMemo)(()=>!o?.newsletters||!t?null:o.newsletters.find(e=>e.id===t)||null,[o,t]),_=(0,Z.useMemo)(()=>{let e=g?.count?.active_members||d?.stats?.[0]?.total||0,t=0,n=0;if(p?.stats&&p.stats.length>0){let e=p.stats,r=e.reduce((e,t)=>e+(t.open_rate||0),0),i=e.reduce((e,t)=>e+(t.click_rate||0),0);t=r/e.length,n=i/e.length}return{totalSubscribers:e,avgOpenRate:t,avgClickRate:n}},[g,d,p]),v=(0,Z.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=K(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Z.useMemo)(()=>p?.stats?p.stats.map(e=>({post_id:e.post_id,post_title:e.post_title,send_date:e.send_date,sent_to:e.sent_to,total_opens:e.total_opens,open_rate:e.open_rate,total_clicks:e.total_clicks||0,click_rate:e.click_rate||0})):[],[p]),b=f||h||m;return r===!1?(0,Q.jsx)(l,{to:`/analytics`}):(0,Q.jsxs)(me,{children:[(0,Q.jsx)(he,{children:(0,Q.jsxs)(i,{children:[(0,Q.jsx)(we,{newsletters:o?.newsletters}),(0,Q.jsx)(pe,{})]})}),(0,Q.jsx)(ge,{isLoading:!1,loadingComponent:(0,Q.jsx)(Q.Fragment,{}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(I,{"data-testid":`newsletters-card`,children:(0,Q.jsx)(N,{children:(0,Q.jsx)(Ce,{avgsData:y,initialTab:a,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,Q.jsx)($,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{je as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{h as r}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{s as i}from"./router-provider-CJC58zTy.js";import{pn as a}from"./button-BshWPHvn.js";import{t as o}from"./skeleton-D7hwjdry.js";import{n as s}from"./loading-indicator-SFTqyYVE.js";import{t as c}from"./use-navigate-with-base-path-CK989MlC.js";import{$t as l,H as u,U as d,V as f,et as p,ot as m,st as h,tn as g,ut as _,yt as v}from"./index-CDP9tIOk.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-JYFKSO83.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=c(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(d,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(o,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(o,{className:`w-24`}),(0,w.jsx)(o,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(o,{}),(0,w.jsx)(o,{className:`w-4/5`}),(0,w.jsx)(o,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(o,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(o,{className:`w-52`}),(0,w.jsx)(o,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(d,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(u,{children:[(0,w.jsx)(f,{children:(0,w.jsx)(a,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(d,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(_,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(v,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{h(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:g(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:m(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(p,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(p,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(p,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:l(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(p,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:l(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(p,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:l(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(s,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{h as r}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{s as i}from"./router-provider-B0gZyiGJ.js";import{pn as a}from"./button-B2jcu6bk.js";import{t as o}from"./skeleton-Ce9GgUpf.js";import{n as s}from"./loading-indicator-BpFWTVgh.js";import{t as c}from"./use-navigate-with-base-path-BHPA228f.js";import{Ct as l,G as u,K as d,an as f,dt as p,it as m,mt as h,q as g,rn as _,ut as v}from"./index-DjQe-e5s.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-BeQwz8oF.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=c(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(g,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(o,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(o,{className:`w-24`}),(0,w.jsx)(o,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(o,{}),(0,w.jsx)(o,{className:`w-4/5`}),(0,w.jsx)(o,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(o,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(o,{className:`w-52`}),(0,w.jsx)(o,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(g,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(d,{children:[(0,w.jsx)(u,{children:(0,w.jsx)(a,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(g,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(h,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(l,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{p(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:f(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:v(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(m,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(m,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(m,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:_(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(m,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:_(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(m,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:_(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(s,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./dist-B3keLvjj.js";import{Zn as i,at as a,fn as o,h as s,mr as c,st as l,t as u,vr as d}from"./button-B2jcu6bk.js";import{t as f}from"./skeleton-Ce9GgUpf.js";import{n as p}from"./loading-indicator-BpFWTVgh.js";import{t as m}from"./use-navigate-with-base-path-BHPA228f.js";import{Ct as h,G as g,K as _,St as v,Vt as y,W as b,bt as x,ct as S,dt as C,in as w,lt as T,mt as E,ot as D,pt as O,q as k,rt as A,ut as j,xt as M}from"./index-DjQe-e5s.js";import"./layout-c_B_1hax.js";var N=e(t(),1),P=n(),F=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,c=`white`,u=t===`sm`?13:20,f=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,P.jsx)(s,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:c,size:u,strokeWidth:f}),i=`bg-blue-600`;break;case`like`:r=(0,P.jsx)(o,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:c,strokeWidth:f}),i=`bg-pink-600`;break;case`reply`:r=(0,P.jsx)(a,{className:`mr-px mb-px`,color:c,size:u,strokeWidth:f}),i=`bg-purple-600`;break;case`repost`:r=(0,P.jsx)(l,{color:c,size:u,strokeWidth:f}),i=`bg-green-500`;break;case`mention`:r=(0,P.jsx)(d,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:c,size:u,strokeWidth:f}),i=`bg-orange-500`;break}return(0,P.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},I=N.createContext(void 0),L=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,P.jsx)(I.Provider,{value:{onClick:r,url:i},children:(0,P.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});L.Icon=({size:e=`lg`,type:t})=>(0,P.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,P.jsx)(F,{notificationType:t,size:e})}),L.Avatars=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),L.Content=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var R=()=>(0,P.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function z(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function B(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${z(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var V=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=m(),s=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(E,{actor:t,align:`center`,isCurrentUser:!1,children:(0,P.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&C(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,P.jsxs)(P.Fragment,{children:[s,` followed you`]});case`like`:return(0,P.jsxs)(P.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,P.jsxs)(P.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,P.jsx)(P.Fragment,{})},H=({content:e,className:t,stripTags:n=[]})=>{let r=(0,N.useRef)(null),i=m();return(0,N.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),C(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,P.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(M(e||``,n))},ref:r,className:t})},U=({post:e,variant:t})=>{let n=e?.attachments??[],r=n.length>0,{contentWarning:i,shouldHideContentWarning:a,shouldHideSensitiveMedia:o,revealSensitiveMedia:s,revealContentWarning:c}=T({contentWarning:e?.contentWarning,sensitive:e?.sensitive,hasMedia:r,resetKey:e?.id});return e?a&&i?t===`inline`?(0,P.jsxs)(`button`,{className:`mt-0.5 block max-w-full truncate text-left text-sm text-gray-700 hover:text-black dark:text-gray-600 dark:hover:text-white`,type:`button`,onClick:c,children:[(0,P.jsx)(`span`,{className:`font-semibold`,children:`Content warning:`}),` `,i,` `,(0,P.jsx)(`span`,{className:`font-semibold`,children:`Show`})]}):(0,P.jsx)(A,{className:`mt-2.5`,label:i,size:`compact`,onReveal:c}):t===`inline`?(0,P.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[e.type===`article`&&e.title&&(0,P.jsxs)(P.Fragment,{children:[e.title,` — `]}),(0,P.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(M(e.content||``))}})]}):(0,P.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,P.jsx)(H,{className:`ap-note-content text-pretty`,content:e.content||``,stripTags:[`a`]}),r&&(0,P.jsxs)(`div`,{className:`relative mt-2.5 aspect-square w-[calc(20%-6.4px)] min-w-[96px] overflow-hidden rounded-md [&_img]:absolute [&_img]:inset-0 [&_img]:mt-0 [&_img]:size-full [&_img]:max-h-none [&_img]:max-w-none [&_img]:object-cover [&>.attachment-gallery]:absolute [&>.attachment-gallery]:inset-0 [&>.attachment-gallery]:mt-0 [&>.attachment-gallery]:grid [&>.attachment-gallery]:size-full`,children:[S({type:`Note`,attachment:n}),o&&(0,P.jsx)(D,{showLabel:!1,size:`compact`,isLayered:!0,onReveal:s})]})]}):null},W=()=>{let[e,t]=N.useState({}),n=m(),a=e=>{t(t=>({...t,[e]:!t[e]}))},o=()=>{},{data:s,error:l,fetchNextPage:d,hasNextPage:x,isFetchingNextPage:S,isLoading:T}=y(`index`),E=s?.pages.flatMap(e=>B(e.notifications))??Array(10).fill({actors:[{}]}),D=(0,N.useRef)(null),A=(0,N.useRef)(null);(0,N.useEffect)(()=>(D.current&&D.current.disconnect(),D.current=new IntersectionObserver(e=>{e[0].isIntersecting&&x&&!S&&d()}),A.current&&D.current.observe(A.current),()=>{D.current&&D.current.disconnect()}),[x,S,d]);let M=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?a(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&C(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return l&&w(l)?(0,P.jsx)(b,{errorCode:l.code,statusCode:l.statusCode}):(0,P.jsx)(k,{children:(0,P.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[T===!1&&E.length===0&&(0,P.jsxs)(_,{children:[(0,P.jsx)(g,{children:(0,P.jsx)(c,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),E.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:E.map((t,s)=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsxs)(L,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>M(t,s),children:[T?(0,P.jsx)(f,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,P.jsx)(L.Icon,{type:t.type}):(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(h,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,P.jsx)(F,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,P.jsx)(L.Avatars,{children:(0,P.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${s}`]&&t.actors.slice(0,5).map(e=>(0,P.jsx)(h,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${s}`]&&(0,P.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,P.jsxs)(u,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${s}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),a(t.id||`${t.type}_${s}`)},children:[(0,P.jsx)(i,{className:`${e[t.id||`${t.type}_${s}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${s}`]?`Hide`:(0,P.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,P.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${s}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${s}`]&&t.actors.length>1&&(0,P.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,P.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&C(e.handle,n)},children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,P.jsx)(h,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,P.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,P.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,P.jsx)(v,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,P.jsxs)(L.Content,{children:[(0,P.jsx)(`div`,{children:T?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(f,{}),(0,P.jsx)(f,{className:`w-full max-w-60`})]}):(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:(0,P.jsx)(V,{group:t})}),t.actors.length<2&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,P.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:j(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,P.jsx)(v,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(0,P.jsx)(U,{post:t.post,variant:t.type!==`reply`&&t.type!==`mention`?`inline`:`quoted`}),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,P.jsx)(`div`,{className:`mt-1.5`,children:(0,P.jsx)(O,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:o})})]})]}),s<E.length-1&&(0,P.jsx)(`div`,{className:`pl-[52px]`,children:(0,P.jsx)(R,{})})]},t.id||`${t.type}_${s}`))}),(0,P.jsx)(`div`,{ref:A,className:`h-1`}),S&&(0,P.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,P.jsx)(p,{size:`md`})})]})]})})};export{W as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{_ as r,f as i,p as a}from"./hooks-CuEZV2-q.js";import{n as o}from"./dist-Ndy-PuGN.js";import{t as s}from"./use-form-vRjI0Kwk.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-9J1CSiLy.js";import{i as p,r as m}from"./currency-Dy4Tc2R2.js";import{f as h}from"./dist-Cb5RSHSg.js";import{t as g}from"./inline-Cw-gigDW.js";import{t as _}from"./stack-CIfOAAVf.js";import{$t as v,_r as y,t as b,wr as x,yr as S}from"./button-BshWPHvn.js";import{t as C}from"./switch-C9djUIMO.js";import{t as w}from"./input-UHrKuvBT.js";import{i as T,n as E,o as D,s as O,t as k}from"./select-D_RQaXgt.js";import{o as A,t as j}from"./use-settings-navigation-BBzro2-V.js";import{a as M,i as N,n as P,o as F,r as I,t as L}from"./field-LmNk7wZh.js";import{a as R,i as z,n as B,r as V,t as H}from"./input-group-BPAxETpQ.js";import{n as ee,t as te}from"./radio-group-CjtmsCPl.js";import{a as U,c as W,n as G,r as K,s as q,t as ne}from"./table-CrqQtkR2.js";import{t as re}from"./textarea-d9qEkMOP.js";import{Hn as ie,Jn as ae,Kn as oe,Ln as J,Qn as se,Un as ce,Wn as le,Xn as ue,Yn as de,qn as fe,vn as pe}from"./index-CDP9tIOk.js";import{a as me,r as he}from"./tiers-Nd_z4BZY.js";import{n as ge}from"./confirmation-context-CLFHhyyH.js";import{n as Y}from"./global-data-context-gAMDH9u1.js";import{t as _e}from"./brand-icon-09YqFZjV.js";import{o as ve,r as ye}from"./zapier-modal-BO6PS_Vd.js";import{t as be}from"./preview-modal-MlTjP8UU.js";import{t as xe}from"./portal-frame-DjBF-uy2.js";import{t as Se}from"./settings-breadcrumbs-sLDNedBW.js";var Ce=(e,t)=>{let{disableBackground:n=!1,name:r,code:i,displayTitle:a=``,displayDescription:o=``,type:s,cadence:c,amount:l=0,duration:u,durationInMonths:d,currency:f=`usd`,status:p,tierId:m,redemptionType:h=`signup`}=e;t=t.replace(/\/$/,``);let g=new URLSearchParams;return g.append(`disableBackground`,`false`),g.append(`name`,encodeURIComponent(r)),g.append(`code`,encodeURIComponent(i)),g.append(`display_title`,encodeURIComponent(a)),g.append(`display_description`,encodeURIComponent(o)),g.append(`type`,encodeURIComponent(s)),g.append(`cadence`,encodeURIComponent(c)),g.append(`amount`,encodeURIComponent(l)),g.append(`duration`,encodeURIComponent(u)),g.append(`duration_in_months`,encodeURIComponent(d)),g.append(`currency`,encodeURIComponent(f)),g.append(`status`,encodeURIComponent(p)),g.append(`tier_id`,encodeURIComponent(m)),g.append(`redemption_type`,encodeURIComponent(h)),n&&g.append(`disableBackground`,`true`),g.append(`admin_toolbar`,`0`),`${t}/?v=modal-portal-offer#/portal/preview/offer?${g.toString()}`},we=e=>{let t=[];return e.forEach(e=>{t.push({label:`${e.name} - Monthly`,value:`${e.id}-month-${e.currency}`}),t.push({label:`${e.name} - Yearly`,value:`${e.id}-year-${e.currency}`})}),t},X=e(t(),1),Z=n();function Te(e){return e.toString().toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^\w-]+/g,``).replace(/--+/g,`-`)}var Ee=191,De=e=>{let{fixedAmount:t=0,percentAmount:n=0,trialAmount:r=0,amount:i=0}=e;switch(e.type){case`fixed`:return t*100;case`percent`:return n;case`trial`:return r;default:return i}},Oe=({tierOptions:e,handleTierChange:t,selectedTier:n,typeOptions:r,durationOptions:i,handleTypeChange:a,handleDurationChange:o,overrides:s,handleAmountTypeChange:c,handleNameInput:l,handleTextAreaInput:u,handleDisplayTitleInput:d,handleDurationInMonthsInput:f,handleAmountInput:p,handleCodeInput:m,clearError:g,errors:_,testId:v,handleTrialAmountInput:y,amountOptions:x})=>{let S=s.cadence===`year`,C=S?i.filter(e=>e.value!==`repeating`):i,[A,j]=(0,X.useState)(0),V=A>40?`text-red`:`text-green`,{siteData:U}=Y(),[W,G]=(0,X.useState)(!1),K=pe(U),q=`${K}${s.code.value}`,ne=async()=>{await navigator.clipboard.writeText(q),G(!0),setTimeout(()=>G(!1),2e3)};return(0,Z.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,Z.jsxs)(M,{className:`mb-10 gap-8`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{"data-invalid":!!_.name||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(w,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),j(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,Z.jsx)(N,{children:_.name}):(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Z.jsxs)(`strong`,{children:[(0,Z.jsx)(`span`,{className:V,children:h(A)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(L,{"data-invalid":!!_.displayTitle||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(w,{"aria-invalid":!!_.displayTitle||void 0,id:`offer-display-title`,maxLength:Ee,placeholder:`Black Friday Special`,value:s.displayTitle.value,onChange:e=>{d(e)},onKeyDown:()=>g(`displayTitle`)}),_.displayTitle&&(0,Z.jsx)(N,{children:_.displayTitle})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`offer-display-description`,maxLength:Ee,placeholder:`Take advantage of this limited-time offer.`,value:s.displayDescription,onChange:e=>{u(e)}})]})]})]}),(0,Z.jsxs)(`section`,{className:`mt-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(te,{"aria-label":`Offer type`,className:`rounded-md border border-border-default p-4`,value:s.type===`trial`?`trial`:`percent`,onValueChange:a,children:r.map(e=>{let t=`offer-type-${e.value}`;return(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsx)(ee,{id:t,value:e.value}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(F,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(I,{children:e.description})]})]},e.value)})}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Tier — Cadence`}),(0,Z.jsxs)(k,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,Z.jsx)(D,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:e.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(L,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-amount`,children:`Amount off`}),(0,Z.jsxs)(H,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(z,{id:`offer-amount`,type:`number`,value:s.type===`fixed`?s.fixedAmount===0?``:s.fixedAmount?.toString():s.percentAmount===0?``:s.percentAmount?.toString(),onChange:e=>{p(e)},onKeyDown:()=>g(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsxs)(k,{value:s.type===`percent`?x[0].value:x[1].value,onValueChange:c,children:[(0,Z.jsx)(D,{"aria-label":`Amount type`,className:`h-7 w-20 border-0 bg-transparent px-2 shadow-none focus-visible:ring-0`,"data-testid":`amount-type-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{align:`end`,children:x.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,Z.jsx)(N,{children:_.amount})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Duration`}),(0,Z.jsxs)(k,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,Z.jsx)(D,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:C.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!S&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(L,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsxs)(H,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!_.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:s.durationInMonths===0?``:String(s.durationInMonths),onChange:e=>{f(e)},onKeyDown:()=>g(`durationInMonths`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,Z.jsx)(N,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,Z.jsxs)(L,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,Z.jsx)(w,{"aria-invalid":!!_.amount||void 0,id:`trial-duration`,type:`number`,value:s.trialAmount?.toString(),onChange:e=>{y(e)},onKeyDown:()=>g(`amount`)}),_.amount&&(0,Z.jsx)(N,{children:_.amount})]}),(0,Z.jsxs)(L,{"data-invalid":!!_.code||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsx)(w,{"aria-invalid":!!_.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:s.code.value,onChange:e=>{m(e)},onKeyDown:()=>g(`code`)}),_.code?(0,Z.jsx)(N,{children:_.code}):s.code.value!==``&&(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[K,(0,Z.jsx)(`span`,{className:`font-bold`,children:s.code.value})]}),(0,Z.jsx)(b,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void ne(),children:W?`Copied`:`Copy`})]})})]})]})]})]})})},Q=e=>{let[t,n,r]=e.split(`-`);if(!t||!n||!r)throw Error(`Invalid input format. Expected format is: id-period-currency`);return{id:t,period:n,currency:r}},ke=()=>{let{siteData:e}=Y(),t=[{title:`Discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free trial`,description:`Give free access for a limited time`,value:`trial`}],n=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],[i,a]=(0,X.useState)(``),{updateRoute:c}=j(),{data:{tiers:l}={}}=me(),d=he(l||[]),p=we(d),{mutateAsync:m}=f(),[h,g]=(0,X.useState)({tier:p[0]||{},dataset:{id:p[0]?.value?Q(p[0]?.value).id:``,period:p[0]?.value?Q(p[0]?.value).period:``,currency:p[0]?.value?Q(p[0]?.value).currency:``}}),{data:{offers:_=[]}={}}=u(),{formState:v,updateForm:y,handleSave:b,saveState:x,okProps:S,validate:C,errors:w,clearError:T}=s({initialState:{disableBackground:!1,name:``,code:{isDirty:!1,value:``},displayTitle:{isDirty:!1,value:``},displayDescription:``,type:`percent`,cadence:h?.dataset?.period||``,amount:0,duration:`once`,durationInMonths:1,currency:h?.dataset?.currency||`USD`,status:`active`,tierId:h?.dataset?.id||``,trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{let e=v.type===`trial`?`trial`:v.duration,t={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:De(v)||0,duration:e,...e===`repeating`?{duration_in_months:v.durationInMonths}:{},currency:v.currency,status:v.status,redemption_type:`signup`,tier:{id:v.tierId},type:v.type,currency_restriction:!1},n=await m(t);n&&n.offers&&n.offers.length>0&&c(`offers/success/${n.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{let e={};return!v.name&&v.name.length===0&&(e.name=`Name is required`),!v.code.value&&v.code.value.length===0&&(e.code=`Code is required`),!v.displayTitle.value&&v.displayTitle.value.length===0&&(e.displayTitle=`Display title is required`),v.type===`percent`&&v.percentAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`percent`&&(v.percentAmount<1||v.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),(v.type===`fixed`&&v.fixedAmount===0||v.type===`fixed`&&v.fixedAmount<1)&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount<1&&(e.amount=`Free trial must be at least 1 day.`),v.type!==`trial`&&v.duration===`repeating`&&(!Number.isInteger(v.durationInMonths)||v.durationInMonths<1)&&(e.durationInMonths=`Enter a whole number of months (1 or more).`),e},savingDelay:500}),E=[{value:`percent`,label:`%`},{value:`fixed`,label:v.currency}],D=e=>{let t=Q(e.value),n=t.period===`year`;g({tier:e,dataset:t}),y(e=>({...e,cadence:t.period,currency:t.currency,tierId:t.id,duration:n&&e.duration===`repeating`?`once`:e.duration})),n&&T(`durationInMonths`)},O=e=>{e===`trial`&&(T(`amount`),T(`durationInMonths`)),y(t=>({...t,type:e}))},k=e=>{y(t=>({...t,type:e===`percent`?`percent`:`fixed`}))},A=e=>{let t=e.target;v.type===`fixed`?y(e=>({...e,fixedAmount:Number(t.value)})):v.type===`percent`?y(e=>({...e,percentAmount:Number(t.value)})):y(e=>({...e,amount:Number(t.value)}))},M=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},N=e=>{let t=e.target.value;y(e=>{let n={...e};return n.name=t,e.code.isDirty||(T(`code`),n.code={...e.code,value:Te(t)}),e.displayTitle.isDirty||(T(`displayTitle`),n.displayTitle={...e.displayTitle,value:t}),n})},P=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},F=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},I=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},L=e=>{y(t=>({...t,duration:e}))},R=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},z=()=>{_.length>0?c(`offers/edit`):c(`offers`)},B=(0,X.useMemo)(()=>({name:v.name||``,code:v.code.value||``,displayTitle:v.displayTitle.value||``,displayDescription:v.displayDescription||``,type:v.type||`percent`,cadence:v.cadence||`month`,amount:De(v)||0,duration:v.type===`trial`?`trial`:v.duration||`once`,durationInMonths:v.durationInMonths||0,currency:v.currency||`USD`,status:v.status||`active`,tierId:v.tierId||d[0]?.id,redemptionType:`signup`}),[v,d]);(0,X.useEffect)(()=>{let t=Ce(B,e.url);a(t)},[v,e.url,v.type,B]);let V=(0,Z.jsx)(Oe,{amountOptions:E,clearError:T,durationOptions:n,errors:w,handleAmountInput:A,handleAmountTypeChange:k,handleCodeInput:R,handleDisplayTitleInput:P,handleDurationChange:L,handleDurationInMonthsInput:M,handleNameInput:N,handleTextAreaInput:F,handleTierChange:D,handleTrialAmountInput:I,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),H=(0,Z.jsx)(xe,{href:i||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:x===`unsaved`,height:`full`,okLabel:`Publish`,okVariant:S.variant,preview:H,previewToolbar:!1,sidebar:V,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:z,onClose:()=>{c(`offers`)},onOk:async()=>{if(C(),!Object.values(w).every(e=>!e)){o.dismiss(),o.info(`Can't save offer`,{description:`Make sure you filled all required fields`});return}try{if(await b({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:t||`Please try again later`})}}})},Ae=e=>new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`}),je=e=>{let t=`${i().adminRoot}#/members`,n=`offer_redemptions:[${e.join(`,`)}]`;return`${t}?filter=${encodeURIComponent(n)}`},Me=e=>je([e]),Ne=({amount:e,duration:t})=>e===100&&t===`repeating`,Pe=(e,t)=>`Retention ${e} (${t})`,Fe=({amount:e,duration:t,durationInMonths:n})=>Ne({amount:e,duration:t})?`${n} ${n===1?`month`:`months`} free`:t===`once`?`${e}% off once`:t===`repeating`?`${e}% off for ${n} mo`:`${e}% off forever`,Ie=(e,t)=>{let n=t.trim(),r=Fe(e),i=Pe(r,n);if(i.length<=40)return i;let a=i.length-40,o=Math.max(3,n.length-a);return Pe(r,n.slice(0,o))},Le=e=>e===`month`?`monthly`:`yearly`,Re=e=>e===`once`?`First payment`:e===`repeating`?`Repeating`:`Forever`,ze=(e,t,n,r,i)=>{let a=``,o=n===`month`?i?.monthly_price??0:i?.yearly_price??0,s=o,c=e=>parseFloat(e.toFixed(2)),l=e=>h(c(m(e)),{maximumFractionDigits:2}),u=p(r)+l(o);switch(e){case`percent`:a=`${h(t)}% off`,s=o-o*t/100;break;case`fixed`:a=`${l(t)} ${r} off`,s=o-t;break;case`trial`:a=`${h(t)} days free`,u=``;break;default:break}s<0&&(s=0);let d=p(r)+l(s);return{discountOffer:a,originalPriceWithCurrency:u,updatedPriceWithCurrency:d}};function Be(e){return new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`})}var Ve=({clearError:e,errors:t,offer:n,updateOffer:r})=>{let{siteData:i}=Y(),[s,c]=(0,X.useState)(!1),u=a(),{confirm:d}=ge(),{mutateAsync:f}=l(),[p,m]=(0,X.useState)(n?.name.length||0),g=p>40?`text-red`:`text-green`,{updateRoute:_}=j();(0,X.useEffect)(()=>{n?.name&&m(n?.name.length)},[n?.name]);let v=pe(i),y=`${v}${n?.code}`,x=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},S=()=>{n?.status===`active`?d({title:`Archive offer`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:`New members will no longer be able to subscribe using this offer.`}),(0,Z.jsxs)(`p`,{children:[`All members that previously redeemed `,(0,Z.jsx)(`strong`,{children:n?.name}),` will remain unchanged.`]})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async e=>{try{await f({...n,status:`archived`}),e?.remove(),o.success(`Offer archived`),_(`offers/edit`)}catch(e){u(e)}}}):d({title:`Reactivate offer`,prompt:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`p`,{children:[`Reactivating `,(0,Z.jsx)(`strong`,{children:n?.name}),` will allow new members to subscribe using this offer. Existing members will remain unchanged.`]})}),okLabel:`Reactivate`,onOk:async e=>{try{await f({...n,status:`active`}),e?.remove(),o.success(`Offer reactivated`),_(`offers/edit`)}catch(e){u(e)}}})};return(0,Z.jsxs)(`div`,{className:`flex grow flex-col pt-2`,children:[(0,Z.jsxs)(M,{className:`mb-10 grow gap-8`,children:[(0,Z.jsx)(`section`,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Created on`}),(0,Z.jsx)(`span`,{children:Be(n?.created_at?n.created_at:``)})]}),(0,Z.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Z.jsxs)(`span`,{children:[h(n?.redemption_count||0),` `,n?.redemption_count===1?`redemption`:`redemptions`]})]}),n?.redemption_count>0&&n?.last_redeemed?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Z.jsx)(`span`,{children:Be(n?.last_redeemed)})]}):null]}),n?.redemption_count>0?(0,Z.jsx)(`a`,{className:`font-semibold text-green`,href:Me(n?.id),children:`See members →`}):null]})]})}),(0,Z.jsxs)(`section`,{className:`mt-2`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{"data-invalid":!!t.name||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(w,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),r({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,Z.jsx)(N,{children:t.name}):(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Z.jsxs)(`strong`,{children:[(0,Z.jsx)(`span`,{className:g,children:h(p)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(L,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsxs)(H,{"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>r({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(V,{onClick:()=>void x(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,Z.jsx)(N,{children:t.code}):n?.code!==``&&(0,Z.jsxs)(I,{className:`truncate`,children:[v,(0,Z.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,Z.jsxs)(L,{"data-invalid":!!t.displayTitle||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(w,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>r({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,Z.jsx)(N,{children:t.displayTitle})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`offer-display-description`,placeholder:`Take advantage of this limited-time offer.`,value:n?.display_description??``,onChange:e=>r({display_description:e.target.value})})]})]})]})]}),(0,Z.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,Z.jsx)(b,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:S,children:`Archive offer`}):(0,Z.jsx)(b,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:S,children:`Reactivate offer`})})]})},He=({id:e})=>{let{siteData:t}=Y(),{updateRoute:n}=j(),i=a(),{mutateAsync:c}=l(),[u,f]=(0,X.useState)(``),{data:{offers:p=[]}={}}=d(e||``),{formState:m,saveState:h,updateForm:g,setFormState:_,handleSave:v,validate:y,errors:b,clearError:x,okProps:S}=s({initialState:p[0],savingDelay:500,onSave:async()=>{await c(m)},onSaveError:i,onValidate:()=>{let e={};return m?.name||(e.name=`Name is required`),m?.display_title||(e.displayTitle=`Display title is required`),m?.code||(e.code=`Please enter a code`),e}});(0,X.useEffect)(()=>{_(()=>p[0])},[_,p]);let C=(0,Z.jsx)(Ve,{clearError:x,errors:b,offer:m,updateOffer:e=>{g(t=>({...t,...e}))},validate:y});(0,X.useEffect)(()=>{let e=Ce({name:m?.name||``,code:m?.code||``,displayTitle:m?.display_title||``,displayDescription:m?.display_description||``,type:m?.type||``,cadence:m?.cadence||``,amount:m?.amount,duration:m?.duration||``,durationInMonths:m?.duration_in_months||0,currency:m?.currency||``,status:m?.status||``,tierId:m?.tier?.id||``,redemptionType:`signup`},t.url);f(e)},[m,t]);let w=(0,Z.jsx)(xe,{href:u||``,portalParent:`offers`}),T=()=>{n(`offers/edit`)};return p?(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:h===`unsaved`,height:`full`,okLabel:S.label||`Save`,okVariant:S.variant,preview:w,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:m?.name||`Offer`,label:`Offers`,onBack:T}),sidebar:C,size:`lg`,testId:`offer-update-modal`,title:`Offer`,width:1140,onCancel:T,onClose:()=>{n(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:`Please try again later`})}}}):null},Ue=[{title:`Percentage discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free month(s)`,description:`Give free access for a limited time`,value:`free_months`}],We=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],Ge=191,Ke=99,qe=`Enter a whole number of months between 1 and ${Ke}.`,Je=e=>Math.max(1,Number.isFinite(e)?Math.trunc(e):0),Ye=({type:e,percentAmount:t,freeMonths:n,lastPercentAmount:r,lastFreeMonths:i})=>e===`free_months`?n>0?n:i:t>0?t:r,Xe=(e=`monthly`)=>({enabled:!1,displayTitle:``,displayDescription:``,type:e===`yearly`?`percent`:`free_months`,percentAmount:20,duration:`once`,durationInMonths:1,freeMonths:1}),Ze=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,Qe=(e,t=`monthly`)=>{let n=Xe(t);if(!e)return n;let r=Ze(e),i=e.type===`percent`&&!r,a=e.duration===`repeating`&&e.duration_in_months?e.duration_in_months:n.durationInMonths;return{enabled:e.status===`active`,displayTitle:e.display_title||``,displayDescription:e.display_description||``,type:r?`free_months`:`percent`,percentAmount:i?e.amount:n.percentAmount,duration:i?e.duration:n.duration,durationInMonths:a,freeMonths:r&&e.duration_in_months||n.freeMonths}},$e=({formState:e,lastPercentAmount:t,lastFreeMonths:n})=>{let r=Ye({type:e.type,percentAmount:e.percentAmount,freeMonths:e.freeMonths,lastPercentAmount:t,lastFreeMonths:n});if(e.type===`free_months`)return{type:`percent`,amount:100,duration:`repeating`,durationInMonths:Je(r)};let i=e.duration;return{type:`percent`,amount:r,duration:i,durationInMonths:i===`repeating`?Je(e.durationInMonths):0}},et=e=>{if(!e)return null;let t=e.duration_in_months??0;return{type:`percent`,amount:e.amount,duration:e.duration,durationInMonths:t}},tt=e=>e?`${e.type}:${e.amount}:${e.duration}:${e.durationInMonths}`:``,nt=e=>Number.isInteger(e)&&e>0&&e<=Ke,rt=(e,t)=>e.displayTitle!==t.displayTitle||e.displayDescription!==t.displayDescription||e.type!==t.type||e.percentAmount!==t.percentAmount||e.duration!==t.duration||e.durationInMonths!==t.durationInMonths||e.freeMonths!==t.freeMonths,it=({formState:e,updateForm:t,clearError:n,errors:r,cadence:i,lastRedeemed:a,membersFilterUrl:o,redemptions:s})=>{let c=i===`yearly`?We.filter(e=>e.value!==`repeating`):We;return(0,Z.jsx)(`div`,{className:`flex grow flex-col pt-2`,children:(0,Z.jsxs)(M,{className:`mb-10 grow gap-8`,children:[(0,Z.jsx)(`section`,{children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Z.jsxs)(`span`,{children:[h(s),` `,s===1?`redemption`:`redemptions`]})]}),s>0&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Z.jsx)(`span`,{children:Ae(a)})]}):null]}),s>0&&o?(0,Z.jsx)(`a`,{className:`font-semibold text-green`,href:o,children:`See members →`}):null]})})})}),(0,Z.jsx)(`section`,{className:`mt-2`,children:(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsxs)(P,{children:[(0,Z.jsxs)(F,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,Z.jsx)(I,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,Z.jsx)(C,{checked:e.enabled,id:`${i}-retention-enabled`,onCheckedChange:e=>t(t=>({...t,enabled:e}))})]})}),e.enabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`mt-2`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`retention-display-title`,children:`Display title`}),(0,Z.jsx)(w,{id:`retention-display-title`,maxLength:Ge,placeholder:`Before you go`,value:e.displayTitle,onChange:e=>{t(t=>({...t,displayTitle:e.target.value}))}})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`retention-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`retention-display-description`,maxLength:Ge,placeholder:`We'd hate to see you leave. How about a special offer to stay?`,value:e.displayDescription,onChange:e=>{t(t=>({...t,displayDescription:e.target.value}))}})]})]})]}),(0,Z.jsxs)(`section`,{className:`mt-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i===`monthly`&&(0,Z.jsx)(te,{"aria-label":`${i} retention offer type`,className:`rounded-md border border-border-default p-4`,value:e.type,onValueChange:e=>{n(`amount`),n(`durationInMonths`),t(t=>({...t,type:e}))},children:Ue.map(e=>{let t=`${i}-retention-type-${e.value}`;return(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsx)(ee,{id:t,value:e.value}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(F,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(I,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(L,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`retention-amount`,children:`Amount off`}),(0,Z.jsxs)(H,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.amount||void 0,id:`retention-amount`,type:`number`,value:e.percentAmount===0?``:String(e.percentAmount),onChange:e=>{let n=Number(e.target.value),r=Number.isNaN(n)?0:n;t(e=>({...e,percentAmount:r}))},onKeyDown:()=>n(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:`%`})})]}),r.amount&&(0,Z.jsx)(N,{children:r.amount})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Duration`}),(0,Z.jsxs)(k,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,Z.jsx)(D,{"aria-label":`Duration`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:c.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(L,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsxs)(H,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:e.durationInMonths===0?``:String(e.durationInMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`durationInMonths`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,Z.jsx)(N,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,Z.jsxs)(L,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`retention-free-months`,children:`Free months`}),(0,Z.jsxs)(H,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.amount||void 0,id:`retention-free-months`,type:`number`,value:e.freeMonths===0?``:String(e.freeMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,freeMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,Z.jsx)(N,{children:r.amount})]})]})]})]})]})})},at=({cadence:e})=>{let{updateRoute:t}=j(),{siteData:n}=Y(),{data:{tiers:i=[]}={}}=me(),{data:{offers:a=[]}={},isFetched:d,isFetching:p}=u(),{mutateAsync:m}=f(),{mutateAsync:h}=l(),g=c(),[_,v]=(0,X.useState)(``),y=e===`monthly`?`Monthly retention`:`Yearly retention`,b=e===`monthly`?`month`:`year`,x=he(i||[]),S=(0,X.useMemo)(()=>a.filter(e=>e.redemption_type===`retention`&&e.cadence===b).sort((e,t)=>{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n}),[a,b]),C=(0,X.useMemo)(()=>S.find(e=>e.status===`active`)||null,[S]),w=S[0]||null,T=C||w,E=(0,X.useMemo)(()=>S.reduce((e,t)=>e+(t.redemption_count||0),0),[S]),D=(0,X.useMemo)(()=>S.map(e=>e.id),[S]),O=(0,X.useMemo)(()=>S.map(e=>e.last_redeemed).filter(e=>!!e).sort((e,t)=>new Date(t).getTime()-new Date(e).getTime())[0]||null,[S]),k=(0,X.useMemo)(()=>E===0||D.length===0?null:je(D),[D,E]),[A,M]=(0,X.useState)(20),[N,P]=(0,X.useState)(1),[F,I]=(0,X.useState)(null),{formState:L,setFormState:R,updateForm:z,handleSave:B,saveState:V,okProps:H,errors:ee,clearError:te}=s({initialState:Xe(e),savingDelay:500,onSave:async()=>{let t=!1,n=$e({formState:L,lastPercentAmount:A,lastFreeMonths:N}),r=tt(et(T))!==tt(n),i=L.enabled?`active`:`archived`,a=L.displayTitle||``,o=L.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Xe(e),l=!L.enabled&&!T&&rt(L,c),u=async e=>{let r=crypto.getRandomValues(new Uint32Array(1))[0].toString(16).padStart(8,`0`),i=Ie(n,r);await m({name:i,code:r,display_title:a,display_description:o,cadence:b,amount:n.amount,duration:n.duration,duration_in_months:n.duration===`repeating`?n.durationInMonths:null,currency:null,status:e,redemption_type:`retention`,tier:null,type:n.type,currency_restriction:!1}),t=!0},d=async()=>{t&&await g()};if(!(!T&&!L.enabled&&!l)){if(r){!L.enabled&&C&&(await h({...C,status:`archived`}),t=!0),await u(i),await d();return}if(T){let e=T.status!==i;(s||e)&&(await h({...T,display_title:a,display_description:o,status:i}),t=!0),await d();return}(L.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message||t),o.dismiss(),o.error(`Failed to save offer`,{description:t})},onValidate:()=>{let e={};return L.enabled?(L.type===`percent`&&((L.percentAmount<1||L.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),L.duration===`repeating`&&!nt(L.durationInMonths)&&(e.durationInMonths=qe)),L.type===`free_months`&&(nt(L.freeMonths)||(e.amount=qe)),e):e}}),U=`${e}:${T?.id||`none`}`;(0,X.useEffect)(()=>{!d||p||V===`unsaved`||F===U||(R(()=>Qe(T,e)),I(U))},[e,U,T,d,F,p,V,R]),(0,X.useEffect)(()=>{L.percentAmount>0&&M(L.percentAmount)},[L.percentAmount]),(0,X.useEffect)(()=>{L.freeMonths>0&&P(L.freeMonths)},[L.freeMonths]);let W=()=>{t(`offers/edit`)},G=(0,Z.jsx)(it,{cadence:e,clearError:te,errors:ee,formState:L,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:z}),K=async()=>{try{await B({force:!0})&&W()}catch{}},q=(0,X.useMemo)(()=>{let t=$e({formState:L,lastPercentAmount:A,lastFreeMonths:N}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:L.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:L.displayTitle||``,displayDescription:L.displayDescription||``,type:t.type,cadence:b,amount:t.amount,duration:t.duration,durationInMonths:t.durationInMonths,currency:``,status:`active`,tierId:n?.id||``,redemptionType:`retention`}},[x,e,L,N,A,b]);(0,X.useEffect)(()=>{if(!n.url){v(``);return}let e=Ce(q,n.url);v(e)},[q,n.url]);let ne=(0,Z.jsx)(xe,{href:_||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:V===`unsaved`,height:`full`,okLabel:H.label||`Save`,okVariant:H.variant,preview:ne,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:y,label:`Offers`,onBack:W}),sidebar:G,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:W,onClose:()=>t(`offers`),onOk:K})},ot=({id:e})=>{let{updateRoute:t}=j(),{data:{offers:n=[]}={}}=d(e||``),[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(``),{siteData:s}=Y();(0,X.useEffect)(()=>{if(n.length>0){let e=n[0],t=`${pe(s)}${e?.code}`;o(t),i(e)}},[n,s]);let[c,l]=(0,X.useState)(!1),u=()=>{let e=``;switch(r?.type){case`percent`:e=r?.amount+`% discount`;break;case`fixed`:e=h(m(r?.amount),{maximumFractionDigits:2})+` `+r?.currency+` discount`;break;case`trial`:e=r?.amount+` days free trial`;break;default:break}return`${encodeURIComponent(r?.name||``)} — Check out ${encodeURIComponent(e)} on:`},f=async()=>{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)};return(0,Z.jsx)(A,{animate:!1,backDropClick:!1,footer:!1,height:`full`,size:`lg`,testId:`offer-success-modal`,topRightContent:`close`,width:1140,onClose:()=>{t(`offers`)},children:(0,Z.jsxs)(`div`,{className:`-mt-6 flex h-full flex-col items-center justify-center text-center`,children:[(0,Z.jsx)(Se,{className:`absolute top-5 left-6`,current:r?.name||``,label:`Offers`,onBack:()=>t(`offers/edit`)}),(0,Z.jsx)(y,{className:`-mt-4 size-10 text-grey-700`}),(0,Z.jsx)(`h1`,{className:`mt-6 text-4xl`,children:`Your new offer is live!`}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[510px] text-[1.6rem]`,children:`You can share the link anywhere. In your newsletter, social media, a podcast, or in-person. It all just works.`}),(0,Z.jsxs)(`div`,{className:`mt-8 flex w-full max-w-md flex-col gap-8`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2`,children:[(0,Z.jsx)(w,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,Z.jsx)(b,{className:`w-full`,type:`button`,onClick:()=>void f(),children:c?`Copied!`:`Copy link`})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-4 text-sm font-medium before:h-px before:grow before:bg-grey-300 before:content-[""] after:h-px after:grow after:bg-grey-300 after:content-[""] dark:before:bg-grey-800 dark:after:bg-grey-800`,children:`OR`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(b,{"aria-label":`Share on X`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(a)}&text=${u()}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`twitter-x`})}),(0,Z.jsx)(b,{"aria-label":`Share on Facebook`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(a)}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`facebook`})}),(0,Z.jsx)(b,{"aria-label":`Share on LinkedIn`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(a)}&title=${u()}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`linkedin`})})]})]})]})})},st=(e,t)=>e.find(e=>e.redemption_type===`retention`&&e.cadence===t&&e.status===`active`)||null,ct=(e,t)=>e.reduce((e,n)=>n.redemption_type!==`retention`||n.cadence!==t?e:e+(n.redemption_count||0),0),lt=(e,t)=>e.filter(e=>e.redemption_type===`retention`&&e.cadence===t).map(e=>e.id),ut=(e,t)=>{let n=e.filter(e=>e.redemption_type===`retention`&&e.cadence===t&&e.created_at).map(e=>new Date(e.created_at).getTime()).filter(e=>!Number.isNaN(e));return n.length===0?null:new Date(Math.max(...n)).toISOString()},dt=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,ft=e=>{if(!e)return null;if(dt(e)){let t=e.duration_in_months||0,n=t===1?`month`:`months`;return`${h(t)} ${n} free`}return e.type===`percent`?`${h(e.amount)}% OFF`:null},pt=e=>{if(!e)return null;if(dt(e))return``;if(e.duration===`once`)return`First payment`;if(e.duration===`repeating`&&e.duration_in_months){let t=e.duration_in_months===1?`month`:`months`;return`For ${h(e.duration_in_months)} ${t}`}return e.duration===`forever`?`Forever`:null},mt=e=>{let t=st(e,`month`),n=st(e,`year`),r=lt(e,`month`),i=lt(e,`year`),a=ct(e,`month`),o=ct(e,`year`);return[{id:`monthly`,name:`Monthly retention`,description:`Applied to monthly plans`,terms:ft(t),termsDetail:pt(t),redemptionOfferIds:r,redemptions:a,status:t?`active`:`inactive`,createdAt:ut(e,`month`)},{id:`yearly`,name:`Yearly retention`,description:`Applied to annual plans`,terms:ft(n),termsDetail:pt(n),redemptionOfferIds:i,redemptions:o,status:n?`active`:`inactive`,createdAt:ut(e,`year`)}]},ht=({showArchived:e,setShowArchived:t,sortOption:n,sortDirection:r,onSortChange:i,onDirectionChange:a})=>(0,Z.jsxs)(ie,{children:[(0,Z.jsx)(se,{asChild:!0,children:(0,Z.jsx)(b,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(v,{size:16,strokeWidth:1.5})})}),(0,Z.jsxs)(le,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,Z.jsx)(fe,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,Z.jsxs)(ae,{value:n,onValueChange:i,children:[(0,Z.jsx)(de,{value:`date-added`,children:`Date added`}),(0,Z.jsx)(de,{value:`name`,children:`Name`}),(0,Z.jsx)(de,{value:`redemptions`,children:`Redemptions`})]}),(0,Z.jsxs)(oe,{onSelect:a,children:[r===`asc`?(0,Z.jsx)(S,{className:`size-3`}):(0,Z.jsx)(x,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,Z.jsx)(ue,{}),(0,Z.jsx)(ce,{checked:e,onCheckedChange:e=>t(!!e),children:`Show archived`})]})]}),gt=({offer:e,onClick:t})=>{let n=e.redemptions>0&&e.redemptionOfferIds.length>0?je(e.redemptionOfferIds):void 0;return(0,Z.jsxs)(W,{"data-testid":`retention-offer-item`,children:[(0,Z.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.terms?(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:e.terms}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.termsDetail})]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:n?(0,Z.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,"data-testid":`retention-redemptions-link-${e.id}`,href:n,children:h(e.redemptions)}):(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,"data-testid":`retention-redemptions-link-${e.id}`,type:`button`,onClick:t,children:h(e.redemptions)})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.status===`active`?(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`secondary`,children:`Inactive`})})})]})},_t=({archived:e,offer:t,tier:n,onClick:r})=>{let{discountOffer:i,originalPriceWithCurrency:a,updatedPriceWithCurrency:o}=ze(t.type,t.amount,t.cadence,t.currency||`USD`,n);return(0,Z.jsxs)(W,{className:e?`opacity-60`:void 0,"data-testid":`offer-item`,children:[(0,Z.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:t.name}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.name,` `,Le(t.cadence)]})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:i}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.type===`trial`?`Trial period`:Re(t.duration)})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsxs)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:o}),` `,t.type===`trial`?null:(0,Z.jsx)(`span`,{className:`relative text-sm text-muted-foreground before:absolute before:-inset-x-0.5 before:top-1/2 before:rotate-[-20deg] before:border-t before:content-[""]`,children:a})]})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:t.redemption_count>0&&t.id?(0,Z.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,href:Me(t.id),children:h(t.redemption_count)}):(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:h(t.redemption_count)})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:e?(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`success`,children:`Active`})})})]})},$=e=>e.offer.name,vt=e=>e.kind===`retention`?e.offer.redemptions:e.offer.redemption_count,yt=e=>e.kind===`retention`?e.offer.createdAt:e.offer.created_at||null,bt=(e,t,n)=>{let r=n===`desc`?-1:1;return[...e].sort((e,n)=>{let i;switch(t){case`name`:i=$(e).localeCompare($(n));break;case`redemptions`:i=vt(e)-vt(n);break;default:{let t=yt(e),r=yt(n);if(!t&&!r)i=0;else if(!t)return 1;else if(r)i=new Date(t).getTime()-new Date(r).getTime();else return-1;break}}return(i||$(e).localeCompare($(n)))*r})},xt=()=>{let{updateRoute:e}=j(),{data:{offers:t=[]}={}}=u(),{data:{tiers:n}={}}=me(),r=t.filter(e=>e.redemption_type===`signup`),i=mt(t),{sortingState:a,setSortingState:s}=ve(),c=a?.find(e=>e.type===`offers`),{offersShowArchived:l,setOffersShowArchived:d}=ye(),f=c?.option||`date-added`,p=c?.direction||`desc`,m=t=>{t&&e(`offers/edit/${t}`)},h=t=>{e(`offers/edit/retention/${t}`)},v=he(n||[]),y=r.filter(e=>{let t=n?.find(t=>t.id===e?.tier?.id),r=e.status===`active`&&t&&t.active===!0,i=e.status===`archived`||t&&t.active===!1;return!!(r||l&&i)}),x=bt([...i.map(e=>({kind:`retention`,offer:e})),...y.map(e=>({kind:`signup`,offer:e}))],f,p),S=e=>{s?.([{type:`offers`,option:e,direction:p}])},C=()=>{s?.([{type:`offers`,option:f,direction:p===`asc`?`desc`:`asc`}])},w=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,Z.jsx)(A,{animate:!1,backDropClick:!1,cancelLabel:``,footer:!1,height:`full`,size:`lg`,testId:`offers-modal`,title:`Offers`,topRightContent:(0,Z.jsxs)(g,{gap:`md`,children:[(0,Z.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,Z.jsx)(b,{type:`button`,onClick:()=>{v.length===0?o.info(`You must have an active tier to create an offer.`):e(`offers/new`)},children:`New offer`})]}),width:1140,onClose:()=>{e(`offers`)},children:(0,Z.jsx)(_,{className:`h-full pt-8`,children:(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(ne,{className:`m-0 min-w-[900px]`,children:[(0,Z.jsxs)(`colgroup`,{children:[(0,Z.jsx)(`col`,{className:`w-[25%]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[220px]`})]}),(0,Z.jsx)(q,{children:(0,Z.jsxs)(W,{children:[(0,Z.jsx)(U,{className:`sticky left-0 z-10 h-auto bg-background p-0 pb-2.5 pl-5 uppercase`,children:`Name`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Terms`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Price`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Redemptions`}),(0,Z.jsx)(U,{className:`h-auto p-0 px-5 pb-2.5 uppercase`,children:(0,Z.jsxs)(g,{align:`center`,justify:`between`,children:[`Status`,(0,Z.jsx)(ht,{setShowArchived:d,showArchived:l,sortDirection:p,sortOption:f,onDirectionChange:C,onSortChange:S})]})})]})}),(0,Z.jsx)(G,{"data-testid":`offers-table-body`,children:x.map(e=>{if(e.kind===`retention`)return(0,Z.jsx)(gt,{offer:e.offer,onClick:()=>h(e.offer.id)},`retention-${e.offer.id}`);let t=e.offer,r=n?.find(e=>e.id===t?.tier?.id);if(!r)return null;let i=w(t);return(0,Z.jsx)(_t,{archived:i,offer:t,tier:r,onClick:()=>m(t.id)},`signup-${t.id}`)})})]})})})})},St=`offers/edit/retention/`,Ct=e=>{let t=e.slice(22).replace(/\/+$/,``);return t===`monthly`||t===`yearly`?t:null},wt=({route:e})=>{if(e===`offers/new`)return(0,Z.jsx)(ke,{});if(e===`offers/edit/retention`||e.startsWith(St)){let t=e.startsWith(St)?Ct(e):null;return t?(0,Z.jsx)(at,{cadence:t}):(0,Z.jsx)(xt,{})}else if(e.startsWith(`offers/edit/`)&&e.length>12){let t=e.split(`/`).pop();return(0,Z.jsx)(He,{id:t||``})}else if(e.startsWith(`offers/success/`)&&e.length>15){let t=e.split(`/`).pop();return(0,Z.jsx)(ot,{id:t||``})}else if(e===`offers/edit`||e===`offers/edit/`)return(0,Z.jsx)(xt,{})},Tt=()=>{let{route:e}=j();return(0,Z.jsx)(wt,{route:e})};export{Tt as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{_ as r,f as i,p as a}from"./hooks-CuEZV2-q.js";import{n as o}from"./dist-Ndy-PuGN.js";import{t as s}from"./use-form-vRjI0Kwk.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-9J1CSiLy.js";import{i as p,r as m}from"./currency-Dy4Tc2R2.js";import{m as h}from"./dist-B3keLvjj.js";import{t as g}from"./inline-BWSs_VzR.js";import{t as _}from"./stack-B2eszIiq.js";import{$t as v,_r as y,t as b,wr as x,yr as S}from"./button-B2jcu6bk.js";import{t as C}from"./switch-CI4gLWqb.js";import{t as w}from"./input--W-rCTrX.js";import{i as T,n as E,o as D,s as O,t as k}from"./select-DuDUFdPq.js";import{o as A,t as j}from"./use-settings-navigation-BbrSUVcf.js";import{a as M,i as N,n as P,o as F,r as I,t as L}from"./field-Cj8lmDOo.js";import{a as R,i as z,n as B,r as V,t as H}from"./input-group-D8sCXRF5.js";import{n as ee,t as te}from"./radio-group-Bgz60i81.js";import{a as U,c as W,n as G,r as K,s as q,t as ne}from"./table-B2pIKjVh.js";import{t as re}from"./textarea-DJ1Q5V39.js";import{$n as ie,Jn as ae,Kn as oe,Qn as se,Sn as ce,Vn as J,Xn as le,Zn as ue,er as de,nr as fe,qn as pe}from"./index-DjQe-e5s.js";import{a as me,r as he}from"./tiers-Nd_z4BZY.js";import{n as ge}from"./confirmation-context-BhbmQQEl.js";import{n as Y}from"./global-data-context-gAMDH9u1.js";import{t as _e}from"./brand-icon-CrIGOA3Z.js";import{o as ve,r as ye}from"./zapier-modal-Cw3BTBUu.js";import{t as be}from"./preview-modal-C-BL-F9k.js";import{t as xe}from"./portal-frame-dc4XKr0e.js";import{t as Se}from"./settings-breadcrumbs-CyP_9zTo.js";var Ce=(e,t)=>{let{disableBackground:n=!1,name:r,code:i,displayTitle:a=``,displayDescription:o=``,type:s,cadence:c,amount:l=0,duration:u,durationInMonths:d,currency:f=`usd`,status:p,tierId:m,redemptionType:h=`signup`}=e;t=t.replace(/\/$/,``);let g=new URLSearchParams;return g.append(`disableBackground`,`false`),g.append(`name`,encodeURIComponent(r)),g.append(`code`,encodeURIComponent(i)),g.append(`display_title`,encodeURIComponent(a)),g.append(`display_description`,encodeURIComponent(o)),g.append(`type`,encodeURIComponent(s)),g.append(`cadence`,encodeURIComponent(c)),g.append(`amount`,encodeURIComponent(l)),g.append(`duration`,encodeURIComponent(u)),g.append(`duration_in_months`,encodeURIComponent(d)),g.append(`currency`,encodeURIComponent(f)),g.append(`status`,encodeURIComponent(p)),g.append(`tier_id`,encodeURIComponent(m)),g.append(`redemption_type`,encodeURIComponent(h)),n&&g.append(`disableBackground`,`true`),g.append(`admin_toolbar`,`0`),`${t}/?v=modal-portal-offer#/portal/preview/offer?${g.toString()}`},we=e=>{let t=[];return e.forEach(e=>{t.push({label:`${e.name} - Monthly`,value:`${e.id}-month-${e.currency}`}),t.push({label:`${e.name} - Yearly`,value:`${e.id}-year-${e.currency}`})}),t},X=e(t(),1),Z=n();function Te(e){return e.toString().toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^\w-]+/g,``).replace(/--+/g,`-`)}var Ee=191,De=e=>{let{fixedAmount:t=0,percentAmount:n=0,trialAmount:r=0,amount:i=0}=e;switch(e.type){case`fixed`:return t*100;case`percent`:return n;case`trial`:return r;default:return i}},Oe=({tierOptions:e,handleTierChange:t,selectedTier:n,typeOptions:r,durationOptions:i,handleTypeChange:a,handleDurationChange:o,overrides:s,handleAmountTypeChange:c,handleNameInput:l,handleTextAreaInput:u,handleDisplayTitleInput:d,handleDurationInMonthsInput:f,handleAmountInput:p,handleCodeInput:m,clearError:g,errors:_,testId:v,handleTrialAmountInput:y,amountOptions:x})=>{let S=s.cadence===`year`,C=S?i.filter(e=>e.value!==`repeating`):i,[A,j]=(0,X.useState)(0),V=A>40?`text-red`:`text-green`,{siteData:U}=Y(),[W,G]=(0,X.useState)(!1),K=ce(U),q=`${K}${s.code.value}`,ne=async()=>{await navigator.clipboard.writeText(q),G(!0),setTimeout(()=>G(!1),2e3)};return(0,Z.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,Z.jsxs)(M,{className:`mb-10 gap-8`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{"data-invalid":!!_.name||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(w,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),j(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,Z.jsx)(N,{children:_.name}):(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Z.jsxs)(`strong`,{children:[(0,Z.jsx)(`span`,{className:V,children:h(A)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(L,{"data-invalid":!!_.displayTitle||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(w,{"aria-invalid":!!_.displayTitle||void 0,id:`offer-display-title`,maxLength:Ee,placeholder:`Black Friday Special`,value:s.displayTitle.value,onChange:e=>{d(e)},onKeyDown:()=>g(`displayTitle`)}),_.displayTitle&&(0,Z.jsx)(N,{children:_.displayTitle})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`offer-display-description`,maxLength:Ee,placeholder:`Take advantage of this limited-time offer.`,value:s.displayDescription,onChange:e=>{u(e)}})]})]})]}),(0,Z.jsxs)(`section`,{className:`mt-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsx)(te,{"aria-label":`Offer type`,className:`rounded-md border border-border-default p-4`,value:s.type===`trial`?`trial`:`percent`,onValueChange:a,children:r.map(e=>{let t=`offer-type-${e.value}`;return(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsx)(ee,{id:t,value:e.value}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(F,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(I,{children:e.description})]})]},e.value)})}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Tier — Cadence`}),(0,Z.jsxs)(k,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,Z.jsx)(D,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:e.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(L,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-amount`,children:`Amount off`}),(0,Z.jsxs)(H,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(z,{id:`offer-amount`,type:`number`,value:s.type===`fixed`?s.fixedAmount===0?``:s.fixedAmount?.toString():s.percentAmount===0?``:s.percentAmount?.toString(),onChange:e=>{p(e)},onKeyDown:()=>g(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsxs)(k,{value:s.type===`percent`?x[0].value:x[1].value,onValueChange:c,children:[(0,Z.jsx)(D,{"aria-label":`Amount type`,className:`h-7 w-20 border-0 bg-transparent px-2 shadow-none focus-visible:ring-0`,"data-testid":`amount-type-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{align:`end`,children:x.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,Z.jsx)(N,{children:_.amount})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Duration`}),(0,Z.jsxs)(k,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,Z.jsx)(D,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:C.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!S&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(L,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsxs)(H,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!_.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:s.durationInMonths===0?``:String(s.durationInMonths),onChange:e=>{f(e)},onKeyDown:()=>g(`durationInMonths`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,Z.jsx)(N,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,Z.jsxs)(L,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,Z.jsx)(w,{"aria-invalid":!!_.amount||void 0,id:`trial-duration`,type:`number`,value:s.trialAmount?.toString(),onChange:e=>{y(e)},onKeyDown:()=>g(`amount`)}),_.amount&&(0,Z.jsx)(N,{children:_.amount})]}),(0,Z.jsxs)(L,{"data-invalid":!!_.code||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsx)(w,{"aria-invalid":!!_.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:s.code.value,onChange:e=>{m(e)},onKeyDown:()=>g(`code`)}),_.code?(0,Z.jsx)(N,{children:_.code}):s.code.value!==``&&(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsxs)(`div`,{children:[K,(0,Z.jsx)(`span`,{className:`font-bold`,children:s.code.value})]}),(0,Z.jsx)(b,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void ne(),children:W?`Copied`:`Copy`})]})})]})]})]})]})})},Q=e=>{let[t,n,r]=e.split(`-`);if(!t||!n||!r)throw Error(`Invalid input format. Expected format is: id-period-currency`);return{id:t,period:n,currency:r}},ke=()=>{let{siteData:e}=Y(),t=[{title:`Discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free trial`,description:`Give free access for a limited time`,value:`trial`}],n=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],[i,a]=(0,X.useState)(``),{updateRoute:c}=j(),{data:{tiers:l}={}}=me(),d=he(l||[]),p=we(d),{mutateAsync:m}=f(),[h,g]=(0,X.useState)({tier:p[0]||{},dataset:{id:p[0]?.value?Q(p[0]?.value).id:``,period:p[0]?.value?Q(p[0]?.value).period:``,currency:p[0]?.value?Q(p[0]?.value).currency:``}}),{data:{offers:_=[]}={}}=u(),{formState:v,updateForm:y,handleSave:b,saveState:x,okProps:S,validate:C,errors:w,clearError:T}=s({initialState:{disableBackground:!1,name:``,code:{isDirty:!1,value:``},displayTitle:{isDirty:!1,value:``},displayDescription:``,type:`percent`,cadence:h?.dataset?.period||``,amount:0,duration:`once`,durationInMonths:1,currency:h?.dataset?.currency||`USD`,status:`active`,tierId:h?.dataset?.id||``,trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{let e=v.type===`trial`?`trial`:v.duration,t={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:De(v)||0,duration:e,...e===`repeating`?{duration_in_months:v.durationInMonths}:{},currency:v.currency,status:v.status,redemption_type:`signup`,tier:{id:v.tierId},type:v.type,currency_restriction:!1},n=await m(t);n&&n.offers&&n.offers.length>0&&c(`offers/success/${n.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{let e={};return!v.name&&v.name.length===0&&(e.name=`Name is required`),!v.code.value&&v.code.value.length===0&&(e.code=`Code is required`),!v.displayTitle.value&&v.displayTitle.value.length===0&&(e.displayTitle=`Display title is required`),v.type===`percent`&&v.percentAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`percent`&&(v.percentAmount<1||v.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),(v.type===`fixed`&&v.fixedAmount===0||v.type===`fixed`&&v.fixedAmount<1)&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount<1&&(e.amount=`Free trial must be at least 1 day.`),v.type!==`trial`&&v.duration===`repeating`&&(!Number.isInteger(v.durationInMonths)||v.durationInMonths<1)&&(e.durationInMonths=`Enter a whole number of months (1 or more).`),e},savingDelay:500}),E=[{value:`percent`,label:`%`},{value:`fixed`,label:v.currency}],D=e=>{let t=Q(e.value),n=t.period===`year`;g({tier:e,dataset:t}),y(e=>({...e,cadence:t.period,currency:t.currency,tierId:t.id,duration:n&&e.duration===`repeating`?`once`:e.duration})),n&&T(`durationInMonths`)},O=e=>{e===`trial`&&(T(`amount`),T(`durationInMonths`)),y(t=>({...t,type:e}))},k=e=>{y(t=>({...t,type:e===`percent`?`percent`:`fixed`}))},A=e=>{let t=e.target;v.type===`fixed`?y(e=>({...e,fixedAmount:Number(t.value)})):v.type===`percent`?y(e=>({...e,percentAmount:Number(t.value)})):y(e=>({...e,amount:Number(t.value)}))},M=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},N=e=>{let t=e.target.value;y(e=>{let n={...e};return n.name=t,e.code.isDirty||(T(`code`),n.code={...e.code,value:Te(t)}),e.displayTitle.isDirty||(T(`displayTitle`),n.displayTitle={...e.displayTitle,value:t}),n})},P=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},F=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},I=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},L=e=>{y(t=>({...t,duration:e}))},R=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},z=()=>{_.length>0?c(`offers/edit`):c(`offers`)},B=(0,X.useMemo)(()=>({name:v.name||``,code:v.code.value||``,displayTitle:v.displayTitle.value||``,displayDescription:v.displayDescription||``,type:v.type||`percent`,cadence:v.cadence||`month`,amount:De(v)||0,duration:v.type===`trial`?`trial`:v.duration||`once`,durationInMonths:v.durationInMonths||0,currency:v.currency||`USD`,status:v.status||`active`,tierId:v.tierId||d[0]?.id,redemptionType:`signup`}),[v,d]);(0,X.useEffect)(()=>{let t=Ce(B,e.url);a(t)},[v,e.url,v.type,B]);let V=(0,Z.jsx)(Oe,{amountOptions:E,clearError:T,durationOptions:n,errors:w,handleAmountInput:A,handleAmountTypeChange:k,handleCodeInput:R,handleDisplayTitleInput:P,handleDurationChange:L,handleDurationInMonthsInput:M,handleNameInput:N,handleTextAreaInput:F,handleTierChange:D,handleTrialAmountInput:I,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),H=(0,Z.jsx)(xe,{href:i||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:x===`unsaved`,height:`full`,okLabel:`Publish`,okVariant:S.variant,preview:H,previewToolbar:!1,sidebar:V,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:z,onClose:()=>{c(`offers`)},onOk:async()=>{if(C(),!Object.values(w).every(e=>!e)){o.dismiss(),o.info(`Can't save offer`,{description:`Make sure you filled all required fields`});return}try{if(await b({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:t||`Please try again later`})}}})},Ae=e=>new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`}),je=e=>{let t=`${i().adminRoot}#/members`,n=`offer_redemptions:[${e.join(`,`)}]`;return`${t}?filter=${encodeURIComponent(n)}`},Me=e=>je([e]),Ne=({amount:e,duration:t})=>e===100&&t===`repeating`,Pe=(e,t)=>`Retention ${e} (${t})`,Fe=({amount:e,duration:t,durationInMonths:n})=>Ne({amount:e,duration:t})?`${n} ${n===1?`month`:`months`} free`:t===`once`?`${e}% off once`:t===`repeating`?`${e}% off for ${n} mo`:`${e}% off forever`,Ie=(e,t)=>{let n=t.trim(),r=Fe(e),i=Pe(r,n);if(i.length<=40)return i;let a=i.length-40,o=Math.max(3,n.length-a);return Pe(r,n.slice(0,o))},Le=e=>e===`month`?`monthly`:`yearly`,Re=e=>e===`once`?`First payment`:e===`repeating`?`Repeating`:`Forever`,ze=(e,t,n,r,i)=>{let a=``,o=n===`month`?i?.monthly_price??0:i?.yearly_price??0,s=o,c=e=>parseFloat(e.toFixed(2)),l=e=>h(c(m(e)),{maximumFractionDigits:2}),u=p(r)+l(o);switch(e){case`percent`:a=`${h(t)}% off`,s=o-o*t/100;break;case`fixed`:a=`${l(t)} ${r} off`,s=o-t;break;case`trial`:a=`${h(t)} days free`,u=``;break;default:break}s<0&&(s=0);let d=p(r)+l(s);return{discountOffer:a,originalPriceWithCurrency:u,updatedPriceWithCurrency:d}};function Be(e){return new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`})}var Ve=({clearError:e,errors:t,offer:n,updateOffer:r})=>{let{siteData:i}=Y(),[s,c]=(0,X.useState)(!1),u=a(),{confirm:d}=ge(),{mutateAsync:f}=l(),[p,m]=(0,X.useState)(n?.name.length||0),g=p>40?`text-red`:`text-green`,{updateRoute:_}=j();(0,X.useEffect)(()=>{n?.name&&m(n?.name.length)},[n?.name]);let v=ce(i),y=`${v}${n?.code}`,x=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},S=()=>{n?.status===`active`?d({title:`Archive offer`,prompt:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:`New members will no longer be able to subscribe using this offer.`}),(0,Z.jsxs)(`p`,{children:[`All members that previously redeemed `,(0,Z.jsx)(`strong`,{children:n?.name}),` will remain unchanged.`]})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async e=>{try{await f({...n,status:`archived`}),e?.remove(),o.success(`Offer archived`),_(`offers/edit`)}catch(e){u(e)}}}):d({title:`Reactivate offer`,prompt:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`p`,{children:[`Reactivating `,(0,Z.jsx)(`strong`,{children:n?.name}),` will allow new members to subscribe using this offer. Existing members will remain unchanged.`]})}),okLabel:`Reactivate`,onOk:async e=>{try{await f({...n,status:`active`}),e?.remove(),o.success(`Offer reactivated`),_(`offers/edit`)}catch(e){u(e)}}})};return(0,Z.jsxs)(`div`,{className:`flex grow flex-col pt-2`,children:[(0,Z.jsxs)(M,{className:`mb-10 grow gap-8`,children:[(0,Z.jsx)(`section`,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Created on`}),(0,Z.jsx)(`span`,{children:Be(n?.created_at?n.created_at:``)})]}),(0,Z.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Z.jsxs)(`span`,{children:[h(n?.redemption_count||0),` `,n?.redemption_count===1?`redemption`:`redemptions`]})]}),n?.redemption_count>0&&n?.last_redeemed?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Z.jsx)(`span`,{children:Be(n?.last_redeemed)})]}):null]}),n?.redemption_count>0?(0,Z.jsx)(`a`,{className:`font-semibold text-green`,href:Me(n?.id),children:`See members →`}):null]})]})}),(0,Z.jsxs)(`section`,{className:`mt-2`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{"data-invalid":!!t.name||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(w,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),r({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,Z.jsx)(N,{children:t.name}):(0,Z.jsx)(I,{children:(0,Z.jsxs)(`div`,{className:`flex justify-between`,children:[(0,Z.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,Z.jsxs)(`strong`,{children:[(0,Z.jsx)(`span`,{className:g,children:h(p)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(L,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsxs)(H,{"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>r({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(V,{onClick:()=>void x(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,Z.jsx)(N,{children:t.code}):n?.code!==``&&(0,Z.jsxs)(I,{className:`truncate`,children:[v,(0,Z.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,Z.jsxs)(L,{"data-invalid":!!t.displayTitle||void 0,children:[(0,Z.jsx)(F,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(w,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>r({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,Z.jsx)(N,{children:t.displayTitle})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`offer-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`offer-display-description`,placeholder:`Take advantage of this limited-time offer.`,value:n?.display_description??``,onChange:e=>r({display_description:e.target.value})})]})]})]})]}),(0,Z.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,Z.jsx)(b,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:S,children:`Archive offer`}):(0,Z.jsx)(b,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:S,children:`Reactivate offer`})})]})},He=({id:e})=>{let{siteData:t}=Y(),{updateRoute:n}=j(),i=a(),{mutateAsync:c}=l(),[u,f]=(0,X.useState)(``),{data:{offers:p=[]}={}}=d(e||``),{formState:m,saveState:h,updateForm:g,setFormState:_,handleSave:v,validate:y,errors:b,clearError:x,okProps:S}=s({initialState:p[0],savingDelay:500,onSave:async()=>{await c(m)},onSaveError:i,onValidate:()=>{let e={};return m?.name||(e.name=`Name is required`),m?.display_title||(e.displayTitle=`Display title is required`),m?.code||(e.code=`Please enter a code`),e}});(0,X.useEffect)(()=>{_(()=>p[0])},[_,p]);let C=(0,Z.jsx)(Ve,{clearError:x,errors:b,offer:m,updateOffer:e=>{g(t=>({...t,...e}))},validate:y});(0,X.useEffect)(()=>{let e=Ce({name:m?.name||``,code:m?.code||``,displayTitle:m?.display_title||``,displayDescription:m?.display_description||``,type:m?.type||``,cadence:m?.cadence||``,amount:m?.amount,duration:m?.duration||``,durationInMonths:m?.duration_in_months||0,currency:m?.currency||``,status:m?.status||``,tierId:m?.tier?.id||``,redemptionType:`signup`},t.url);f(e)},[m,t]);let w=(0,Z.jsx)(xe,{href:u||``,portalParent:`offers`}),T=()=>{n(`offers/edit`)};return p?(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:h===`unsaved`,height:`full`,okLabel:S.label||`Save`,okVariant:S.variant,preview:w,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:m?.name||`Offer`,label:`Offers`,onBack:T}),sidebar:C,size:`lg`,testId:`offer-update-modal`,title:`Offer`,width:1140,onCancel:T,onClose:()=>{n(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:`Please try again later`})}}}):null},Ue=[{title:`Percentage discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free month(s)`,description:`Give free access for a limited time`,value:`free_months`}],We=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],Ge=191,Ke=99,qe=`Enter a whole number of months between 1 and ${Ke}.`,Je=e=>Math.max(1,Number.isFinite(e)?Math.trunc(e):0),Ye=({type:e,percentAmount:t,freeMonths:n,lastPercentAmount:r,lastFreeMonths:i})=>e===`free_months`?n>0?n:i:t>0?t:r,Xe=(e=`monthly`)=>({enabled:!1,displayTitle:``,displayDescription:``,type:e===`yearly`?`percent`:`free_months`,percentAmount:20,duration:`once`,durationInMonths:1,freeMonths:1}),Ze=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,Qe=(e,t=`monthly`)=>{let n=Xe(t);if(!e)return n;let r=Ze(e),i=e.type===`percent`&&!r,a=e.duration===`repeating`&&e.duration_in_months?e.duration_in_months:n.durationInMonths;return{enabled:e.status===`active`,displayTitle:e.display_title||``,displayDescription:e.display_description||``,type:r?`free_months`:`percent`,percentAmount:i?e.amount:n.percentAmount,duration:i?e.duration:n.duration,durationInMonths:a,freeMonths:r&&e.duration_in_months||n.freeMonths}},$e=({formState:e,lastPercentAmount:t,lastFreeMonths:n})=>{let r=Ye({type:e.type,percentAmount:e.percentAmount,freeMonths:e.freeMonths,lastPercentAmount:t,lastFreeMonths:n});if(e.type===`free_months`)return{type:`percent`,amount:100,duration:`repeating`,durationInMonths:Je(r)};let i=e.duration;return{type:`percent`,amount:r,duration:i,durationInMonths:i===`repeating`?Je(e.durationInMonths):0}},et=e=>{if(!e)return null;let t=e.duration_in_months??0;return{type:`percent`,amount:e.amount,duration:e.duration,durationInMonths:t}},tt=e=>e?`${e.type}:${e.amount}:${e.duration}:${e.durationInMonths}`:``,nt=e=>Number.isInteger(e)&&e>0&&e<=Ke,rt=(e,t)=>e.displayTitle!==t.displayTitle||e.displayDescription!==t.displayDescription||e.type!==t.type||e.percentAmount!==t.percentAmount||e.duration!==t.duration||e.durationInMonths!==t.durationInMonths||e.freeMonths!==t.freeMonths,it=({formState:e,updateForm:t,clearError:n,errors:r,cadence:i,lastRedeemed:a,membersFilterUrl:o,redemptions:s})=>{let c=i===`yearly`?We.filter(e=>e.value!==`repeating`):We;return(0,Z.jsx)(`div`,{className:`flex grow flex-col pt-2`,children:(0,Z.jsxs)(M,{className:`mb-10 grow gap-8`,children:[(0,Z.jsx)(`section`,{children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-5 rounded-md border border-grey-300 p-4 pb-3.5 dark:border-grey-800`,children:(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,Z.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Performance`}),(0,Z.jsxs)(`span`,{children:[h(s),` `,s===1?`redemption`:`redemptions`]})]}),s>0&&a?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm leading-none font-semibold text-grey-700`,children:`Last redemption`}),(0,Z.jsx)(`span`,{children:Ae(a)})]}):null]}),s>0&&o?(0,Z.jsx)(`a`,{className:`font-semibold text-green`,href:o,children:`See members →`}):null]})})})}),(0,Z.jsx)(`section`,{className:`mt-2`,children:(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsxs)(P,{children:[(0,Z.jsxs)(F,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,Z.jsx)(I,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,Z.jsx)(C,{checked:e.enabled,id:`${i}-retention-enabled`,onCheckedChange:e=>t(t=>({...t,enabled:e}))})]})}),e.enabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{className:`mt-2`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`retention-display-title`,children:`Display title`}),(0,Z.jsx)(w,{id:`retention-display-title`,maxLength:Ge,placeholder:`Before you go`,value:e.displayTitle,onChange:e=>{t(t=>({...t,displayTitle:e.target.value}))}})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{htmlFor:`retention-display-description`,children:`Display description`}),(0,Z.jsx)(re,{id:`retention-display-description`,maxLength:Ge,placeholder:`We'd hate to see you leave. How about a special offer to stay?`,value:e.displayDescription,onChange:e=>{t(t=>({...t,displayDescription:e.target.value}))}})]})]})]}),(0,Z.jsxs)(`section`,{className:`mt-4`,children:[(0,Z.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i===`monthly`&&(0,Z.jsx)(te,{"aria-label":`${i} retention offer type`,className:`rounded-md border border-border-default p-4`,value:e.type,onValueChange:e=>{n(`amount`),n(`durationInMonths`),t(t=>({...t,type:e}))},children:Ue.map(e=>{let t=`${i}-retention-type-${e.value}`;return(0,Z.jsxs)(L,{orientation:`horizontal`,children:[(0,Z.jsx)(ee,{id:t,value:e.value}),(0,Z.jsxs)(P,{children:[(0,Z.jsx)(F,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(I,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(L,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`retention-amount`,children:`Amount off`}),(0,Z.jsxs)(H,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.amount||void 0,id:`retention-amount`,type:`number`,value:e.percentAmount===0?``:String(e.percentAmount),onChange:e=>{let n=Number(e.target.value),r=Number.isNaN(n)?0:n;t(e=>({...e,percentAmount:r}))},onKeyDown:()=>n(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:`%`})})]}),r.amount&&(0,Z.jsx)(N,{children:r.amount})]}),(0,Z.jsxs)(L,{children:[(0,Z.jsx)(F,{children:`Duration`}),(0,Z.jsxs)(k,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,Z.jsx)(D,{"aria-label":`Duration`,children:(0,Z.jsx)(O,{})}),(0,Z.jsx)(E,{children:c.map(e=>(0,Z.jsx)(T,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(L,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsxs)(H,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:e.durationInMonths===0?``:String(e.durationInMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`durationInMonths`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,Z.jsx)(N,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,Z.jsxs)(L,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(F,{htmlFor:`retention-free-months`,children:`Free months`}),(0,Z.jsxs)(H,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(z,{"aria-invalid":!!r.amount||void 0,id:`retention-free-months`,type:`number`,value:e.freeMonths===0?``:String(e.freeMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,freeMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`amount`)}),(0,Z.jsx)(B,{align:`inline-end`,children:(0,Z.jsx)(R,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,Z.jsx)(N,{children:r.amount})]})]})]})]})]})})},at=({cadence:e})=>{let{updateRoute:t}=j(),{siteData:n}=Y(),{data:{tiers:i=[]}={}}=me(),{data:{offers:a=[]}={},isFetched:d,isFetching:p}=u(),{mutateAsync:m}=f(),{mutateAsync:h}=l(),g=c(),[_,v]=(0,X.useState)(``),y=e===`monthly`?`Monthly retention`:`Yearly retention`,b=e===`monthly`?`month`:`year`,x=he(i||[]),S=(0,X.useMemo)(()=>a.filter(e=>e.redemption_type===`retention`&&e.cadence===b).sort((e,t)=>{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n}),[a,b]),C=(0,X.useMemo)(()=>S.find(e=>e.status===`active`)||null,[S]),w=S[0]||null,T=C||w,E=(0,X.useMemo)(()=>S.reduce((e,t)=>e+(t.redemption_count||0),0),[S]),D=(0,X.useMemo)(()=>S.map(e=>e.id),[S]),O=(0,X.useMemo)(()=>S.map(e=>e.last_redeemed).filter(e=>!!e).sort((e,t)=>new Date(t).getTime()-new Date(e).getTime())[0]||null,[S]),k=(0,X.useMemo)(()=>E===0||D.length===0?null:je(D),[D,E]),[A,M]=(0,X.useState)(20),[N,P]=(0,X.useState)(1),[F,I]=(0,X.useState)(null),{formState:L,setFormState:R,updateForm:z,handleSave:B,saveState:V,okProps:H,errors:ee,clearError:te}=s({initialState:Xe(e),savingDelay:500,onSave:async()=>{let t=!1,n=$e({formState:L,lastPercentAmount:A,lastFreeMonths:N}),r=tt(et(T))!==tt(n),i=L.enabled?`active`:`archived`,a=L.displayTitle||``,o=L.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Xe(e),l=!L.enabled&&!T&&rt(L,c),u=async e=>{let r=crypto.getRandomValues(new Uint32Array(1))[0].toString(16).padStart(8,`0`),i=Ie(n,r);await m({name:i,code:r,display_title:a,display_description:o,cadence:b,amount:n.amount,duration:n.duration,duration_in_months:n.duration===`repeating`?n.durationInMonths:null,currency:null,status:e,redemption_type:`retention`,tier:null,type:n.type,currency_restriction:!1}),t=!0},d=async()=>{t&&await g()};if(!(!T&&!L.enabled&&!l)){if(r){!L.enabled&&C&&(await h({...C,status:`archived`}),t=!0),await u(i),await d();return}if(T){let e=T.status!==i;(s||e)&&(await h({...T,display_title:a,display_description:o,status:i}),t=!0),await d();return}(L.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message||t),o.dismiss(),o.error(`Failed to save offer`,{description:t})},onValidate:()=>{let e={};return L.enabled?(L.type===`percent`&&((L.percentAmount<1||L.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),L.duration===`repeating`&&!nt(L.durationInMonths)&&(e.durationInMonths=qe)),L.type===`free_months`&&(nt(L.freeMonths)||(e.amount=qe)),e):e}}),U=`${e}:${T?.id||`none`}`;(0,X.useEffect)(()=>{!d||p||V===`unsaved`||F===U||(R(()=>Qe(T,e)),I(U))},[e,U,T,d,F,p,V,R]),(0,X.useEffect)(()=>{L.percentAmount>0&&M(L.percentAmount)},[L.percentAmount]),(0,X.useEffect)(()=>{L.freeMonths>0&&P(L.freeMonths)},[L.freeMonths]);let W=()=>{t(`offers/edit`)},G=(0,Z.jsx)(it,{cadence:e,clearError:te,errors:ee,formState:L,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:z}),K=async()=>{try{await B({force:!0})&&W()}catch{}},q=(0,X.useMemo)(()=>{let t=$e({formState:L,lastPercentAmount:A,lastFreeMonths:N}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:L.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:L.displayTitle||``,displayDescription:L.displayDescription||``,type:t.type,cadence:b,amount:t.amount,duration:t.duration,durationInMonths:t.durationInMonths,currency:``,status:`active`,tierId:n?.id||``,redemptionType:`retention`}},[x,e,L,N,A,b]);(0,X.useEffect)(()=>{if(!n.url){v(``);return}let e=Ce(q,n.url);v(e)},[q,n.url]);let ne=(0,Z.jsx)(xe,{href:_||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:V===`unsaved`,height:`full`,okLabel:H.label||`Save`,okVariant:H.variant,preview:ne,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:y,label:`Offers`,onBack:W}),sidebar:G,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:W,onClose:()=>t(`offers`),onOk:K})},ot=({id:e})=>{let{updateRoute:t}=j(),{data:{offers:n=[]}={}}=d(e||``),[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(``),{siteData:s}=Y();(0,X.useEffect)(()=>{if(n.length>0){let e=n[0],t=`${ce(s)}${e?.code}`;o(t),i(e)}},[n,s]);let[c,l]=(0,X.useState)(!1),u=()=>{let e=``;switch(r?.type){case`percent`:e=r?.amount+`% discount`;break;case`fixed`:e=h(m(r?.amount),{maximumFractionDigits:2})+` `+r?.currency+` discount`;break;case`trial`:e=r?.amount+` days free trial`;break;default:break}return`${encodeURIComponent(r?.name||``)} — Check out ${encodeURIComponent(e)} on:`},f=async()=>{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)};return(0,Z.jsx)(A,{animate:!1,backDropClick:!1,footer:!1,height:`full`,size:`lg`,testId:`offer-success-modal`,topRightContent:`close`,width:1140,onClose:()=>{t(`offers`)},children:(0,Z.jsxs)(`div`,{className:`-mt-6 flex h-full flex-col items-center justify-center text-center`,children:[(0,Z.jsx)(Se,{className:`absolute top-5 left-6`,current:r?.name||``,label:`Offers`,onBack:()=>t(`offers/edit`)}),(0,Z.jsx)(y,{className:`-mt-4 size-10 text-grey-700`}),(0,Z.jsx)(`h1`,{className:`mt-6 text-4xl`,children:`Your new offer is live!`}),(0,Z.jsx)(`p`,{className:`mt-3 max-w-[510px] text-[1.6rem]`,children:`You can share the link anywhere. In your newsletter, social media, a podcast, or in-person. It all just works.`}),(0,Z.jsxs)(`div`,{className:`mt-8 flex w-full max-w-md flex-col gap-8`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col-reverse gap-2`,children:[(0,Z.jsx)(w,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,Z.jsx)(b,{className:`w-full`,type:`button`,onClick:()=>void f(),children:c?`Copied!`:`Copy link`})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-4 text-sm font-medium before:h-px before:grow before:bg-grey-300 before:content-[""] after:h-px after:grow after:bg-grey-300 after:content-[""] dark:before:bg-grey-800 dark:after:bg-grey-800`,children:`OR`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(b,{"aria-label":`Share on X`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(a)}&text=${u()}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`twitter-x`})}),(0,Z.jsx)(b,{"aria-label":`Share on Facebook`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(a)}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`facebook`})}),(0,Z.jsx)(b,{"aria-label":`Share on LinkedIn`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(a)}&title=${u()}`,`_blank`)},children:(0,Z.jsx)(_e,{className:`size-3.5!`,name:`linkedin`})})]})]})]})})},st=(e,t)=>e.find(e=>e.redemption_type===`retention`&&e.cadence===t&&e.status===`active`)||null,ct=(e,t)=>e.reduce((e,n)=>n.redemption_type!==`retention`||n.cadence!==t?e:e+(n.redemption_count||0),0),lt=(e,t)=>e.filter(e=>e.redemption_type===`retention`&&e.cadence===t).map(e=>e.id),ut=(e,t)=>{let n=e.filter(e=>e.redemption_type===`retention`&&e.cadence===t&&e.created_at).map(e=>new Date(e.created_at).getTime()).filter(e=>!Number.isNaN(e));return n.length===0?null:new Date(Math.max(...n)).toISOString()},dt=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,ft=e=>{if(!e)return null;if(dt(e)){let t=e.duration_in_months||0,n=t===1?`month`:`months`;return`${h(t)} ${n} free`}return e.type===`percent`?`${h(e.amount)}% OFF`:null},pt=e=>{if(!e)return null;if(dt(e))return``;if(e.duration===`once`)return`First payment`;if(e.duration===`repeating`&&e.duration_in_months){let t=e.duration_in_months===1?`month`:`months`;return`For ${h(e.duration_in_months)} ${t}`}return e.duration===`forever`?`Forever`:null},mt=e=>{let t=st(e,`month`),n=st(e,`year`),r=lt(e,`month`),i=lt(e,`year`),a=ct(e,`month`),o=ct(e,`year`);return[{id:`monthly`,name:`Monthly retention`,description:`Applied to monthly plans`,terms:ft(t),termsDetail:pt(t),redemptionOfferIds:r,redemptions:a,status:t?`active`:`inactive`,createdAt:ut(e,`month`)},{id:`yearly`,name:`Yearly retention`,description:`Applied to annual plans`,terms:ft(n),termsDetail:pt(n),redemptionOfferIds:i,redemptions:o,status:n?`active`:`inactive`,createdAt:ut(e,`year`)}]},ht=({showArchived:e,setShowArchived:t,sortOption:n,sortDirection:r,onSortChange:i,onDirectionChange:a})=>(0,Z.jsxs)(oe,{children:[(0,Z.jsx)(fe,{asChild:!0,children:(0,Z.jsx)(b,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(v,{size:16,strokeWidth:1.5})})}),(0,Z.jsxs)(ae,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,Z.jsx)(ue,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,Z.jsxs)(se,{value:n,onValueChange:i,children:[(0,Z.jsx)(ie,{value:`date-added`,children:`Date added`}),(0,Z.jsx)(ie,{value:`name`,children:`Name`}),(0,Z.jsx)(ie,{value:`redemptions`,children:`Redemptions`})]}),(0,Z.jsxs)(le,{onSelect:a,children:[r===`asc`?(0,Z.jsx)(S,{className:`size-3`}):(0,Z.jsx)(x,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,Z.jsx)(de,{}),(0,Z.jsx)(pe,{checked:e,onCheckedChange:e=>t(!!e),children:`Show archived`})]})]}),gt=({offer:e,onClick:t})=>{let n=e.redemptions>0&&e.redemptionOfferIds.length>0?je(e.redemptionOfferIds):void 0;return(0,Z.jsxs)(W,{"data-testid":`retention-offer-item`,children:[(0,Z.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.terms?(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:e.terms}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:e.termsDetail})]}):(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:n?(0,Z.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,"data-testid":`retention-redemptions-link-${e.id}`,href:n,children:h(e.redemptions)}):(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,"data-testid":`retention-redemptions-link-${e.id}`,type:`button`,onClick:t,children:h(e.redemptions)})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.status===`active`?(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`secondary`,children:`Inactive`})})})]})},_t=({archived:e,offer:t,tier:n,onClick:r})=>{let{discountOffer:i,originalPriceWithCurrency:a,updatedPriceWithCurrency:o}=ze(t.type,t.amount,t.cadence,t.currency||`USD`,n);return(0,Z.jsxs)(W,{className:e?`opacity-60`:void 0,"data-testid":`offer-item`,children:[(0,Z.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`font-semibold`,children:t.name}),(0,Z.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.name,` `,Le(t.cadence)]})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,Z.jsxs)(_,{gap:`none`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:i}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.type===`trial`?`Trial period`:Re(t.duration)})]})})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsxs)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:o}),` `,t.type===`trial`?null:(0,Z.jsx)(`span`,{className:`relative text-sm text-muted-foreground before:absolute before:-inset-x-0.5 before:top-1/2 before:rotate-[-20deg] before:border-t before:content-[""]`,children:a})]})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:t.redemption_count>0&&t.id?(0,Z.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,href:Me(t.id),children:h(t.redemption_count)}):(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:h(t.redemption_count)})}),(0,Z.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,Z.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:e?(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,Z.jsx)(J,{className:`rounded-full uppercase`,variant:`success`,children:`Active`})})})]})},$=e=>e.offer.name,vt=e=>e.kind===`retention`?e.offer.redemptions:e.offer.redemption_count,yt=e=>e.kind===`retention`?e.offer.createdAt:e.offer.created_at||null,bt=(e,t,n)=>{let r=n===`desc`?-1:1;return[...e].sort((e,n)=>{let i;switch(t){case`name`:i=$(e).localeCompare($(n));break;case`redemptions`:i=vt(e)-vt(n);break;default:{let t=yt(e),r=yt(n);if(!t&&!r)i=0;else if(!t)return 1;else if(r)i=new Date(t).getTime()-new Date(r).getTime();else return-1;break}}return(i||$(e).localeCompare($(n)))*r})},xt=()=>{let{updateRoute:e}=j(),{data:{offers:t=[]}={}}=u(),{data:{tiers:n}={}}=me(),r=t.filter(e=>e.redemption_type===`signup`),i=mt(t),{sortingState:a,setSortingState:s}=ve(),c=a?.find(e=>e.type===`offers`),{offersShowArchived:l,setOffersShowArchived:d}=ye(),f=c?.option||`date-added`,p=c?.direction||`desc`,m=t=>{t&&e(`offers/edit/${t}`)},h=t=>{e(`offers/edit/retention/${t}`)},v=he(n||[]),y=r.filter(e=>{let t=n?.find(t=>t.id===e?.tier?.id),r=e.status===`active`&&t&&t.active===!0,i=e.status===`archived`||t&&t.active===!1;return!!(r||l&&i)}),x=bt([...i.map(e=>({kind:`retention`,offer:e})),...y.map(e=>({kind:`signup`,offer:e}))],f,p),S=e=>{s?.([{type:`offers`,option:e,direction:p}])},C=()=>{s?.([{type:`offers`,option:f,direction:p===`asc`?`desc`:`asc`}])},w=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,Z.jsx)(A,{animate:!1,backDropClick:!1,cancelLabel:``,footer:!1,height:`full`,size:`lg`,testId:`offers-modal`,title:`Offers`,topRightContent:(0,Z.jsxs)(g,{gap:`md`,children:[(0,Z.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,Z.jsx)(b,{type:`button`,onClick:()=>{v.length===0?o.info(`You must have an active tier to create an offer.`):e(`offers/new`)},children:`New offer`})]}),width:1140,onClose:()=>{e(`offers`)},children:(0,Z.jsx)(_,{className:`h-full pt-8`,children:(0,Z.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Z.jsxs)(ne,{className:`m-0 min-w-[900px]`,children:[(0,Z.jsxs)(`colgroup`,{children:[(0,Z.jsx)(`col`,{className:`w-[25%]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[200px]`}),(0,Z.jsx)(`col`,{className:`w-[220px]`})]}),(0,Z.jsx)(q,{children:(0,Z.jsxs)(W,{children:[(0,Z.jsx)(U,{className:`sticky left-0 z-10 h-auto bg-background p-0 pb-2.5 pl-5 uppercase`,children:`Name`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Terms`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Price`}),(0,Z.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Redemptions`}),(0,Z.jsx)(U,{className:`h-auto p-0 px-5 pb-2.5 uppercase`,children:(0,Z.jsxs)(g,{align:`center`,justify:`between`,children:[`Status`,(0,Z.jsx)(ht,{setShowArchived:d,showArchived:l,sortDirection:p,sortOption:f,onDirectionChange:C,onSortChange:S})]})})]})}),(0,Z.jsx)(G,{"data-testid":`offers-table-body`,children:x.map(e=>{if(e.kind===`retention`)return(0,Z.jsx)(gt,{offer:e.offer,onClick:()=>h(e.offer.id)},`retention-${e.offer.id}`);let t=e.offer,r=n?.find(e=>e.id===t?.tier?.id);if(!r)return null;let i=w(t);return(0,Z.jsx)(_t,{archived:i,offer:t,tier:r,onClick:()=>m(t.id)},`signup-${t.id}`)})})]})})})})},St=`offers/edit/retention/`,Ct=e=>{let t=e.slice(22).replace(/\/+$/,``);return t===`monthly`||t===`yearly`?t:null},wt=({route:e})=>{if(e===`offers/new`)return(0,Z.jsx)(ke,{});if(e===`offers/edit/retention`||e.startsWith(St)){let t=e.startsWith(St)?Ct(e):null;return t?(0,Z.jsx)(at,{cadence:t}):(0,Z.jsx)(xt,{})}else if(e.startsWith(`offers/edit/`)&&e.length>12){let t=e.split(`/`).pop();return(0,Z.jsx)(He,{id:t||``})}else if(e.startsWith(`offers/success/`)&&e.length>15){let t=e.split(`/`).pop();return(0,Z.jsx)(ot,{id:t||``})}else if(e===`offers/edit`||e===`offers/edit/`)return(0,Z.jsx)(xt,{})},Tt=()=>{let{route:e}=j();return(0,Z.jsx)(wt,{route:e})};export{Tt as default};