ghost 6.40.0 → 6.41.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 (184) hide show
  1. package/core/boot.js +8 -8
  2. package/core/built/admin/assets/{PolarAngleAxis-D7m1zwVk.js → PolarAngleAxis-Bh28wbPV.js} +1 -1
  3. package/core/built/admin/assets/{_baseAssignValue-BDsvYKNK.js → _baseAssignValue-hdDG700N.js} +1 -1
  4. package/core/built/admin/assets/{a-large-small-DxRNdz0F.js → a-large-small-BiK5_5LV.js} +1 -1
  5. package/core/built/admin/assets/{account-migration-SYnE1jBW.js → account-migration-DsSHanIB.js} +1 -1
  6. package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +1 -1
  7. package/core/built/admin/assets/admin-x-settings/{code-editor-view-Bj9rgbLw.mjs → code-editor-view-BEIdFhw3.mjs} +2 -2
  8. package/core/built/admin/assets/admin-x-settings/{index-BrZ9YAzd.mjs → index-BEh3nFEy.mjs} +3 -3
  9. package/core/built/admin/assets/admin-x-settings/{index-DRndIh9T.mjs → index-BLF2n6YB.mjs} +2 -2
  10. package/core/built/admin/assets/admin-x-settings/{index-CIl25Teq.mjs → index-BmPIWs5F.mjs} +3 -3
  11. package/core/built/admin/assets/admin-x-settings/{index-CNyNY3Wh.mjs → index-CP9YnNzc.mjs} +3 -3
  12. package/core/built/admin/assets/admin-x-settings/{index-SGr5sE2h.mjs → index-Cd2Ns-D2.mjs} +2 -2
  13. package/core/built/admin/assets/admin-x-settings/{index-PGoLP2kh.mjs → index-CjqAcKpK.mjs} +5 -5
  14. package/core/built/admin/assets/admin-x-settings/{index-pCIv_7bB.mjs → index-CnMcD9aj.mjs} +6212 -6158
  15. package/core/built/admin/assets/admin-x-settings/{index-CPCcgad-.mjs → index-LzsrZC40.mjs} +3 -3
  16. package/core/built/admin/assets/admin-x-settings/{index-DPqY4h5h.mjs → index-ZYW0UW7I.mjs} +3 -3
  17. package/core/built/admin/assets/admin-x-settings/{modals-lo32WZLi.mjs → modals-C48Tq1rW.mjs} +9 -9
  18. package/core/built/admin/assets/{arrow-right-BixoEua4.js → arrow-right-Bk43nMGd.js} +1 -1
  19. package/core/built/admin/assets/{at-sign-BsHNViA_.js → at-sign-DWOf36uj.js} +1 -1
  20. package/core/built/admin/assets/{audience-0RCWjbIK.js → audience-CvP78Gug.js} +1 -1
  21. package/core/built/admin/assets/{automations-DTUfYvf6.js → automations-BBWZhrha.js} +1 -1
  22. package/core/built/admin/assets/{automations-DiGkcVt-.js → automations-CmulGWwu.js} +1 -1
  23. package/core/built/admin/assets/{avatar-flipboard-BgoH-wIq.js → avatar-flipboard-CVf-N6wp.js} +1 -1
  24. package/core/built/admin/assets/{bluesky-sharing-C2xwSoS-.js → bluesky-sharing-DVC3I9Um.js} +1 -1
  25. package/core/built/admin/assets/{chart-X5cLIH1X.js → chart-CUKSNmKY.js} +1 -1
  26. package/core/built/admin/assets/{checkbox-DMamS4oG.js → checkbox-B_yDSM8z.js} +1 -1
  27. package/core/built/admin/assets/{chevron-up-CVgBkTk5.js → chevron-up-DuaKtE_M.js} +1 -1
  28. package/core/built/admin/assets/{chunk.941.f47098cbbce89a049e03.js → chunk.331.2ec2e2702eda02de96cd.js} +3 -3
  29. package/core/built/admin/assets/{chunk.524.a1d668dcc84709a5d702.js → chunk.524.49cc01002e1a5dba8ef9.js} +4 -4
  30. package/core/built/admin/assets/{chunk.582.180bf2525cf552f5ac5f.js → chunk.582.4bbc54c5f7d3dfb93288.js} +6 -6
  31. package/core/built/admin/assets/{circle-alert-Dg3UkvRP.js → circle-alert-bcK_Yqap.js} +1 -1
  32. package/core/built/admin/assets/{code-editor-view-CAICoZJe.js → code-editor-view-Bl4Jzjhk.js} +1 -1
  33. package/core/built/admin/assets/{comments-BHru9ZQ8.js → comments-DMea0nul.js} +1 -1
  34. package/core/built/admin/assets/{content-helpers-BByMp-Y5.js → content-helpers-B2yRzdvJ.js} +1 -1
  35. package/core/built/admin/assets/{copy-D7jqplrv.js → copy-DVtQi_VJ.js} +1 -1
  36. package/core/built/admin/assets/{data-list-DUaY9nlT.js → data-list-BF4GeUmt.js} +1 -1
  37. package/core/built/admin/assets/{deleted-feed-item-jLcSKuul.js → deleted-feed-item-DO2u3qmi.js} +1 -1
  38. package/core/built/admin/assets/{dropzone-DSPf3N_o.js → dropzone-Cs4DrURS.js} +1 -1
  39. package/core/built/admin/assets/{edit-profile-BvU2-lW5.js → edit-profile-CnuBNQhO.js} +1 -1
  40. package/core/built/admin/assets/{editor-D3fcjt_F.js → editor-CTO9FIUW.js} +1 -1
  41. package/core/built/admin/assets/{empty-indicator-2Pjmce3n.js → empty-indicator-BvyaMcmw.js} +1 -1
  42. package/core/built/admin/assets/{en-Bu-6PYn5.js → en-CjPXRj8j.js} +1 -1
  43. package/core/built/admin/assets/{feed-CygLK1Ad.js → feed-D2wk4cCS.js} +1 -1
  44. package/core/built/admin/assets/{filter-query-core-a0PNU2EO.js → filter-query-core-VEnwTCyO.js} +1 -1
  45. package/core/built/admin/assets/{filters-jiyRsLMH.js → filters-DtIsuqv5.js} +1 -1
  46. package/core/built/admin/assets/{gh-chart-CEhBBu3F.js → gh-chart-JxzKqaoO.js} +1 -1
  47. package/core/built/admin/assets/{ghost-0ab96884815339963364804ab266c99f.js → ghost-30c3dedbe1cca943b92efa7efd2710e4.js} +36 -21
  48. package/core/built/admin/assets/{growth-Fz3Oatml.js → growth-CPNrBpHK.js} +1 -1
  49. package/core/built/admin/assets/{hash-CeFrjo3C.js → hash-CJzbTA5k.js} +1 -1
  50. package/core/built/admin/assets/{inbox-CCirPaG2.js → inbox-CVVAkCmd.js} +1 -1
  51. package/core/built/admin/assets/{index-Dd2BJRZH.js → index-AkQJUr1z.js} +1 -1
  52. package/core/built/admin/assets/{index-CYPN5csJ.js → index-BLWOUf31.js} +1 -1
  53. package/core/built/admin/assets/{index-D7Ui3Fih.js → index-BRBRkRqa.js} +1 -1
  54. package/core/built/admin/assets/{index-CFEzD2_M.js → index-BkbhBpVC.js} +3 -3
  55. package/core/built/admin/assets/{index-BYwL7gFN.js → index-BxFFWYdP.js} +1 -1
  56. package/core/built/admin/assets/{index-D3LfHeBl.js → index-C5_ZKpC1.js} +1 -1
  57. package/core/built/admin/assets/{index-Bjw2qAph.js → index-Cdbufdfy.js} +1 -1
  58. package/core/built/admin/assets/{index-BTf6YUBb.js → index-Cq5vsvxE.js} +1 -1
  59. package/core/built/admin/assets/{index-DPbi4ie_.js → index-CuGoX8Ub.js} +1 -1
  60. package/core/built/admin/assets/{index-CsaU9dfl.js → index-CuH5raTz.js} +1 -1
  61. package/core/built/admin/assets/{index-Bf83suMc.js → index-D3A8RTi0.js} +1 -1
  62. package/core/built/admin/assets/{index-Dskrbhv3.js → index-DIyK69JM.js} +1 -1
  63. package/core/built/admin/assets/{index-GExKMpy_.js → index-DLFVpwt3.js} +1 -1
  64. package/core/built/admin/assets/{index-BOMdiHRG.js → index-DQZp_NsL.js} +1 -1
  65. package/core/built/admin/assets/{index-2qcjFCQs.js → index-DR74ulj2.js} +1 -1
  66. package/core/built/admin/assets/{index-WKMARia9.js → index-DYE2untj.js} +1 -1
  67. package/core/built/admin/assets/{index-DNZUJQ8v.js → index-DssW7xhk.js} +1 -1
  68. package/core/built/admin/assets/{index-Cq4mS7QK.js → index-DvyNqFct.js} +1 -1
  69. package/core/built/admin/assets/{index-C7xLyJVb.js → index-DxB7NHpG.js} +1 -1
  70. package/core/built/admin/assets/{index-Bw4DM4Pr.js → index-IDaHqjnu.js} +1 -1
  71. package/core/built/admin/assets/{index-ClOB5u8L.js → index-TtBMzSeP.js} +1 -1
  72. package/core/built/admin/assets/{index-takfwHSn.js → index-UMWVIyz7.js} +1 -1
  73. package/core/built/admin/assets/{koenig-lexical-BJM9wAwQ.js → koenig-lexical-DVAmevhl.js} +1 -1
  74. package/core/built/admin/assets/{kpi-card-BP-2yicn.js → kpi-card-D3CzvsrI.js} +1 -1
  75. package/core/built/admin/assets/{kpi-card-DOplXdDT.js → kpi-card-DV-nN7xT.js} +1 -1
  76. package/core/built/admin/assets/{kpi-tabs-Rq5jJW2Z.js → kpi-tabs-B3NkaTwb.js} +1 -1
  77. package/core/built/admin/assets/{kpis-yHgME_iy.js → kpis-CVwF08QL.js} +1 -1
  78. package/core/built/admin/assets/{label-fijjy1Mb.js → label-BiPpMny2.js} +1 -1
  79. package/core/built/admin/assets/{links-s3IeAkbo.js → links-BY0Uo6O5.js} +1 -1
  80. package/core/built/admin/assets/{list-page-CUcB5ebB.js → list-page-COHNMpOi.js} +1 -1
  81. package/core/built/admin/assets/{loader-circle-C7mWzo52.js → loader-circle-B1uEfpbZ.js} +1 -1
  82. package/core/built/admin/assets/{mail-9TFkAaAh.js → mail-ccQhEr7k.js} +1 -1
  83. package/core/built/admin/assets/{main-layout-XtviVkg1.js → main-layout-BYKdA6Z1.js} +1 -1
  84. package/core/built/admin/assets/{members-XkHao5Yf.js → members-DkpEnvG5.js} +1 -1
  85. package/core/built/admin/assets/minus-C68D81nx.js +1 -0
  86. package/core/built/admin/assets/{modals-B6R7oqvb.js → modals-X6RSWn5Y.js} +3 -3
  87. package/core/built/admin/assets/{moderation-B2Tixfce.js → moderation-BFrrwfvx.js} +1 -1
  88. package/core/built/admin/assets/{newsletter-CbESXhxf.js → newsletter-n7kc6cxR.js} +1 -1
  89. package/core/built/admin/assets/{newsletters-DOIL_cOY.js → newsletters-CSCa3QdE.js} +1 -1
  90. package/core/built/admin/assets/{note-mUikaB-p.js → note-CMZjeK8e.js} +1 -1
  91. package/core/built/admin/assets/{onboarding-route-Dqv2nP7b.js → onboarding-route-BaX0a-pu.js} +1 -1
  92. package/core/built/admin/assets/{overview-yZ-7KJdx.js → overview-CS9dmE_6.js} +1 -1
  93. package/core/built/admin/assets/{pagemenu-TxGvHwRO.js → pagemenu-O_y8Jm4v.js} +1 -1
  94. package/core/built/admin/assets/{pencil-CKTgzafp.js → pencil-BcymGPnE.js} +1 -1
  95. package/core/built/admin/assets/{pin-BU_u-xRX.js → pin-Bl3nSr7I.js} +1 -1
  96. package/core/built/admin/assets/{post-analytics-CWA8invj.js → post-analytics-DW-TKu-t.js} +1 -1
  97. package/core/built/admin/assets/{post-analytics-context-BWDhMRq_.js → post-analytics-context-D7PgEMo8.js} +1 -1
  98. package/core/built/admin/assets/{post-analytics-header-Bm0mcxjK.js → post-analytics-header-B8C0vA5Y.js} +1 -1
  99. package/core/built/admin/assets/{post-share-modal-D8BtRD2u.js → post-share-modal-D0OlASBQ.js} +1 -1
  100. package/core/built/admin/assets/{posts-u-CAKddc.js → posts-BZaw4-dc.js} +1 -1
  101. package/core/built/admin/assets/{power-DR9gpiQR.js → power-DWm6pts5.js} +1 -1
  102. package/core/built/admin/assets/{referrers-DV_Ihg9y.js → referrers-BsZ85Z0a.js} +1 -1
  103. package/core/built/admin/assets/{repeat-uXmOJ6y8.js → repeat-DQay9e22.js} +1 -1
  104. package/core/built/admin/assets/{reply-9ZyqaxI-.js → reply-CoNqmExw.js} +1 -1
  105. package/core/built/admin/assets/{rocket-DMOr1OCt.js → rocket-Dne6P_8f.js} +1 -1
  106. package/core/built/admin/assets/{select-CPSy44ld.js → select-BfWJkrKc.js} +1 -1
  107. package/core/built/admin/assets/{settings-krk0432u.js → settings-BoXzKMhL.js} +1 -1
  108. package/core/built/admin/assets/{settings-66Zv8QvL.js → settings-rRY210wx.js} +25 -25
  109. package/core/built/admin/assets/{share-modal-BRmGllZq.js → share-modal-CtdLQbnQ.js} +1 -1
  110. package/core/built/admin/assets/{sort-button-5fyeViQL.js → sort-button-7pVgpa0d.js} +1 -1
  111. package/core/built/admin/assets/{source-icon-DeeHyZRn.js → source-icon-Dtua85oN.js} +1 -1
  112. package/core/built/admin/assets/{sprout-956Q4On2.js → sprout-CpwUJAPT.js} +1 -1
  113. package/core/built/admin/assets/{square-BaCvbKJY.js → square-CDrQjv8R.js} +1 -1
  114. package/core/built/admin/assets/{stats-BVKNZJO6.js → stats-Yo9Gco0_.js} +1 -1
  115. package/core/built/admin/assets/{stats-view-gtyaqudG.js → stats-view-DubukX9V.js} +1 -1
  116. package/core/built/admin/assets/{step-1-09wdjzdX.js → step-1-CH8jWKi7.js} +1 -1
  117. package/core/built/admin/assets/{step-2-8iaQ0efq.js → step-2-CWy7Qi0Q.js} +1 -1
  118. package/core/built/admin/assets/{step-3-BuHAZbdD.js → step-3-CNiDFH17.js} +1 -1
  119. package/core/built/admin/assets/{table-DTofVyjA.js → table-qQi9EXB1.js} +1 -1
  120. package/core/built/admin/assets/{tabs-CL5eaCGL.js → tabs-M6kFEqPE.js} +1 -1
  121. package/core/built/admin/assets/{tags-DJrbEw5-.js → tags-74U6lgwY.js} +1 -1
  122. package/core/built/admin/assets/{tags-U3lciBmd.js → tags-DuMshkTz.js} +1 -1
  123. package/core/built/admin/assets/{textarea-DdDuNixZ.js → textarea-CGBp9nOo.js} +1 -1
  124. package/core/built/admin/assets/{tiers-DXKbghdk.js → tiers-D2DYHaeO.js} +1 -1
  125. package/core/built/admin/assets/{toggle-group-DaZKTYDS.js → toggle-group-GYp_w6Po.js} +1 -1
  126. package/core/built/admin/assets/{topic-filter-BzqiVOAU.js → topic-filter-N3CzJ01P.js} +1 -1
  127. package/core/built/admin/assets/{trash-CKK_p9G5.js → trash-CUqAK3SQ.js} +1 -1
  128. package/core/built/admin/assets/{underline-Bq0P-5Zy.js → underline-CwuJG-Ql.js} +1 -1
  129. package/core/built/admin/assets/{undo-2-CcBtw-tW.js → undo-2-D6ZRqONE.js} +1 -1
  130. package/core/built/admin/assets/{upload-BcylHEMw.js → upload-BLiT66bJ.js} +1 -1
  131. package/core/built/admin/assets/{use-growth-stats-Ci0gymWp.js → use-growth-stats-u18So4Gq.js} +1 -1
  132. package/core/built/admin/assets/{use-simple-pagination-ByaFwxfZ.js → use-simple-pagination-Dp2sTt2S.js} +1 -1
  133. package/core/built/admin/assets/{user-round-check-D0I7NO1g.js → user-round-check-BDomHaso.js} +1 -1
  134. package/core/built/admin/assets/{user-round-x-DeGVH29o.js → user-round-x-Cc0RL-V9.js} +1 -1
  135. package/core/built/admin/assets/{virtual-list-window-S0xZxQAf.js → virtual-list-window-BnjCoNIr.js} +1 -1
  136. package/core/built/admin/assets/{wallet-cards-B9TQg4x3.js → wallet-cards-CVZ99Nm3.js} +1 -1
  137. package/core/built/admin/assets/{web-BRN2mUpo.js → web-B_MLxGxZ.js} +1 -1
  138. package/core/built/admin/index.html +5 -5
  139. package/core/server/{services/custom-redirects/file-store.js → adapters/redirects/FileStore.js} +6 -5
  140. package/core/server/{services/custom-redirects/file-store.ts → adapters/redirects/FileStore.ts} +6 -4
  141. package/core/server/adapters/redirects/RedirectsStoreBase.d.ts +9 -0
  142. package/core/server/adapters/redirects/RedirectsStoreBase.js +8 -0
  143. package/core/server/{services/custom-redirects/gcs-store.js → adapters/redirects/S3RedirectsStore.js} +50 -18
  144. package/core/server/adapters/redirects/S3RedirectsStore.ts +163 -0
  145. package/core/server/adapters/scheduling/scheduling-base.js +41 -0
  146. package/core/server/adapters/scheduling/types.js +2 -0
  147. package/core/server/adapters/scheduling/types.ts +36 -0
  148. package/core/server/api/endpoints/authentication.js +26 -5
  149. package/core/server/api/endpoints/schedules.js +0 -30
  150. package/core/server/api/endpoints/utils/serializers/output/authentication.js +10 -0
  151. package/core/server/data/migrations/versions/6.41/2026-05-13-12-00-00-rename-reset-all-passwords-permission.js +21 -0
  152. package/core/server/data/schema/fixtures/fixtures.json +3 -3
  153. package/core/server/models/api-key.js +18 -0
  154. package/core/server/models/user.js +18 -0
  155. package/core/server/services/adapter-manager/config.js +6 -0
  156. package/core/server/services/adapter-manager/index.js +1 -0
  157. package/core/server/services/auth/index.js +4 -0
  158. package/core/server/services/auth/reset-authentication.js +50 -0
  159. package/core/server/services/auth/reset-authentication.ts +75 -0
  160. package/core/server/services/automations/index.js +21 -15
  161. package/core/server/services/custom-redirects/index.js +2 -4
  162. package/core/server/services/gifts/gift-bookshelf-repository.js +7 -0
  163. package/core/server/services/gifts/gift-bookshelf-repository.ts +10 -0
  164. package/core/server/services/gifts/gift-reminder-scheduler.js +94 -0
  165. package/core/server/services/gifts/gift-reminder-scheduler.ts +109 -0
  166. package/core/server/services/gifts/gift-repository.ts +1 -0
  167. package/core/server/services/gifts/gift-service-wrapper.js +10 -7
  168. package/core/server/services/gifts/gift-service.js +1 -32
  169. package/core/server/services/gifts/gift-service.ts +3 -59
  170. package/core/server/services/internal-keys/index.js +1 -3
  171. package/core/server/services/internal-keys/index.ts +11 -3
  172. package/core/server/services/post-scheduling/index.js +16 -28
  173. package/core/server/services/post-scheduling/index.ts +14 -0
  174. package/core/server/services/post-scheduling/post-scheduling.js +115 -0
  175. package/core/server/services/post-scheduling/post-scheduling.ts +138 -0
  176. package/core/server/services/users.js +29 -16
  177. package/core/server/web/api/endpoints/admin/middleware.js +8 -4
  178. package/core/server/web/api/endpoints/admin/routes.js +1 -1
  179. package/core/shared/config/defaults.json +5 -0
  180. package/core/shared/labs.js +2 -1
  181. package/package.json +1 -1
  182. package/core/built/admin/assets/minus-DPrXh11r.js +0 -1
  183. package/core/server/services/custom-redirects/gcs-store.ts +0 -117
  184. package/core/server/services/post-scheduling/post-scheduler-service.js +0 -126
@@ -1,4 +1,4 @@
1
- import{r as o,j as n,cS as Sn,cT as En,B as A,ct as Vn,cU as _n,bi as Yn,t as dn,d6 as Qn,b as In,de as pn,S as E,P as Zn,A as Jn,g as bn,d as Xn,h as Gn,m as ne,bP as ee,e as un,F as on,i as rn,df as te,dg as D,dh as xn,o as ae,a as oe,u as re,p as ie,L as de,a$ as se,D as ce,v as le,w as ge,x as pe,ac as ue,di as he,dj as me,bH as vn,bI as ke}from"./index-CFEzD2_M.js";import{M as fe}from"./minus-DPrXh11r.js";import{u as be,D as xe,A as ve,S as yn}from"./deleted-feed-item-jLcSKuul.js";import{T as ye}from"./topic-filter-BzqiVOAU.js";import{E as wn}from"./empty-indicator-2Pjmce3n.js";import{I as jn}from"./inbox-CCirPaG2.js";import"./trash-CKK_p9G5.js";const hn=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],W={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},we=()=>{const[t,c]=o.useState(()=>localStorage.getItem(W.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[a,p]=o.useState(()=>{const r=localStorage.getItem(W.FONT_SIZE);return r?parseInt(r):2}),[s,k]=o.useState(()=>localStorage.getItem(W.FONT_STYLE)||"sans"),i=r=>{c(r),localStorage.setItem(W.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(W.FONT_SIZE,a.toString())},[a]),o.useEffect(()=>{localStorage.setItem(W.FONT_STYLE,s)},[s]),{backgroundColor:t,currentFontSizeIndex:a,fontStyle:s,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,hn.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:hn[a]}},Cn=({backgroundColor:t,currentFontSizeIndex:c,fontStyle:a,onColorChange:p,onFontStyleChange:s,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>t===l,r=l=>a===l;return n.jsx(je,{backgroundColor:t,currentFontSizeIndex:c,fontStyle:a,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:s,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},je=({backgroundColor:t,isActiveColor:c,isActiveFont:a,onColorChange:p,onFontStyleChange:s,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Sn,{modal:!1,onOpenChange:h,children:[n.jsx(En,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[t].button}`,variant:"ghost",children:n.jsx(Vn.Typography,{className:"size-[18px]!"})})}),n.jsx(_n,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${c("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${c("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${c("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${c("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${a("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>s("sans"),children:[n.jsx("span",{className:"text-[2rem] leading-none font-bold",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${a("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>s("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] leading-none font-bold",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(fe,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===hn.length-1,variant:"secondary",onClick:u,children:n.jsx(Yn,{})})]})]})})]}),Ce=({tocItems:t,iframeElement:c,modalRef:a,className:p="visible! absolute inset-y-0 right-7 z-40 hidden lg:block!",onOpenChange:s})=>{const[k,i]=o.useState(null),u=dn.useRef(!1),v=h=>{if(!c?.contentDocument)return;const r=c.contentDocument.getElementById(h);r&&a.current&&(u.current=!0,i(h),a.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!c?.contentDocument||t.length<=1)return;const h=a.current;if(!h)return;const r=()=>{if(u.current)return;const d=c.contentDocument;if(!d)return;const _=h.scrollTop,F=100,B=t.map(z=>d.getElementById(z.id)).filter(z=>z!==null).map(z=>({id:z.id,top:z.offsetTop}));if(!B.length)return;const L=B.reduce((z,M)=>M.top-F<=_?M:z);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[c,t,a]),t.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Ee,{activeHeading:k||"",items:t,onItemClick:v,onOpenChange:s})})})},ze={1:"w-3",2:"w-2",3:"w-1"},Se={1:"pl-2",2:"pl-6",3:"pl-10"},Ee=({items:t,activeHeading:c,onItemClick:a,onOpenChange:p})=>{const[s,k]=o.useState(!1),i=dn.useRef();if(dn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),t.length===0)return null;const u=d=>Math.min(d,3),v=d=>ze[u(d)],h=d=>Se[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Sn,{modal:!1,open:s,onOpenChange:k,children:[n.jsx(En,{asChild:!0,children:n.jsx("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:t.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${c===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(_n,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:t.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${c===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>a(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},_e=()=>`<style>
1
+ import{r as o,j as n,cS as Sn,cT as En,B as A,ct as Vn,cU as _n,bi as Yn,t as dn,d6 as Qn,b as In,de as pn,S as E,P as Zn,A as Jn,g as bn,d as Xn,h as Gn,m as ne,bP as ee,e as un,F as on,i as rn,df as te,dg as D,dh as xn,o as ae,a as oe,u as re,p as ie,L as de,a$ as se,D as ce,v as le,w as ge,x as pe,ac as ue,di as he,dj as me,bH as vn,bI as ke}from"./index-BkbhBpVC.js";import{M as fe}from"./minus-C68D81nx.js";import{u as be,D as xe,A as ve,S as yn}from"./deleted-feed-item-DO2u3qmi.js";import{T as ye}from"./topic-filter-N3CzJ01P.js";import{E as wn}from"./empty-indicator-BvyaMcmw.js";import{I as jn}from"./inbox-CVVAkCmd.js";import"./trash-CUqAK3SQ.js";const hn=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],W={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},we=()=>{const[t,c]=o.useState(()=>localStorage.getItem(W.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[a,p]=o.useState(()=>{const r=localStorage.getItem(W.FONT_SIZE);return r?parseInt(r):2}),[s,k]=o.useState(()=>localStorage.getItem(W.FONT_STYLE)||"sans"),i=r=>{c(r),localStorage.setItem(W.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(W.FONT_SIZE,a.toString())},[a]),o.useEffect(()=>{localStorage.setItem(W.FONT_STYLE,s)},[s]),{backgroundColor:t,currentFontSizeIndex:a,fontStyle:s,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,hn.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:hn[a]}},Cn=({backgroundColor:t,currentFontSizeIndex:c,fontStyle:a,onColorChange:p,onFontStyleChange:s,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>t===l,r=l=>a===l;return n.jsx(je,{backgroundColor:t,currentFontSizeIndex:c,fontStyle:a,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:s,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},je=({backgroundColor:t,isActiveColor:c,isActiveFont:a,onColorChange:p,onFontStyleChange:s,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Sn,{modal:!1,onOpenChange:h,children:[n.jsx(En,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[t].button}`,variant:"ghost",children:n.jsx(Vn.Typography,{className:"size-[18px]!"})})}),n.jsx(_n,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${c("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${c("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${c("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${c("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${a("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>s("sans"),children:[n.jsx("span",{className:"text-[2rem] leading-none font-bold",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${a("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>s("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] leading-none font-bold",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(fe,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===hn.length-1,variant:"secondary",onClick:u,children:n.jsx(Yn,{})})]})]})})]}),Ce=({tocItems:t,iframeElement:c,modalRef:a,className:p="visible! absolute inset-y-0 right-7 z-40 hidden lg:block!",onOpenChange:s})=>{const[k,i]=o.useState(null),u=dn.useRef(!1),v=h=>{if(!c?.contentDocument)return;const r=c.contentDocument.getElementById(h);r&&a.current&&(u.current=!0,i(h),a.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!c?.contentDocument||t.length<=1)return;const h=a.current;if(!h)return;const r=()=>{if(u.current)return;const d=c.contentDocument;if(!d)return;const _=h.scrollTop,F=100,B=t.map(z=>d.getElementById(z.id)).filter(z=>z!==null).map(z=>({id:z.id,top:z.offsetTop}));if(!B.length)return;const L=B.reduce((z,M)=>M.top-F<=_?M:z);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[c,t,a]),t.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Ee,{activeHeading:k||"",items:t,onItemClick:v,onOpenChange:s})})})},ze={1:"w-3",2:"w-2",3:"w-1"},Se={1:"pl-2",2:"pl-6",3:"pl-10"},Ee=({items:t,activeHeading:c,onItemClick:a,onOpenChange:p})=>{const[s,k]=o.useState(!1),i=dn.useRef();if(dn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),t.length===0)return null;const u=d=>Math.min(d,3),v=d=>ze[u(d)],h=d=>Se[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Sn,{modal:!1,open:s,onOpenChange:k,children:[n.jsx(En,{asChild:!0,children:n.jsx("div",{className:"absolute top-1/2 right-2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:t.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${c===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(_n,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:t.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${c===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>a(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},_e=()=>`<style>
2
2
 
3
3
  /* Variables */
4
4
 
@@ -1 +1 @@
1
- import{j as t,bL as F,t as u,b as g,bM as z,r as j,bH as T,bI as E,L as S,E as M,c as P,bN as L,S as w,A as $,B as U,bz as B,m as C,h as v,d as W,n as _,bO as H,bP as O,e as D,P as q}from"./index-CFEzD2_M.js";import{A as V}from"./at-sign-BsHNViA_.js";import{R as G,U as K}from"./user-round-check-D0I7NO1g.js";import{R as Q}from"./reply-9ZyqaxI-.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",c=l==="sm"?13:20,o=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mt-0.5 -mr-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:c,strokeWidth:o}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:o}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mr-px mb-px",color:n,size:c,strokeWidth:o}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:c,strokeWidth:o}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:c,strokeWidth:o}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const c=`_${te(s.createdAt)}`,o=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${c}${o}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${c}${o}`);break;case"follow":n=`follow_${c}${o}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),c=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:o=>{o?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[c," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[c," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[c," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return c;break;case"mention":return c}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const c=o=>{const y=o.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(o.preventDefault(),o.stopPropagation(),v(x,s))}};return n.addEventListener("click",c),()=>{n.removeEventListener("click",c)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},ce=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:c,error:o,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=z("index"),k=c?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return o&&T(o)?t.jsx(E,{errorCode:o.code,statusCode:o.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(L,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 bg-[#F3F3F3]! outline outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(U,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(B,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item break-anywhere flex items-center justify-between gap-4",onClick:A=>{A?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:H({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(O,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center",children:t.jsx(D,{size:"md"})})]})]})})};export{ce as default};
1
+ import{j as t,bL as F,t as u,b as g,bM as z,r as j,bH as T,bI as E,L as S,E as M,c as P,bN as L,S as w,A as $,B as U,bz as B,m as C,h as v,d as W,n as _,bO as H,bP as O,e as D,P as q}from"./index-BkbhBpVC.js";import{A as V}from"./at-sign-DWOf36uj.js";import{R as G,U as K}from"./user-round-check-BDomHaso.js";import{R as Q}from"./reply-CoNqmExw.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",c=l==="sm"?13:20,o=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mt-0.5 -mr-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:c,strokeWidth:o}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:o}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mr-px mb-px",color:n,size:c,strokeWidth:o}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:c,strokeWidth:o}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:c,strokeWidth:o}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const c=`_${te(s.createdAt)}`,o=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${c}${o}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${c}${o}`);break;case"follow":n=`follow_${c}${o}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),c=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:o=>{o?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[c," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[c," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[c," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return c;break;case"mention":return c}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const c=o=>{const y=o.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(o.preventDefault(),o.stopPropagation(),v(x,s))}};return n.addEventListener("click",c),()=>{n.removeEventListener("click",c)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},ce=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:c,error:o,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=z("index"),k=c?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return o&&T(o)?t.jsx(E,{errorCode:o.code,statusCode:o.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(L,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 bg-[#F3F3F3]! outline outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(U,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(B,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item break-anywhere flex items-center justify-between gap-4",onClick:A=>{A?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:H({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(O,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center",children:t.jsx(D,{size:"md"})})]})]})})};export{ce as default};
@@ -1 +1 @@
1
- import{r as a,j as u,as as F,at as I,au as L,av as S,aw as j,ax as O,ay as z,az as H}from"./index-CFEzD2_M.js";var R="Checkbox",[G]=H(R),[K,P]=G(R);function U(t){const{__scopeCheckbox:c,checked:s,children:l,defaultChecked:r,disabled:e,form:f,name:h,onCheckedChange:d,required:C,value:k="on",internal_do_not_use_render:i}=t,[p,v]=L({prop:s,defaultProp:r??!1,onChange:d,caller:R}),[x,m]=a.useState(null),[E,o]=a.useState(null),n=a.useRef(!1),_=x?!!f||!!x.closest("form"):!0,y={checked:p,disabled:e,setChecked:v,control:x,setControl:m,name:h,form:f,value:k,hasConsumerStoppedPropagationRef:n,required:C,defaultChecked:b(r)?!1:r,isFormControl:_,bubbleInput:E,setBubbleInput:o};return u.jsx(K,{scope:c,...y,children:Q(i)?i(y):l})}var w="CheckboxTrigger",N=a.forwardRef(({__scopeCheckbox:t,onKeyDown:c,onClick:s,...l},r)=>{const{control:e,value:f,disabled:h,checked:d,required:C,setControl:k,setChecked:i,hasConsumerStoppedPropagationRef:p,isFormControl:v,bubbleInput:x}=P(w,t),m=S(r,k),E=a.useRef(d);return a.useEffect(()=>{const o=e?.form;if(o){const n=()=>i(E.current);return o.addEventListener("reset",n),()=>o.removeEventListener("reset",n)}},[e,i]),u.jsx(I.button,{type:"button",role:"checkbox","aria-checked":b(d)?"mixed":d,"aria-required":C,"data-state":q(d),"data-disabled":h?"":void 0,disabled:h,value:f,...l,ref:m,onKeyDown:j(c,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:j(s,o=>{i(n=>b(n)?!0:!n),x&&v&&(p.current=o.isPropagationStopped(),p.current||o.stopPropagation())})})});N.displayName=w;var X=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,name:l,checked:r,defaultChecked:e,required:f,disabled:h,value:d,onCheckedChange:C,form:k,...i}=t;return u.jsx(U,{__scopeCheckbox:s,checked:r,defaultChecked:e,disabled:h,required:f,onCheckedChange:C,name:l,form:k,value:d,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(N,{...i,ref:c,__scopeCheckbox:s}),p&&u.jsx(T,{__scopeCheckbox:s})]})})});X.displayName=R;var B="CheckboxIndicator",J=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,forceMount:l,...r}=t,e=P(B,s);return u.jsx(F,{present:l||b(e.checked)||e.checked===!0,children:u.jsx(I.span,{"data-state":q(e.checked),"data-disabled":e.disabled?"":void 0,...r,ref:c,style:{pointerEvents:"none",...t.style}})})});J.displayName=B;var M="CheckboxBubbleInput",T=a.forwardRef(({__scopeCheckbox:t,...c},s)=>{const{control:l,hasConsumerStoppedPropagationRef:r,checked:e,defaultChecked:f,required:h,disabled:d,name:C,value:k,form:i,bubbleInput:p,setBubbleInput:v}=P(M,t),x=S(s,v),m=O(e),E=z(l);a.useEffect(()=>{const n=p;if(!n)return;const _=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(_,"checked").set,A=!r.current;if(m!==e&&g){const D=new Event("click",{bubbles:A});n.indeterminate=b(e),g.call(n,b(e)?!1:e),n.dispatchEvent(D)}},[p,m,e,r]);const o=a.useRef(b(e)?!1:e);return u.jsx(I.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??o.current,required:h,disabled:d,name:C,value:k,form:i,...c,tabIndex:-1,ref:x,style:{...c.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});T.displayName=M;function Q(t){return typeof t=="function"}function b(t){return t==="indeterminate"}function q(t){return b(t)?"indeterminate":t?"checked":"unchecked"}export{X as C,J as a};
1
+ import{r as a,j as u,as as F,at as I,au as L,av as S,aw as j,ax as O,ay as z,az as H}from"./index-BkbhBpVC.js";var R="Checkbox",[G]=H(R),[K,P]=G(R);function U(t){const{__scopeCheckbox:c,checked:s,children:l,defaultChecked:r,disabled:e,form:f,name:h,onCheckedChange:d,required:C,value:k="on",internal_do_not_use_render:i}=t,[p,v]=L({prop:s,defaultProp:r??!1,onChange:d,caller:R}),[x,m]=a.useState(null),[E,o]=a.useState(null),n=a.useRef(!1),_=x?!!f||!!x.closest("form"):!0,y={checked:p,disabled:e,setChecked:v,control:x,setControl:m,name:h,form:f,value:k,hasConsumerStoppedPropagationRef:n,required:C,defaultChecked:b(r)?!1:r,isFormControl:_,bubbleInput:E,setBubbleInput:o};return u.jsx(K,{scope:c,...y,children:Q(i)?i(y):l})}var w="CheckboxTrigger",N=a.forwardRef(({__scopeCheckbox:t,onKeyDown:c,onClick:s,...l},r)=>{const{control:e,value:f,disabled:h,checked:d,required:C,setControl:k,setChecked:i,hasConsumerStoppedPropagationRef:p,isFormControl:v,bubbleInput:x}=P(w,t),m=S(r,k),E=a.useRef(d);return a.useEffect(()=>{const o=e?.form;if(o){const n=()=>i(E.current);return o.addEventListener("reset",n),()=>o.removeEventListener("reset",n)}},[e,i]),u.jsx(I.button,{type:"button",role:"checkbox","aria-checked":b(d)?"mixed":d,"aria-required":C,"data-state":q(d),"data-disabled":h?"":void 0,disabled:h,value:f,...l,ref:m,onKeyDown:j(c,o=>{o.key==="Enter"&&o.preventDefault()}),onClick:j(s,o=>{i(n=>b(n)?!0:!n),x&&v&&(p.current=o.isPropagationStopped(),p.current||o.stopPropagation())})})});N.displayName=w;var X=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,name:l,checked:r,defaultChecked:e,required:f,disabled:h,value:d,onCheckedChange:C,form:k,...i}=t;return u.jsx(U,{__scopeCheckbox:s,checked:r,defaultChecked:e,disabled:h,required:f,onCheckedChange:C,name:l,form:k,value:d,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(N,{...i,ref:c,__scopeCheckbox:s}),p&&u.jsx(T,{__scopeCheckbox:s})]})})});X.displayName=R;var B="CheckboxIndicator",J=a.forwardRef((t,c)=>{const{__scopeCheckbox:s,forceMount:l,...r}=t,e=P(B,s);return u.jsx(F,{present:l||b(e.checked)||e.checked===!0,children:u.jsx(I.span,{"data-state":q(e.checked),"data-disabled":e.disabled?"":void 0,...r,ref:c,style:{pointerEvents:"none",...t.style}})})});J.displayName=B;var M="CheckboxBubbleInput",T=a.forwardRef(({__scopeCheckbox:t,...c},s)=>{const{control:l,hasConsumerStoppedPropagationRef:r,checked:e,defaultChecked:f,required:h,disabled:d,name:C,value:k,form:i,bubbleInput:p,setBubbleInput:v}=P(M,t),x=S(s,v),m=O(e),E=z(l);a.useEffect(()=>{const n=p;if(!n)return;const _=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(_,"checked").set,A=!r.current;if(m!==e&&g){const D=new Event("click",{bubbles:A});n.indeterminate=b(e),g.call(n,b(e)?!1:e),n.dispatchEvent(D)}},[p,m,e,r]);const o=a.useRef(b(e)?!1:e);return u.jsx(I.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??o.current,required:h,disabled:d,name:C,value:k,form:i,...c,tabIndex:-1,ref:x,style:{...c.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});T.displayName=M;function Q(t){return typeof t=="function"}function b(t){return t==="indeterminate"}function q(t){return b(t)?"indeterminate":t?"checked":"unchecked"}export{X as C,J as a};
@@ -1 +1 @@
1
- import{r as c,c6 as K,aZ as te,bg as se,c7 as F,ao as D,j as e,a_ as ee,an as _,b7 as pe,aW as he,b9 as xe,bb as Y,c8 as fe,be as ae,ak as X,al as H,c9 as ge,t as Q,b_ as be,B as je}from"./index-CFEzD2_M.js";import{s as ve,g as Z,S as ke,a as we,D as Ne,b as Se}from"./stats-view-gtyaqudG.js";import{C as _e,a as ye,R as Ce,B as Te}from"./chart-X5cLIH1X.js";import{E as re}from"./empty-indicator-2Pjmce3n.js";import{T as De,a as Me}from"./tabs-CL5eaCGL.js";import{G as Le,C as Re,X as Oe,Y as Be,a as Ee}from"./gh-chart-CEhBBu3F.js";import{K as U,a as B,b as Pe}from"./kpi-tabs-Rq5jJW2Z.js";import{B as Ae,S as W}from"./sort-button-5fyeViQL.js";import{M as ne}from"./mail-9TFkAaAh.js";import{S as ze,a as Ve,b as We,c as $e,d as He,e as Ke,f as Fe}from"./select-CPSy44ld.js";import{i as Ge,C as oe,c as ie,a as Ie,b as Ye,g as Ue}from"./pagemenu-TxGvHwRO.js";import{T as Xe,d as Qe,a as Ze,b as $,c as P,e as L}from"./table-DTofVyjA.js";import{u as qe}from"./newsletters-DOIL_cOY.js";import{e as Je,f as et,g as tt}from"./stats-BVKNZJO6.js";import"./loader-circle-C7mWzo52.js";import"./sprout-956Q4On2.js";import"./_baseAssignValue-BDsvYKNK.js";import"./index-WKMARia9.js";import"./value-BGBiTkF3.js";import"./a-large-small-DxRNdz0F.js";import"./wallet-cards-B9TQg4x3.js";import"./undo-2-CcBtw-tW.js";import"./upload-BcylHEMw.js";import"./arrow-right-BixoEua4.js";import"./at-sign-BsHNViA_.js";import"./underline-Bq0P-5Zy.js";import"./chevron-up-CVgBkTk5.js";import"./circle-alert-Dg3UkvRP.js";import"./power-DR9gpiQR.js";import"./copy-D7jqplrv.js";import"./pin-BU_u-xRX.js";import"./hash-CeFrjo3C.js";import"./inbox-CCirPaG2.js";import"./minus-DPrXh11r.js";import"./pencil-CKTgzafp.js";import"./square-BaCvbKJY.js";import"./user-round-check-D0I7NO1g.js";import"./repeat-uXmOJ6y8.js";import"./reply-9ZyqaxI-.js";import"./rocket-DMOr1OCt.js";import"./tags-U3lciBmd.js";import"./trash-CKK_p9G5.js";import"./user-round-x-DeGVH29o.js";const st=({active:a,payload:s})=>{if(!a||!s?.length)return null;const r=s[0].payload,o=typeof r.send_date=="string"?r.send_date:r.send_date.toISOString().split("T")[0];return e.jsxs("div",{className:"max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex w-full flex-col border-b pb-2",children:[e.jsx("span",{className:"text-sm leading-tight font-semibold",children:r.post_title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Sent on ",ae(o)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Sent"}),e.jsx("div",{className:"ml-2 w-full text-right font-mono",children:D(r.sent_to)})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Opens"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_opens)," / "]}),_(r.open_rate)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Clicks"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_clicks)," / "]}),_(r.click_rate)]})]})]})},at=({subscribersData:a,avgsData:s,totals:r,isLoading:o,isAvgsLoading:t,initialTab:i="total-subscribers"})=>{const[n,h]=c.useState(i),[p,v]=c.useState(!1),{range:u}=K(),w=te(),[b]=se(),{appSettings:N}=F(),{emailTrackClicks:j,emailTrackOpens:S}=N?.analytics||{},{totalSubscribers:R,avgOpenRate:m,avgClickRate:d}=r,g=c.useMemo(()=>{if(!a||a.length===0)return[];let l=[];return l=ve(a,u,"value","exact"),l.map(M=>({...M,formattedValue:D(M.value),label:"Total Subscribers"}))},[a,u]),y=c.useMemo(()=>{if(!g||g.length<=1)return{direction:"same",value:"0%"};const l=g[0]?.value??0,k=g[g.length-1]?.value??0;let M="same";k>l?M="up":k<l&&(M="down");let E;if(l===0)E=k===0?"0%":"+100%";else{const A=(k-l)/l*100,z=Math.round(A*10)/10;E=`${A>=0?"+":""}${z}%`}return{direction:M,value:E}},[g]);c.useEffect(()=>{h(i)},[i]);const x=l=>{h(l);const k=new URLSearchParams(b);k.set("tab",l),w(`?${k.toString()}`,{replace:!0})},C={open_rate:{label:"Open rate"}},f=c.useMemo(()=>({"total-subscribers":{color:"var(--chart-darkblue)",datakey:"value"},"avg-open-rate":{color:"var(--chart-blue)",datakey:"open_rate"},"avg-click-rate":{color:"var(--chart-teal)",datakey:"click_rate"}}),[]),{barDomain:T,barTicks:O}=c.useMemo(()=>{if(!s||s.length===0||n==="total-subscribers")return{barDomain:[0,1],barTicks:[0,1]};const l=f[n]?.datakey;if(!l)return{barDomain:[0,1],barTicks:[0,1]};const k=s.map(I=>I[l]).filter(I=>typeof I=="number");if(k.length===0)return{barDomain:[0,1],barTicks:[0,1]};const M=Math.min(...k),E=Math.max(...k),A=Math.floor(M*10)/10,z=Math.ceil(E*10)/10,V=Math.max(0,A),J=z===V?V+.1:z;return{barDomain:[V,J],barTicks:[V,J]}},[s,n,f]);if(o)return e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(ee,{})});let G="grid-cols-3";(!j||!S)&&(G="grid-cols-2"),!j&&!S&&(G="grid-cols-1");const ue=n==="avg-open-rate"&&m>T[0]&&m<T[1]||n==="avg-click-rate"&&d>T[0]&&d<T[1],q=n==="avg-open-rate"?m:d;return e.jsxs(De,{defaultValue:i,variant:"kpis",children:[e.jsxs(Me,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${G}`,children:[e.jsx(U,{className:`${!S&&!j&&"cursor-auto after:hidden"}`,value:"total-subscribers",onClick:()=>{x("total-subscribers")},children:e.jsx(B,{color:f["total-subscribers"].color,"data-testid":"total-subscribers-value",diffDirection:y.direction,diffValue:y.value,label:"Total subscribers",value:D(R)})}),S&&e.jsx(U,{value:"avg-open-rate",onClick:()=>{x("avg-open-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:f["avg-open-rate"].color,label:"Avg. open rate",value:_(m)})}),j&&e.jsx(U,{value:"avg-click-rate",onClick:()=>{x("avg-click-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:f["avg-click-rate"].color,label:"Avg. click rate",value:_(d)})})]}),e.jsxs(pe,{children:[e.jsx(he,{className:"md:hidden",asChild:!0,children:e.jsxs(Pe,{children:[n==="total-subscribers"&&e.jsx(B,{color:f["total-subscribers"].color,label:"Total subscribers",value:D(R)}),n==="avg-open-rate"&&S&&e.jsx(B,{className:t?"opacity-50":"",color:f["avg-open-rate"].color,label:"Avg. open rate",value:_(m)}),n==="avg-click-rate"&&j&&e.jsx(B,{className:t?"opacity-50":"",color:f["avg-click-rate"].color,label:"Avg. click rate",value:_(d)})]})}),e.jsxs(xe,{align:"end",className:"w-56",children:[e.jsx(Y,{onClick:()=>x("total-subscribers"),children:"Total subscribers"}),S&&e.jsx(Y,{onClick:()=>x("avg-open-rate"),children:"Avg. open rate"}),j&&e.jsx(Y,{onClick:()=>x("avg-click-rate"),children:"Avg. click rate"})]})]}),e.jsxs("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:[n==="total-subscribers"&&e.jsx(Le,{className:"-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full",color:f["total-subscribers"].color,data:g,id:"mrr",range:u}),(n==="avg-open-rate"&&S||n==="avg-click-rate"&&j)&&e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"h-[320px] w-full items-center justify-center",children:e.jsx(ee,{})}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]",config:C,children:e.jsxs(Ae,{className:p?"cursor-pointer!":"",data:s,margin:{top:20},onClick:l=>{l.activePayload&&l.activePayload[0].payload.post_id&&w(`/posts/analytics/${l.activePayload[0].payload.post_id}`,{crossApp:!0})},onMouseLeave:()=>v(!1),onMouseMove:l=>{v(!!(l.activePayload&&l.activePayload[0].payload.post_id))},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"barGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f[n].color,stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:f[n].color,stopOpacity:.6})]})}),e.jsx(Re,{horizontal:!0,stroke:"var(--border)",vertical:!1}),e.jsx(Oe,{axisLine:{stroke:"var(--border)",strokeWidth:1},dataKey:"post_id",interval:0,stroke:"var(--border)",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Be,{axisLine:!1,domain:T,tickFormatter:l=>_(l),tickLine:!1,ticks:O,width:fe(O,l=>_(l))}),e.jsx(ye,{content:e.jsx(st,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),ue&&e.jsx(Ce,{label:{value:`${_(q)}`,position:"left",offset:8,fill:"var(--muted-foreground)"},opacity:.5,stroke:"var(--muted-foreground)",strokeDasharray:"4 4",y:q}),e.jsx(Te,{activeBar:{fillOpacity:1},dataKey:f[n].datakey,fill:"url(#barGradient)",fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),e.jsxs("div",{className:"-mt-4 text-center text-sm text-muted-foreground",children:["Newsletters ",n==="avg-open-rate"?"opens":"clicks"," in this period"]})]}):e.jsx(re,{className:"size-full py-20",title:`No newsletters ${Z(u)}`,children:e.jsx(ne,{strokeWidth:1.5})})})]})]})},rt=({newsletters:a})=>{const{selectedNewsletterId:s,setSelectedNewsletterId:r}=K(),o=c.useMemo(()=>a?.filter(t=>t.status==="active")||[],[a]);return c.useEffect(()=>{if(o.length>0&&!s){const t=o.find(i=>i.sort_order===0);r(t?t.id:o[0].id)}},[o,s,r]),o.length<=1?null:e.jsxs(ze,{value:s||"",onValueChange:t=>{r(t)},children:[e.jsxs(Ve,{className:"w-auto",children:[e.jsx(Ee,{className:"mr-2",size:16,strokeWidth:1.5}),e.jsx(We,{placeholder:"Select a newsletter"})]}),e.jsx($e,{align:"end",children:e.jsxs(He,{children:[e.jsx(Ke,{children:"Newsletters"}),o.map(t=>e.jsx(Fe,{value:t.id,children:t.name},t.id))]})})]})},nt=(a,s,r=!0)=>{const o=a??30,{startDate:t,endDate:i}=c.useMemo(()=>X(o),[o]),n=c.useMemo(()=>{const p={date_from:H(t),date_to:H(i)};return s&&(p.newsletter_id=s),p},[t,i,s]),h=Je({searchParams:n,enabled:r});return r?h:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:h.refetch}},ot=(a,s,r,o=!0)=>{const t=a??30,i=s??"date desc",{startDate:n,endDate:h}=c.useMemo(()=>X(t),[t]),p=c.useMemo(()=>{const u={date_from:H(n),date_to:H(h),order:i};return r&&(u.newsletter_id=r),u},[n,h,i,r]),v=et({searchParams:p,enabled:o});return o?v:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:v.refetch}},it=(a,s=[],r=!0)=>{const o=c.useMemo(()=>{const i={};return a&&(i.newsletter_id=a),s.length>0&&(i.post_ids=s.join(",")),i},[a,s]),t=tt({searchParams:o,enabled:r});return r?t:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:t.refetch}},le=(a,s,r,o=!0)=>{const t=ot(a,s,r,o),i=c.useMemo(()=>t.data?.stats?t.data.stats.map(p=>p.post_id):[],[t.data]),n=it(r,i,o&&i.length>0);return{data:c.useMemo(()=>{if(!t.data?.stats)return;const p=t.data.stats,v=n.data?.stats||[],u=new Map;v.forEach(b=>{u.set(b.post_id,b)});const w=p.map(b=>{const N=u.get(b.post_id);return{...b,total_clicks:N?.total_clicks||0,click_rate:N?.click_rate||0}});return{...t.data,stats:w}},[t.data,n.data]),isLoading:t.isLoading,isClicksLoading:n.isLoading,error:t.error||n.error,isError:t.isError||n.isError,refetch:()=>{t.refetch(),n.refetch()}}},ce=Q.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:o})=>{const t=te(),{settings:i}=K(),n=String(i.find(m=>m.key==="timezone")?.value||"Etc/UTC"),{data:h,isLoading:p,isClicksLoading:v}=le(a,o,s||void 0,!!r),{appSettings:u}=F(),{emailTrackClicks:w,emailTrackOpens:b}=u?.analytics||{},N=c.useMemo(()=>h?.stats||[],[h]),j=b&&w?5:b||w?4:3,S=c.useMemo(()=>e.jsx(e.Fragment,{children:e.jsx($,{className:"last:border-none [&>td]:py-2.5",children:e.jsx(L,{className:"font-medium",colSpan:j,children:e.jsx(be,{className:"mt-5"})})})}),[j]),R=c.useMemo(()=>N.length>0?e.jsx(e.Fragment,{children:N.map(m=>e.jsxs($,{className:"last:border-none [&>td]:py-2.5",children:[e.jsx(L,{className:"font-medium",children:e.jsx("div",{className:"group/link inline-flex items-center gap-2",children:m.post_id?e.jsx(je,{className:"h-auto p-0 text-left whitespace-normal hover:underline!",title:"View post analytics",variant:"link",onClick:()=>{t(`/posts/analytics/${m.post_id}/`,{crossApp:!0})},children:m.post_title}):e.jsx(e.Fragment,{children:m.post_title})})}),e.jsx(L,{className:"text-sm whitespace-nowrap",children:ae(m.send_date,n)}),e.jsx(L,{className:"text-right font-mono text-sm",children:D(m.sent_to)}),b&&e.jsxs(L,{className:"text-right font-mono text-sm",children:[e.jsx("span",{className:"group-hover:hidden",children:_(m.open_rate)}),e.jsx("span",{className:"hidden group-hover:visible! group-hover:block!",children:D(m.total_opens)})]}),w&&e.jsx(L,{className:"text-right font-mono text-sm",children:v?e.jsx("span",{className:"inline-block h-4 w-8 animate-pulse rounded bg-gray-200"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"group-hover:hidden",children:_(m.click_rate)}),e.jsx("span",{className:"hidden group-hover:visible! group-hover:block!",children:D(m.total_clicks)})]})})]},m.post_id))}):e.jsx($,{className:"border-none hover:bg-transparent",children:e.jsx(L,{className:"text-center group-hover:bg-transparent!",colSpan:j,children:e.jsx(re,{className:"size-full py-20",title:`No newsletters ${Z(a)}`,children:e.jsx(ne,{strokeWidth:1.5})})})}),[N,v,t,w,b,a]);return p||!h?S:R});ce.displayName="NewsletterTableRows";const de=Q.memo(({sortBy:a,setSortBy:s,range:r})=>{const o=c.useMemo(()=>e.jsxs(Ie,{children:[e.jsx(Ye,{children:"Top newsletters"}),e.jsxs(Ue,{children:[" Your best performing newsletters ",Z(r)]})]}),[r]),{appSettings:t}=F(),{emailTrackClicks:i,emailTrackOpens:n}=t?.analytics||{};return e.jsx(Ze,{children:e.jsxs($,{children:[e.jsx(P,{className:"min-w-[320px]",variant:"cardhead",children:o}),e.jsx(P,{className:"w-[65px]",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"date desc",children:"Date"})}),e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"sent_to desc",children:"Sent"})}),n&&e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"open_rate desc",children:"Opens"})}),i&&e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"click_rate desc",children:"Clicks"})})]})})});de.displayName="NewsletterTableHeader";const me=Q.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r})=>{const[o,t]=c.useState("open_rate desc");return e.jsx(oe,{className:"w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]","data-testid":"top-newsletters-card",children:e.jsx(ie,{children:e.jsxs(Xe,{children:[e.jsx(de,{range:a,setSortBy:t,sortBy:o}),e.jsx(Qe,{children:e.jsx(ce,{range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:o})})]})})})});me.displayName="TopNewslettersTable";const Zt=()=>{const{range:a,selectedNewsletterId:s}=K(),[r]=se(),{appSettings:o}=F(),t=r.get("tab")||"total-subscribers",{data:i,isLoading:n}=qe({searchParams:{limit:"50"}}),h=!n&&i&&i.newsletters.length>0&&!!s,{data:p,isLoading:v}=nt(a,s||void 0,h||!1),{data:u,isLoading:w,isClicksLoading:b}=le(a,"date asc",s||void 0,h||!1),N=c.useMemo(()=>!i?.newsletters||!s?null:i.newsletters.find(d=>d.id===s)||null,[i,s]),j=c.useMemo(()=>{const d=N?.count?.active_members||p?.stats?.[0]?.total||0;let g=0,y=0;if(u?.stats&&u.stats.length>0){const x=u.stats,C=x.reduce((T,O)=>T+(O.open_rate||0),0),f=x.reduce((T,O)=>T+(O.click_rate||0),0);g=C/x.length,y=f/x.length}return{totalSubscribers:d,avgOpenRate:g,avgClickRate:y}},[N,p,u]),S=c.useMemo(()=>{if(!p?.stats?.[0]?.values||p.stats[0].values.length===0){const{startDate:g,endDate:y}=X(a),x=[],C=g.clone().toDate(),f=y.toDate();for(;C<=f;)x.push({date:C.toISOString().split("T")[0],value:0}),C.setDate(C.getDate()+1);return x}const d=p.stats[0].values;if(d.length===1){const g=d[0],y=new Date,x=a,C=new Date(y.getTime()-x*24*60*60*1e3);return[{...g,date:C.toISOString().split("T")[0]},{...g,date:y.toISOString().split("T")[0]}]}return d},[p,a]),R=c.useMemo(()=>u?.stats?u.stats.map(d=>({post_id:d.post_id,post_title:d.post_title,send_date:d.send_date,sent_to:d.sent_to,total_opens:d.total_opens,open_rate:d.open_rate,total_clicks:d.total_clicks||0,click_rate:d.click_rate||0})):[],[u]),m=v||b||w;return o&&!o.newslettersEnabled?e.jsx(ge,{to:"/analytics"}):e.jsxs(ke,{children:[e.jsx(we,{children:e.jsxs(Ge,{children:[e.jsx(rt,{newsletters:i?.newsletters}),e.jsx(Ne,{})]})}),e.jsx(Se,{isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:e.jsxs(e.Fragment,{children:[e.jsx(oe,{"data-testid":"newsletters-card",children:e.jsx(ie,{children:e.jsx(at,{avgsData:R,initialTab:t,isAvgsLoading:!1,isLoading:m,subscribersData:S,totals:j})})}),e.jsx(me,{range:a,selectedNewsletterId:s,shouldFetchStats:!!h})]})})]})};export{Zt as default};
1
+ import{r as c,c6 as K,aZ as te,bg as se,c7 as F,ao as D,j as e,a_ as ee,an as _,b7 as pe,aW as he,b9 as xe,bb as Y,c8 as fe,be as ae,ak as X,al as H,c9 as ge,t as Q,b_ as be,B as je}from"./index-BkbhBpVC.js";import{s as ve,g as Z,S as ke,a as we,D as Ne,b as Se}from"./stats-view-DubukX9V.js";import{C as _e,a as ye,R as Ce,B as Te}from"./chart-CUKSNmKY.js";import{E as re}from"./empty-indicator-BvyaMcmw.js";import{T as De,a as Me}from"./tabs-M6kFEqPE.js";import{G as Le,C as Re,X as Oe,Y as Be,a as Ee}from"./gh-chart-JxzKqaoO.js";import{K as U,a as B,b as Pe}from"./kpi-tabs-B3NkaTwb.js";import{B as Ae,S as W}from"./sort-button-7pVgpa0d.js";import{M as ne}from"./mail-ccQhEr7k.js";import{S as ze,a as Ve,b as We,c as $e,d as He,e as Ke,f as Fe}from"./select-BfWJkrKc.js";import{i as Ge,C as oe,c as ie,a as Ie,b as Ye,g as Ue}from"./pagemenu-O_y8Jm4v.js";import{T as Xe,d as Qe,a as Ze,b as $,c as P,e as L}from"./table-qQi9EXB1.js";import{u as qe}from"./newsletters-CSCa3QdE.js";import{e as Je,f as et,g as tt}from"./stats-Yo9Gco0_.js";import"./loader-circle-B1uEfpbZ.js";import"./sprout-CpwUJAPT.js";import"./_baseAssignValue-hdDG700N.js";import"./index-DYE2untj.js";import"./value-BGBiTkF3.js";import"./a-large-small-BiK5_5LV.js";import"./wallet-cards-CVZ99Nm3.js";import"./undo-2-D6ZRqONE.js";import"./upload-BLiT66bJ.js";import"./arrow-right-Bk43nMGd.js";import"./at-sign-DWOf36uj.js";import"./underline-CwuJG-Ql.js";import"./chevron-up-DuaKtE_M.js";import"./circle-alert-bcK_Yqap.js";import"./power-DWm6pts5.js";import"./copy-DVtQi_VJ.js";import"./pin-Bl3nSr7I.js";import"./hash-CJzbTA5k.js";import"./inbox-CVVAkCmd.js";import"./minus-C68D81nx.js";import"./pencil-BcymGPnE.js";import"./square-CDrQjv8R.js";import"./user-round-check-BDomHaso.js";import"./repeat-DQay9e22.js";import"./reply-CoNqmExw.js";import"./rocket-Dne6P_8f.js";import"./tags-DuMshkTz.js";import"./trash-CUqAK3SQ.js";import"./user-round-x-Cc0RL-V9.js";const st=({active:a,payload:s})=>{if(!a||!s?.length)return null;const r=s[0].payload,o=typeof r.send_date=="string"?r.send_date:r.send_date.toISOString().split("T")[0];return e.jsxs("div",{className:"max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[e.jsxs("div",{className:"mb-2 flex w-full flex-col border-b pb-2",children:[e.jsx("span",{className:"text-sm leading-tight font-semibold",children:r.post_title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Sent on ",ae(o)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Sent"}),e.jsx("div",{className:"ml-2 w-full text-right font-mono",children:D(r.sent_to)})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Opens"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_opens)," / "]}),_(r.open_rate)]})]}),e.jsxs("div",{className:"mb-1 flex w-full justify-between",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Clicks"}),e.jsxs("div",{className:"ml-2 w-full text-right font-mono",children:[e.jsxs("span",{className:"text-muted-foreground",children:[D(r.total_clicks)," / "]}),_(r.click_rate)]})]})]})},at=({subscribersData:a,avgsData:s,totals:r,isLoading:o,isAvgsLoading:t,initialTab:i="total-subscribers"})=>{const[n,h]=c.useState(i),[p,v]=c.useState(!1),{range:u}=K(),w=te(),[b]=se(),{appSettings:N}=F(),{emailTrackClicks:j,emailTrackOpens:S}=N?.analytics||{},{totalSubscribers:R,avgOpenRate:m,avgClickRate:d}=r,g=c.useMemo(()=>{if(!a||a.length===0)return[];let l=[];return l=ve(a,u,"value","exact"),l.map(M=>({...M,formattedValue:D(M.value),label:"Total Subscribers"}))},[a,u]),y=c.useMemo(()=>{if(!g||g.length<=1)return{direction:"same",value:"0%"};const l=g[0]?.value??0,k=g[g.length-1]?.value??0;let M="same";k>l?M="up":k<l&&(M="down");let E;if(l===0)E=k===0?"0%":"+100%";else{const A=(k-l)/l*100,z=Math.round(A*10)/10;E=`${A>=0?"+":""}${z}%`}return{direction:M,value:E}},[g]);c.useEffect(()=>{h(i)},[i]);const x=l=>{h(l);const k=new URLSearchParams(b);k.set("tab",l),w(`?${k.toString()}`,{replace:!0})},C={open_rate:{label:"Open rate"}},f=c.useMemo(()=>({"total-subscribers":{color:"var(--chart-darkblue)",datakey:"value"},"avg-open-rate":{color:"var(--chart-blue)",datakey:"open_rate"},"avg-click-rate":{color:"var(--chart-teal)",datakey:"click_rate"}}),[]),{barDomain:T,barTicks:O}=c.useMemo(()=>{if(!s||s.length===0||n==="total-subscribers")return{barDomain:[0,1],barTicks:[0,1]};const l=f[n]?.datakey;if(!l)return{barDomain:[0,1],barTicks:[0,1]};const k=s.map(I=>I[l]).filter(I=>typeof I=="number");if(k.length===0)return{barDomain:[0,1],barTicks:[0,1]};const M=Math.min(...k),E=Math.max(...k),A=Math.floor(M*10)/10,z=Math.ceil(E*10)/10,V=Math.max(0,A),J=z===V?V+.1:z;return{barDomain:[V,J],barTicks:[V,J]}},[s,n,f]);if(o)return e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(ee,{})});let G="grid-cols-3";(!j||!S)&&(G="grid-cols-2"),!j&&!S&&(G="grid-cols-1");const ue=n==="avg-open-rate"&&m>T[0]&&m<T[1]||n==="avg-click-rate"&&d>T[0]&&d<T[1],q=n==="avg-open-rate"?m:d;return e.jsxs(De,{defaultValue:i,variant:"kpis",children:[e.jsxs(Me,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${G}`,children:[e.jsx(U,{className:`${!S&&!j&&"cursor-auto after:hidden"}`,value:"total-subscribers",onClick:()=>{x("total-subscribers")},children:e.jsx(B,{color:f["total-subscribers"].color,"data-testid":"total-subscribers-value",diffDirection:y.direction,diffValue:y.value,label:"Total subscribers",value:D(R)})}),S&&e.jsx(U,{value:"avg-open-rate",onClick:()=>{x("avg-open-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:f["avg-open-rate"].color,label:"Avg. open rate",value:_(m)})}),j&&e.jsx(U,{value:"avg-click-rate",onClick:()=>{x("avg-click-rate")},children:e.jsx(B,{className:t?"opacity-50":"",color:f["avg-click-rate"].color,label:"Avg. click rate",value:_(d)})})]}),e.jsxs(pe,{children:[e.jsx(he,{className:"md:hidden",asChild:!0,children:e.jsxs(Pe,{children:[n==="total-subscribers"&&e.jsx(B,{color:f["total-subscribers"].color,label:"Total subscribers",value:D(R)}),n==="avg-open-rate"&&S&&e.jsx(B,{className:t?"opacity-50":"",color:f["avg-open-rate"].color,label:"Avg. open rate",value:_(m)}),n==="avg-click-rate"&&j&&e.jsx(B,{className:t?"opacity-50":"",color:f["avg-click-rate"].color,label:"Avg. click rate",value:_(d)})]})}),e.jsxs(xe,{align:"end",className:"w-56",children:[e.jsx(Y,{onClick:()=>x("total-subscribers"),children:"Total subscribers"}),S&&e.jsx(Y,{onClick:()=>x("avg-open-rate"),children:"Avg. open rate"}),j&&e.jsx(Y,{onClick:()=>x("avg-click-rate"),children:"Avg. click rate"})]})]}),e.jsxs("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:[n==="total-subscribers"&&e.jsx(Le,{className:"-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full",color:f["total-subscribers"].color,data:g,id:"mrr",range:u}),(n==="avg-open-rate"&&S||n==="avg-click-rate"&&j)&&e.jsx(e.Fragment,{children:t?e.jsx("div",{className:"h-[320px] w-full items-center justify-center",children:e.jsx(ee,{})}):s&&s.length>0?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]",config:C,children:e.jsxs(Ae,{className:p?"cursor-pointer!":"",data:s,margin:{top:20},onClick:l=>{l.activePayload&&l.activePayload[0].payload.post_id&&w(`/posts/analytics/${l.activePayload[0].payload.post_id}`,{crossApp:!0})},onMouseLeave:()=>v(!1),onMouseMove:l=>{v(!!(l.activePayload&&l.activePayload[0].payload.post_id))},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"barGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:f[n].color,stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:f[n].color,stopOpacity:.6})]})}),e.jsx(Re,{horizontal:!0,stroke:"var(--border)",vertical:!1}),e.jsx(Oe,{axisLine:{stroke:"var(--border)",strokeWidth:1},dataKey:"post_id",interval:0,stroke:"var(--border)",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Be,{axisLine:!1,domain:T,tickFormatter:l=>_(l),tickLine:!1,ticks:O,width:fe(O,l=>_(l))}),e.jsx(ye,{content:e.jsx(st,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),ue&&e.jsx(Ce,{label:{value:`${_(q)}`,position:"left",offset:8,fill:"var(--muted-foreground)"},opacity:.5,stroke:"var(--muted-foreground)",strokeDasharray:"4 4",y:q}),e.jsx(Te,{activeBar:{fillOpacity:1},dataKey:f[n].datakey,fill:"url(#barGradient)",fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),e.jsxs("div",{className:"-mt-4 text-center text-sm text-muted-foreground",children:["Newsletters ",n==="avg-open-rate"?"opens":"clicks"," in this period"]})]}):e.jsx(re,{className:"size-full py-20",title:`No newsletters ${Z(u)}`,children:e.jsx(ne,{strokeWidth:1.5})})})]})]})},rt=({newsletters:a})=>{const{selectedNewsletterId:s,setSelectedNewsletterId:r}=K(),o=c.useMemo(()=>a?.filter(t=>t.status==="active")||[],[a]);return c.useEffect(()=>{if(o.length>0&&!s){const t=o.find(i=>i.sort_order===0);r(t?t.id:o[0].id)}},[o,s,r]),o.length<=1?null:e.jsxs(ze,{value:s||"",onValueChange:t=>{r(t)},children:[e.jsxs(Ve,{className:"w-auto",children:[e.jsx(Ee,{className:"mr-2",size:16,strokeWidth:1.5}),e.jsx(We,{placeholder:"Select a newsletter"})]}),e.jsx($e,{align:"end",children:e.jsxs(He,{children:[e.jsx(Ke,{children:"Newsletters"}),o.map(t=>e.jsx(Fe,{value:t.id,children:t.name},t.id))]})})]})},nt=(a,s,r=!0)=>{const o=a??30,{startDate:t,endDate:i}=c.useMemo(()=>X(o),[o]),n=c.useMemo(()=>{const p={date_from:H(t),date_to:H(i)};return s&&(p.newsletter_id=s),p},[t,i,s]),h=Je({searchParams:n,enabled:r});return r?h:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:h.refetch}},ot=(a,s,r,o=!0)=>{const t=a??30,i=s??"date desc",{startDate:n,endDate:h}=c.useMemo(()=>X(t),[t]),p=c.useMemo(()=>{const u={date_from:H(n),date_to:H(h),order:i};return r&&(u.newsletter_id=r),u},[n,h,i,r]),v=et({searchParams:p,enabled:o});return o?v:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:v.refetch}},it=(a,s=[],r=!0)=>{const o=c.useMemo(()=>{const i={};return a&&(i.newsletter_id=a),s.length>0&&(i.post_ids=s.join(",")),i},[a,s]),t=tt({searchParams:o,enabled:r});return r?t:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:t.refetch}},le=(a,s,r,o=!0)=>{const t=ot(a,s,r,o),i=c.useMemo(()=>t.data?.stats?t.data.stats.map(p=>p.post_id):[],[t.data]),n=it(r,i,o&&i.length>0);return{data:c.useMemo(()=>{if(!t.data?.stats)return;const p=t.data.stats,v=n.data?.stats||[],u=new Map;v.forEach(b=>{u.set(b.post_id,b)});const w=p.map(b=>{const N=u.get(b.post_id);return{...b,total_clicks:N?.total_clicks||0,click_rate:N?.click_rate||0}});return{...t.data,stats:w}},[t.data,n.data]),isLoading:t.isLoading,isClicksLoading:n.isLoading,error:t.error||n.error,isError:t.isError||n.isError,refetch:()=>{t.refetch(),n.refetch()}}},ce=Q.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:o})=>{const t=te(),{settings:i}=K(),n=String(i.find(m=>m.key==="timezone")?.value||"Etc/UTC"),{data:h,isLoading:p,isClicksLoading:v}=le(a,o,s||void 0,!!r),{appSettings:u}=F(),{emailTrackClicks:w,emailTrackOpens:b}=u?.analytics||{},N=c.useMemo(()=>h?.stats||[],[h]),j=b&&w?5:b||w?4:3,S=c.useMemo(()=>e.jsx(e.Fragment,{children:e.jsx($,{className:"last:border-none [&>td]:py-2.5",children:e.jsx(L,{className:"font-medium",colSpan:j,children:e.jsx(be,{className:"mt-5"})})})}),[j]),R=c.useMemo(()=>N.length>0?e.jsx(e.Fragment,{children:N.map(m=>e.jsxs($,{className:"last:border-none [&>td]:py-2.5",children:[e.jsx(L,{className:"font-medium",children:e.jsx("div",{className:"group/link inline-flex items-center gap-2",children:m.post_id?e.jsx(je,{className:"h-auto p-0 text-left whitespace-normal hover:underline!",title:"View post analytics",variant:"link",onClick:()=>{t(`/posts/analytics/${m.post_id}/`,{crossApp:!0})},children:m.post_title}):e.jsx(e.Fragment,{children:m.post_title})})}),e.jsx(L,{className:"text-sm whitespace-nowrap",children:ae(m.send_date,n)}),e.jsx(L,{className:"text-right font-mono text-sm",children:D(m.sent_to)}),b&&e.jsxs(L,{className:"text-right font-mono text-sm",children:[e.jsx("span",{className:"group-hover:hidden",children:_(m.open_rate)}),e.jsx("span",{className:"hidden group-hover:visible! group-hover:block!",children:D(m.total_opens)})]}),w&&e.jsx(L,{className:"text-right font-mono text-sm",children:v?e.jsx("span",{className:"inline-block h-4 w-8 animate-pulse rounded bg-gray-200"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"group-hover:hidden",children:_(m.click_rate)}),e.jsx("span",{className:"hidden group-hover:visible! group-hover:block!",children:D(m.total_clicks)})]})})]},m.post_id))}):e.jsx($,{className:"border-none hover:bg-transparent",children:e.jsx(L,{className:"text-center group-hover:bg-transparent!",colSpan:j,children:e.jsx(re,{className:"size-full py-20",title:`No newsletters ${Z(a)}`,children:e.jsx(ne,{strokeWidth:1.5})})})}),[N,v,t,w,b,a]);return p||!h?S:R});ce.displayName="NewsletterTableRows";const de=Q.memo(({sortBy:a,setSortBy:s,range:r})=>{const o=c.useMemo(()=>e.jsxs(Ie,{children:[e.jsx(Ye,{children:"Top newsletters"}),e.jsxs(Ue,{children:[" Your best performing newsletters ",Z(r)]})]}),[r]),{appSettings:t}=F(),{emailTrackClicks:i,emailTrackOpens:n}=t?.analytics||{};return e.jsx(Ze,{children:e.jsxs($,{children:[e.jsx(P,{className:"min-w-[320px]",variant:"cardhead",children:o}),e.jsx(P,{className:"w-[65px]",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"date desc",children:"Date"})}),e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"sent_to desc",children:"Sent"})}),n&&e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"open_rate desc",children:"Opens"})}),i&&e.jsx(P,{className:"w-[90px] text-right",children:e.jsx(W,{activeSortBy:a,setSortBy:s,sortBy:"click_rate desc",children:"Clicks"})})]})})});de.displayName="NewsletterTableHeader";const me=Q.memo(({range:a,selectedNewsletterId:s,shouldFetchStats:r})=>{const[o,t]=c.useState("open_rate desc");return e.jsx(oe,{className:"w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]","data-testid":"top-newsletters-card",children:e.jsx(ie,{children:e.jsxs(Xe,{children:[e.jsx(de,{range:a,setSortBy:t,sortBy:o}),e.jsx(Qe,{children:e.jsx(ce,{range:a,selectedNewsletterId:s,shouldFetchStats:r,sortBy:o})})]})})})});me.displayName="TopNewslettersTable";const Zt=()=>{const{range:a,selectedNewsletterId:s}=K(),[r]=se(),{appSettings:o}=F(),t=r.get("tab")||"total-subscribers",{data:i,isLoading:n}=qe({searchParams:{limit:"50"}}),h=!n&&i&&i.newsletters.length>0&&!!s,{data:p,isLoading:v}=nt(a,s||void 0,h||!1),{data:u,isLoading:w,isClicksLoading:b}=le(a,"date asc",s||void 0,h||!1),N=c.useMemo(()=>!i?.newsletters||!s?null:i.newsletters.find(d=>d.id===s)||null,[i,s]),j=c.useMemo(()=>{const d=N?.count?.active_members||p?.stats?.[0]?.total||0;let g=0,y=0;if(u?.stats&&u.stats.length>0){const x=u.stats,C=x.reduce((T,O)=>T+(O.open_rate||0),0),f=x.reduce((T,O)=>T+(O.click_rate||0),0);g=C/x.length,y=f/x.length}return{totalSubscribers:d,avgOpenRate:g,avgClickRate:y}},[N,p,u]),S=c.useMemo(()=>{if(!p?.stats?.[0]?.values||p.stats[0].values.length===0){const{startDate:g,endDate:y}=X(a),x=[],C=g.clone().toDate(),f=y.toDate();for(;C<=f;)x.push({date:C.toISOString().split("T")[0],value:0}),C.setDate(C.getDate()+1);return x}const d=p.stats[0].values;if(d.length===1){const g=d[0],y=new Date,x=a,C=new Date(y.getTime()-x*24*60*60*1e3);return[{...g,date:C.toISOString().split("T")[0]},{...g,date:y.toISOString().split("T")[0]}]}return d},[p,a]),R=c.useMemo(()=>u?.stats?u.stats.map(d=>({post_id:d.post_id,post_title:d.post_title,send_date:d.send_date,sent_to:d.sent_to,total_opens:d.total_opens,open_rate:d.open_rate,total_clicks:d.total_clicks||0,click_rate:d.click_rate||0})):[],[u]),m=v||b||w;return o&&!o.newslettersEnabled?e.jsx(ge,{to:"/analytics"}):e.jsxs(ke,{children:[e.jsx(we,{children:e.jsxs(Ge,{children:[e.jsx(rt,{newsletters:i?.newsletters}),e.jsx(Ne,{})]})}),e.jsx(Se,{isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:e.jsxs(e.Fragment,{children:[e.jsx(oe,{"data-testid":"newsletters-card",children:e.jsx(ie,{children:e.jsx(at,{avgsData:R,initialTab:t,isAvgsLoading:!1,isLoading:m,subscribersData:S,totals:j})})}),e.jsx(me,{range:a,selectedNewsletterId:s,shouldFetchStats:!!h})]})})]})};export{Zt as default};
@@ -1 +1 @@
1
- import{L as a}from"./index-BOMdiHRG.js";import{s,t as r,L as n,f as i,i as P,j as o,g as Q,k as p}from"./settings-66Zv8QvL.js";import"./index-CFEzD2_M.js";import"./tabs-CL5eaCGL.js";import"./newsletters-DOIL_cOY.js";import"./posts-u-CAKddc.js";import"./typeof-QjJsDpFa.js";import"./tiers-DXKbghdk.js";import"./dropzone-DSPf3N_o.js";import"./index-WKMARia9.js";import"./referrers-DV_Ihg9y.js";import"./select-CPSy44ld.js";import"./chevron-up-CVgBkTk5.js";import"./underline-Bq0P-5Zy.js";import"./toggle-group-DaZKTYDS.js";import"./textarea-DdDuNixZ.js";const c=s({String:r.string,Number:r.number,"True False":r.bool,PropertyName:r.propertyName,Null:r.null,", :":r.separator,"[ ]":r.squareBracket,"{ }":r.brace}),m=a.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[c],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),X=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(O){if(!(O instanceof SyntaxError))throw O;const e=g(O,t.state.doc);return[{from:e,message:O.message,severity:"error",to:e}]}return[]};function g(t,O){let e;return(e=t.message.match(/at position (\d+)/))?Math.min(+e[1],O.length):(e=t.message.match(/at line (\d+) column (\d+)/))?Math.min(O.line(+e[1]).from+ +e[2]-1,O.length):0}const l=i.define({name:"json",parser:m.configure({props:[P.add({Object:o({except:/^\s*\}/}),Array:o({except:/^\s*\]/})}),Q.add({"Object Array":p})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Y(){return new n(l)}export{Y as json,l as jsonLanguage,X as jsonParseLinter};
1
+ import{L as a}from"./index-DQZp_NsL.js";import{s,t as r,L as n,f as i,i as P,j as o,g as Q,k as p}from"./settings-rRY210wx.js";import"./index-BkbhBpVC.js";import"./tabs-M6kFEqPE.js";import"./newsletters-CSCa3QdE.js";import"./posts-BZaw4-dc.js";import"./typeof-QjJsDpFa.js";import"./tiers-D2DYHaeO.js";import"./dropzone-Cs4DrURS.js";import"./index-DYE2untj.js";import"./referrers-BsZ85Z0a.js";import"./select-BfWJkrKc.js";import"./chevron-up-DuaKtE_M.js";import"./underline-CwuJG-Ql.js";import"./toggle-group-GYp_w6Po.js";import"./textarea-CGBp9nOo.js";const c=s({String:r.string,Number:r.number,"True False":r.bool,PropertyName:r.propertyName,Null:r.null,", :":r.separator,"[ ]":r.squareBracket,"{ }":r.brace}),m=a.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[c],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),X=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(O){if(!(O instanceof SyntaxError))throw O;const e=g(O,t.state.doc);return[{from:e,message:O.message,severity:"error",to:e}]}return[]};function g(t,O){let e;return(e=t.message.match(/at position (\d+)/))?Math.min(+e[1],O.length):(e=t.message.match(/at line (\d+) column (\d+)/))?Math.min(O.line(+e[1]).from+ +e[2]-1,O.length):0}const l=i.define({name:"json",parser:m.configure({props:[P.add({Object:o({except:/^\s*\}/}),Array:o({except:/^\s*\]/})}),Q.add({"Object Array":p})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function Y(){return new n(l)}export{Y as json,l as jsonLanguage,X as jsonParseLinter};