ghost 6.68.0 → 6.69.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 (300) hide show
  1. package/components/ghost-storage-base-3.0.1.tgz +0 -0
  2. package/components/tryghost-adapter-base-cache-0.2.1.tgz +0 -0
  3. package/components/tryghost-adapter-base-scheduling-0.2.5.tgz +0 -0
  4. package/components/tryghost-adapter-base-sso-0.1.4.tgz +0 -0
  5. package/components/tryghost-app-contracts-0.0.0.tgz +0 -0
  6. package/components/tryghost-checkout-0.0.0.tgz +0 -0
  7. package/components/tryghost-i18n-0.0.0.tgz +0 -0
  8. package/components/tryghost-kg-card-factory-5.2.6.tgz +0 -0
  9. package/components/tryghost-kg-clean-basic-html-4.3.6.tgz +0 -0
  10. package/components/tryghost-kg-converters-1.2.6.tgz +0 -0
  11. package/components/tryghost-kg-default-cards-10.3.7.tgz +0 -0
  12. package/components/tryghost-kg-default-nodes-2.2.3.tgz +0 -0
  13. package/components/tryghost-kg-default-transforms-1.3.6.tgz +0 -0
  14. package/components/tryghost-kg-html-to-lexical-1.4.1.tgz +0 -0
  15. package/components/tryghost-kg-lexical-html-renderer-1.5.1.tgz +0 -0
  16. package/components/tryghost-kg-markdown-html-renderer-7.2.7.tgz +0 -0
  17. package/components/tryghost-kg-utils-1.1.6.tgz +0 -0
  18. package/components/tryghost-metafield-csv-0.0.0.tgz +0 -0
  19. package/components/tryghost-metafield-types-0.1.1.tgz +0 -0
  20. package/core/boot.js +6 -0
  21. package/core/built/admin/assets/{about-D_nwtf7X.js → about-Dxp30cNg.js} +1 -1
  22. package/core/built/admin/assets/{account-migration-BaecWw1T.js → account-migration-D05akW4q.js} +1 -1
  23. package/core/built/admin/assets/activitypub/{account-migration-4saTEZ6p.js → account-migration-BmiwuzXI.js} +6 -6
  24. package/core/built/admin/assets/activitypub/activitypub.js +2 -2
  25. package/core/built/admin/assets/activitypub/{bluesky-sharing-BHBNuZQH.js → bluesky-sharing-B1fzMdFb.js} +6 -6
  26. package/core/built/admin/assets/activitypub/{content-formatters-DVx9YktY.js → content-formatters-G0qBT5QE.js} +3 -3
  27. package/core/built/admin/assets/activitypub/{domain-rAmlMXBC.js → domain-B3UtdA1m.js} +7 -7
  28. package/core/built/admin/assets/activitypub/{edit-profile-CXYL4ZrS.js → edit-profile-9EodzviR.js} +4 -4
  29. package/core/built/admin/assets/activitypub/{explore-dqpEx3GA.js → explore-DmwPdxHI.js} +8 -8
  30. package/core/built/admin/assets/activitypub/{feed-Cb-wYNw9.js → feed-yauqnu7A.js} +5 -5
  31. package/core/built/admin/assets/activitypub/{field-JxegcPt6.js → field-CsrMjbg2.js} +2 -2
  32. package/core/built/admin/assets/activitypub/{inbox-2hXDJBn5.js → inbox-DV3RrpFH.js} +7 -7
  33. package/core/built/admin/assets/activitypub/{label-DRQzZ7lb.js → label-DPs40NLn.js} +2 -2
  34. package/core/built/admin/assets/activitypub/layout-CvOhndCA.js +1 -0
  35. package/core/built/admin/assets/activitypub/{moderation-BnYKcTXY.js → moderation-DGa6hVNH.js} +7 -7
  36. package/core/built/admin/assets/activitypub/{note-C6ucS3Wu.js → note-BVL6LVHF.js} +5 -5
  37. package/core/built/admin/assets/activitypub/{notifications-DgBW9wEC.js → notifications-CRUu_uMC.js} +5 -5
  38. package/core/built/admin/assets/activitypub/{onboarding-DGu6yG4L.js → onboarding-Dpm-nLkQ.js} +2 -2
  39. package/core/built/admin/assets/activitypub/{onboarding-Bq3fNf_a.js → onboarding-KtpJA-xb.js} +2 -2
  40. package/core/built/admin/assets/activitypub/{preferences-C3jI1eVN.js → preferences-CdFuVqIt.js} +7 -7
  41. package/core/built/admin/assets/activitypub/{profile-Cn3vRb5Z.js → profile-KnNAoHYu.js} +8 -8
  42. package/core/built/admin/assets/activitypub/{routes-DbrwlS9h.js → routes-BRndai50.js} +26 -26
  43. package/core/built/admin/assets/activitypub/{settings-D0BALDQu.js → settings-DU7ftJ8w.js} +4 -4
  44. package/core/built/admin/assets/activitypub/{site-BFGj8HuQ.js → site-D1ZYV3AT.js} +2 -2
  45. package/core/built/admin/assets/activitypub/{step-1-CaoPg0a5.js → step-1-9IHheE78.js} +4 -4
  46. package/core/built/admin/assets/activitypub/{step-3-5k0TkyC9.js → step-3-DBERnfa-.js} +3 -3
  47. package/core/built/admin/assets/activitypub/{tabs-BV4JU7Vg.js → tabs-CvkwStij.js} +4 -4
  48. package/core/built/admin/assets/activitypub/{topic-filter-71sX5nfN.js → topic-filter-CS0Jsf_4.js} +2 -2
  49. package/core/built/admin/assets/activitypub/{use-activity-pub-queries-B3srUuKt.js → use-activity-pub-queries-CGgtQrxL.js} +2 -2
  50. package/core/built/admin/assets/activitypub/{use-reply-chain-data-Cl6bGNy7.js → use-reply-chain-data-CLdUpx1t.js} +4 -4
  51. package/core/built/admin/assets/activitypub/{users-EcSPpds5.js → users-CyoMXlwX.js} +11 -3
  52. package/core/built/admin/assets/{add-integration-modal-DBFzeAUT.js → add-integration-modal-BVg-ec8i.js} +1 -1
  53. package/core/built/admin/assets/{add-newsletter-modal-CYJe-dTC.js → add-newsletter-modal-Du6th521.js} +1 -1
  54. package/core/built/admin/assets/{add-recommendation-modal-CgwGKH-_.js → add-recommendation-modal-BiCJ0-q5.js} +1 -1
  55. package/core/built/admin/assets/{analytics-CcXT_WqF.js → analytics-CQJzDDdJ.js} +1 -1
  56. package/core/built/admin/assets/{announcement-bar-modal-Ldcg-PB-.js → announcement-bar-modal-CskyZLzT.js} +1 -1
  57. package/core/built/admin/assets/{api-BLteQZ7W.js → api-BFocMbDg.js} +2 -2
  58. package/core/built/admin/assets/{api-keys-CoeerpwI.js → api-keys-CqKJHuAV.js} +1 -1
  59. package/core/built/admin/assets/{audience-Deg9lzfk.js → audience-Dn7LuH-r.js} +1 -1
  60. package/core/built/admin/assets/{auth-layout-CRaMX7g6.js → auth-layout-VLhXgXn5.js} +1 -1
  61. package/core/built/admin/assets/{automated-emails-WcjjRkRV.js → automated-emails-D5cFl1wr.js} +1 -1
  62. package/core/built/admin/assets/{automations-CbIdX0rd.js → automations-BpweKEcq.js} +1 -1
  63. package/core/built/admin/assets/automations-DBTYwNTJ.js +1 -0
  64. package/core/built/admin/assets/{bluesky-sharing-BJMNRwnU.js → bluesky-sharing-CrfpFHQ9.js} +1 -1
  65. package/core/built/admin/assets/{chart-helpers-D-3N170i.js → chart-helpers-BSuFLd6-.js} +1 -1
  66. package/core/built/admin/assets/{chunk.524.94ab17e1199b4c3f4615.js → chunk.524.e24d68bc6253b274b726.js} +4 -4
  67. package/core/built/admin/assets/{chunk.582.6f09b19a007e2805824e.js → chunk.582.47834285406dfa1abb29.js} +6 -6
  68. package/core/built/admin/assets/{chunk.476.53b5794a67d68111e0bf.js → chunk.837.e1454abc054e1fba1fe5.js} +5 -5
  69. package/core/built/admin/assets/{code-editor-view-DhTwpxxv.js → code-editor-view-BrGe3eS4.js} +1 -1
  70. package/core/built/admin/assets/{code-editor-view-C7wXGiuv.js → code-editor-view-CY6JCXNv.js} +1 -1
  71. package/core/built/admin/assets/{color-picker-field-Cjz2zY11.js → color-picker-field-DGe9HH6W.js} +1 -1
  72. package/core/built/admin/assets/{comments-DY-VLVxh.js → comments-iRbF6XiJ.js} +1 -1
  73. package/core/built/admin/assets/{config-B3HuCo0y.js → config-CRAZ4Civ.js} +1 -1
  74. package/core/built/admin/assets/{content-api-modal-2jt-jWiM.js → content-api-modal-B-XRbzeW.js} +1 -1
  75. package/core/built/admin/assets/{content-formatters-VqvNA7Pv.js → content-formatters-C08JJbUJ.js} +2 -2
  76. package/core/built/admin/assets/{context-menu-BWbk9nd5.js → context-menu-BxGXsgQO.js} +1 -1
  77. package/core/built/admin/assets/{custom-field-type-option-CIatEwIN.js → custom-field-type-option-C8Nt4X6x.js} +1 -1
  78. package/core/built/admin/assets/{custom-integration-modal-Cw0w2Tb3.js → custom-integration-modal-DzI16qjN.js} +1 -1
  79. package/core/built/admin/assets/{date-range-select-O-uA-BRV.js → date-range-select-BZqsYsGx.js} +1 -1
  80. package/core/built/admin/assets/{design-and-theme-modal-BLjNHRYN.js → design-and-theme-modal-1ty_KEkM.js} +2 -2
  81. package/core/built/admin/assets/{dist-DJhCsld6.js → dist-B4jqKAG5.js} +1 -1
  82. package/core/built/admin/assets/{dist-5Ol0DC_t.js → dist-Bmo2j_KH.js} +1 -1
  83. package/core/built/admin/assets/{dist-p52UDdoR.js → dist-C-_aTlvJ.js} +1 -1
  84. package/core/built/admin/assets/{dist-CcN1a5SB.js → dist-CWHIoxYn.js} +1 -1
  85. package/core/built/admin/assets/{dist-BcfsaiCV.js → dist-Cp2M5TzT.js} +1 -1
  86. package/core/built/admin/assets/{dist-kjTYGivb.js → dist-DQAAPbtg.js} +1 -1
  87. package/core/built/admin/assets/{dist-IMek6Acg.js → dist-DyO279y5.js} +1 -1
  88. package/core/built/admin/assets/{domain-DaPAeOFF.js → domain-DiFl_Z1A.js} +1 -1
  89. package/core/built/admin/assets/{edit-profile-BKO5qonH.js → edit-profile-PrLbJV3P.js} +1 -1
  90. package/core/built/admin/assets/editor-BBJDJL8U.js +8 -0
  91. package/core/built/admin/assets/{editor-screen-l4BUPE2o.js → editor-screen-nblrp808.js} +3 -3
  92. package/core/built/admin/assets/{email-previews-B1Ska3CF.js → email-previews-BKJxrW29.js} +1 -1
  93. package/core/built/admin/assets/{email-sending-status-provider-Bjn5KTy2.js → email-sending-status-provider-DB9ylBWk.js} +1 -1
  94. package/core/built/admin/assets/{emails-qxNbhO6X.js → emails-8YiSmC2X.js} +1 -1
  95. package/core/built/admin/assets/{embed-signup-form-modal-DSgds6Js.js → embed-signup-form-modal-CZmbYKfd.js} +1 -1
  96. package/core/built/admin/assets/{error-boundary-CJODV8Rg.js → error-boundary-DrxPFFO-.js} +1 -1
  97. package/core/built/admin/assets/{esm-CNLDtBMc.js → esm-_iCUCvbN.js} +1 -1
  98. package/core/built/admin/assets/{explore-C6V_JpUZ.js → explore-C69LSRVg.js} +1 -1
  99. package/core/built/admin/assets/{feed-B_TyFn9E.js → feed-B_0m7WhZ.js} +1 -1
  100. package/core/built/admin/assets/{feedback-gKOzmiGt.js → feedback-DW1DXdzT.js} +1 -1
  101. package/core/built/admin/assets/{filters-Bf6E1qAP.js → filters-Dr3vMnjZ.js} +1 -1
  102. package/core/built/admin/assets/{filters-DhsiEotO.js → filters-M2sRWPoF.js} +1 -1
  103. package/core/built/admin/assets/{first-promoter-modal-LmTXHr-z.js → first-promoter-modal-D43R2zhI.js} +1 -1
  104. package/core/built/admin/assets/{focus-koenig-editor-on-bottom-click-BAcLNJti.js → focus-koenig-editor-on-bottom-click-BzS8jiJf.js} +1 -1
  105. package/core/built/admin/assets/fullscreen-close-button-CWSp-MsK.js +1 -0
  106. package/core/built/admin/assets/{ghost-63bc7da4336844000c523a5a0819531e.js → ghost-ffde29676517b768b1aef5ec8d492418.js} +93 -96
  107. package/core/built/admin/assets/{gift-link-modal-uZtwRHzl.js → gift-link-modal-CNE7dfPD.js} +1 -1
  108. package/core/built/admin/assets/{gift-links-HVqaXear.js → gift-links-lQ7H_D8Z.js} +1 -1
  109. package/core/built/admin/assets/global-search-modal-DzRM3aON.js +1 -0
  110. package/core/built/admin/assets/{growth-BlPW4DHj.js → growth-CAi_5HIf.js} +1 -1
  111. package/core/built/admin/assets/{growth-CflU3vR0.js → growth-CMHbTWKE.js} +1 -1
  112. package/core/built/admin/assets/history-modal-BIz13vhr.js +1 -0
  113. package/core/built/admin/assets/{hooks-C-BDQ6Hs.js → hooks-0r7qxGEo.js} +2 -2
  114. package/core/built/admin/assets/{html-field-D6G0G1d_.js → html-field-vTe2q1be.js} +1 -1
  115. package/core/built/admin/assets/{iframe-buffering-DW-Axhvc.js → iframe-buffering-cu-yK7NA.js} +1 -1
  116. package/core/built/admin/assets/{images-BSUWxquu.js → images-DTZtaIAr.js} +1 -1
  117. package/core/built/admin/assets/{inbox-BkU3sg13.js → inbox-BHfpmmzn.js} +1 -1
  118. package/core/built/admin/assets/{index-z8-nEVdb.css → index-B02LJqc8.css} +1 -1
  119. package/core/built/admin/assets/{index-CuDhPtkB.js → index-RuRs_qGS.js} +3 -3
  120. package/core/built/admin/assets/{index.es-H6HOI4DG.js → index.es-rdb1skp_.js} +1 -1
  121. package/core/built/admin/assets/{integrations-BRo5DwA5.js → integrations-Deg9-u8X.js} +1 -1
  122. package/core/built/admin/assets/{invite-user-modal-CydBOG99.js → invite-user-modal-C4DeNcoO.js} +1 -1
  123. package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +10483 -10455
  124. package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +131 -131
  125. package/core/built/admin/assets/{koenig-lexical-CG_eb4dw.js → koenig-lexical-BhXu1__-.js} +96 -96
  126. package/core/built/admin/assets/{kpi-helpers-CyRx_yD6.js → kpi-helpers-H-Hl6h7h.js} +1 -1
  127. package/core/built/admin/assets/{kpi-tabs-V1_Nu9sh.js → kpi-tabs-k4A9-imn.js} +1 -1
  128. package/core/built/admin/assets/{label-picker-GTIIlBQ6.js → label-picker-DaivLdMw.js} +1 -1
  129. package/core/built/admin/assets/{labels-BVGLgdAj.js → labels-BCj6D_nl.js} +1 -1
  130. package/core/built/admin/assets/{layout-CG58T6P7.js → layout-_g2xhB0L.js} +1 -1
  131. package/core/built/admin/assets/{lib-Dkic19kH.js → lib-Bre6UXdJ.js} +2 -2
  132. package/core/built/admin/assets/{links-jD8AkkIu.js → links-C8RnEJVJ.js} +1 -1
  133. package/core/built/admin/assets/{member-activity-JggQ0VNQ.js → member-activity-DNJPUW5X.js} +1 -1
  134. package/core/built/admin/assets/{member-activity-feed-BBeCZmLM.js → member-activity-feed-CvKEetHS.js} +1 -1
  135. package/core/built/admin/assets/{member-custom-fields-DPsyP1Hq.js → member-custom-fields-CBdiwPD9.js} +1 -1
  136. package/core/built/admin/assets/{member-detail-D7qugPN7.js → member-detail-BIoyIIsl.js} +1 -1
  137. package/core/built/admin/assets/{members-Cj_BUZUL.js → members-CH6KeXQc.js} +1 -1
  138. package/core/built/admin/assets/{members-alDWPKDd.js → members-Dd9RczFK.js} +1 -1
  139. package/core/built/admin/assets/{migrate-2uKKakld.js → migrate-CVQIWsXO.js} +1 -1
  140. package/core/built/admin/assets/{moderation-pCUKsxbF.js → moderation-OtjZoNOc.js} +1 -1
  141. package/core/built/admin/assets/{navigation-modal-D0FBI5-m.js → navigation-modal-Bl02NjtO.js} +1 -1
  142. package/core/built/admin/assets/{newsletter-4urgCSR_.js → newsletter-BXyT7o69.js} +1 -1
  143. package/core/built/admin/assets/{newsletter-detail-modal-Chh1jvjH.js → newsletter-detail-modal-DxuKNu_1.js} +1 -1
  144. package/core/built/admin/assets/{newsletter-emails-CzVCiC2K.js → newsletter-emails-DicgmnMU.js} +1 -1
  145. package/core/built/admin/assets/{newsletters-eRQTtOBH.js → newsletters-By25FmUs.js} +1 -1
  146. package/core/built/admin/assets/{newsletters-BMEgeL2l.js → newsletters-CACa0VCx.js} +1 -1
  147. package/core/built/admin/assets/{note-dqog4Bua.js → note-CF4LrSmR.js} +1 -1
  148. package/core/built/admin/assets/{notifications-rcEVv-gx.js → notifications-BmHJmqIJ.js} +1 -1
  149. package/core/built/admin/assets/{offers-hV7zBtsI.js → offers-Df9Jzay5.js} +1 -1
  150. package/core/built/admin/assets/{offers-container-modal-DgZgkMsA.js → offers-container-modal-R0HRwugm.js} +1 -1
  151. package/core/built/admin/assets/{onboarding-4TxbZb90.js → onboarding-Bpo1yTzA.js} +1 -1
  152. package/core/built/admin/assets/{onboarding-SGscZLIc.js → onboarding-bMq3R8jB.js} +1 -1
  153. package/core/built/admin/assets/{onboarding-route-B3mN9l7E.js → onboarding-route-flf5YWti.js} +1 -1
  154. package/core/built/admin/assets/{overview-D4EanvDG.js → overview-C9WvmmOC.js} +1 -1
  155. package/core/built/admin/assets/{overview-CCwbHet8.js → overview-CDkHdIJM.js} +1 -1
  156. package/core/built/admin/assets/{page-header-Baymg6VR.js → page-header-CxTb0je5.js} +1 -1
  157. package/core/built/admin/assets/{pagemenu--UL0gW1x.js → pagemenu-DXr_U43J.js} +1 -1
  158. package/core/built/admin/assets/{pages-Cbq1M2kG.js → pages-Bm-zFXyP.js} +1 -1
  159. package/core/built/admin/assets/pages-route-LCw94aIO.js +1 -0
  160. package/core/built/admin/assets/{pintura-modal-D6HGlnJa.js → pintura-modal-B5sIPWcj.js} +1 -1
  161. package/core/built/admin/assets/{portal-modal-Bhqsevn_.js → portal-modal-DjOO3Unv.js} +1 -1
  162. package/core/built/admin/assets/{post-analytics-header-DX9fETdi.js → post-analytics-header-D2anehCj.js} +1 -1
  163. package/core/built/admin/assets/{post-analytics-provider-U7RtOle1.js → post-analytics-provider-BLQvV5C0.js} +1 -1
  164. package/core/built/admin/assets/{post-analytics-BJWDtC3a.js → post-analytics-wdu9gq8u.js} +1 -1
  165. package/core/built/admin/assets/{post-debug-D1b8Amju.js → post-debug-BnABXMfD.js} +1 -1
  166. package/core/built/admin/assets/{posts-Lg-p_ZHg.js → posts-CftunZgV.js} +1 -1
  167. package/core/built/admin/assets/{posts-list-screen-CmsW18e_.js → posts-list-screen-CwXmvY68.js} +2 -2
  168. package/core/built/admin/assets/posts-route-J74fMhCe.js +1 -0
  169. package/core/built/admin/assets/{preferences-CMlDfHfa.js → preferences-DFhf_pJF.js} +1 -1
  170. package/core/built/admin/assets/{preview-modal-D8om_cQv.js → preview-modal-BrZza3R_.js} +1 -1
  171. package/core/built/admin/assets/{profile-yFsIoZom.js → profile-CS4fP60N.js} +1 -1
  172. package/core/built/admin/assets/{radio-group-DwgLjwWB.js → radio-group-Xfp-frJz.js} +1 -1
  173. package/core/built/admin/assets/{referrers-DzP5QoXL.js → referrers-C8LJlrBm.js} +1 -1
  174. package/core/built/admin/assets/{reload-CZ-KP3IQ.js → reload-D0fnKoCm.js} +1 -1
  175. package/core/built/admin/assets/{reset-CCAa8v35.js → reset-CB-ATcLE.js} +1 -1
  176. package/core/built/admin/assets/{restore-screen-Ba0i2Y1K.js → restore-screen-EaZf4V8j.js} +1 -1
  177. package/core/built/admin/assets/{routes-DrnhmKTT.js → routes-DKfpFMfF.js} +2 -2
  178. package/core/built/admin/assets/search-index-sM3OjEUl.js +1 -0
  179. package/core/built/admin/assets/settings-BWzod-5X.js +4 -0
  180. package/core/built/admin/assets/{settings-lqWkfSmT.js → settings-DvgngbFt.js} +1 -1
  181. package/core/built/admin/assets/{setup-BopRPuaM.js → setup-CdHAchG5.js} +1 -1
  182. package/core/built/admin/assets/{signin-e8NgsU9M.js → signin-CUEEme88.js} +1 -1
  183. package/core/built/admin/assets/{signin-verify-CHkFJevb.js → signin-verify-CYRphSrj.js} +1 -1
  184. package/core/built/admin/assets/{signout-DRvQZuWa.js → signout-kLCJau9G.js} +1 -1
  185. package/core/built/admin/assets/{signup-DQHi7jZz.js → signup-J2Vjq7Gt.js} +1 -1
  186. package/core/built/admin/assets/{slack-modal-BuGESzgn.js → slack-modal-DKamr_94.js} +1 -1
  187. package/core/built/admin/assets/source-icon-DqBCPDIK.js +1 -0
  188. package/core/built/admin/assets/{stats-CHOikfoP.js → stats-BL_FJ7Ns.js} +1 -1
  189. package/core/built/admin/assets/{stats-view-DQZzKeEz.js → stats-view-BwbdkdOQ.js} +1 -1
  190. package/core/built/admin/assets/{step-1-C8XwHcKt.js → step-1-CLYhNmG9.js} +1 -1
  191. package/core/built/admin/assets/{step-2-BXaXAdwY.js → step-2-B2ujMlpa.js} +1 -1
  192. package/core/built/admin/assets/{step-3-DytbqpJi.js → step-3-DoaTWqqj.js} +1 -1
  193. package/core/built/admin/assets/{stripe-connect-modal-BhudjSeO.js → stripe-connect-modal-DytxH9DJ.js} +1 -1
  194. package/core/built/admin/assets/{tabs-CDb_TceL.js → tabs-fHs3A8WC.js} +1 -1
  195. package/core/built/admin/assets/{tag-detail-V72Zlro8.js → tag-detail-BcO46Ids.js} +2 -2
  196. package/core/built/admin/assets/{tag-picker-M3fC-yOF.js → tag-picker-Ct6NeqWK.js} +1 -1
  197. package/core/built/admin/assets/{tags-CXqE2A2T.js → tags-C1h3wCpW.js} +1 -1
  198. package/core/built/admin/assets/{tags-ZhqbPPc6.js → tags-OlmRJ6Ps.js} +1 -1
  199. package/core/built/admin/assets/{testimonials-modal-Cn8gvIFA.js → testimonials-modal-DMsQzSCB.js} +1 -1
  200. package/core/built/admin/assets/{themes-pOHHvnkt.js → themes-CPJSMo_W.js} +1 -1
  201. package/core/built/admin/assets/{tier-detail-modal-CeDla1OO.js → tier-detail-modal-DssSmhkF.js} +1 -1
  202. package/core/built/admin/assets/{tiers-D7aGzwZ-.js → tiers-DlvS8D6_.js} +1 -1
  203. package/core/built/admin/assets/{toggle-group-D7ly9OGa.js → toggle-group-BFWCtH3p.js} +1 -1
  204. package/core/built/admin/assets/{topic-filter-DQ3pr6AB.js → topic-filter-DAJ-DFPb.js} +1 -1
  205. package/core/built/admin/assets/{transistor-modal-4_Yx2vRo.js → transistor-modal-CtyFRsD0.js} +1 -1
  206. package/core/built/admin/assets/{unsplash-modal-Dm7R4k4k.js → unsplash-modal-DHnnTPmZ.js} +1 -1
  207. package/core/built/admin/assets/{use-activity-pub-queries-Gy9_locM.js → use-activity-pub-queries-BgR1USeY.js} +1 -1
  208. package/core/built/admin/assets/{use-analytics-data-oJ2o0pSS.js → use-analytics-data-Byf83QE-.js} +1 -1
  209. package/core/built/admin/assets/{use-availability-BqL7Dvn_.js → use-availability-CgZC6L_V.js} +1 -1
  210. package/core/built/admin/assets/{use-check-theme-limit-error-CxC9uKJz.js → use-check-theme-limit-error-DjprzKAN.js} +1 -1
  211. package/core/built/admin/assets/use-definitions-CJuXLSob.js +1 -0
  212. package/core/built/admin/assets/{use-email-sending-status-BFAg5TIb.js → use-email-sending-status-7kopNcza.js} +1 -1
  213. package/core/built/admin/assets/{use-filter-params-BOo9yZ5j.js → use-filter-params-DQ7uX-Zp.js} +1 -1
  214. package/core/built/admin/assets/{use-filterable-api-BnNLaS_r.js → use-filterable-api-CDrrxoGD.js} +1 -1
  215. package/core/built/admin/assets/{use-growth-stats-BS62uyyn.js → use-growth-stats-CCpnBgqS.js} +1 -1
  216. package/core/built/admin/assets/{use-host-limits-CNh4AAEs.js → use-host-limits-BZx7rzRI.js} +1 -1
  217. package/core/built/admin/assets/{use-limiter-DPKxoO1_.js → use-limiter-gF219BEg.js} +1 -1
  218. package/core/built/admin/assets/{use-pintura-config-CyVO62ZV.js → use-pintura-config-D-pmGkn2.js} +1 -1
  219. package/core/built/admin/assets/{use-pintura-editor-B5VBPbiO.js → use-pintura-editor-D_4zhlGE.js} +1 -1
  220. package/core/built/admin/assets/{use-post-referrers-nUPolSk7.js → use-post-referrers-Bc8eq4uy.js} +1 -1
  221. package/core/built/admin/assets/{use-post-top-links-DCH4eO11.js → use-post-top-links-DjltnQuI.js} +1 -1
  222. package/core/built/admin/assets/{use-reply-chain-data-UMzFbDvh.js → use-reply-chain-data-BiV3Cl0B.js} +1 -1
  223. package/core/built/admin/assets/use-sending-eta-gE-2B0Zw.js +1 -0
  224. package/core/built/admin/assets/{use-setting-group-Bf3vY8br.js → use-setting-group-YP84CqrJ.js} +1 -1
  225. package/core/built/admin/assets/{use-staff-users-CcQzTHqH.js → use-staff-users-CnwfdSx1.js} +1 -1
  226. package/core/built/admin/assets/{use-tinybird-query-CPy5ipAP.js → use-tinybird-query-BYbl5gKY.js} +1 -1
  227. package/core/built/admin/assets/{use-tinybird-token-DVNHuhu_.js → use-tinybird-token-Dz37zvb7.js} +1 -1
  228. package/core/built/admin/assets/{use-unsaved-changes-guard-Bvcp_Rny.js → use-unsaved-changes-guard-BkCuSlvU.js} +1 -1
  229. package/core/built/admin/assets/{use-upgrade-route-Bsxw9ZLN.js → use-upgrade-route-C-V-Xfak.js} +1 -1
  230. package/core/built/admin/assets/{use-url-input-DPJ592FB.js → use-url-input-BeYKYMGh.js} +1 -1
  231. package/core/built/admin/assets/{user-detail-modal-6UY6GdNy.js → user-detail-modal-CSoj7vOC.js} +1 -1
  232. package/core/built/admin/assets/{users-CzgQKbfO.js → users-CKJaAxEJ.js} +1 -1
  233. package/core/built/admin/assets/{view-site-DA_-zfGq.js → view-site-SpMx4P7G.js} +1 -1
  234. package/core/built/admin/assets/{web-Cq5YiD2r.js → web-CZf-k4F0.js} +1 -1
  235. package/core/built/admin/assets/{web-DqFIrOxt.js → web-uAqgYPK9.js} +1 -1
  236. package/core/built/admin/assets/{zapier-modal-DgqU-OBB.js → zapier-modal-DENbgTyE.js} +1 -1
  237. package/core/built/admin/index.html +24 -24
  238. package/core/frontend/helpers/color_to_rgba.js +15 -13
  239. package/core/frontend/helpers/facebook_url.js +27 -15
  240. package/core/frontend/services/assets-minification/card-assets.js +1 -1
  241. package/core/frontend/services/helpers/register-ghost-helpers.js +2 -2
  242. package/core/server/api/endpoints/app-installations.js +36 -0
  243. package/core/server/api/endpoints/automations.js +1 -1
  244. package/core/server/api/endpoints/index.js +4 -0
  245. package/core/server/data/exporter/table-lists.js +2 -0
  246. package/core/server/data/migrations/versions/6.69/2026-10-07-06-20-43-add-app-installation-permissions.js +40 -0
  247. package/core/server/data/schema/fixtures/fixtures.json +21 -0
  248. package/core/server/data/schema/in-development.js +1 -1
  249. package/core/server/data/schema/schema.js +53 -0
  250. package/core/server/lib/after-commit.js +20 -0
  251. package/core/server/models/action.js +6 -0
  252. package/core/server/services/app-installations/actions.js +44 -0
  253. package/core/server/services/app-installations/codec.js +20 -0
  254. package/core/server/services/app-installations/index.js +42 -0
  255. package/core/server/services/app-installations/schema.js +52 -0
  256. package/core/server/services/app-installations/service.js +160 -0
  257. package/core/server/services/automations/README.md +3 -3
  258. package/core/server/services/automations/automations-api.js +1 -1
  259. package/core/server/services/comments/comments-service-emails.js +8 -6
  260. package/core/server/services/email-service/README.md +16 -0
  261. package/core/server/services/email-service/email-service-wrapper.js +1 -0
  262. package/core/server/services/email-service/email-service.js +94 -53
  263. package/core/server/services/email-service/sending-status-serializers.js +4 -1
  264. package/core/server/services/email-service/sending-status-service.js +13 -0
  265. package/core/server/services/email-service/sending-status.js +12 -1
  266. package/core/server/services/members/members-api/repositories/member-repository.js +5 -23
  267. package/core/server/services/posts/post-email-handler.js +61 -28
  268. package/core/server/services/posts/posts-service.js +27 -2
  269. package/core/server/services/service-inventory.yaml +93 -7
  270. package/core/server/services/stats/stats-service.js +1 -5
  271. package/core/server/services/tinybird-sync/index.js +0 -3
  272. package/core/server/services/tinybird-sync/tinybird-sync-service.js +2 -6
  273. package/core/server/web/api/endpoints/admin/routes.js +25 -12
  274. package/core/shared/labs.js +4 -6
  275. package/package.json +11 -10
  276. package/pnpm-lock.yaml +112 -100
  277. package/pnpm-workspace.yaml +14 -12
  278. package/components/ghost-storage-base-3.0.0.tgz +0 -0
  279. package/components/tryghost-adapter-base-cache-0.2.0.tgz +0 -0
  280. package/components/tryghost-checkout-0.0.1.tgz +0 -0
  281. package/components/tryghost-kg-card-factory-5.2.4.tgz +0 -0
  282. package/components/tryghost-kg-clean-basic-html-4.3.4.tgz +0 -0
  283. package/components/tryghost-kg-converters-1.2.5.tgz +0 -0
  284. package/components/tryghost-kg-default-transforms-1.3.4.tgz +0 -0
  285. package/components/tryghost-kg-html-to-lexical-1.4.0.tgz +0 -0
  286. package/components/tryghost-kg-markdown-html-renderer-7.2.6.tgz +0 -0
  287. package/components/tryghost-kg-utils-1.1.4.tgz +0 -0
  288. package/components/tryghost-metafield-csv-0.0.1.tgz +0 -0
  289. package/core/built/admin/assets/activitypub/layout-QTbY0t8e.js +0 -1
  290. package/core/built/admin/assets/automations-DVToctfJ.js +0 -1
  291. package/core/built/admin/assets/editor-CMXR0YvR.js +0 -8
  292. package/core/built/admin/assets/fullscreen-close-button-DXssPeDB.js +0 -1
  293. package/core/built/admin/assets/global-search-modal-C8LVJmiz.js +0 -1
  294. package/core/built/admin/assets/history-modal-parBtjpz.js +0 -1
  295. package/core/built/admin/assets/pages-route-CDk3V9rq.js +0 -1
  296. package/core/built/admin/assets/posts-route-CexHhklY.js +0 -1
  297. package/core/built/admin/assets/settings-xqakrAWa.js +0 -4
  298. package/core/built/admin/assets/source-icon-BjVangBd.js +0 -1
  299. package/core/built/admin/assets/use-definitions-DMVU3mTG.js +0 -1
  300. package/core/built/admin/assets/use-sending-eta-BsnKdQhv.js +0 -1
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`2eebbbf5-c899-4c81-9890-ba4830330d0f`,e._sentryDebugIdIdentifier=`sentry-dbid-2eebbbf5-c899-4c81-9890-ba4830330d0f`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{b as n,g as r,m as i}from"./hooks-C-BDQ6Hs.js";import{t as a}from"./jsx-runtime-Bm2_KH-0.js";import{n as o}from"./dist-pogVoW2G.js";import{t as s}from"./use-form-ElCUnbKi.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-hV7zBtsI.js";import{i as p,r as m}from"./currency-DgOqjQBh.js";import{H as h}from"./shade-provider-DvrXKKQZ.js";import{t as g}from"./inline-Qoyy4r2g.js";import{t as _}from"./stack-C3OmgpUv.js";import{Ar as v,Ir as y,Or as b,en as x,t as S}from"./button-CTHYSI-d.js";import{t as C}from"./badge-DuMiqyUH.js";import{a as w,i as T,n as E,o as D,r as O,t as k}from"./field-DCPPrQDr.js";import{t as A}from"./input-BHb2A_DU.js";import{a as j,i as M,n as N,r as P,t as F}from"./input-group-DL5EFP5r.js";import{n as I,t as L}from"./radio-group-DwgLjwWB.js";import{i as R,n as z,o as B,s as V,t as H}from"./select-DeloOYCg.js";import{t as ee}from"./switch-BppWscjz.js";import{a as U,c as W,n as te,r as G,s as K,t as ne}from"./table-DQ63Yu4a.js";import{t as re}from"./textarea-B_rfKtjs.js";import{t as ie}from"./settings-modal-3x4v8abr.js";import{a as ae,r as oe}from"./tiers-D7aGzwZ-.js";import{ct as se,ft as ce,gt as le,h as ue,ht as de,lt as fe,mt as pe,pt as me,ut as he,vt as ge}from"./index-CuDhPtkB.js";import{t as q}from"./brand-icon-BFOhZhQt.js";import{t as J}from"./use-settings-navigation-CO2nUqDW.js";import{n as _e}from"./confirmation-context-By_jX_cA.js";import{n as Y}from"./global-data-context-ogIy0FUG.js";import{o as ve,r as ye}from"./zapier-modal-DgqU-OBB.js";import{t as be}from"./preview-modal-D8om_cQv.js";import{t as xe}from"./portal-frame-DMlXe-EA.js";import{t as Se}from"./settings-breadcrumbs-Bq3nGk-N.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=a();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:b})=>{let x=s.cadence===`year`,C=x?i.filter(e=>e.value!==`repeating`):i,[P,ee]=(0,X.useState)(0),U=P>40?`text-red`:`text-green`,{siteData:W}=Y(),[te,G]=(0,X.useState)(!1),K=ue(W),ne=`${K}${s.code.value}`,ie=async()=>{await navigator.clipboard.writeText(ne),G(!0),setTimeout(()=>G(!1),2e3)};return(0,Z.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,Z.jsxs)(w,{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)(k,{"data-invalid":!!_.name||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(A,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),ee(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,Z.jsx)(T,{children:_.name}):(0,Z.jsx)(O,{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:U,children:h(P)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(k,{"data-invalid":!!_.displayTitle||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(A,{"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)(T,{children:_.displayTitle})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{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)(L,{"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)(k,{orientation:`horizontal`,children:[(0,Z.jsx)(I,{id:t,value:e.value}),(0,Z.jsxs)(E,{children:[(0,Z.jsx)(D,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(O,{children:e.description})]})]},e.value)})}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Tier — Cadence`}),(0,Z.jsxs)(H,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,Z.jsx)(B,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:e.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(k,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-amount`,children:`Amount off`}),(0,Z.jsxs)(F,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(M,{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)(N,{align:`inline-end`,children:(0,Z.jsxs)(H,{value:s.type===`percent`?b[0].value:b[1].value,onValueChange:c,children:[(0,Z.jsx)(B,{"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)(V,{})}),(0,Z.jsx)(z,{align:`end`,children:b.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,Z.jsx)(T,{children:_.amount})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Duration`}),(0,Z.jsxs)(H,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,Z.jsx)(B,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:C.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!x&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(k,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsxs)(F,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,Z.jsx)(T,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,Z.jsxs)(k,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,Z.jsx)(A,{"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)(T,{children:_.amount})]}),(0,Z.jsxs)(k,{"data-invalid":!!_.code||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsx)(A,{"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)(T,{children:_.code}):s.code.value!==``&&(0,Z.jsx)(O,{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)(S,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void ie(),children:te?`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`}],r=[{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}={}}=ae(),d=oe(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)}))},j=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},M=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})},N=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},P=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},F=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},I=e=>{y(t=>({...t,duration:e}))},L=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},R=()=>{_.length>0?c(`offers/edit`):c(`offers`)},z=(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(z,e.url);a(t)},[v,e.url,v.type,z]);let B=(0,Z.jsx)(Oe,{amountOptions:E,clearError:T,durationOptions:r,errors:w,handleAmountInput:A,handleAmountTypeChange:k,handleCodeInput:L,handleDisplayTitleInput:N,handleDurationChange:I,handleDurationInMonthsInput:j,handleNameInput:M,handleTextAreaInput:P,handleTierChange:D,handleTrialAmountInput:F,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),V=(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:V,previewToolbar:!1,sidebar:B,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:R,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 n&&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:i})=>{let{siteData:a}=Y(),[s,c]=(0,X.useState)(!1),u=r(),{confirm:d}=_e(),{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=ue(a),y=`${v}${n?.code}`,b=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},x=()=>{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)(w,{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-gray-300 p-4 pb-3.5 dark:border-gray-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-gray-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-gray-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-gray-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)(k,{"data-invalid":!!t.name||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(A,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),i({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,Z.jsx)(T,{children:t.name}):(0,Z.jsx)(O,{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)(k,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsxs)(F,{"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(M,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>i({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,Z.jsx)(N,{align:`inline-end`,children:(0,Z.jsx)(P,{onClick:()=>void b(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,Z.jsx)(T,{children:t.code}):n?.code!==``&&(0,Z.jsxs)(O,{className:`truncate`,children:[v,(0,Z.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,Z.jsxs)(k,{"data-invalid":!!t.displayTitle||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(A,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>i({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,Z.jsx)(T,{children:t.displayTitle})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{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=>i({display_description:e.target.value})})]})]})]})]}),(0,Z.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,Z.jsx)(S,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:x,children:`Archive offer`}):(0,Z.jsx)(S,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:x,children:`Reactivate offer`})})]})},He=({id:e})=>{let{siteData:t}=Y(),{updateRoute:i}=J(),a=r(),{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:a,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=()=>{i(`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:()=>{i(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof n&&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)(w,{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-gray-300 p-4 pb-3.5 dark:border-gray-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-gray-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-gray-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)(k,{orientation:`horizontal`,children:[(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(D,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,Z.jsx)(O,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,Z.jsx)(ee,{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)(k,{children:[(0,Z.jsx)(D,{htmlFor:`retention-display-title`,children:`Display title`}),(0,Z.jsx)(A,{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)(k,{children:[(0,Z.jsx)(D,{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)(L,{"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)(k,{orientation:`horizontal`,children:[(0,Z.jsx)(I,{id:t,value:e.value}),(0,Z.jsxs)(E,{children:[(0,Z.jsx)(D,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(O,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(k,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`retention-amount`,children:`Amount off`}),(0,Z.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:`%`})})]}),r.amount&&(0,Z.jsx)(T,{children:r.amount})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Duration`}),(0,Z.jsxs)(H,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,Z.jsx)(B,{"aria-label":`Duration`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:c.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(k,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsxs)(F,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,Z.jsx)(T,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,Z.jsxs)(k,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`retention-free-months`,children:`Free months`}),(0,Z.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,Z.jsx)(T,{children:r.amount})]})]})]})]})]})})},at=({cadence:e})=>{let{updateRoute:t}=J(),{siteData:r}=Y(),{data:{tiers:i=[]}={}}=ae(),{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=oe(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,j]=(0,X.useState)(20),[M,N]=(0,X.useState)(1),[P,F]=(0,X.useState)(null),{formState:I,setFormState:L,updateForm:R,handleSave:z,saveState:B,okProps:V,errors:H,clearError:ee}=s({initialState:Xe(e),savingDelay:500,onSave:async()=>{let t=!1,n=$e({formState:I,lastPercentAmount:A,lastFreeMonths:M}),r=tt(et(T))!==tt(n),i=I.enabled?`active`:`archived`,a=I.displayTitle||``,o=I.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Xe(e),l=!I.enabled&&!T&&rt(I,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&&!I.enabled&&!l)){if(r){!I.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}(I.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof n&&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 I.enabled?(I.type===`percent`&&((I.percentAmount<1||I.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),I.duration===`repeating`&&!nt(I.durationInMonths)&&(e.durationInMonths=qe)),I.type===`free_months`&&(nt(I.freeMonths)||(e.amount=qe)),e):e}}),U=`${e}:${T?.id||`none`}`;(0,X.useEffect)(()=>{!d||p||B===`unsaved`||P===U||(L(()=>Qe(T,e)),F(U))},[e,U,T,d,P,p,B,L]),(0,X.useEffect)(()=>{I.percentAmount>0&&j(I.percentAmount)},[I.percentAmount]),(0,X.useEffect)(()=>{I.freeMonths>0&&N(I.freeMonths)},[I.freeMonths]);let W=()=>{t(`offers/edit`)},te=(0,Z.jsx)(it,{cadence:e,clearError:ee,errors:H,formState:I,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:R}),G=async()=>{try{await z({force:!0})&&W()}catch{}},K=(0,X.useMemo)(()=>{let t=$e({formState:I,lastPercentAmount:A,lastFreeMonths:M}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:I.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:I.displayTitle||``,displayDescription:I.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,I,M,A,b]);(0,X.useEffect)(()=>{if(!r.url){v(``);return}let e=Ce(K,r.url);v(e)},[K,r.url]);let ne=(0,Z.jsx)(xe,{href:_||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:B===`unsaved`,height:`full`,okLabel:V.label||`Save`,okVariant:V.variant,preview:ne,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:y,label:`Offers`,onBack:W}),sidebar:te,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:W,onClose:()=>t(`offers`),onOk:G})},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=`${ue(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)(ie,{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)(b,{className:`-mt-4 size-10 text-gray-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)(A,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,Z.jsx)(S,{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-gray-300 before:content-[""] after:h-px after:grow after:bg-gray-300 after:content-[""] dark:before:bg-gray-800 dark:after:bg-gray-800`,children:`OR`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(S,{"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)(q,{className:`size-3.5!`,name:`twitter-x`})}),(0,Z.jsx)(S,{"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)(q,{className:`size-3.5!`,name:`facebook`})}),(0,Z.jsx)(S,{"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)(q,{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)(se,{children:[(0,Z.jsx)(ge,{asChild:!0,children:(0,Z.jsx)(S,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(x,{size:16,strokeWidth:1.5})})}),(0,Z.jsxs)(he,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,Z.jsx)(me,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,Z.jsxs)(pe,{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)(ce,{onSelect:a,children:[r===`asc`?(0,Z.jsx)(v,{className:`size-3`}):(0,Z.jsx)(y,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,Z.jsx)(le,{}),(0,Z.jsx)(fe,{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)(G,{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)(G,{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)(G,{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)(G,{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)(G,{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)(C,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,Z.jsx)(C,{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)(G,{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)(G,{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)(G,{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)(G,{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)(G,{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)(C,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,Z.jsx)(C,{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}={},isLoading:r}=ae(),i=t.filter(e=>e.redemption_type===`signup`),a=mt(t),{sortingState:s,setSortingState:c}=ve(),l=s?.find(e=>e.type===`offers`),{offersShowArchived:d,setOffersShowArchived:f}=ye(),p=l?.option||`date-added`,m=l?.direction||`desc`,h=t=>{t&&e(`offers/edit/${t}`)},v=t=>{e(`offers/edit/retention/${t}`)},y=oe(n||[]),b=i.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||d&&i)}),x=bt([...a.map(e=>({kind:`retention`,offer:e})),...b.map(e=>({kind:`signup`,offer:e}))],p,m),C=e=>{c?.([{type:`offers`,option:e,direction:m}])},w=()=>{c?.([{type:`offers`,option:p,direction:m===`asc`?`desc`:`asc`}])},T=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,Z.jsx)(ie,{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)(S,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,Z.jsx)(S,{disabled:r,type:`button`,onClick:()=>{y.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)(K,{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:f,showArchived:d,sortDirection:m,sortOption:p,onDirectionChange:w,onSortChange:C})]})})]})}),(0,Z.jsx)(te,{"data-testid":`offers-table-body`,children:x.map(e=>{if(e.kind===`retention`)return(0,Z.jsx)(gt,{offer:e.offer,onClick:()=>v(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=T(t);return(0,Z.jsx)(_t,{archived:i,offer:t,tier:r,onClick:()=>h(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
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`be5f7a1e-91af-4d14-badd-e6612c0acc0e`,e._sentryDebugIdIdentifier=`sentry-dbid-be5f7a1e-91af-4d14-badd-e6612c0acc0e`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{b as n,g as r,m as i}from"./hooks-0r7qxGEo.js";import{t as a}from"./jsx-runtime-Bm2_KH-0.js";import{n as o}from"./dist-pogVoW2G.js";import{t as s}from"./use-form-ElCUnbKi.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-Df9Jzay5.js";import{i as p,r as m}from"./currency-DgOqjQBh.js";import{H as h}from"./shade-provider-DvrXKKQZ.js";import{t as g}from"./inline-Qoyy4r2g.js";import{t as _}from"./stack-C3OmgpUv.js";import{Ar as v,Ir as y,Or as b,en as x,t as S}from"./button-CTHYSI-d.js";import{t as C}from"./badge-DuMiqyUH.js";import{a as w,i as T,n as E,o as D,r as O,t as k}from"./field-DCPPrQDr.js";import{t as A}from"./input-BHb2A_DU.js";import{a as j,i as M,n as N,r as P,t as F}from"./input-group-DL5EFP5r.js";import{n as I,t as L}from"./radio-group-Xfp-frJz.js";import{i as R,n as z,o as B,s as V,t as H}from"./select-DeloOYCg.js";import{t as ee}from"./switch-BppWscjz.js";import{a as U,c as W,n as te,r as G,s as K,t as ne}from"./table-DQ63Yu4a.js";import{t as re}from"./textarea-B_rfKtjs.js";import{t as ie}from"./settings-modal-3x4v8abr.js";import{a as ae,r as oe}from"./tiers-DlvS8D6_.js";import{ct as se,ft as ce,gt as le,h as ue,ht as de,lt as fe,mt as pe,pt as me,ut as he,vt as ge}from"./index-RuRs_qGS.js";import{t as q}from"./brand-icon-BFOhZhQt.js";import{t as J}from"./use-settings-navigation-CO2nUqDW.js";import{n as _e}from"./confirmation-context-By_jX_cA.js";import{n as Y}from"./global-data-context-ogIy0FUG.js";import{o as ve,r as ye}from"./zapier-modal-DENbgTyE.js";import{t as be}from"./preview-modal-BrZza3R_.js";import{t as xe}from"./portal-frame-DMlXe-EA.js";import{t as Se}from"./settings-breadcrumbs-Bq3nGk-N.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=a();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:b})=>{let x=s.cadence===`year`,C=x?i.filter(e=>e.value!==`repeating`):i,[P,ee]=(0,X.useState)(0),U=P>40?`text-red`:`text-green`,{siteData:W}=Y(),[te,G]=(0,X.useState)(!1),K=ue(W),ne=`${K}${s.code.value}`,ie=async()=>{await navigator.clipboard.writeText(ne),G(!0),setTimeout(()=>G(!1),2e3)};return(0,Z.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,Z.jsxs)(w,{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)(k,{"data-invalid":!!_.name||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(A,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),ee(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,Z.jsx)(T,{children:_.name}):(0,Z.jsx)(O,{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:U,children:h(P)}),` /`,` `,h(40)]})]})})]}),(0,Z.jsxs)(k,{"data-invalid":!!_.displayTitle||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(A,{"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)(T,{children:_.displayTitle})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{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)(L,{"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)(k,{orientation:`horizontal`,children:[(0,Z.jsx)(I,{id:t,value:e.value}),(0,Z.jsxs)(E,{children:[(0,Z.jsx)(D,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(O,{children:e.description})]})]},e.value)})}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Tier — Cadence`}),(0,Z.jsxs)(H,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,Z.jsx)(B,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:e.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(k,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-amount`,children:`Amount off`}),(0,Z.jsxs)(F,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(M,{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)(N,{align:`inline-end`,children:(0,Z.jsxs)(H,{value:s.type===`percent`?b[0].value:b[1].value,onValueChange:c,children:[(0,Z.jsx)(B,{"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)(V,{})}),(0,Z.jsx)(z,{align:`end`,children:b.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,Z.jsx)(T,{children:_.amount})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Duration`}),(0,Z.jsxs)(H,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,Z.jsx)(B,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:C.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!x&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(k,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsxs)(F,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,Z.jsx)(T,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,Z.jsxs)(k,{"data-invalid":!!_.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,Z.jsx)(A,{"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)(T,{children:_.amount})]}),(0,Z.jsxs)(k,{"data-invalid":!!_.code||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsx)(A,{"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)(T,{children:_.code}):s.code.value!==``&&(0,Z.jsx)(O,{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)(S,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void ie(),children:te?`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`}],r=[{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}={}}=ae(),d=oe(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)}))},j=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},M=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})},N=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},P=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},F=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},I=e=>{y(t=>({...t,duration:e}))},L=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},R=()=>{_.length>0?c(`offers/edit`):c(`offers`)},z=(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(z,e.url);a(t)},[v,e.url,v.type,z]);let B=(0,Z.jsx)(Oe,{amountOptions:E,clearError:T,durationOptions:r,errors:w,handleAmountInput:A,handleAmountTypeChange:k,handleCodeInput:L,handleDisplayTitleInput:N,handleDurationChange:I,handleDurationInMonthsInput:j,handleNameInput:M,handleTextAreaInput:P,handleTierChange:D,handleTrialAmountInput:F,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),V=(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:V,previewToolbar:!1,sidebar:B,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:R,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 n&&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:i})=>{let{siteData:a}=Y(),[s,c]=(0,X.useState)(!1),u=r(),{confirm:d}=_e(),{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=ue(a),y=`${v}${n?.code}`,b=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},x=()=>{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)(w,{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-gray-300 p-4 pb-3.5 dark:border-gray-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-gray-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-gray-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-gray-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)(k,{"data-invalid":!!t.name||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-name`,children:`Offer name`}),(0,Z.jsx)(A,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),i({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,Z.jsx)(T,{children:t.name}):(0,Z.jsx)(O,{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)(k,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-code`,children:`Offer code`}),(0,Z.jsxs)(F,{"data-invalid":!!t.code||void 0,children:[(0,Z.jsx)(M,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>i({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,Z.jsx)(N,{align:`inline-end`,children:(0,Z.jsx)(P,{onClick:()=>void b(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,Z.jsx)(T,{children:t.code}):n?.code!==``&&(0,Z.jsxs)(O,{className:`truncate`,children:[v,(0,Z.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,Z.jsxs)(k,{"data-invalid":!!t.displayTitle||void 0,children:[(0,Z.jsx)(D,{htmlFor:`offer-display-title`,children:`Display title`}),(0,Z.jsx)(A,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>i({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,Z.jsx)(T,{children:t.displayTitle})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{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=>i({display_description:e.target.value})})]})]})]})]}),(0,Z.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,Z.jsx)(S,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:x,children:`Archive offer`}):(0,Z.jsx)(S,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:x,children:`Reactivate offer`})})]})},He=({id:e})=>{let{siteData:t}=Y(),{updateRoute:i}=J(),a=r(),{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:a,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=()=>{i(`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:()=>{i(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof n&&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)(w,{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-gray-300 p-4 pb-3.5 dark:border-gray-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-gray-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-gray-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)(k,{orientation:`horizontal`,children:[(0,Z.jsxs)(E,{children:[(0,Z.jsxs)(D,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,Z.jsx)(O,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,Z.jsx)(ee,{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)(k,{children:[(0,Z.jsx)(D,{htmlFor:`retention-display-title`,children:`Display title`}),(0,Z.jsx)(A,{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)(k,{children:[(0,Z.jsx)(D,{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)(L,{"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)(k,{orientation:`horizontal`,children:[(0,Z.jsx)(I,{id:t,value:e.value}),(0,Z.jsxs)(E,{children:[(0,Z.jsx)(D,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,Z.jsx)(O,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(k,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`retention-amount`,children:`Amount off`}),(0,Z.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:`%`})})]}),r.amount&&(0,Z.jsx)(T,{children:r.amount})]}),(0,Z.jsxs)(k,{children:[(0,Z.jsx)(D,{children:`Duration`}),(0,Z.jsxs)(H,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,Z.jsx)(B,{"aria-label":`Duration`,children:(0,Z.jsx)(V,{})}),(0,Z.jsx)(z,{children:c.map(e=>(0,Z.jsx)(R,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,Z.jsx)(`div`,{className:`-mt-4`,children:(0,Z.jsxs)(k,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsxs)(F,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,Z.jsx)(T,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,Z.jsxs)(k,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(D,{htmlFor:`retention-free-months`,children:`Free months`}),(0,Z.jsxs)(F,{"data-invalid":!!r.amount||void 0,children:[(0,Z.jsx)(M,{"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)(N,{align:`inline-end`,children:(0,Z.jsx)(j,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,Z.jsx)(T,{children:r.amount})]})]})]})]})]})})},at=({cadence:e})=>{let{updateRoute:t}=J(),{siteData:r}=Y(),{data:{tiers:i=[]}={}}=ae(),{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=oe(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,j]=(0,X.useState)(20),[M,N]=(0,X.useState)(1),[P,F]=(0,X.useState)(null),{formState:I,setFormState:L,updateForm:R,handleSave:z,saveState:B,okProps:V,errors:H,clearError:ee}=s({initialState:Xe(e),savingDelay:500,onSave:async()=>{let t=!1,n=$e({formState:I,lastPercentAmount:A,lastFreeMonths:M}),r=tt(et(T))!==tt(n),i=I.enabled?`active`:`archived`,a=I.displayTitle||``,o=I.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Xe(e),l=!I.enabled&&!T&&rt(I,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&&!I.enabled&&!l)){if(r){!I.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}(I.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof n&&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 I.enabled?(I.type===`percent`&&((I.percentAmount<1||I.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),I.duration===`repeating`&&!nt(I.durationInMonths)&&(e.durationInMonths=qe)),I.type===`free_months`&&(nt(I.freeMonths)||(e.amount=qe)),e):e}}),U=`${e}:${T?.id||`none`}`;(0,X.useEffect)(()=>{!d||p||B===`unsaved`||P===U||(L(()=>Qe(T,e)),F(U))},[e,U,T,d,P,p,B,L]),(0,X.useEffect)(()=>{I.percentAmount>0&&j(I.percentAmount)},[I.percentAmount]),(0,X.useEffect)(()=>{I.freeMonths>0&&N(I.freeMonths)},[I.freeMonths]);let W=()=>{t(`offers/edit`)},te=(0,Z.jsx)(it,{cadence:e,clearError:ee,errors:H,formState:I,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:R}),G=async()=>{try{await z({force:!0})&&W()}catch{}},K=(0,X.useMemo)(()=>{let t=$e({formState:I,lastPercentAmount:A,lastFreeMonths:M}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:I.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:I.displayTitle||``,displayDescription:I.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,I,M,A,b]);(0,X.useEffect)(()=>{if(!r.url){v(``);return}let e=Ce(K,r.url);v(e)},[K,r.url]);let ne=(0,Z.jsx)(xe,{href:_||``,portalParent:`offers`});return(0,Z.jsx)(be,{backDropClick:!1,cancelLabel:`Cancel`,dirty:B===`unsaved`,height:`full`,okLabel:V.label||`Save`,okVariant:V.variant,preview:ne,previewToolbarBreadcrumbs:(0,Z.jsx)(Se,{current:y,label:`Offers`,onBack:W}),sidebar:te,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:W,onClose:()=>t(`offers`),onOk:G})},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=`${ue(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)(ie,{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)(b,{className:`-mt-4 size-10 text-gray-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)(A,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,Z.jsx)(S,{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-gray-300 before:content-[""] after:h-px after:grow after:bg-gray-300 after:content-[""] dark:before:bg-gray-800 dark:after:bg-gray-800`,children:`OR`}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(S,{"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)(q,{className:`size-3.5!`,name:`twitter-x`})}),(0,Z.jsx)(S,{"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)(q,{className:`size-3.5!`,name:`facebook`})}),(0,Z.jsx)(S,{"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)(q,{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)(se,{children:[(0,Z.jsx)(ge,{asChild:!0,children:(0,Z.jsx)(S,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,Z.jsx)(x,{size:16,strokeWidth:1.5})})}),(0,Z.jsxs)(he,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,Z.jsx)(me,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,Z.jsxs)(pe,{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)(ce,{onSelect:a,children:[r===`asc`?(0,Z.jsx)(v,{className:`size-3`}):(0,Z.jsx)(y,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,Z.jsx)(le,{}),(0,Z.jsx)(fe,{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)(G,{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)(G,{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)(G,{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)(G,{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)(G,{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)(C,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,Z.jsx)(C,{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)(G,{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)(G,{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)(G,{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)(G,{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)(G,{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)(C,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,Z.jsx)(C,{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}={},isLoading:r}=ae(),i=t.filter(e=>e.redemption_type===`signup`),a=mt(t),{sortingState:s,setSortingState:c}=ve(),l=s?.find(e=>e.type===`offers`),{offersShowArchived:d,setOffersShowArchived:f}=ye(),p=l?.option||`date-added`,m=l?.direction||`desc`,h=t=>{t&&e(`offers/edit/${t}`)},v=t=>{e(`offers/edit/retention/${t}`)},y=oe(n||[]),b=i.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||d&&i)}),x=bt([...a.map(e=>({kind:`retention`,offer:e})),...b.map(e=>({kind:`signup`,offer:e}))],p,m),C=e=>{c?.([{type:`offers`,option:e,direction:m}])},w=()=>{c?.([{type:`offers`,option:p,direction:m===`asc`?`desc`:`asc`}])},T=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,Z.jsx)(ie,{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)(S,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,Z.jsx)(S,{disabled:r,type:`button`,onClick:()=>{y.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)(K,{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:f,showArchived:d,sortDirection:m,sortOption:p,onDirectionChange:w,onSortChange:C})]})})]})}),(0,Z.jsx)(te,{"data-testid":`offers-table-body`,children:x.map(e=>{if(e.kind===`retention`)return(0,Z.jsx)(gt,{offer:e.offer,onClick:()=>v(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=T(t);return(0,Z.jsx)(_t,{archived:i,offer:t,tier:r,onClick:()=>h(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 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6feac36e-649b-4b7c-9422-85db60c14f0e`,e._sentryDebugIdIdentifier=`sentry-dbid-6feac36e-649b-4b7c-9422-85db60c14f0e`)}catch{}})();import{i as e}from"./react-C9lG_SsT.js";import{n as t,t as n}from"./onboarding-SGscZLIc.js";var r=e({default:()=>n,useOnboardingStatus:()=>t});export{r as t};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6feac36e-649b-4b7c-9422-85db60c14f0e`,e._sentryDebugIdIdentifier=`sentry-dbid-6feac36e-649b-4b7c-9422-85db60c14f0e`)}catch{}})();import{i as e}from"./react-C9lG_SsT.js";import{n as t,t as n}from"./onboarding-bMq3R8jB.js";var r=e({default:()=>n,useOnboardingStatus:()=>t});export{r as t};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3586f452-35e9-494f-99c8-b13ade22a0c3`,e._sentryDebugIdIdentifier=`sentry-dbid-3586f452-35e9-494f-99c8-b13ade22a0c3`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{o as n}from"./hooks-C-BDQ6Hs.js";import{t as r}from"./jsx-runtime-Bm2_KH-0.js";import{i}from"./chunk-OB3PAWPO-D3muQBsq.js";import{m as a}from"./users-CzgQKbfO.js";var o=e(t(),1);function s(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function c(e,t){let n=s(e);return JSON.stringify({...n,...t})}var l=r(),u=()=>{let{data:e}=n(),{mutateAsync:t}=a(),r=o.useMemo(()=>e?.accessibility&&s(e.accessibility).apOnboarding||{},[e?.accessibility]),i=o.useCallback(async n=>{if(!e)return;let r=s(e.accessibility),i=c(e.accessibility,{apOnboarding:{...r.apOnboarding,...n}});await t({...e,accessibility:i})},[e,t]);return{isOnboarded:!!r.welcomeStepsFinished,isExplainerClosed:!!r.exploreExplainerClosed,setOnboarded:e=>i({welcomeStepsFinished:e}),setExplainerClosed:e=>i({exploreExplainerClosed:e})}},d=()=>(0,l.jsx)(`div`,{className:`h-full pt-14`,children:(0,l.jsx)(i,{})});export{u as n,d as t};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3586f452-35e9-494f-99c8-b13ade22a0c3`,e._sentryDebugIdIdentifier=`sentry-dbid-3586f452-35e9-494f-99c8-b13ade22a0c3`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{o as n}from"./hooks-0r7qxGEo.js";import{t as r}from"./jsx-runtime-Bm2_KH-0.js";import{i}from"./chunk-OB3PAWPO-D3muQBsq.js";import{m as a}from"./users-CKJaAxEJ.js";var o=e(t(),1);function s(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function c(e,t){let n=s(e);return JSON.stringify({...n,...t})}var l=r(),u=()=>{let{data:e}=n(),{mutateAsync:t}=a(),r=o.useMemo(()=>e?.accessibility&&s(e.accessibility).apOnboarding||{},[e?.accessibility]),i=o.useCallback(async n=>{if(!e)return;let r=s(e.accessibility),i=c(e.accessibility,{apOnboarding:{...r.apOnboarding,...n}});await t({...e,accessibility:i})},[e,t]);return{isOnboarded:!!r.welcomeStepsFinished,isExplainerClosed:!!r.exploreExplainerClosed,setOnboarded:e=>i({welcomeStepsFinished:e}),setExplainerClosed:e=>i({exploreExplainerClosed:e})}},d=()=>(0,l.jsx)(`div`,{className:`h-full pt-14`,children:(0,l.jsx)(i,{})});export{u as n,d as t};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`b3af741d-a1a2-4331-a4f7-68e15403fb30`,e._sentryDebugIdIdentifier=`sentry-dbid-b3af741d-a1a2-4331-a4f7-68e15403fb30`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{_ as r}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as i,t as a}from"./router-provider-Cf-bcYZr.js";import{Nr as o,at as s,fn as c,or as l,t as u}from"./button-CTHYSI-d.js";import{t as d}from"./share-modal-CdHbFNEw.js";import{Ht as f,Kt as p,L as m,R as h,g,r as _}from"./index-CuDhPtkB.js";var v=e(t(),1),y=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:_,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:s}){let c=s.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${s.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(c,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:s.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:s.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(l,{className:`size-5`}):(0,b.jsx)(o,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(l,{className:`size-5`})})]}),h.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:h[t+1]?.id===n,isLast:t===h.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(u,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(u,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(u,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),s=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(d.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(d.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(d.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(d.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(d.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(d.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(c,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(u,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(d.Footer,{children:[(0,b.jsx)(d.SocialLinks,{links:s}),(0,b.jsx)(d.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),o=m(),s=p(),c=g(),l=(0,v.useRef)(!1),[u,d]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),x=String(f(s.data?.settings,`title`)||c.data?.site.title||`your publication`),S=String(f(s.data?.settings,`description`)||c.data?.site.description||``),E=String(f(s.data?.settings,`cover_image`)||``),D=c.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=o;if(N||c.isLoading||u||l.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{l.current=!0,d(!0);try{await t(),e(n,{replace:!0})}catch(e){l.current=!1,d(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=h.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:_,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`91d7f673-4c09-4f9a-8cdc-719d573e7352`,e._sentryDebugIdIdentifier=`sentry-dbid-91d7f673-4c09-4f9a-8cdc-719d573e7352`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{_ as r}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as i,t as a}from"./router-provider-Cf-bcYZr.js";import{Nr as o,at as s,fn as c,or as l,t as u}from"./button-CTHYSI-d.js";import{t as d}from"./share-modal-CdHbFNEw.js";import{Ht as f,Kt as p,L as m,R as h,g,r as _}from"./index-RuRs_qGS.js";var v=e(t(),1),y=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:_,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:s}){let c=s.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${s.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(c,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:s.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:s.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(l,{className:`size-5`}):(0,b.jsx)(o,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(l,{className:`size-5`})})]}),h.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:h[t+1]?.id===n,isLast:t===h.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(u,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(u,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(u,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),s=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(d.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(d.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(d.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(d.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(d.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(d.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(c,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(u,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(d.Footer,{children:[(0,b.jsx)(d.SocialLinks,{links:s}),(0,b.jsx)(d.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),o=m(),s=p(),c=g(),l=(0,v.useRef)(!1),[u,d]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),x=String(f(s.data?.settings,`title`)||c.data?.site.title||`your publication`),S=String(f(s.data?.settings,`description`)||c.data?.site.description||``),E=String(f(s.data?.settings,`cover_image`)||``),D=c.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=o;if(N||c.isLoading||u||l.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{l.current=!0,d(!0);try{await t(),e(n,{replace:!0})}catch(e){l.current=!1,d(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=h.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:_,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`24d1b4d5-f885-4467-ba81-b8446c8b2645`,e._sentryDebugIdIdentifier=`sentry-dbid-24d1b4d5-f885-4467-ba81-b8446c8b2645`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-CPy5ipAP.js";import{r as i}from"./post-helpers-DC_rgYgU.js";import{h as a}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as o}from"./router-provider-Cf-bcYZr.js";import{H as s,L as c,U as l,r as u}from"./shade-provider-DvrXKKQZ.js";import{a as d}from"./heading-Ch2Mb19A.js";import{Wt as f,X as p,nn as m,q as h,t as g,vn as _,yn as v}from"./button-CTHYSI-d.js";import{a as y,n as b,o as x,t as S}from"./card-Cd6xB_Ok.js";import{t as C}from"./gh-chart-Boqv6SC0.js";import{c as w,l as ee,n as te,o as T,r as ne,s as re,t as E,u as ie}from"./data-list-CNs61th8.js";import{t as D}from"./empty-indicator-BhVwqSVH.js";import{t as O}from"./skeleton-C1s6yr9e.js";import{t as k}from"./loading-indicator-DaRyGrxv.js";import{n as A,r as j,t as M}from"./kpi-card-BLsrKWhX.js";import{$t as ae,Xt as oe,Yt as se,Zt as ce,nn as le,q as ue,st as N}from"./index-CuDhPtkB.js";import{t as de}from"./disabled-sources-indicator-DSRkkSw-.js";import{a as fe,c as pe,n as me,o as he,r as ge,t as _e}from"./chart-helpers-D-3N170i.js";import{t as ve}from"./use-analytics-data-oJ2o0pSS.js";import{t as P}from"./clean-tracked-url-iZ-wi2Sn.js";import{n as F}from"./email-sending-status-context-7yrRlgjQ.js";import{n as ye}from"./post-analytics-context-v4FXmVDC.js";import{a as I,n as L,r as R,t as z}from"./kpi-card-Djsroynj.js";import{n as be,r as xe,t as Se}from"./post-analytics-header-DX9fETdi.js";import{t as Ce}from"./gift-links-HVqaXear.js";import{r as we,t as Te}from"./gift-link-modal-uZtwRHzl.js";import{t as Ee}from"./use-post-referrers-nUPolSk7.js";import{i as B,r as V,t as H}from"./use-post-top-links-DCH4eO11.js";import{n as De,r as U}from"./kpi-helpers-CyRx_yD6.js";var W=e(t(),1),G=n(),Oe=({post:e,isNewsletterStatsLoading:t,isWebShown:n})=>{let{isAdmin7:r}=u(),{postId:i}=a(),p=o(),{isNewsletterDataHidden:h}=F(),_=(0,W.useMemo)(()=>{let t=e.email?.opened_count||0,n=e.email?.email_count||0,r=e.count?.clicks||0;return{opened:t,clicked:r,openedRate:n>0?t/n:0,clickedRate:n>0?r/n:0,sent:n}},[e]),{topLinks:v}=H(),C=[{datatype:`Clicked`,value:_.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`},{datatype:`Opened`,value:_.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],D={percentage:{label:`Opened`},Average:{label:`Clicked`},"This newsletter":{label:`Opened`}},O=e.email_only||!n;return(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${O&&`col-span-2`}`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(f,{size:16,strokeWidth:1.5}),`Newsletter performance`]})}),!h&&(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{p(`/posts/analytics/${i}/newsletter`)},children:r?`View more →`:`View more`})]}),t?(0,G.jsx)(b,{children:(0,G.jsx)(`div`,{className:`mx-auto flex min-h-[250px] items-center justify-center xl:size-full`,children:(0,G.jsx)(k,{})})}):(0,G.jsx)(b,{children:(0,G.jsxs)(B,{className:c(O&&`grid gap-6 md:grid-cols-2 md:gap-0`),description:`Opens and clicks will appear once every email has been sent`,title:`Your newsletter is being sent`,children:[(0,G.jsxs)(`div`,{className:c(O&&`md:border-r md:pr-6`),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-blue)`,children:`Open rate`}),(0,G.jsx)(j,{value:l(_.openedRate)})]})}),(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-teal)`,children:`Click rate`}),(0,G.jsx)(j,{value:l(_.clickedRate)})]})})]}),!O&&(0,G.jsx)(N,{}),(0,G.jsx)(`div`,{className:`mx-auto my-6 h-[240px]`,children:(0,G.jsx)(V,{className:`pointer-events-none aspect-square h-[240px]`,config:D,data:C,tooltip:!1})})]}),(0,G.jsxs)(`div`,{className:c(O&&`border-t pt-6 md:border-t-0 md:pt-0 md:pl-6`),children:[!O&&(0,G.jsx)(N,{}),(0,G.jsxs)(`div`,{className:O?``:`pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${O?`pb-3`:`py-3`}`,children:[(0,G.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Top clicked links in this email`}),(0,G.jsx)(d,{children:`Members`})]}),v.length>0?(0,G.jsx)(E,{className:``,children:(0,G.jsx)(ne,{children:v.slice(0,O?10:5).map(e=>{let t=_.clicked>0?Math.min(e.count/_.clicked,1):0;return(0,G.jsxs)(ie,{children:[(0,G.jsx)(te,{style:{width:`${t?Math.round(t*100):0}%`}}),(0,G.jsx)(T,{children:(0,G.jsxs)(`div`,{className:`flex items-center space-x-2 overflow-hidden`,children:[(0,G.jsx)(m,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),(0,G.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:e.link.to,rel:`noreferrer`,target:`_blank`,title:e.link.to,children:P(e.link.to,!0)})]})}),(0,G.jsxs)(re,{children:[(0,G.jsx)(w,{children:s(e.count||0)}),(0,G.jsx)(ee,{children:l(t)})]})]},e.link.link_id)})})}):(0,G.jsx)(`div`,{className:`py-20 text-center text-sm text-muted-foreground`,children:`You have no links in your post.`})]})]})]})})]})},ke=({chartData:e,range:t,isLoading:n,visitors:r,sourcesData:i,isNewsletterShown:c=!0})=>{let{isAdmin7:l}=u(),{postId:f}=a(),p=o(),{site:m}=ve(),h=m.url,v=m.icon,w=(0,W.useMemo)(()=>i?i.reduce((e,t)=>e+Number(t.visits||0),0):0,[i]);return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${!c&&`col-span-2`}`,"data-testid":`web-performance`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(_,{size:16,strokeWidth:1.5}),`Web performance`]})}),(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{p(`/posts/analytics/${f}/web`)},children:l?`View more →`:`View more`})]}),(0,G.jsxs)(b,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,"data-testid":`unique-visitors`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-blue)`,children:`Unique visitors`}),(0,G.jsx)(j,{value:s(r)})]})}),(0,G.jsx)(N,{}),(0,G.jsx)(`div`,{className:`max-h-[288px] py-6 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:n?(0,G.jsx)(`div`,{className:`flex h-[16vw] min-h-[240px] items-center justify-center`,children:(0,G.jsx)(k,{})}):(0,G.jsx)(C,{className:`aspect-auto h-[240px] w-full`,color:`var(--chart-blue)`,data:e||[],id:`visitors`,range:t,syncId:`overview-charts`})})]}),c&&(0,G.jsxs)(`div`,{className:c?`border-t pt-3`:`-mt-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,G.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`How readers found this post`}),(0,G.jsx)(d,{children:`Visitors`})]})}),i&&i.length>0?(0,G.jsx)(U,{data:i,range:t,siteIcon:v,siteUrl:h,tableOnly:!0,topSourcesLimit:5,totalVisitors:w}):(0,G.jsx)(D,{className:`h-full py-10`,description:`Once someone visits this post, sources will show here`,title:`No visitors since you published this post`,children:(0,G.jsx)(_,{strokeWidth:1.5})})]})]})]})})},K=()=>{let{isAdmin7:e}=u(),t=o(),{statsConfig:n,isLoading:a}=ve(),{post:c,isPostLoading:l,postId:d}=ye(),{totals:f,isLoading:m,currencySymbol:_}=Ee(d),C=se(),w=oe(),ee=ce(),te=ae(),T=le(),{hasNewsletterAnalytics:ne,isStatusLoading:re}=F(),E=be(c),{token:ie,isLoading:D,error:A}=Ce(d,{enabled:E}),{usage:j,loading:M,error:N}=we({postUuid:c?.uuid,token:ie,tokenLoading:D,tokenError:A,enabled:E}),[P,B]=(0,W.useState)(!1),V=(0,W.useMemo)(()=>c?.published_at?he(c.published_at):ue.allTime.value,[c?.published_at]),{startDate:H,endDate:U,timezone:K}=fe(V),q=(0,W.useMemo)(()=>{let e={site_uuid:n?.id||``,date_from:me(H),date_to:me(U),timezone:K,post_uuid:``};return!l&&c?.uuid?{...e,post_uuid:c.uuid}:e},[l,c,n?.id,H,U,K]),{data:J,loading:Ae}=r({endpoint:`api_kpis`,statsConfig:n,params:q}),je=(0,W.useMemo)(()=>J?.length?J.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0):0,[J]),Y=De.visits,Me=ge(V,J||[],{fieldName:Y.dataKey}),Ne=pe(J||[],V,Y.dataKey,`sum`)?.map(e=>{let t=Number(e[Y.dataKey]);return{date:String(e.date),value:t,formattedValue:Y.formatter(t),label:Y.label}}),{data:Pe,loading:Fe}=r({endpoint:`api_top_sources`,statsConfig:n,params:q}),Ie=a||m||l||Ae,Le=l||a||Ae,X=ne&&w&&C,Z=!c?.email_only&&T,Q=ee,$=!!(E&&c&&T);return(0,W.useEffect)(()=>{!l&&c&&i(c)&&!T&&Q&&t(`/posts/analytics/${d}/growth`,{replace:!0})},[l,c,T,t,d,Q]),l?(0,G.jsx)(k,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Se,{currentTab:`Overview`}),(0,G.jsx)(xe,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 lg:grid lg:grid-cols-2`,children:[Z&&(0,G.jsx)(ke,{chartData:Ne,isLoading:Le||Ie||Fe,isNewsletterShown:X,range:Me,sourcesData:Pe,visitors:je}),X&&(0,G.jsx)(Oe,{isNewsletterStatsLoading:l||re,isWebShown:Z,post:c}),(Q||$)&&(0,G.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-6 lg:grid lg:grid-cols-3`,children:[Q&&(0,G.jsxs)(S,{className:`group overflow-hidden p-0 ${$?`lg:col-span-2`:`lg:col-span-3`}`,"data-testid":`growth`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(h,{size:16,strokeWidth:1.5}),`Growth`]})}),(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{t(`/posts/analytics/${d}/growth`)},children:e?`View more →`:`View more`})]}),(0,G.jsx)(b,{className:`flex flex-col gap-6 px-0 md:grid md:grid-cols-3 md:items-stretch md:gap-0`,children:Ie?Array.from({length:3},(e,t)=>(0,G.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,G.jsx)(O,{className:`w-2/3`}),(0,G.jsx)(O,{className:`h-7 w-12`})]},t)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`Free members`}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{className:`text-[2.2rem]`,children:s(f?.free_members||0)})})]}),te&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`Paid members`}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{className:`text-[2.2rem]`,children:s(f?.paid_members||0)})})]}),(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`MRR impact`}),(0,G.jsx)(L,{children:(0,G.jsxs)(I,{className:`text-[2.2rem]`,children:[_,s(_e(f?.mrr||0))]})})]})]})]})})]}),$&&(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${Q?`lg:col-span-1`:`lg:col-span-3`}`,"data-testid":`gift-link-card`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(v,{size:16,strokeWidth:1.5}),`Gift link`]})}),(0,G.jsxs)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>B(!0),children:[e&&(0,G.jsx)(p,{}),`Share`]})]}),!M&&!N&&(0,G.jsxs)(b,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Visitors`}),(0,G.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold`,"data-testid":`gift-link-card-visitors`,children:s(j?.visits??0)})]})]})]}),!Z&&!X&&!Q&&!$&&(0,G.jsx)(de,{className:`col-span-2 py-20`})]})}),$&&(0,G.jsx)(Te,{open:P,postId:d,source:`gift-link-card`,onOpenChange:B},d)]})};export{K as default};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`eae52fad-b974-4ff1-a0bd-07a323464b75`,e._sentryDebugIdIdentifier=`sentry-dbid-eae52fad-b974-4ff1-a0bd-07a323464b75`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-BYbl5gKY.js";import{r as i}from"./post-helpers-DC_rgYgU.js";import{h as a}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as o}from"./router-provider-Cf-bcYZr.js";import{H as s,L as c,U as l,r as u}from"./shade-provider-DvrXKKQZ.js";import{a as d}from"./heading-Ch2Mb19A.js";import{Wt as f,X as p,nn as m,q as h,t as g,vn as _,yn as v}from"./button-CTHYSI-d.js";import{a as y,n as b,o as x,t as S}from"./card-Cd6xB_Ok.js";import{t as C}from"./gh-chart-Boqv6SC0.js";import{c as w,l as ee,n as te,o as T,r as ne,s as re,t as E,u as ie}from"./data-list-CNs61th8.js";import{t as D}from"./empty-indicator-BhVwqSVH.js";import{t as O}from"./skeleton-C1s6yr9e.js";import{t as k}from"./loading-indicator-DaRyGrxv.js";import{n as A,r as j,t as M}from"./kpi-card-BLsrKWhX.js";import{$t as ae,Xt as oe,Yt as se,Zt as ce,nn as le,q as ue,st as N}from"./index-RuRs_qGS.js";import{t as de}from"./disabled-sources-indicator-DSRkkSw-.js";import{a as fe,c as pe,n as me,o as he,r as ge,t as _e}from"./chart-helpers-BSuFLd6-.js";import{t as ve}from"./use-analytics-data-Byf83QE-.js";import{t as P}from"./clean-tracked-url-iZ-wi2Sn.js";import{n as F}from"./email-sending-status-context-7yrRlgjQ.js";import{n as ye}from"./post-analytics-context-v4FXmVDC.js";import{a as I,n as L,r as R,t as z}from"./kpi-card-Djsroynj.js";import{n as be,r as xe,t as Se}from"./post-analytics-header-D2anehCj.js";import{t as Ce}from"./gift-links-lQ7H_D8Z.js";import{r as we,t as Te}from"./gift-link-modal-CNE7dfPD.js";import{t as Ee}from"./use-post-referrers-Bc8eq4uy.js";import{i as B,r as V,t as H}from"./use-post-top-links-DjltnQuI.js";import{n as De,r as U}from"./kpi-helpers-H-Hl6h7h.js";var W=e(t(),1),G=n(),Oe=({post:e,isNewsletterStatsLoading:t,isWebShown:n})=>{let{isAdmin7:r}=u(),{postId:i}=a(),p=o(),{isNewsletterDataHidden:h}=F(),_=(0,W.useMemo)(()=>{let t=e.email?.opened_count||0,n=e.email?.email_count||0,r=e.count?.clicks||0;return{opened:t,clicked:r,openedRate:n>0?t/n:0,clickedRate:n>0?r/n:0,sent:n}},[e]),{topLinks:v}=H(),C=[{datatype:`Clicked`,value:_.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`},{datatype:`Opened`,value:_.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],D={percentage:{label:`Opened`},Average:{label:`Clicked`},"This newsletter":{label:`Opened`}},O=e.email_only||!n;return(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${O&&`col-span-2`}`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(f,{size:16,strokeWidth:1.5}),`Newsletter performance`]})}),!h&&(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{p(`/posts/analytics/${i}/newsletter`)},children:r?`View more →`:`View more`})]}),t?(0,G.jsx)(b,{children:(0,G.jsx)(`div`,{className:`mx-auto flex min-h-[250px] items-center justify-center xl:size-full`,children:(0,G.jsx)(k,{})})}):(0,G.jsx)(b,{children:(0,G.jsxs)(B,{className:c(O&&`grid gap-6 md:grid-cols-2 md:gap-0`),description:`Opens and clicks will appear once every email has been sent`,title:`Your newsletter is being sent`,children:[(0,G.jsxs)(`div`,{className:c(O&&`md:border-r md:pr-6`),children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-blue)`,children:`Open rate`}),(0,G.jsx)(j,{value:l(_.openedRate)})]})}),(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-teal)`,children:`Click rate`}),(0,G.jsx)(j,{value:l(_.clickedRate)})]})})]}),!O&&(0,G.jsx)(N,{}),(0,G.jsx)(`div`,{className:`mx-auto my-6 h-[240px]`,children:(0,G.jsx)(V,{className:`pointer-events-none aspect-square h-[240px]`,config:D,data:C,tooltip:!1})})]}),(0,G.jsxs)(`div`,{className:c(O&&`border-t pt-6 md:border-t-0 md:pt-0 md:pl-6`),children:[!O&&(0,G.jsx)(N,{}),(0,G.jsxs)(`div`,{className:O?``:`pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${O?`pb-3`:`py-3`}`,children:[(0,G.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Top clicked links in this email`}),(0,G.jsx)(d,{children:`Members`})]}),v.length>0?(0,G.jsx)(E,{className:``,children:(0,G.jsx)(ne,{children:v.slice(0,O?10:5).map(e=>{let t=_.clicked>0?Math.min(e.count/_.clicked,1):0;return(0,G.jsxs)(ie,{children:[(0,G.jsx)(te,{style:{width:`${t?Math.round(t*100):0}%`}}),(0,G.jsx)(T,{children:(0,G.jsxs)(`div`,{className:`flex items-center space-x-2 overflow-hidden`,children:[(0,G.jsx)(m,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),(0,G.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:e.link.to,rel:`noreferrer`,target:`_blank`,title:e.link.to,children:P(e.link.to,!0)})]})}),(0,G.jsxs)(re,{children:[(0,G.jsx)(w,{children:s(e.count||0)}),(0,G.jsx)(ee,{children:l(t)})]})]},e.link.link_id)})})}):(0,G.jsx)(`div`,{className:`py-20 text-center text-sm text-muted-foreground`,children:`You have no links in your post.`})]})]})]})})]})},ke=({chartData:e,range:t,isLoading:n,visitors:r,sourcesData:i,isNewsletterShown:c=!0})=>{let{isAdmin7:l}=u(),{postId:f}=a(),p=o(),{site:m}=ve(),h=m.url,v=m.icon,w=(0,W.useMemo)(()=>i?i.reduce((e,t)=>e+Number(t.visits||0),0):0,[i]);return(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${!c&&`col-span-2`}`,"data-testid":`web-performance`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(_,{size:16,strokeWidth:1.5}),`Web performance`]})}),(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{p(`/posts/analytics/${f}/web`)},children:l?`View more →`:`View more`})]}),(0,G.jsxs)(b,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(M,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,"data-testid":`unique-visitors`,children:(0,G.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,G.jsx)(A,{color:`var(--chart-blue)`,children:`Unique visitors`}),(0,G.jsx)(j,{value:s(r)})]})}),(0,G.jsx)(N,{}),(0,G.jsx)(`div`,{className:`max-h-[288px] py-6 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:n?(0,G.jsx)(`div`,{className:`flex h-[16vw] min-h-[240px] items-center justify-center`,children:(0,G.jsx)(k,{})}):(0,G.jsx)(C,{className:`aspect-auto h-[240px] w-full`,color:`var(--chart-blue)`,data:e||[],id:`visitors`,range:t,syncId:`overview-charts`})})]}),c&&(0,G.jsxs)(`div`,{className:c?`border-t pt-3`:`-mt-3`,children:[(0,G.jsx)(`div`,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,G.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`How readers found this post`}),(0,G.jsx)(d,{children:`Visitors`})]})}),i&&i.length>0?(0,G.jsx)(U,{data:i,range:t,siteIcon:v,siteUrl:h,tableOnly:!0,topSourcesLimit:5,totalVisitors:w}):(0,G.jsx)(D,{className:`h-full py-10`,description:`Once someone visits this post, sources will show here`,title:`No visitors since you published this post`,children:(0,G.jsx)(_,{strokeWidth:1.5})})]})]})]})})},K=()=>{let{isAdmin7:e}=u(),t=o(),{statsConfig:n,isLoading:a}=ve(),{post:c,isPostLoading:l,postId:d}=ye(),{totals:f,isLoading:m,currencySymbol:_}=Ee(d),C=se(),w=oe(),ee=ce(),te=ae(),T=le(),{hasNewsletterAnalytics:ne,isStatusLoading:re}=F(),E=be(c),{token:ie,isLoading:D,error:A}=Ce(d,{enabled:E}),{usage:j,loading:M,error:N}=we({postUuid:c?.uuid,token:ie,tokenLoading:D,tokenError:A,enabled:E}),[P,B]=(0,W.useState)(!1),V=(0,W.useMemo)(()=>c?.published_at?he(c.published_at):ue.allTime.value,[c?.published_at]),{startDate:H,endDate:U,timezone:K}=fe(V),q=(0,W.useMemo)(()=>{let e={site_uuid:n?.id||``,date_from:me(H),date_to:me(U),timezone:K,post_uuid:``};return!l&&c?.uuid?{...e,post_uuid:c.uuid}:e},[l,c,n?.id,H,U,K]),{data:J,loading:Ae}=r({endpoint:`api_kpis`,statsConfig:n,params:q}),je=(0,W.useMemo)(()=>J?.length?J.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0):0,[J]),Y=De.visits,Me=ge(V,J||[],{fieldName:Y.dataKey}),Ne=pe(J||[],V,Y.dataKey,`sum`)?.map(e=>{let t=Number(e[Y.dataKey]);return{date:String(e.date),value:t,formattedValue:Y.formatter(t),label:Y.label}}),{data:Pe,loading:Fe}=r({endpoint:`api_top_sources`,statsConfig:n,params:q}),Ie=a||m||l||Ae,Le=l||a||Ae,X=ne&&w&&C,Z=!c?.email_only&&T,Q=ee,$=!!(E&&c&&T);return(0,W.useEffect)(()=>{!l&&c&&i(c)&&!T&&Q&&t(`/posts/analytics/${d}/growth`,{replace:!0})},[l,c,T,t,d,Q]),l?(0,G.jsx)(k,{}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Se,{currentTab:`Overview`}),(0,G.jsx)(xe,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 lg:grid lg:grid-cols-2`,children:[Z&&(0,G.jsx)(ke,{chartData:Ne,isLoading:Le||Ie||Fe,isNewsletterShown:X,range:Me,sourcesData:Pe,visitors:je}),X&&(0,G.jsx)(Oe,{isNewsletterStatsLoading:l||re,isWebShown:Z,post:c}),(Q||$)&&(0,G.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-6 lg:grid lg:grid-cols-3`,children:[Q&&(0,G.jsxs)(S,{className:`group overflow-hidden p-0 ${$?`lg:col-span-2`:`lg:col-span-3`}`,"data-testid":`growth`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(h,{size:16,strokeWidth:1.5}),`Growth`]})}),(0,G.jsx)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>{t(`/posts/analytics/${d}/growth`)},children:e?`View more →`:`View more`})]}),(0,G.jsx)(b,{className:`flex flex-col gap-6 px-0 md:grid md:grid-cols-3 md:items-stretch md:gap-0`,children:Ie?Array.from({length:3},(e,t)=>(0,G.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,G.jsx)(O,{className:`w-2/3`}),(0,G.jsx)(O,{className:`h-7 w-12`})]},t)):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`Free members`}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{className:`text-[2.2rem]`,children:s(f?.free_members||0)})})]}),te&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`Paid members`}),(0,G.jsx)(L,{children:(0,G.jsx)(I,{className:`text-[2.2rem]`,children:s(f?.paid_members||0)})})]}),(0,G.jsxs)(z,{className:`grow gap-1 py-0`,children:[(0,G.jsx)(R,{children:`MRR impact`}),(0,G.jsx)(L,{children:(0,G.jsxs)(I,{className:`text-[2.2rem]`,children:[_,s(_e(f?.mrr||0))]})})]})]})]})})]}),$&&(0,G.jsxs)(S,{className:`group/datalist overflow-hidden ${Q?`lg:col-span-1`:`lg:col-span-3`}`,"data-testid":`gift-link-card`,children:[(0,G.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,G.jsx)(y,{children:(0,G.jsxs)(x,{className:`flex items-center gap-1.5 text-lg`,children:[(0,G.jsx)(v,{size:16,strokeWidth:1.5}),`Gift link`]})}),(0,G.jsxs)(g,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:()=>B(!0),children:[e&&(0,G.jsx)(p,{}),`Share`]})]}),!M&&!N&&(0,G.jsxs)(b,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Visitors`}),(0,G.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold`,"data-testid":`gift-link-card-visitors`,children:s(j?.visits??0)})]})]})]}),!Z&&!X&&!Q&&!$&&(0,G.jsx)(de,{className:`col-span-2 py-20`})]})}),$&&(0,G.jsx)(Te,{open:P,postId:d,source:`gift-link-card`,onOpenChange:B},d)]})};export{K as default};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`fe57c9ec-e212-4daa-a109-b6d00450706a`,e._sentryDebugIdIdentifier=`sentry-dbid-fe57c9ec-e212-4daa-a109-b6d00450706a`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-CPy5ipAP.js";import{i}from"./pagemenu--UL0gW1x.js";import{r as a}from"./posts-Lg-p_ZHg.js";import{o}from"./config-B3HuCo0y.js";import{t as s}from"./analytics-CDjjaA4a.js";import{t as c}from"./post-utils-Cj-QlpPF.js";import{t as l}from"./post-helpers-DC_rgYgU.js";import{u}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as d}from"./router-provider-Cf-bcYZr.js";import{F as f,H as p,L as m,R as h,U as g,r as _}from"./shade-provider-DvrXKKQZ.js";import{r as v}from"./heading-Ch2Mb19A.js";import{Jt as y,On as b,Ot as x,Rn as S,X as C,bt as w,et as T,fr as ee,g as E,kt as D,r as te,sr as O,t as k,u as A,ur as ne,vn as j}from"./button-CTHYSI-d.js";import{a as M,n as N,o as P,r as F,s as re,t as I}from"./card-Cd6xB_Ok.js";import{t as L}from"./gh-chart-Boqv6SC0.js";import{t as R}from"./empty-indicator-BhVwqSVH.js";import{n as z,t as B}from"./skeleton-C1s6yr9e.js";import{t as ie}from"./loading-indicator-DaRyGrxv.js";import{t as V}from"./use-host-limits-CNh4AAEs.js";import{n as ae,r as oe,t as se}from"./kpi-card-BLsrKWhX.js";import{$t as H,N as ce,V as le,X as U,Xt as ue,Yt as de,Zt as fe,nn as W,q as pe,u as me}from"./index-CuDhPtkB.js";import{i as he,n as ge,r as _e,t as ve}from"./stats-view-DQZzKeEz.js";import{g as ye,u as be}from"./stats-CHOikfoP.js";import{a as xe,c as G,i as K,n as q,r as Se,t as J}from"./chart-helpers-D-3N170i.js";import{t as Ce}from"./use-growth-stats-BS62uyyn.js";import{t as Y}from"./use-analytics-data-oJ2o0pSS.js";import{n as we}from"./audience-Deg9lzfk.js";import{n as Te}from"./url-helpers-BGuw1NzR.js";import{t as Ee}from"./get-site-timezone-BnQQpb6P.js";import{t as De}from"./post-share-modal-Z_oAYgWz.js";import{t as Oe}from"./feature-image-placeholder-moUV4yhR.js";var X=e(t(),1),ke=()=>{let{data:{posts:[e]}={posts:[]},isLoading:t}=a({searchParams:{filter:`status:[published,sent]`,order:`published_at DESC`,limit:`1`,include:`authors,email,count.clicks`}}),n=e,{data:r,isLoading:i}=be(n?.id||``,{enabled:!!n?.id});return{data:(0,X.useMemo)(()=>{if(!n)return null;let e=r?.stats?.[0]||{id:n.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:n.id,uuid:n.uuid,title:n.title||``,slug:n.slug||``,feature_image:n.feature_image||null,published_at:n.published_at||``,url:n.url||``,excerpt:n.excerpt||``,email_only:n.email_only||!1,status:n.status,email:n.email,count:n.count,authors:n.authors||[],recipient_count:e.recipient_count,opened_count:e.opened_count,open_rate:e.open_rate,member_delta:e.member_delta,free_members:e.free_members,paid_members:e.paid_members,visitors:e.visitors,click_rate:null}},[n,r]),isLoading:t||!!n?.id&&i}},Z=n(),Ae=e=>e.email_only?`Sent`:e.email?`Published and sent`:`Published`,je=({latestPostStats:e,isLoading:t})=>{let n=d(),r=u(),{isAdmin7:i}=_(),[a,o]=(0,X.useState)(!1),{site:c,settings:f}=Y(),v=de(),x=ue(),S=W(),T=fe()??!1;(0,X.useEffect)(()=>{a&&s(`Share Modal Opened`,{giftLinkShown:!1,source:`stats-overview`})},[a]);let ee=c.title||String(f.find(e=>e.key===`title`)?.value||`Ghost Site`),te=Ee(f),O=e?l(e,{membersTrackSources:T}):null,A=`group mr-2 flex flex-col gap-1.5 hover:cursor-pointer`,re=!!e?.email,L=Te({postId:e?.id,hasEmailData:re,analytics:{webAnalytics:S,membersTrackSources:T}}),z=L.startsWith(`/editor/`),ie=me(L),V=()=>n(L,ie?{crossApp:!0}:{state:z?ce(r):void 0});return(0,Z.jsxs)(I,{className:`group/card`,"data-testid":`latest-post`,children:[(0,Z.jsxs)(M,{children:[(0,Z.jsx)(P,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:`Latest post performance`}),(0,Z.jsx)(F,{className:`hidden`,children:`How your last post did`})]}),(0,Z.jsxs)(N,{className:`flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3`,children:[t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-6 px-6 xl:col-span-2`,children:[(0,Z.jsx)(`div`,{className:`w-full max-w-[232px] grow`,children:(0,Z.jsx)(B,{className:`aspect-[16/10] rounded-md`})}),(0,Z.jsxs)(`div`,{className:`w-full grow`,children:[(0,Z.jsx)(B,{className:`w-full max-w-[420px]`}),(0,Z.jsx)(B,{className:`w-1/2`})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col items-stretch gap-2 px-6`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]})]})})]}),!t&&e&&O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2`,children:[e.feature_image&&(0,Z.jsx)(`div`,{className:`aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]`,style:{backgroundImage:`url(${e.feature_image})`}}),(0,Z.jsxs)(`div`,{className:`flex grow flex-col items-start justify-center self-stretch`,children:[(0,Z.jsx)(`div`,{className:`text-md leading-tighter font-semibold tracking-tight wrap-anywhere hover:cursor-pointer hover:opacity-75`,onClick:()=>{!t&&e&&V()},children:e.title}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.authors&&e.authors.length>0&&(0,Z.jsxs)(`div`,{children:[`By `,e.authors.map(e=>e.name).join(`, `),` –`,` `,h(e.published_at,te)]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:Ae(e)})]}),(0,Z.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[!e.email_only&&(0,Z.jsx)(De,{author:e.authors?.map(e=>e.name).join(`, `)||``,description:``,faviconURL:c.icon||``,featureImageURL:e.feature_image||``,open:a,postExcerpt:e.excerpt||``,postTitle:e.title,postURL:e.url||``,siteTitle:ee,onClose:()=>o(!1),onOpenChange:o,children:(0,Z.jsxs)(k,{onClick:()=>o(!0),children:[(0,Z.jsx)(C,{}),` Share post`]})}),(0,Z.jsx)(k,{className:e.email_only?`w-full`:``,variant:i||z?`outline`:`subtle`,onClick:()=>{V()},children:z?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Edit post`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:e.email_only?`Post analytics`:`Analytics`})]})})]})]})]}),(0,Z.jsx)(`div`,{className:`flex w-full flex-col items-stretch gap-2 px-6 lg:-ml-4 lg:pr-6 lg:pl-0 xl:h-full xl:max-w-none`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 lg:border-l lg:pl-10 xl:h-full`,children:[O.showWebMetrics&&S&&(0,Z.jsxs)(`div`,{className:A,"data-testid":`latest-post-visitors`,onClick:()=>{n(`/posts/analytics/${e.id}/web`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(j,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Visitors`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:p(e.visitors)})]}),O.showMemberGrowth&&(0,Z.jsxs)(`div`,{className:m(A,O.showEmailMetrics&&(!O.showWebMetrics||!S)&&`col-[1/2] row-[2/3]`),"data-testid":`latest-post-members`,onClick:()=>{n(`/posts/analytics/${e.id}/growth`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(E,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Members`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.member_delta?(0,Z.jsxs)(Z.Fragment,{children:[`+`,p(e.member_delta)]}):0})]}),O.showEmailMetrics&&e.email&&(0,Z.jsxs)(Z.Fragment,{children:[x&&(0,Z.jsxs)(`div`,{className:A,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(y,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Opens`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count?g((e.email.opened_count||0)/e.email.email_count):`0%`})]}),v&&(0,Z.jsxs)(`div`,{className:A,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(D,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Clicks`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count&&e.count?.clicks?g((e.count.clicks||0)/e.email.email_count):`0%`})]})]})]})})]}):!t&&(0,Z.jsx)(R,{actions:(0,Z.jsx)(k,{variant:`secondary`,onClick:()=>{n(`/editor/post`,{crossApp:!0})},children:`New post`}),className:`w-full pb-10 xl:col-span-3`,description:`Once it's live, you can track performance here`,title:`Publish your first post`,children:(0,Z.jsx)(b,{strokeWidth:1.5})})]})]})},Q=({title:e,iconName:t,description:n,color:r,diffDirection:i,diffValue:a,formattedValue:o,trendingFromValue:s,children:c,onClick:l})=>{let{range:u}=U(),{isAdmin7:d}=_(),f=t&&te[t],p=X.useMemo(()=>{if(!i||i===`empty`||u===pe.allTime.value||!a)return``;let e=i===`up`?`up`:i===`down`?`down`:`at`,t=K(u).replace(`in the `,``).replace(/^\(|\)$/g,``);return i===`same`?(0,Z.jsxs)(`span`,{children:[`You're trending at the same level as`,` `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:o}),` compared to the`,` `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:t})]}):(0,Z.jsxs)(`span`,{children:[`You're trending`,` `,(0,Z.jsxs)(`span`,{className:`font-semibold`,children:[e,` `,a]}),` `,`from `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:s}),` compared to the`,` `,t]})},[i,a,s,o,u]);return(0,Z.jsxs)(I,{className:`group`,"data-testid":e,children:[(0,Z.jsxs)(M,{className:`hidden`,children:[(0,Z.jsx)(P,{children:e}),(0,Z.jsx)(F,{children:n})]}),(0,Z.jsxs)(se,{className:`relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,Z.jsxs)(ae,{className:l&&`transition-all group-hover:text-foreground`,children:[r&&(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r}}),f&&(0,Z.jsx)(f,{size:16,strokeWidth:1.5}),e]}),(0,Z.jsx)(oe,{diffDirection:u===pe.allTime.value?`hidden`:i,diffTooltip:p,diffValue:a,value:o})]}),l&&(0,Z.jsx)(k,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:l,children:d?`View more →`:`View more`})]}),(0,Z.jsx)(N,{children:c})]})},Me=({kpiValues:e,visitorsChartData:t,visitorsChartRange:n,visitorsYRange:r,growthTotals:i,membersChartData:a,mrrChartData:s,growthChartRange:c,currencySymbol:l,isLoading:u})=>{let f=d(),m=W(),h=H(),g=V(),{config:_}=Y(),v=g?.limitAnalytics?.disabled===!0,y=`-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:cursor-pointer!`;if(u)return(0,Z.jsx)(re,{className:`flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:cursor-pointer!`,children:(0,Z.jsx)(ie,{})});let b=m,x=v&&!b,S=h,C=[b,x,!0,S].filter(Boolean).length,w=`lg:grid-cols-3`;return C===2?w=`lg:grid-cols-2`:C===1&&(w=`lg:grid-cols-1`),(0,Z.jsxs)(`div`,{className:`flex flex-col lg:grid ${w} gap-6`,children:[b&&!x&&(0,Z.jsx)(Q,{description:`Number of individual people who visited your website`,diffDirection:`empty`,formattedValue:e.visits,iconName:`Globe`,linkto:`/analytics/web/`,title:`Unique visitors`,onClick:()=>{f(`/analytics/web/`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-blue)`,data:t,id:`visitors`,range:n,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`,yAxisRange:r})}),x&&(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(M,{className:`hidden`,children:[(0,Z.jsx)(P,{children:`Unlock web analytics`}),(0,Z.jsx)(F,{children:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`})]}),(0,Z.jsx)(N,{className:`flex h-full items-center justify-center p-6`,children:(0,Z.jsx)(R,{actions:(0,Z.jsx)(k,{variant:`outline`,onClick:()=>f(o(_),{crossApp:!0}),children:`Upgrade now`}),className:`py-10`,description:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`,title:`Unlock web analytics`,children:(0,Z.jsx)(O,{})})})]}),(0,Z.jsx)(Q,{description:`How number of members of your publication changed over time`,diffDirection:i.directions.total,diffValue:i.percentChanges.total,formattedValue:p(i.totalMembers),iconName:`User`,linkto:`/analytics/growth/`,title:`Members`,trendingFromValue:`${p(a[0]?.value??0)}`,onClick:()=>{f(`/analytics/growth/?tab=total-members`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-darkblue)`,data:a,id:`members`,range:c,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})}),S&&(0,Z.jsx)(Q,{description:`Monthly recurring revenue changes over time`,diffDirection:i.directions.mrr,diffValue:i.percentChanges.mrr,formattedValue:`${l}${p(J(i.mrr))}`,iconName:`Coins`,linkto:`/analytics/growth/`,title:`MRR`,trendingFromValue:`${l}${p(s[0]?.value??0)}`,onClick:()=>{f(`/analytics/growth/?tab=mrr`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-teal)`,data:s,id:`mrr`,range:c,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})})]})},$=({metrics:e,title:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute right-0 bottom-[calc(100%+2px)] z-50 min-w-[160px] rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100`,children:[(0,Z.jsx)(`div`,{className:`mb-1.5 border-b pr-10 pb-1.5 font-medium whitespace-nowrap text-muted-foreground`,children:t}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e?.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[e.icon,e.label]}),(0,Z.jsx)(`span`,{className:`font-mono`,children:e.metric})]},e.label))})]})}),Ne=({topPostsData:e,isLoading:t})=>{let n=d(),r=u(),i=me(`/editor`),{range:a}=U(),{settings:o}=Y(),s=H(),l=Ee(o),m=W(),g=fe()??!1,_=de()??!1,v=ue()??!1,C=`flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground`;return(0,Z.jsxs)(I,{className:`group/card w-full lg:col-span-2`,"data-testid":`top-posts-card`,children:[(0,Z.jsxs)(M,{children:[(0,Z.jsxs)(P,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:[`Top posts `,K(a)]}),(0,Z.jsx)(F,{className:`hidden`,children:`Most viewed posts in this period`})]}),(0,Z.jsx)(N,{children:t?(0,Z.jsx)(z,{className:`mt-6`}):(0,Z.jsxs)(Z.Fragment,{children:[e?.stats?.map(e=>(0,Z.jsxs)(`div`,{className:`group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-table-row-hover before:content-[""] first:border-border! hover:cursor-pointer hover:border-transparent hover:before:block md:items-center [&+div]:hover:border-transparent`,children:[(0,Z.jsxs)(`div`,{className:`z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]`,onClick:()=>{let t=Te({postId:e.post_id,hasEmailData:e.sent_count!==null,analytics:{webAnalytics:m,membersTrackSources:g}}),a=t.startsWith(`/editor/`);n(t,a&&i?{crossApp:!0}:{state:a?ce(r):void 0})},children:[e.feature_image?(0,Z.jsx)(`div`,{className:`hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:visible! sm:block! lg:w-[100px]`,style:{backgroundImage:`url(${e.feature_image})`}}):(0,Z.jsx)(Oe,{className:`hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:visible! sm:flex! lg:w-[100px]`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 text-md font-semibold wrap-anywhere`,children:e.title}),(0,Z.jsxs)(`span`,{className:`text text-muted-foreground`,children:[`By `,e.authors,` –`,` `,h(e.published_at,l)]}),(0,Z.jsx)(`span`,{className:`text text-muted-foreground`,children:c(e)})]})]}),(0,Z.jsxs)(`div`,{className:`z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3`,children:[m&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-visitors`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/web`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(j,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Unique visitors`,metric:p(e.views)}],title:`Web traffic`}),(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(j,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),f(e.views)]})]}),e.sent_count!==null&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/newsletter`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(T,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Sent`,metric:p(e.sent_count||0)},...v?[{icon:(0,Z.jsx)(y,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Opens`,metric:p(e.opened_count||0)}]:[],..._?[{icon:(0,Z.jsx)(x,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Clicks`,metric:p(e.clicked_count||0)}]:[]],title:`Newsletter performance`}),(0,Z.jsx)(`div`,{className:C,children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.open_rate?`${Math.round(e.open_rate)}%`:`0%`]}):_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(x,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.click_rate?`${Math.round(e.click_rate)}%`:`0%`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),f(e.sent_count||0)]})})]}),g&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-members`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/growth`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(A,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Free`,metric:e.free_members>0?`+${p(e.free_members)}`:`0`},...s?[{icon:(0,Z.jsx)(S,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Paid`,metric:e.paid_members>0?`+${p(e.paid_members)}`:`0`}]:[]],title:`New members`}),(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(E,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.members>0?`+${p(e.members)}`:`0`]})]})]})]},e.post_id)),(!e?.stats||e.stats.length===0)&&(0,Z.jsx)(R,{className:`w-full pb-10`,title:`No posts ${K(a)}`,children:(0,Z.jsx)(b,{strokeWidth:1.5})})]})})]})},Pe=({className:e,title:t,description:n,url:r,children:i})=>(0,Z.jsx)(`a`,{className:m(`group/card block rounded-xl border bg-card p-6 transition-all hover:bg-table-row-hover hover:shadow-xs`,e),href:r,rel:`noreferrer`,target:`_blank`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-6`,children:[i,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-tight`,children:[(0,Z.jsx)(`span`,{className:`text-base font-semibold`,children:t}),(0,Z.jsx)(`span`,{className:`text-sm font-normal text-gray-700`,children:n})]})]})}),Fe=()=>{let e=H(),{range:t}=U(),{statsConfig:n,isLoading:a}=Y(),{startDate:o,endDate:s,timezone:c}=xe(t),{isLoading:l,chartData:u,totals:d,currencySymbol:f}=Ce(t),{data:m,isLoading:h}=ke(),{data:g,isLoading:_}=ye({searchParams:{date_from:q(o),date_to:q(s),limit:`5`,timezone:c}}),{data:y,loading:b}=r({endpoint:`api_kpis`,statsConfig:n,params:{site_uuid:n?.id||``,date_from:q(o),date_to:q(s),timezone:c,member_status:we(le)}}),x=(0,X.useMemo)(()=>G(y||[],t,`visits`,`sum`)?.map(e=>{let t=Number(e.visits),n=isNaN(t)?0:t;return{date:String(e.date),value:n,formattedValue:p(n),label:`Visitors`}}),[y,t]),S=(0,X.useMemo)(()=>Se(t,y||[],{fieldName:`visits`}),[y,t]),C=(0,X.useMemo)(()=>{let e=[0,1];if(!x||x.length===0)return e;let t=x.map(e=>e.value).filter(e=>e>=0);return t.length===0?e:[0,Math.max(...t)||e[1]]},[x]),w=(0,X.useMemo)(()=>Se(t,u||[]),[u,t]),T=(0,X.useMemo)(()=>{if(!u||u.length===0)return[];let e=[];return e=G(u,t,`value`,`exact`),e.map(e=>({date:e.date,value:e.free+e.paid,formattedValue:p(e.free+e.paid),label:`Members`}))},[u,t]),E=(0,X.useMemo)(()=>{if(!e||!u||u.length===0)return[];let n=[];return n=G(u,t,`mrr`,`exact`),n.map(e=>({date:e.date,value:J(e.mrr),formattedValue:`${f}${p(J(e.mrr))}`,label:`MRR`}))},[u,t,f,e]),D=(0,X.useMemo)(()=>y?.length?{visits:p(y.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0))}:{visits:`0`},[y]);return(0,Z.jsxs)(ge,{children:[(0,Z.jsx)(_e,{children:(0,Z.jsx)(i,{children:(0,Z.jsx)(he,{excludeRanges:[`today`]})})}),(0,Z.jsxs)(ve,{isLoading:a,loadingComponent:(0,Z.jsx)(Z.Fragment,{}),children:[(0,Z.jsx)(Me,{currencySymbol:f,growthChartRange:w,growthTotals:d,isLoading:b||l,kpiValues:D,membersChartData:T,mrrChartData:E,visitorsChartData:x,visitorsChartRange:S,visitorsYRange:C}),(0,Z.jsx)(je,{isLoading:h,latestPostStats:m}),(0,Z.jsx)(Ne,{isLoading:_,topPostsData:g}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,Z.jsx)(v,{className:`mt-4 -mb-4 lg:col-span-2`,children:`Grow your audience`}),(0,Z.jsx)(Pe,{description:`Find out how to review the performance of your content and get the most out of post analytics in Ghost.`,title:`Understanding analytics in Ghost`,url:`https://ghost.org/help/native-analytics`,children:(0,Z.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,Z.jsx)(ee,{className:`text-[#00BBA7]`,size:20,strokeWidth:1.5})})}),(0,Z.jsx)(Pe,{description:`Use these content distribution tactics to get more people to discover your work and increase engagement.`,title:`How to get your content seen online`,url:`https://ghost.org/resources/content-distribution/`,children:(0,Z.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,Z.jsx)(j,{className:`text-[#FE9A00]`,size:20,strokeWidth:1.5})})})]})]})]})};export{Fe as default};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`fe57c9ec-e212-4daa-a109-b6d00450706a`,e._sentryDebugIdIdentifier=`sentry-dbid-fe57c9ec-e212-4daa-a109-b6d00450706a`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-BYbl5gKY.js";import{i}from"./pagemenu-DXr_U43J.js";import{r as a}from"./posts-CftunZgV.js";import{o}from"./config-CRAZ4Civ.js";import{t as s}from"./analytics-CDjjaA4a.js";import{t as c}from"./post-utils-Cj-QlpPF.js";import{t as l}from"./post-helpers-DC_rgYgU.js";import{u}from"./chunk-OB3PAWPO-D3muQBsq.js";import{a as d}from"./router-provider-Cf-bcYZr.js";import{F as f,H as p,L as m,R as h,U as g,r as _}from"./shade-provider-DvrXKKQZ.js";import{r as v}from"./heading-Ch2Mb19A.js";import{Jt as y,On as b,Ot as x,Rn as S,X as C,bt as w,et as T,fr as ee,g as E,kt as D,r as te,sr as O,t as k,u as A,ur as ne,vn as j}from"./button-CTHYSI-d.js";import{a as M,n as N,o as P,r as F,s as re,t as I}from"./card-Cd6xB_Ok.js";import{t as L}from"./gh-chart-Boqv6SC0.js";import{t as R}from"./empty-indicator-BhVwqSVH.js";import{n as z,t as B}from"./skeleton-C1s6yr9e.js";import{t as ie}from"./loading-indicator-DaRyGrxv.js";import{t as V}from"./use-host-limits-BZx7rzRI.js";import{n as ae,r as oe,t as se}from"./kpi-card-BLsrKWhX.js";import{$t as H,N as ce,V as le,X as U,Xt as ue,Yt as de,Zt as fe,nn as W,q as pe,u as me}from"./index-RuRs_qGS.js";import{i as he,n as ge,r as _e,t as ve}from"./stats-view-BwbdkdOQ.js";import{g as ye,u as be}from"./stats-BL_FJ7Ns.js";import{a as xe,c as G,i as K,n as q,r as Se,t as J}from"./chart-helpers-BSuFLd6-.js";import{t as Ce}from"./use-growth-stats-CCpnBgqS.js";import{t as Y}from"./use-analytics-data-Byf83QE-.js";import{n as we}from"./audience-Dn7LuH-r.js";import{n as Te}from"./url-helpers-BGuw1NzR.js";import{t as Ee}from"./get-site-timezone-BnQQpb6P.js";import{t as De}from"./post-share-modal-Z_oAYgWz.js";import{t as Oe}from"./feature-image-placeholder-moUV4yhR.js";var X=e(t(),1),ke=()=>{let{data:{posts:[e]}={posts:[]},isLoading:t}=a({searchParams:{filter:`status:[published,sent]`,order:`published_at DESC`,limit:`1`,include:`authors,email,count.clicks`}}),n=e,{data:r,isLoading:i}=be(n?.id||``,{enabled:!!n?.id});return{data:(0,X.useMemo)(()=>{if(!n)return null;let e=r?.stats?.[0]||{id:n.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:n.id,uuid:n.uuid,title:n.title||``,slug:n.slug||``,feature_image:n.feature_image||null,published_at:n.published_at||``,url:n.url||``,excerpt:n.excerpt||``,email_only:n.email_only||!1,status:n.status,email:n.email,count:n.count,authors:n.authors||[],recipient_count:e.recipient_count,opened_count:e.opened_count,open_rate:e.open_rate,member_delta:e.member_delta,free_members:e.free_members,paid_members:e.paid_members,visitors:e.visitors,click_rate:null}},[n,r]),isLoading:t||!!n?.id&&i}},Z=n(),Ae=e=>e.email_only?`Sent`:e.email?`Published and sent`:`Published`,je=({latestPostStats:e,isLoading:t})=>{let n=d(),r=u(),{isAdmin7:i}=_(),[a,o]=(0,X.useState)(!1),{site:c,settings:f}=Y(),v=de(),x=ue(),S=W(),T=fe()??!1;(0,X.useEffect)(()=>{a&&s(`Share Modal Opened`,{giftLinkShown:!1,source:`stats-overview`})},[a]);let ee=c.title||String(f.find(e=>e.key===`title`)?.value||`Ghost Site`),te=Ee(f),O=e?l(e,{membersTrackSources:T}):null,A=`group mr-2 flex flex-col gap-1.5 hover:cursor-pointer`,re=!!e?.email,L=Te({postId:e?.id,hasEmailData:re,analytics:{webAnalytics:S,membersTrackSources:T}}),z=L.startsWith(`/editor/`),ie=me(L),V=()=>n(L,ie?{crossApp:!0}:{state:z?ce(r):void 0});return(0,Z.jsxs)(I,{className:`group/card`,"data-testid":`latest-post`,children:[(0,Z.jsxs)(M,{children:[(0,Z.jsx)(P,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:`Latest post performance`}),(0,Z.jsx)(F,{className:`hidden`,children:`How your last post did`})]}),(0,Z.jsxs)(N,{className:`flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3`,children:[t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-6 px-6 xl:col-span-2`,children:[(0,Z.jsx)(`div`,{className:`w-full max-w-[232px] grow`,children:(0,Z.jsx)(B,{className:`aspect-[16/10] rounded-md`})}),(0,Z.jsxs)(`div`,{className:`w-full grow`,children:[(0,Z.jsx)(B,{className:`w-full max-w-[420px]`}),(0,Z.jsx)(B,{className:`w-1/2`})]})]}),(0,Z.jsx)(`div`,{className:`flex flex-col items-stretch gap-2 px-6`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(B,{className:`w-3/4`}),(0,Z.jsx)(B,{className:`h-10 w-1/3`})]})]})})]}),!t&&e&&O?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2`,children:[e.feature_image&&(0,Z.jsx)(`div`,{className:`aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]`,style:{backgroundImage:`url(${e.feature_image})`}}),(0,Z.jsxs)(`div`,{className:`flex grow flex-col items-start justify-center self-stretch`,children:[(0,Z.jsx)(`div`,{className:`text-md leading-tighter font-semibold tracking-tight wrap-anywhere hover:cursor-pointer hover:opacity-75`,onClick:()=>{!t&&e&&V()},children:e.title}),(0,Z.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.authors&&e.authors.length>0&&(0,Z.jsxs)(`div`,{children:[`By `,e.authors.map(e=>e.name).join(`, `),` –`,` `,h(e.published_at,te)]}),(0,Z.jsx)(`div`,{className:`mt-0.5`,children:Ae(e)})]}),(0,Z.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[!e.email_only&&(0,Z.jsx)(De,{author:e.authors?.map(e=>e.name).join(`, `)||``,description:``,faviconURL:c.icon||``,featureImageURL:e.feature_image||``,open:a,postExcerpt:e.excerpt||``,postTitle:e.title,postURL:e.url||``,siteTitle:ee,onClose:()=>o(!1),onOpenChange:o,children:(0,Z.jsxs)(k,{onClick:()=>o(!0),children:[(0,Z.jsx)(C,{}),` Share post`]})}),(0,Z.jsx)(k,{className:e.email_only?`w-full`:``,variant:i||z?`outline`:`subtle`,onClick:()=>{V()},children:z?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(w,{}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Edit post`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(ne,{}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:e.email_only?`Post analytics`:`Analytics`})]})})]})]})]}),(0,Z.jsx)(`div`,{className:`flex w-full flex-col items-stretch gap-2 px-6 lg:-ml-4 lg:pr-6 lg:pl-0 xl:h-full xl:max-w-none`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 lg:border-l lg:pl-10 xl:h-full`,children:[O.showWebMetrics&&S&&(0,Z.jsxs)(`div`,{className:A,"data-testid":`latest-post-visitors`,onClick:()=>{n(`/posts/analytics/${e.id}/web`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(j,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Visitors`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:p(e.visitors)})]}),O.showMemberGrowth&&(0,Z.jsxs)(`div`,{className:m(A,O.showEmailMetrics&&(!O.showWebMetrics||!S)&&`col-[1/2] row-[2/3]`),"data-testid":`latest-post-members`,onClick:()=>{n(`/posts/analytics/${e.id}/growth`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(E,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Members`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.member_delta?(0,Z.jsxs)(Z.Fragment,{children:[`+`,p(e.member_delta)]}):0})]}),O.showEmailMetrics&&e.email&&(0,Z.jsxs)(Z.Fragment,{children:[x&&(0,Z.jsxs)(`div`,{className:A,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(y,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Opens`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count?g((e.email.opened_count||0)/e.email.email_count):`0%`})]}),v&&(0,Z.jsxs)(`div`,{className:A,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,Z.jsx)(D,{size:16,strokeWidth:1.25}),(0,Z.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Clicks`})]}),(0,Z.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count&&e.count?.clicks?g((e.count.clicks||0)/e.email.email_count):`0%`})]})]})]})})]}):!t&&(0,Z.jsx)(R,{actions:(0,Z.jsx)(k,{variant:`secondary`,onClick:()=>{n(`/editor/post`,{crossApp:!0})},children:`New post`}),className:`w-full pb-10 xl:col-span-3`,description:`Once it's live, you can track performance here`,title:`Publish your first post`,children:(0,Z.jsx)(b,{strokeWidth:1.5})})]})]})},Q=({title:e,iconName:t,description:n,color:r,diffDirection:i,diffValue:a,formattedValue:o,trendingFromValue:s,children:c,onClick:l})=>{let{range:u}=U(),{isAdmin7:d}=_(),f=t&&te[t],p=X.useMemo(()=>{if(!i||i===`empty`||u===pe.allTime.value||!a)return``;let e=i===`up`?`up`:i===`down`?`down`:`at`,t=K(u).replace(`in the `,``).replace(/^\(|\)$/g,``);return i===`same`?(0,Z.jsxs)(`span`,{children:[`You're trending at the same level as`,` `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:o}),` compared to the`,` `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:t})]}):(0,Z.jsxs)(`span`,{children:[`You're trending`,` `,(0,Z.jsxs)(`span`,{className:`font-semibold`,children:[e,` `,a]}),` `,`from `,(0,Z.jsx)(`span`,{className:`font-semibold`,children:s}),` compared to the`,` `,t]})},[i,a,s,o,u]);return(0,Z.jsxs)(I,{className:`group`,"data-testid":e,children:[(0,Z.jsxs)(M,{className:`hidden`,children:[(0,Z.jsx)(P,{children:e}),(0,Z.jsx)(F,{children:n})]}),(0,Z.jsxs)(se,{className:`relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,Z.jsxs)(ae,{className:l&&`transition-all group-hover:text-foreground`,children:[r&&(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r}}),f&&(0,Z.jsx)(f,{size:16,strokeWidth:1.5}),e]}),(0,Z.jsx)(oe,{diffDirection:u===pe.allTime.value?`hidden`:i,diffTooltip:p,diffValue:a,value:o})]}),l&&(0,Z.jsx)(k,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`subtle`,onClick:l,children:d?`View more →`:`View more`})]}),(0,Z.jsx)(N,{children:c})]})},Me=({kpiValues:e,visitorsChartData:t,visitorsChartRange:n,visitorsYRange:r,growthTotals:i,membersChartData:a,mrrChartData:s,growthChartRange:c,currencySymbol:l,isLoading:u})=>{let f=d(),m=W(),h=H(),g=V(),{config:_}=Y(),v=g?.limitAnalytics?.disabled===!0,y=`-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:cursor-pointer!`;if(u)return(0,Z.jsx)(re,{className:`flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:cursor-pointer!`,children:(0,Z.jsx)(ie,{})});let b=m,x=v&&!b,S=h,C=[b,x,!0,S].filter(Boolean).length,w=`lg:grid-cols-3`;return C===2?w=`lg:grid-cols-2`:C===1&&(w=`lg:grid-cols-1`),(0,Z.jsxs)(`div`,{className:`flex flex-col lg:grid ${w} gap-6`,children:[b&&!x&&(0,Z.jsx)(Q,{description:`Number of individual people who visited your website`,diffDirection:`empty`,formattedValue:e.visits,iconName:`Globe`,linkto:`/analytics/web/`,title:`Unique visitors`,onClick:()=>{f(`/analytics/web/`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-blue)`,data:t,id:`visitors`,range:n,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`,yAxisRange:r})}),x&&(0,Z.jsxs)(I,{children:[(0,Z.jsxs)(M,{className:`hidden`,children:[(0,Z.jsx)(P,{children:`Unlock web analytics`}),(0,Z.jsx)(F,{children:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`})]}),(0,Z.jsx)(N,{className:`flex h-full items-center justify-center p-6`,children:(0,Z.jsx)(R,{actions:(0,Z.jsx)(k,{variant:`outline`,onClick:()=>f(o(_),{crossApp:!0}),children:`Upgrade now`}),className:`py-10`,description:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`,title:`Unlock web analytics`,children:(0,Z.jsx)(O,{})})})]}),(0,Z.jsx)(Q,{description:`How number of members of your publication changed over time`,diffDirection:i.directions.total,diffValue:i.percentChanges.total,formattedValue:p(i.totalMembers),iconName:`User`,linkto:`/analytics/growth/`,title:`Members`,trendingFromValue:`${p(a[0]?.value??0)}`,onClick:()=>{f(`/analytics/growth/?tab=total-members`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-darkblue)`,data:a,id:`members`,range:c,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})}),S&&(0,Z.jsx)(Q,{description:`Monthly recurring revenue changes over time`,diffDirection:i.directions.mrr,diffValue:i.percentChanges.mrr,formattedValue:`${l}${p(J(i.mrr))}`,iconName:`Coins`,linkto:`/analytics/growth/`,title:`MRR`,trendingFromValue:`${l}${p(s[0]?.value??0)}`,onClick:()=>{f(`/analytics/growth/?tab=mrr`)},children:(0,Z.jsx)(L,{className:y,color:`var(--chart-teal)`,data:s,id:`mrr`,range:c,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})})]})},$=({metrics:e,title:t})=>(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute right-0 bottom-[calc(100%+2px)] z-50 min-w-[160px] rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100`,children:[(0,Z.jsx)(`div`,{className:`mb-1.5 border-b pr-10 pb-1.5 font-medium whitespace-nowrap text-muted-foreground`,children:t}),(0,Z.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e?.map(e=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[e.icon,e.label]}),(0,Z.jsx)(`span`,{className:`font-mono`,children:e.metric})]},e.label))})]})}),Ne=({topPostsData:e,isLoading:t})=>{let n=d(),r=u(),i=me(`/editor`),{range:a}=U(),{settings:o}=Y(),s=H(),l=Ee(o),m=W(),g=fe()??!1,_=de()??!1,v=ue()??!1,C=`flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground`;return(0,Z.jsxs)(I,{className:`group/card w-full lg:col-span-2`,"data-testid":`top-posts-card`,children:[(0,Z.jsxs)(M,{children:[(0,Z.jsxs)(P,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:[`Top posts `,K(a)]}),(0,Z.jsx)(F,{className:`hidden`,children:`Most viewed posts in this period`})]}),(0,Z.jsx)(N,{children:t?(0,Z.jsx)(z,{className:`mt-6`}):(0,Z.jsxs)(Z.Fragment,{children:[e?.stats?.map(e=>(0,Z.jsxs)(`div`,{className:`group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-table-row-hover before:content-[""] first:border-border! hover:cursor-pointer hover:border-transparent hover:before:block md:items-center [&+div]:hover:border-transparent`,children:[(0,Z.jsxs)(`div`,{className:`z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]`,onClick:()=>{let t=Te({postId:e.post_id,hasEmailData:e.sent_count!==null,analytics:{webAnalytics:m,membersTrackSources:g}}),a=t.startsWith(`/editor/`);n(t,a&&i?{crossApp:!0}:{state:a?ce(r):void 0})},children:[e.feature_image?(0,Z.jsx)(`div`,{className:`hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:visible! sm:block! lg:w-[100px]`,style:{backgroundImage:`url(${e.feature_image})`}}):(0,Z.jsx)(Oe,{className:`hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:visible! sm:flex! lg:w-[100px]`}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 text-md font-semibold wrap-anywhere`,children:e.title}),(0,Z.jsxs)(`span`,{className:`text text-muted-foreground`,children:[`By `,e.authors,` –`,` `,h(e.published_at,l)]}),(0,Z.jsx)(`span`,{className:`text text-muted-foreground`,children:c(e)})]})]}),(0,Z.jsxs)(`div`,{className:`z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3`,children:[m&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-visitors`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/web`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(j,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Unique visitors`,metric:p(e.views)}],title:`Web traffic`}),(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(j,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),f(e.views)]})]}),e.sent_count!==null&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/newsletter`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(T,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Sent`,metric:p(e.sent_count||0)},...v?[{icon:(0,Z.jsx)(y,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Opens`,metric:p(e.opened_count||0)}]:[],..._?[{icon:(0,Z.jsx)(x,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Clicks`,metric:p(e.clicked_count||0)}]:[]],title:`Newsletter performance`}),(0,Z.jsx)(`div`,{className:C,children:v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.open_rate?`${Math.round(e.open_rate)}%`:`0%`]}):_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(x,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.click_rate?`${Math.round(e.click_rate)}%`:`0%`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(T,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),f(e.sent_count||0)]})})]}),g&&(0,Z.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-members`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/growth`)},children:[(0,Z.jsx)($,{metrics:[{icon:(0,Z.jsx)(A,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Free`,metric:e.free_members>0?`+${p(e.free_members)}`:`0`},...s?[{icon:(0,Z.jsx)(S,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Paid`,metric:e.paid_members>0?`+${p(e.paid_members)}`:`0`}]:[]],title:`New members`}),(0,Z.jsxs)(`div`,{className:C,children:[(0,Z.jsx)(E,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.members>0?`+${p(e.members)}`:`0`]})]})]})]},e.post_id)),(!e?.stats||e.stats.length===0)&&(0,Z.jsx)(R,{className:`w-full pb-10`,title:`No posts ${K(a)}`,children:(0,Z.jsx)(b,{strokeWidth:1.5})})]})})]})},Pe=({className:e,title:t,description:n,url:r,children:i})=>(0,Z.jsx)(`a`,{className:m(`group/card block rounded-xl border bg-card p-6 transition-all hover:bg-table-row-hover hover:shadow-xs`,e),href:r,rel:`noreferrer`,target:`_blank`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-6`,children:[i,(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-tight`,children:[(0,Z.jsx)(`span`,{className:`text-base font-semibold`,children:t}),(0,Z.jsx)(`span`,{className:`text-sm font-normal text-gray-700`,children:n})]})]})}),Fe=()=>{let e=H(),{range:t}=U(),{statsConfig:n,isLoading:a}=Y(),{startDate:o,endDate:s,timezone:c}=xe(t),{isLoading:l,chartData:u,totals:d,currencySymbol:f}=Ce(t),{data:m,isLoading:h}=ke(),{data:g,isLoading:_}=ye({searchParams:{date_from:q(o),date_to:q(s),limit:`5`,timezone:c}}),{data:y,loading:b}=r({endpoint:`api_kpis`,statsConfig:n,params:{site_uuid:n?.id||``,date_from:q(o),date_to:q(s),timezone:c,member_status:we(le)}}),x=(0,X.useMemo)(()=>G(y||[],t,`visits`,`sum`)?.map(e=>{let t=Number(e.visits),n=isNaN(t)?0:t;return{date:String(e.date),value:n,formattedValue:p(n),label:`Visitors`}}),[y,t]),S=(0,X.useMemo)(()=>Se(t,y||[],{fieldName:`visits`}),[y,t]),C=(0,X.useMemo)(()=>{let e=[0,1];if(!x||x.length===0)return e;let t=x.map(e=>e.value).filter(e=>e>=0);return t.length===0?e:[0,Math.max(...t)||e[1]]},[x]),w=(0,X.useMemo)(()=>Se(t,u||[]),[u,t]),T=(0,X.useMemo)(()=>{if(!u||u.length===0)return[];let e=[];return e=G(u,t,`value`,`exact`),e.map(e=>({date:e.date,value:e.free+e.paid,formattedValue:p(e.free+e.paid),label:`Members`}))},[u,t]),E=(0,X.useMemo)(()=>{if(!e||!u||u.length===0)return[];let n=[];return n=G(u,t,`mrr`,`exact`),n.map(e=>({date:e.date,value:J(e.mrr),formattedValue:`${f}${p(J(e.mrr))}`,label:`MRR`}))},[u,t,f,e]),D=(0,X.useMemo)(()=>y?.length?{visits:p(y.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0))}:{visits:`0`},[y]);return(0,Z.jsxs)(ge,{children:[(0,Z.jsx)(_e,{children:(0,Z.jsx)(i,{children:(0,Z.jsx)(he,{excludeRanges:[`today`]})})}),(0,Z.jsxs)(ve,{isLoading:a,loadingComponent:(0,Z.jsx)(Z.Fragment,{}),children:[(0,Z.jsx)(Me,{currencySymbol:f,growthChartRange:w,growthTotals:d,isLoading:b||l,kpiValues:D,membersChartData:T,mrrChartData:E,visitorsChartData:x,visitorsChartRange:S,visitorsYRange:C}),(0,Z.jsx)(je,{isLoading:h,latestPostStats:m}),(0,Z.jsx)(Ne,{isLoading:_,topPostsData:g}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,Z.jsx)(v,{className:`mt-4 -mb-4 lg:col-span-2`,children:`Grow your audience`}),(0,Z.jsx)(Pe,{description:`Find out how to review the performance of your content and get the most out of post analytics in Ghost.`,title:`Understanding analytics in Ghost`,url:`https://ghost.org/help/native-analytics`,children:(0,Z.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,Z.jsx)(ee,{className:`text-[#00BBA7]`,size:20,strokeWidth:1.5})})}),(0,Z.jsx)(Pe,{description:`Use these content distribution tactics to get more people to discover your work and increase engagement.`,title:`How to get your content seen online`,url:`https://ghost.org/resources/content-distribution/`,children:(0,Z.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,Z.jsx)(j,{className:`text-[#FE9A00]`,size:20,strokeWidth:1.5})})})]})]})]})};export{Fe as default};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6e9a6533-bc4d-45fb-a6d5-203da01f55f5`,e._sentryDebugIdIdentifier=`sentry-dbid-6e9a6533-bc4d-45fb-a6d5-203da01f55f5`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{E as r,L as i,a,i as o,o as s,r as c,s as l}from"./shade-provider-DvrXKKQZ.js";import{t as u}from"./inline-Qoyy4r2g.js";import{t as d}from"./stack-C3OmgpUv.js";import{t as f}from"./text-BnCSdzao.js";import{t as p}from"./heading-Ch2Mb19A.js";import{en as m,t as h}from"./button-CTHYSI-d.js";import{o as g}from"./select-DeloOYCg.js";import{ct as _,it as v,ut as y,vt as b}from"./index-CuDhPtkB.js";var x=e(t(),1),S=n(),C=x.createContext(!1);function w({children:e}){let{isAdmin7:t}=c(),n=x.useContext(C);return!t||n?(0,S.jsx)(S.Fragment,{children:e}):(0,S.jsx)(C.Provider,{value:!0,children:(0,S.jsx)(s,{delayDuration:1e3,skipDelayDuration:300,children:e})})}function T({children:e,label:t,shortcut:n}){let{isAdmin7:r}=c();return r?(0,S.jsxs)(o,{children:[e,(0,S.jsx)(a,{side:`bottom`,variant:`white`,children:(0,S.jsxs)(u,{align:`center`,gap:`sm`,children:[t,n&&(0,S.jsx)(v,{children:n})]})})]}):(0,S.jsx)(S.Fragment,{children:e})}var E=x.forwardRef(({children:e,asChild:t,...n},i)=>{let{isAdmin7:a}=c();return a?(0,S.jsx)(l,{ref:i,asChild:t,...n,children:e}):(0,S.jsx)(t?r:`button`,{ref:i,...n,children:e})});E.displayName=`PageHeaderTooltipTrigger`;var D=x.createContext(!1),O=x.forwardRef(({label:e,iconOnly:t=!1,primary:n,shortcut:r,tooltip:a=t||!!r,fallbackVariant:o=`outline`,fallbackSize:s,className:u,...d},f)=>{let{isAdmin7:p}=c(),m=x.useContext(D),g=n??m,_=(0,S.jsx)(h,{ref:f,"aria-keyshortcuts":r,"aria-label":e,className:i(p&&`[&_svg]:stroke-2!`,u),size:p?t?`icon`:void 0:s,variant:p?g?`default`:`ghost`:o,...d});return g||!p||!a?_:(0,S.jsx)(T,{label:e,shortcut:r,children:(0,S.jsx)(l,{asChild:!0,children:_})})});O.displayName=`PageHeaderAction`;var k=x.forwardRef((e,t)=>(0,S.jsxs)(O,{ref:t,"data-slot":`filters-add`,label:`Filter`,shortcut:`F`,type:`button`,...e,children:[(0,S.jsx)(m,{className:`size-4`}),`Filter`]}));k.displayName=`PageHeaderFilterTrigger`;var A=x.forwardRef(({label:e,tooltip:t=!0,className:n,...r},a)=>{let{controlShape:o,isAdmin7:s}=c(),l=(0,S.jsx)(g,{ref:a,"aria-label":e,className:i(`w-auto`,s&&`gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0`,n),shape:o,showChevron:!s,variant:s?`ghost`:`default`,...r});return t?(0,S.jsx)(T,{label:e,children:(0,S.jsx)(E,{asChild:!0,children:l})}):l});A.displayName=`PageHeaderSelectTrigger`;function j({className:e,children:t}){return(0,S.jsx)(u,{align:`center`,className:i(`pt-1 text-sm text-muted-foreground`,e),"data-page-header":`breadcrumb`,gap:`sm`,children:t})}function M({className:e,children:t}){return(0,S.jsx)(f,{as:`span`,className:i(`ml-1 text-base tabular-nums`,e),"data-page-header":`count`,tone:`secondary`,weight:`regular`,children:t})}function N({className:e,children:t}){return(0,S.jsx)(f,{as:`p`,className:e,"data-page-header":`description`,size:`sm`,tone:`secondary`,children:t})}function P({className:e,children:t}){return(0,S.jsx)(f,{as:`p`,className:i(`mt-0.5`,e),"data-page-header":`meta`,size:`sm`,tone:`secondary`,children:t})}function F({className:e,children:t}){let n=[],r=[];x.Children.forEach(t,e=>{if(!x.isValidElement(e)){n.push(e);return}switch(e.type){case N:case P:r.push(e);break;default:n.push(e)}});let a=(0,S.jsx)(p,{className:i(`text-lg font-semibold tracking-[0.1px] whitespace-nowrap`,e),"data-page-header":`title`,children:n});return r.length>0?(0,S.jsxs)(d,{"data-page-header":`title-body`,gap:`none`,children:[a,r]}):a}function I({className:e,children:t}){return(0,S.jsx)(d,{className:i(`h-full min-h-(--control-height) min-w-0`,e),"data-page-header":`left`,gap:`xs`,justify:`center`,children:t})}function L({children:e,className:t}){let{isAdmin7:n}=c();return x.Children.toArray(e).length===0?null:(0,S.jsx)(D.Provider,{value:!0,children:n?(0,S.jsx)(u,{className:i(`ms-3 shrink-0 first:ms-0`,t),"data-page-header":`primary`,gap:`none`,children:e}):t?(0,S.jsx)(r,{className:t,children:e}):e})}function R({children:e}){return(0,S.jsx)(_,{children:e})}function z({children:e,...t}){return(0,S.jsx)(b,{asChild:!0,...t,children:e})}function B({children:e,...t}){return(0,S.jsx)(y,{align:`end`,sideOffset:8,...t,children:e})}var V=640,H=e=>typeof window>`u`?!1:window.innerWidth<e,U=e=>{let[t,n]=x.useState(()=>H(e));return x.useEffect(()=>{let t=()=>{n(H(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t},W=Object.assign(function({className:e,children:t,mobileMenuBreakpoint:n=V}){let{isAdmin7:r}=c(),i=x.Children.toArray(t),a=[],o=null,s=null,l=U(n);return i.forEach(e=>{if(!x.isValidElement(e)){a.push(e);return}let t=e;if(t.type===R){o=t;return}if(t.type===L){s=t,a.push(t);return}a.push(t)}),o?l?(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,S.jsxs)(u,{align:`center`,className:`ml-auto`,"data-page-header":`action-group-mobile`,gap:`sm`,children:[o,s&&(r?s:(0,S.jsx)(`div`,{"data-page-header":`action-group-mobile-primary`,children:s}))]})})}):(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,S.jsx)(u,{align:`center`,"data-page-header":`action-group-desktop`,gap:`sm`,justify:`end`,children:a})})}):(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:t})})},{Primary:L,MobileMenu:R,MobileMenuTrigger:z,MobileMenuContent:B});function G({className:e,children:t}){return(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:i(`min-h-(--control-height) shrink-0`,e),"data-page-header":`actions`,gap:`lg`,children:t})})}var K=Object.assign(function({className:e,children:t,sticky:n=!0,blurredBackground:r=!0}){return(0,S.jsx)(`header`,{className:i(`flex flex-col`,n&&`sticky top-0 z-50`,r&&`bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md dark:bg-black`,e),"data-page-header":`page-header`,children:(0,S.jsx)(u,{align:`start`,className:`w-full`,"data-page-header":`main`,gap:`lg`,justify:`between`,children:t})})},{Left:I,Breadcrumb:j,Title:F,Count:M,Description:N,Meta:P,Actions:G,ActionGroup:W,Action:O,FilterTrigger:k,SelectTrigger:A,Tooltip:T,TooltipTrigger:E});export{w as n,K as t};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`6e9a6533-bc4d-45fb-a6d5-203da01f55f5`,e._sentryDebugIdIdentifier=`sentry-dbid-6e9a6533-bc4d-45fb-a6d5-203da01f55f5`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{E as r,L as i,a,i as o,o as s,r as c,s as l}from"./shade-provider-DvrXKKQZ.js";import{t as u}from"./inline-Qoyy4r2g.js";import{t as d}from"./stack-C3OmgpUv.js";import{t as f}from"./text-BnCSdzao.js";import{t as p}from"./heading-Ch2Mb19A.js";import{en as m,t as h}from"./button-CTHYSI-d.js";import{o as g}from"./select-DeloOYCg.js";import{ct as _,it as v,ut as y,vt as b}from"./index-RuRs_qGS.js";var x=e(t(),1),S=n(),C=x.createContext(!1);function w({children:e}){let{isAdmin7:t}=c(),n=x.useContext(C);return!t||n?(0,S.jsx)(S.Fragment,{children:e}):(0,S.jsx)(C.Provider,{value:!0,children:(0,S.jsx)(s,{delayDuration:1e3,skipDelayDuration:300,children:e})})}function T({children:e,label:t,shortcut:n}){let{isAdmin7:r}=c();return r?(0,S.jsxs)(o,{children:[e,(0,S.jsx)(a,{side:`bottom`,variant:`white`,children:(0,S.jsxs)(u,{align:`center`,gap:`sm`,children:[t,n&&(0,S.jsx)(v,{children:n})]})})]}):(0,S.jsx)(S.Fragment,{children:e})}var E=x.forwardRef(({children:e,asChild:t,...n},i)=>{let{isAdmin7:a}=c();return a?(0,S.jsx)(l,{ref:i,asChild:t,...n,children:e}):(0,S.jsx)(t?r:`button`,{ref:i,...n,children:e})});E.displayName=`PageHeaderTooltipTrigger`;var D=x.createContext(!1),O=x.forwardRef(({label:e,iconOnly:t=!1,primary:n,shortcut:r,tooltip:a=t||!!r,fallbackVariant:o=`outline`,fallbackSize:s,className:u,...d},f)=>{let{isAdmin7:p}=c(),m=x.useContext(D),g=n??m,_=(0,S.jsx)(h,{ref:f,"aria-keyshortcuts":r,"aria-label":e,className:i(p&&`[&_svg]:stroke-2!`,u),size:p?t?`icon`:void 0:s,variant:p?g?`default`:`ghost`:o,...d});return g||!p||!a?_:(0,S.jsx)(T,{label:e,shortcut:r,children:(0,S.jsx)(l,{asChild:!0,children:_})})});O.displayName=`PageHeaderAction`;var k=x.forwardRef((e,t)=>(0,S.jsxs)(O,{ref:t,"data-slot":`filters-add`,label:`Filter`,shortcut:`F`,type:`button`,...e,children:[(0,S.jsx)(m,{className:`size-4`}),`Filter`]}));k.displayName=`PageHeaderFilterTrigger`;var A=x.forwardRef(({label:e,tooltip:t=!0,className:n,...r},a)=>{let{controlShape:o,isAdmin7:s}=c(),l=(0,S.jsx)(g,{ref:a,"aria-label":e,className:i(`w-auto`,s&&`gap-1.5 font-medium [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2! [&>svg]:mr-0`,n),shape:o,showChevron:!s,variant:s?`ghost`:`default`,...r});return t?(0,S.jsx)(T,{label:e,children:(0,S.jsx)(E,{asChild:!0,children:l})}):l});A.displayName=`PageHeaderSelectTrigger`;function j({className:e,children:t}){return(0,S.jsx)(u,{align:`center`,className:i(`pt-1 text-sm text-muted-foreground`,e),"data-page-header":`breadcrumb`,gap:`sm`,children:t})}function M({className:e,children:t}){return(0,S.jsx)(f,{as:`span`,className:i(`ml-1 text-base tabular-nums`,e),"data-page-header":`count`,tone:`secondary`,weight:`regular`,children:t})}function N({className:e,children:t}){return(0,S.jsx)(f,{as:`p`,className:e,"data-page-header":`description`,size:`sm`,tone:`secondary`,children:t})}function P({className:e,children:t}){return(0,S.jsx)(f,{as:`p`,className:i(`mt-0.5`,e),"data-page-header":`meta`,size:`sm`,tone:`secondary`,children:t})}function F({className:e,children:t}){let n=[],r=[];x.Children.forEach(t,e=>{if(!x.isValidElement(e)){n.push(e);return}switch(e.type){case N:case P:r.push(e);break;default:n.push(e)}});let a=(0,S.jsx)(p,{className:i(`text-lg font-semibold tracking-[0.1px] whitespace-nowrap`,e),"data-page-header":`title`,children:n});return r.length>0?(0,S.jsxs)(d,{"data-page-header":`title-body`,gap:`none`,children:[a,r]}):a}function I({className:e,children:t}){return(0,S.jsx)(d,{className:i(`h-full min-h-(--control-height) min-w-0`,e),"data-page-header":`left`,gap:`xs`,justify:`center`,children:t})}function L({children:e,className:t}){let{isAdmin7:n}=c();return x.Children.toArray(e).length===0?null:(0,S.jsx)(D.Provider,{value:!0,children:n?(0,S.jsx)(u,{className:i(`ms-3 shrink-0 first:ms-0`,t),"data-page-header":`primary`,gap:`none`,children:e}):t?(0,S.jsx)(r,{className:t,children:e}):e})}function R({children:e}){return(0,S.jsx)(_,{children:e})}function z({children:e,...t}){return(0,S.jsx)(b,{asChild:!0,...t,children:e})}function B({children:e,...t}){return(0,S.jsx)(y,{align:`end`,sideOffset:8,...t,children:e})}var V=640,H=e=>typeof window>`u`?!1:window.innerWidth<e,U=e=>{let[t,n]=x.useState(()=>H(e));return x.useEffect(()=>{let t=()=>{n(H(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t},W=Object.assign(function({className:e,children:t,mobileMenuBreakpoint:n=V}){let{isAdmin7:r}=c(),i=x.Children.toArray(t),a=[],o=null,s=null,l=U(n);return i.forEach(e=>{if(!x.isValidElement(e)){a.push(e);return}let t=e;if(t.type===R){o=t;return}if(t.type===L){s=t,a.push(t);return}a.push(t)}),o?l?(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,S.jsxs)(u,{align:`center`,className:`ml-auto`,"data-page-header":`action-group-mobile`,gap:`sm`,children:[o,s&&(r?s:(0,S.jsx)(`div`,{"data-page-header":`action-group-mobile-primary`,children:s}))]})})}):(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,S.jsx)(u,{align:`center`,"data-page-header":`action-group-desktop`,gap:`sm`,justify:`end`,children:a})})}):(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:t})})},{Primary:L,MobileMenu:R,MobileMenuTrigger:z,MobileMenuContent:B});function G({className:e,children:t}){return(0,S.jsx)(w,{children:(0,S.jsx)(u,{align:`center`,className:i(`min-h-(--control-height) shrink-0`,e),"data-page-header":`actions`,gap:`lg`,children:t})})}var K=Object.assign(function({className:e,children:t,sticky:n=!0,blurredBackground:r=!0}){return(0,S.jsx)(`header`,{className:i(`flex flex-col`,n&&`sticky top-0 z-50`,r&&`bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md dark:bg-black`,e),"data-page-header":`page-header`,children:(0,S.jsx)(u,{align:`start`,className:`w-full`,"data-page-header":`main`,gap:`lg`,justify:`between`,children:t})})},{Left:I,Breadcrumb:j,Title:F,Count:M,Description:N,Meta:P,Actions:G,ActionGroup:W,Action:O,FilterTrigger:k,SelectTrigger:A,Tooltip:T,TooltipTrigger:E});export{w as n,K as t};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`80efff60-7b04-4585-b0a4-043bc154428f`,e._sentryDebugIdIdentifier=`sentry-dbid-80efff60-7b04-4585-b0a4-043bc154428f`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-CPy5ipAP.js";import{L as i,r as a}from"./shade-provider-DvrXKKQZ.js";import{Pn as o,t as s}from"./button-CTHYSI-d.js";import{n as c}from"./page-header-Baymg6VR.js";import{ct as l,ft as u,ut as d,vt as f}from"./index-CuDhPtkB.js";var p=e(t(),1),m=60*1e3,h=(e={})=>{let{postUuid:t,statsConfig:n,enabled:i=!0}=e,[a,o]=(0,p.useState)(null),{data:s,loading:c,error:l}=r({statsConfig:n,endpoint:`api_active_visitors`,params:{site_uuid:n?.id||``,...t&&{post_uuid:t}},enabled:i,refetchInterval:m,refetchIntervalInBackground:!0}),u=s?.[0]?.active_visitors;return(0,p.useEffect)(()=>{i&&u!==void 0&&typeof u==`number`&&o(u)},[i,u]),{activeVisitors:i&&a||0,isLoading:i&&c&&a===null,error:i?l:null}},g=n(),_=p.forwardRef(({children:e,className:t,...n},r)=>{let{isAdmin7:o}=a();return(0,g.jsx)(c,{children:(0,g.jsx)(`div`,{ref:r,className:i(`mt-3 flex items-center [grid-area:actions] lg:mt-0`,o?`gap-1`:`gap-2`,t),"data-navbar":`navbar-actions`,...n,children:e})})});_.displayName=`NavbarActions`;var v=p.forwardRef(({children:e,className:t,...n},r)=>(0,g.jsx)(`div`,{ref:r,className:i(`[grid-area:navigation]`,t),"data-navbar":`navbar-navigation`,...n,children:e}));v.displayName=`NavbarNavigation`;var y=p.forwardRef(({children:e,className:t,...n},r)=>(0,g.jsx)(`div`,{ref:r,className:i(`grid grid-cols-[1fr] justify-between gap-x-5 gap-y-2 border-b [grid-template-areas:'navigation''actions''subactions'] lg:grid-cols-[1fr_auto] lg:[grid-template-areas:'navigation_actions''subactions_subactions']`,t),"data-navbar":`navbar`,...n,children:e}));y.displayName=`Navbar`;var b=p.createContext(null),x=p.forwardRef(({children:e,responsive:t=!1,value:n,defaultValue:r,onValueChange:a,className:c,...m},h)=>{let[_,v]=p.useState(p.Children.count(e)),[y,x]=p.useState(0),S=p.useRef(null),C=p.useRef(null);p.useLayoutEffect(()=>{if(!t||!S.current||!C.current){v(p.Children.count(e));return}requestAnimationFrame(()=>{if(!S.current||!C.current)return;let e=S.current,t=C.current,n=e.clientWidth,r=Array.from(t.children),i=0;for(let e=0;e<r.length;e++){let t=r[e].getBoundingClientRect().width;i+=(e>0?6:0)+t}if(i<=n-8){v(r.length);return}let a=0,o=0;for(let e=0;e<r.length;e++){let t=r[e].getBoundingClientRect().width,i=a+(e>0?6:0)+t;if(i+60<=n)a=i,o+=1;else break}v(o)})},[t,e,y]),p.useLayoutEffect(()=>{if(!t||!S.current)return;let e=new ResizeObserver(()=>{x(e=>e+1)});return e.observe(S.current),()=>e.disconnect()},[t]);let w=p.Children.toArray(e),T=w.slice(0,_),E=w.slice(_),D=E.length>0,O=E.find(e=>p.isValidElement(e)&&e.props?.value===n);return t?(0,g.jsxs)(b.Provider,{value:{defaultValue:r},children:[(0,g.jsx)(`div`,{ref:C,"aria-hidden":`true`,className:`pointer-events-none absolute flex items-center gap-2 opacity-0`,style:{top:-9999,left:-9999},children:e}),(0,g.jsxs)(`div`,{ref:S,className:`flex w-full min-w-0 flex-1 items-center gap-2`,children:[(0,g.jsx)(`div`,{ref:h,className:i(`flex min-w-0 items-center gap-2`,c),...m,children:T}),D&&(0,g.jsxs)(l,{children:[(0,g.jsx)(f,{asChild:!0,children:(0,g.jsx)(s,{className:i(`h-[30px] flex-shrink-0 px-3 py-2`,O&&`bg-accent text-accent-foreground`),variant:`ghost`,children:O?(0,g.jsx)(`span`,{className:`max-w-[100px] truncate`,children:O.props.children}):(0,g.jsx)(o,{className:`size-6`})})}),(0,g.jsx)(d,{align:`end`,children:E.map((e,t)=>!p.isValidElement(e)||!e.props?.value?null:(0,g.jsx)(u,{className:i(e.props.value===n&&`bg-accent text-accent-foreground`),onClick:()=>{a?.(e.props.value),e.props.onClick?.()},children:e.props.children},e.props.value||t))})]})]})]}):(0,g.jsx)(b.Provider,{value:{defaultValue:r},children:(0,g.jsx)(`div`,{ref:h,className:i(`flex items-center gap-2`,c),...m,children:e})})});x.displayName=`PageMenu`;var S=p.forwardRef(({children:e,value:t,className:n,...r},a)=>{let o=p.useContext(b)?.defaultValue===t;return(0,g.jsx)(s,{ref:a,className:i(`relative gap-1.5 px-3 text-control font-medium text-text-secondary hover:text-foreground focus-visible:ring-0`,`data-[state=active]:bg-muted-foreground/10 data-[state=active]:text-foreground`,`dark:hover:bg-tab-hover dark:data-[state=active]:bg-tab-active dark:data-[state=active]:hover:bg-tab-active`,n),"data-state":o?`active`:void 0,variant:`ghost`,...r,children:e})});S.displayName=`PageMenuItem`;export{v as a,_ as i,S as n,h as o,y as r,x as t};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`80efff60-7b04-4585-b0a4-043bc154428f`,e._sentryDebugIdIdentifier=`sentry-dbid-80efff60-7b04-4585-b0a4-043bc154428f`)}catch{}})();import{s as e,t}from"./react-C9lG_SsT.js";import{t as n}from"./jsx-runtime-Bm2_KH-0.js";import{t as r}from"./use-tinybird-query-BYbl5gKY.js";import{L as i,r as a}from"./shade-provider-DvrXKKQZ.js";import{Pn as o,t as s}from"./button-CTHYSI-d.js";import{n as c}from"./page-header-CxTb0je5.js";import{ct as l,ft as u,ut as d,vt as f}from"./index-RuRs_qGS.js";var p=e(t(),1),m=60*1e3,h=(e={})=>{let{postUuid:t,statsConfig:n,enabled:i=!0}=e,[a,o]=(0,p.useState)(null),{data:s,loading:c,error:l}=r({statsConfig:n,endpoint:`api_active_visitors`,params:{site_uuid:n?.id||``,...t&&{post_uuid:t}},enabled:i,refetchInterval:m,refetchIntervalInBackground:!0}),u=s?.[0]?.active_visitors;return(0,p.useEffect)(()=>{i&&u!==void 0&&typeof u==`number`&&o(u)},[i,u]),{activeVisitors:i&&a||0,isLoading:i&&c&&a===null,error:i?l:null}},g=n(),_=p.forwardRef(({children:e,className:t,...n},r)=>{let{isAdmin7:o}=a();return(0,g.jsx)(c,{children:(0,g.jsx)(`div`,{ref:r,className:i(`mt-3 flex items-center [grid-area:actions] lg:mt-0`,o?`gap-1`:`gap-2`,t),"data-navbar":`navbar-actions`,...n,children:e})})});_.displayName=`NavbarActions`;var v=p.forwardRef(({children:e,className:t,...n},r)=>(0,g.jsx)(`div`,{ref:r,className:i(`[grid-area:navigation]`,t),"data-navbar":`navbar-navigation`,...n,children:e}));v.displayName=`NavbarNavigation`;var y=p.forwardRef(({children:e,className:t,...n},r)=>(0,g.jsx)(`div`,{ref:r,className:i(`grid grid-cols-[1fr] justify-between gap-x-5 gap-y-2 border-b [grid-template-areas:'navigation''actions''subactions'] lg:grid-cols-[1fr_auto] lg:[grid-template-areas:'navigation_actions''subactions_subactions']`,t),"data-navbar":`navbar`,...n,children:e}));y.displayName=`Navbar`;var b=p.createContext(null),x=p.forwardRef(({children:e,responsive:t=!1,value:n,defaultValue:r,onValueChange:a,className:c,...m},h)=>{let[_,v]=p.useState(p.Children.count(e)),[y,x]=p.useState(0),S=p.useRef(null),C=p.useRef(null);p.useLayoutEffect(()=>{if(!t||!S.current||!C.current){v(p.Children.count(e));return}requestAnimationFrame(()=>{if(!S.current||!C.current)return;let e=S.current,t=C.current,n=e.clientWidth,r=Array.from(t.children),i=0;for(let e=0;e<r.length;e++){let t=r[e].getBoundingClientRect().width;i+=(e>0?6:0)+t}if(i<=n-8){v(r.length);return}let a=0,o=0;for(let e=0;e<r.length;e++){let t=r[e].getBoundingClientRect().width,i=a+(e>0?6:0)+t;if(i+60<=n)a=i,o+=1;else break}v(o)})},[t,e,y]),p.useLayoutEffect(()=>{if(!t||!S.current)return;let e=new ResizeObserver(()=>{x(e=>e+1)});return e.observe(S.current),()=>e.disconnect()},[t]);let w=p.Children.toArray(e),T=w.slice(0,_),E=w.slice(_),D=E.length>0,O=E.find(e=>p.isValidElement(e)&&e.props?.value===n);return t?(0,g.jsxs)(b.Provider,{value:{defaultValue:r},children:[(0,g.jsx)(`div`,{ref:C,"aria-hidden":`true`,className:`pointer-events-none absolute flex items-center gap-2 opacity-0`,style:{top:-9999,left:-9999},children:e}),(0,g.jsxs)(`div`,{ref:S,className:`flex w-full min-w-0 flex-1 items-center gap-2`,children:[(0,g.jsx)(`div`,{ref:h,className:i(`flex min-w-0 items-center gap-2`,c),...m,children:T}),D&&(0,g.jsxs)(l,{children:[(0,g.jsx)(f,{asChild:!0,children:(0,g.jsx)(s,{className:i(`h-[30px] flex-shrink-0 px-3 py-2`,O&&`bg-accent text-accent-foreground`),variant:`ghost`,children:O?(0,g.jsx)(`span`,{className:`max-w-[100px] truncate`,children:O.props.children}):(0,g.jsx)(o,{className:`size-6`})})}),(0,g.jsx)(d,{align:`end`,children:E.map((e,t)=>!p.isValidElement(e)||!e.props?.value?null:(0,g.jsx)(u,{className:i(e.props.value===n&&`bg-accent text-accent-foreground`),onClick:()=>{a?.(e.props.value),e.props.onClick?.()},children:e.props.children},e.props.value||t))})]})]})]}):(0,g.jsx)(b.Provider,{value:{defaultValue:r},children:(0,g.jsx)(`div`,{ref:h,className:i(`flex items-center gap-2`,c),...m,children:e})})});x.displayName=`PageMenu`;var S=p.forwardRef(({children:e,value:t,className:n,...r},a)=>{let o=p.useContext(b)?.defaultValue===t;return(0,g.jsx)(s,{ref:a,className:i(`relative gap-1.5 px-3 text-control font-medium text-text-secondary hover:text-foreground focus-visible:ring-0`,`data-[state=active]:bg-muted-foreground/10 data-[state=active]:text-foreground`,`dark:hover:bg-tab-hover dark:data-[state=active]:bg-tab-active dark:data-[state=active]:hover:bg-tab-active`,n),"data-state":o?`active`:void 0,variant:`ghost`,...r,children:e})});S.displayName=`PageMenuItem`;export{v as a,_ as i,S as n,h as o,y as r,x as t};
@@ -1 +1 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`8b600a65-3245-4903-ab36-00d220493462`,e._sentryDebugIdIdentifier=`sentry-dbid-8b600a65-3245-4903-ab36-00d220493462`)}catch{}})();import{i as e,n as t,r as n,t as r}from"./hooks-C-BDQ6Hs.js";import{f as i,m as a,p as o}from"./posts-Lg-p_ZHg.js";import{t as s}from"./tags-ZhqbPPc6.js";var c=`PagesResponseType`,l=c,u=n({dataType:c,path:`/pages/`}),d=r({dataType:c,path:`/pages/`,defaultNextPageParams:(e,t)=>{if(e.meta?.pagination.next)return{...t,page:e.meta.pagination.next.toString()}},returnData:e=>{let{pages:t}=e,n=t.flatMap(e=>e.pages),r=t[t.length-1].meta;return{pages:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}});e({dataType:c,path:e=>`/pages/${e}/`});var f=e({dataType:c,path:e=>`/pages/${e}/`}),p=(e,t={})=>{let{searchParams:n,...r}=t;return f(e,{...r,searchParams:{...n,...o()}})},m=t({method:`POST`,path:()=>`/pages/`,searchParams:({options:e})=>i(e),body:({page:e})=>({pages:[a(e,`page`)]}),requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e}),invalidateQueries:{dataType:[c,s]}}),h=t({method:`PUT`,path:({page:e})=>`/pages/${e.id}/`,searchParams:({options:e})=>i(e),body:({page:e})=>({pages:[a(e,`page`)]}),requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e}),invalidateQueries:{dataType:[c,s]}}),g=t({method:`DELETE`,path:({id:e})=>`/pages/${e}/`,requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e})}),_=t({method:`POST`,path:e=>`/pages/${e}/copy/`}),v=t({method:`PUT`,path:()=>`/pages/bulk/`,searchParams:({filter:e})=>({filter:e}),body:({action:e})=>({bulk:{action:e.type,meta:`meta`in e?e.meta:{}}})}),y=t({method:`DELETE`,path:()=>`/pages/`,searchParams:({filter:e})=>({filter:e})});export{y as a,g as c,d as i,h as l,m as n,v as o,u as r,_ as s,l as t,p as u};
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`8b600a65-3245-4903-ab36-00d220493462`,e._sentryDebugIdIdentifier=`sentry-dbid-8b600a65-3245-4903-ab36-00d220493462`)}catch{}})();import{i as e,n as t,r as n,t as r}from"./hooks-0r7qxGEo.js";import{f as i,m as a,p as o}from"./posts-CftunZgV.js";import{t as s}from"./tags-OlmRJ6Ps.js";var c=`PagesResponseType`,l=c,u=n({dataType:c,path:`/pages/`}),d=r({dataType:c,path:`/pages/`,defaultNextPageParams:(e,t)=>{if(e.meta?.pagination.next)return{...t,page:e.meta.pagination.next.toString()}},returnData:e=>{let{pages:t}=e,n=t.flatMap(e=>e.pages),r=t[t.length-1].meta;return{pages:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}});e({dataType:c,path:e=>`/pages/${e}/`});var f=e({dataType:c,path:e=>`/pages/${e}/`}),p=(e,t={})=>{let{searchParams:n,...r}=t;return f(e,{...r,searchParams:{...n,...o()}})},m=t({method:`POST`,path:()=>`/pages/`,searchParams:({options:e})=>i(e),body:({page:e})=>({pages:[a(e,`page`)]}),requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e}),invalidateQueries:{dataType:[c,s]}}),h=t({method:`PUT`,path:({page:e})=>`/pages/${e.id}/`,searchParams:({options:e})=>i(e),body:({page:e})=>({pages:[a(e,`page`)]}),requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e}),invalidateQueries:{dataType:[c,s]}}),g=t({method:`DELETE`,path:({id:e})=>`/pages/${e}/`,requestOptions:({sessionExpiryRedirect:e})=>({sessionExpiryRedirect:e})}),_=t({method:`POST`,path:e=>`/pages/${e}/copy/`}),v=t({method:`PUT`,path:()=>`/pages/bulk/`,searchParams:({filter:e})=>({filter:e}),body:({action:e})=>({bulk:{action:e.type,meta:`meta`in e?e.meta:{}}})}),y=t({method:`DELETE`,path:()=>`/pages/`,searchParams:({filter:e})=>({filter:e})});export{y as a,g as c,d as i,h as l,m as n,v as o,u as r,_ as s,l as t,p as u};
@@ -0,0 +1 @@
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`2f56c7cc-a5cc-4664-abd5-5ead9b215b65`,e._sentryDebugIdIdentifier=`sentry-dbid-2f56c7cc-a5cc-4664-abd5-5ead9b215b65`)}catch{}})();import{t as e}from"./jsx-runtime-Bm2_KH-0.js";import{t}from"./posts-list-screen-CwXmvY68.js";var n=e();function r(){return(0,n.jsx)(t,{resource:`pages`})}export{r as default};