ghost 6.55.0 → 6.56.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 (280) hide show
  1. package/components/tryghost-custom-field-types-0.0.0.tgz +0 -0
  2. package/components/tryghost-kg-default-cards-10.3.3.tgz +0 -0
  3. package/components/tryghost-kg-default-nodes-2.1.4.tgz +0 -0
  4. package/components/tryghost-kg-default-transforms-1.3.3.tgz +0 -0
  5. package/components/tryghost-kg-html-to-lexical-1.3.3.tgz +0 -0
  6. package/components/tryghost-kg-lexical-html-renderer-1.4.3.tgz +0 -0
  7. package/components/tryghost-nql-string-0.0.0.tgz +0 -0
  8. package/core/built/admin/assets/{Combination-CJG7Flp-.js → Combination-BCm9FL4o.js} +1 -1
  9. package/core/built/admin/assets/{PolarAngleAxis-BGjf7sBu.js → PolarAngleAxis-C4qtHy1B.js} +1 -1
  10. package/core/built/admin/assets/{RadialBarChart-zeFf9mBz.js → RadialBarChart-Bh09Stsj.js} +1 -1
  11. package/core/built/admin/assets/{account-migration-sjHLx5dy.js → account-migration-D3O_yVck.js} +1 -1
  12. package/core/built/admin/assets/activitypub/{account-migration-DoYXtnZ8.js → account-migration-D8FbP-Z-.js} +7 -7
  13. package/core/built/admin/assets/activitypub/activitypub.js +6 -6
  14. package/core/built/admin/assets/activitypub/{avatar-B3DEDB1l.js → avatar-11EA1VSs.js} +2 -2
  15. package/core/built/admin/assets/activitypub/{avatar-flipboard-Cqrg0XMx.js → avatar-flipboard-jfbLG-xe.js} +2 -2
  16. package/core/built/admin/assets/activitypub/{bluesky-sharing-Bxeh6MKW.js → bluesky-sharing-f1jTQe2P.js} +16 -16
  17. package/core/built/admin/assets/activitypub/{content-formatters-BpQARh28.js → content-formatters-nmTOPY9M.js} +3 -3
  18. package/core/built/admin/assets/activitypub/{copy-D9UWIAan.js → copy-BCwo9ep3.js} +2 -2
  19. package/core/built/admin/assets/activitypub/{dist-D8sFfdpC.js → dist-BEfX-0aW.js} +12 -12
  20. package/core/built/admin/assets/activitypub/{domain-CWueFW6q.js → domain-AaDlZlrA.js} +9 -9
  21. package/core/built/admin/assets/activitypub/{edit-profile-BGxPU7N5.js → edit-profile-DPi8Tl5M.js} +945 -945
  22. package/core/built/admin/assets/activitypub/{explore-DBK-u0Ch.js → explore-CxTzjILQ.js} +8 -8
  23. package/core/built/admin/assets/activitypub/{feed-Bcir5RQZ.js → feed-DPv5x2MX.js} +33 -33
  24. package/core/built/admin/assets/activitypub/{field-BV-CIT3d.js → field-DbgA8lat.js} +3 -3
  25. package/core/built/admin/assets/activitypub/{hash-BC9Q0N4c.js → hash-BWuZoYkA.js} +2 -2
  26. package/core/built/admin/assets/activitypub/{inbox-DQ4ZnC1m.js → inbox-35VDQ2K2.js} +2 -2
  27. package/core/built/admin/assets/activitypub/{inbox-yC0nfvzl.js → inbox-DSrF_i1O.js} +85 -85
  28. package/core/built/admin/assets/activitypub/{label-DTRS9TDk.js → label-CPjFBbo7.js} +3 -3
  29. package/core/built/admin/assets/activitypub/layout-CTgrezN7.js +1 -0
  30. package/core/built/admin/assets/activitypub/{moderation-Dwl9t0pb.js → moderation-BkDC1XVZ.js} +11 -11
  31. package/core/built/admin/assets/activitypub/{note-B-zKsZ7r.js → note-xEyH4xT-.js} +7 -7
  32. package/core/built/admin/assets/activitypub/{notifications-DjJZD54t.js → notifications-DClaL3ui.js} +9 -9
  33. package/core/built/admin/assets/activitypub/{preferences-CoU8vs6d.js → preferences-DpnOa-4Z.js} +20 -20
  34. package/core/built/admin/assets/activitypub/{profile-BAsaJekx.js → profile-Dvi9mz-6.js} +237 -237
  35. package/core/built/admin/assets/activitypub/{reply-CpdMeAO5.js → reply-Cs9ySd6Z.js} +2 -2
  36. package/core/built/admin/assets/activitypub/{routes-CLH3OVTP.js → routes-DFBeTnfn.js} +1139 -1150
  37. package/core/built/admin/assets/activitypub/{separator-BI1FLsYM.js → separator-C5u_VjzY.js} +3 -3
  38. package/core/built/admin/assets/activitypub/{settings-DA6pNJ-Q.js → settings-CV2fFu6D.js} +13 -13
  39. package/core/built/admin/assets/activitypub/{site-CQD42Pw5.js → site-_TgDd_EM.js} +81 -81
  40. package/core/built/admin/assets/activitypub/{step-1-DIDg4aHb.js → step-1-BfnNL2oF.js} +5 -5
  41. package/core/built/admin/assets/activitypub/{step-2-BfGe8BYt.js → step-2-DLndZkO-.js} +6 -6
  42. package/core/built/admin/assets/activitypub/{step-3-mE9spAqw.js → step-3-A-PZTtRE.js} +10 -10
  43. package/core/built/admin/assets/activitypub/{tabs-Cg0saow1.js → tabs-BUbz7tea.js} +317 -315
  44. package/core/built/admin/assets/activitypub/{topic-filter-DLHBZT93.js → topic-filter-BdX_xYYT.js} +3 -3
  45. package/core/built/admin/assets/activitypub/{use-activity-pub-queries-VzbN99u_.js → use-activity-pub-queries-EwuRemHh.js} +2 -2
  46. package/core/built/admin/assets/activitypub/{use-navigate-with-base-path-CAwXTmqH.js → use-navigate-with-base-path-cy4ACBc4.js} +92 -90
  47. package/core/built/admin/assets/activitypub/{use-reply-chain-data-Br4aOWOh.js → use-reply-chain-data-CyFcGfan.js} +5 -5
  48. package/core/built/admin/assets/activitypub/{x-C8tAnXly.js → x-7zk8mV2p.js} +2 -2
  49. package/core/built/admin/assets/{audience-DjEWNhp3.js → audience-CkBb2LlO.js} +1 -1
  50. package/core/built/admin/assets/{automated-emails-DRy7qY-J.js → automated-emails-6t2bIRWf.js} +1 -1
  51. package/core/built/admin/assets/{automations-Bx3VcFIL.js → automations-cMllU545.js} +1 -1
  52. package/core/built/admin/assets/{bluesky-sharing-ClMd0-Ft.js → bluesky-sharing-DPGpyD-G.js} +1 -1
  53. package/core/built/admin/assets/{box-BWbhXh21.js → box-By_EgGtm.js} +1 -1
  54. package/core/built/admin/assets/{breadcrumb-BD0U2ygg.js → breadcrumb-DIfcF5ow.js} +1 -1
  55. package/core/built/admin/assets/build-CsiH26uS.js +1 -0
  56. package/core/built/admin/assets/{card-DGoDJzrn.js → card-aUHX0hyR.js} +1 -1
  57. package/core/built/admin/assets/{chart-BuRT2Y6p.js → chart-BnXyfH11.js} +1 -1
  58. package/core/built/admin/assets/{chart-helpers-fjQKRVyY.js → chart-helpers-DV0FkdcD.js} +1 -1
  59. package/core/built/admin/assets/{checkbox-CWa28lgO.js → checkbox-BIl077a0.js} +1 -1
  60. package/core/built/admin/assets/{chunk.481.6c7395a49484bb4583aa.js → chunk.332.05991a101d67f732dec3.js} +43 -42
  61. package/core/built/admin/assets/chunk.524.87b52f4fada529df2c4c.js +25 -0
  62. package/core/built/admin/assets/chunk.582.340bcca873e806cbd4bb.js +27 -0
  63. package/core/built/admin/assets/{code-editor-view-CCr0rBWS.js → code-editor-view-C0aWNwdl.js} +1 -1
  64. package/core/built/admin/assets/comments-qwhIjH3c.js +1 -0
  65. package/core/built/admin/assets/{container-BYz2Ed39.js → container-LiZf3XdY.js} +1 -1
  66. package/core/built/admin/assets/{data-list-16rkJYYi.js → data-list-CupF7bjM.js} +1 -1
  67. package/core/built/admin/assets/{date-range-select-BFp58EMk.js → date-range-select-dXc-GsVe.js} +1 -1
  68. package/core/built/admin/assets/{disabled-sources-indicator-CUxMfiPa.js → disabled-sources-indicator-DYAXW-6V.js} +1 -1
  69. package/core/built/admin/assets/dist-BUKmD51u.js +1 -0
  70. package/core/built/admin/assets/{dist-2Tnz2Yfq.js → dist-CNlMj7ML.js} +1 -1
  71. package/core/built/admin/assets/{dist-DGzPJ_bO.js → dist-Cb5RSHSg.js} +1 -1
  72. package/core/built/admin/assets/{dist-P_ohUlTi.js → dist-CqO2lWS0.js} +1 -1
  73. package/core/built/admin/assets/domain-B5ogXUBa.js +1 -0
  74. package/core/built/admin/assets/{dropzone-DlK-K2DQ.js → dropzone-BnFG7dDP.js} +1 -1
  75. package/core/built/admin/assets/{edit-profile-BKT-REJw.js → edit-profile-B07jCZy9.js} +1 -1
  76. package/core/built/admin/assets/editor-DDYSOXGN.js +8 -0
  77. package/core/built/admin/assets/{empty-indicator-oX1u1Pkn.js → empty-indicator-WB1WgT9h.js} +1 -1
  78. package/core/built/admin/assets/{explore-ClUpJZOp.js → explore-Ca1y8HW_.js} +1 -1
  79. package/core/built/admin/assets/{feed-DF92dUMP.js → feed-x4iFMBP4.js} +1 -1
  80. package/core/built/admin/assets/{field-Do7lieBA.js → field-ChCAabZg.js} +1 -1
  81. package/core/built/admin/assets/filter-sources-LdtH1e-T.js +1 -0
  82. package/core/built/admin/assets/filters-CLehPo_D.js +1 -0
  83. package/core/built/admin/assets/filters-CjVKRP8U.js +1 -0
  84. package/core/built/admin/assets/{ghost-c4057474943effc568c5659ccc4909d7.js → ghost-7f01131115186d1af84ead76e79646dd.js} +149 -129
  85. package/core/built/admin/assets/{ghost-a9c788f6f0b1ea6cf0f14ca4b13f4496.css → ghost-d38c30b866e59f2e06a357b5eb844fe5.css} +1 -1
  86. package/core/built/admin/assets/{ghost-dark-db36d795d21c61426837df40af270966.css → ghost-dark-1bffd5099ba7a749303133efacf8480b.css} +1 -1
  87. package/core/built/admin/assets/{gift-link-modal-f9VIMNDv.js → gift-link-modal-Buqh2vXh.js} +1 -1
  88. package/core/built/admin/assets/{growth-B3I6gNLm.js → growth-DajOBdN0.js} +1 -1
  89. package/core/built/admin/assets/{growth-CVw1My4S.js → growth-Dy2UOSay.js} +2 -2
  90. package/core/built/admin/assets/{inbox-CFBSu4Ed.js → inbox-BUOLDoji.js} +12 -12
  91. package/core/built/admin/assets/index-08n05-rc.js +67 -0
  92. package/core/built/admin/assets/index-DgUzgFvS.css +1 -0
  93. package/core/built/admin/assets/{inline-EMAm3okk.js → inline-Cw-gigDW.js} +1 -1
  94. package/core/built/admin/assets/input-group-uSK3XT7b.js +1 -0
  95. package/core/built/admin/assets/{input-surface-BpAjZXY5.js → input-surface-BdOe4KzO.js} +1 -1
  96. package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +9535 -9527
  97. package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +124 -124
  98. package/core/built/admin/assets/{koenig-lexical-f8vHRYvz.js → koenig-lexical-BFc4yFed.js} +86 -86
  99. package/core/built/admin/assets/{kpi-card-DSap9rAy.js → kpi-card-BN-E6WYX.js} +1 -1
  100. package/core/built/admin/assets/{kpi-card-DU0rn9Cj.js → kpi-card-CCt-qeWD.js} +1 -1
  101. package/core/built/admin/assets/{kpi-helpers-Dz33AV6h.js → kpi-helpers-DlxTbTs4.js} +1 -1
  102. package/core/built/admin/assets/{kpi-tabs-BtTTrKvJ.js → kpi-tabs-BlcUttpn.js} +1 -1
  103. package/core/built/admin/assets/{label-DS8Mi6G5.js → label-AVrxwmsz.js} +1 -1
  104. package/core/built/admin/assets/{label-picker-1DvSuLA1.js → label-picker-DVnpu_IF.js} +1 -1
  105. package/core/built/admin/assets/labels-DAIqKed7.js +1 -0
  106. package/core/built/admin/assets/layout-B0YLh7R9.js +1 -0
  107. package/core/built/admin/assets/link-helpers-D9LsDOkG.js +1 -0
  108. package/core/built/admin/assets/{list-page-B6ANtzkd.js → list-page-CdsnQR9N.js} +1 -1
  109. package/core/built/admin/assets/member-custom-fields-C8NpZYza.js +1 -0
  110. package/core/built/admin/assets/member-detail-CIVAdKXf.js +1 -0
  111. package/core/built/admin/assets/{members-CQpVFJu4.js → members-oLPiSkXD.js} +2 -2
  112. package/core/built/admin/assets/modals-CB7v-k3T.js +31 -0
  113. package/core/built/admin/assets/{moderation-DySbgyUS.js → moderation-CQ3urTFE.js} +1 -1
  114. package/core/built/admin/assets/newsletter-rbeDX9Wk.js +1 -0
  115. package/core/built/admin/assets/newsletters-vt3Ni1Ov.js +1 -0
  116. package/core/built/admin/assets/{note-C8kxrz6w.js → note-Dk877BTv.js} +1 -1
  117. package/core/built/admin/assets/{notifications-CgtSfX7t.js → notifications-CPlLjPxO.js} +1 -1
  118. package/core/built/admin/assets/{onboarding-route-4qtziA9d.js → onboarding-route-DdStOtjy.js} +1 -1
  119. package/core/built/admin/assets/{overview-Bf2sbznq.js → overview--4V-kx9c.js} +1 -1
  120. package/core/built/admin/assets/overview-DSLv30oz.js +1 -0
  121. package/core/built/admin/assets/{page-header-B3Wb9Jqv.js → page-header-pp4dWmOS.js} +1 -1
  122. package/core/built/admin/assets/{post-analytics-We-ko5Cb.js → post-analytics-BMJrI81R.js} +1 -1
  123. package/core/built/admin/assets/post-analytics-header-pU2m9ZuV.js +1 -0
  124. package/core/built/admin/assets/{post-analytics-provider-B6UynTGb.js → post-analytics-provider-Btml5vJI.js} +1 -1
  125. package/core/built/admin/assets/{post-share-modal-DFfO93_0.js → post-share-modal-AcUZkbfL.js} +1 -1
  126. package/core/built/admin/assets/preferences-Ru4CRPHC.js +5 -0
  127. package/core/built/admin/assets/profile-BNb1oj7D.js +1 -0
  128. package/core/built/admin/assets/{router-provider-C1R4AZ2o.js → router-provider-BmEZf6c6.js} +1 -1
  129. package/core/built/admin/assets/select-B0HteHrp.js +1 -0
  130. package/core/built/admin/assets/settings-B1C9Q3wo.js +4 -0
  131. package/core/built/admin/assets/{settings-WXNeWyU1.js → settings-BGgk7oCI.js} +1 -1
  132. package/core/built/admin/assets/{shade-app-B3heOAfz-CGXQwWeO.js → shade-app-B3heOAfz-BhQXxNkT.js} +1 -1
  133. package/core/built/admin/assets/{share-modal-DsgW3wbg.js → share-modal-BeuydaBf.js} +1 -1
  134. package/core/built/admin/assets/social-urls-DA2lXrhW.js +8 -0
  135. package/core/built/admin/assets/{sort-button-Bb_FCl7e.js → sort-button-Df4t2AL8.js} +1 -1
  136. package/core/built/admin/assets/{source-icon-BeaRxUn9.js → source-icon-ajoaKb41.js} +1 -1
  137. package/core/built/admin/assets/{stack-xiN0eQ6Z.js → stack-CIfOAAVf.js} +1 -1
  138. package/core/built/admin/assets/{stats-Bjj_kmJ1.js → stats-C_lfxZAw.js} +1 -1
  139. package/core/built/admin/assets/{stats-view-BxPbW6K1.js → stats-view-Cxot1iD8.js} +1 -1
  140. package/core/built/admin/assets/{step-1-B1e3-1F8.js → step-1-ogAA4lDr.js} +1 -1
  141. package/core/built/admin/assets/{step-2-C5WaeBJo.js → step-2-C5Xini-7.js} +1 -1
  142. package/core/built/admin/assets/{step-3-B46iVPwu.js → step-3-CZv1FV81.js} +2 -2
  143. package/core/built/admin/assets/{switch-z5Y6Uzt6.js → switch-CyQcwMAv.js} +1 -1
  144. package/core/built/admin/assets/{table-CB-4_HBJ.js → table-DFj1wiYv.js} +1 -1
  145. package/core/built/admin/assets/{tabs-CCEgKYzq.js → tabs-D4y1gqUd.js} +1 -1
  146. package/core/built/admin/assets/{tags-Cg2VJGmG.js → tags-Dmft-Y4O.js} +1 -1
  147. package/core/built/admin/assets/{text-DwtjwGkh.js → text-DU9Hv33_.js} +1 -1
  148. package/core/built/admin/assets/textarea-d9qEkMOP.js +1 -0
  149. package/core/built/admin/assets/{toggle-group-b3IlxvhV.js → toggle-group-R2QMFvXW.js} +1 -1
  150. package/core/built/admin/assets/{topic-filter-DAFT87tQ.js → topic-filter-DGDxDalo.js} +1 -1
  151. package/core/built/admin/assets/{use-analytics-data-S0FTd43s.js → use-analytics-data-C76v4LIp.js} +1 -1
  152. package/core/built/admin/assets/use-filter-params-WrdhAISv.js +1 -0
  153. package/core/built/admin/assets/{use-growth-stats-CIaiHOVb.js → use-growth-stats-aNXJOmQr.js} +1 -1
  154. package/core/built/admin/assets/{use-post-referrers-Cq2vBPrA.js → use-post-referrers-CG0SZioj.js} +1 -1
  155. package/core/built/admin/assets/{use-reply-chain-data-DBDRtGu-.js → use-reply-chain-data-RLdPKRmS.js} +1 -1
  156. package/core/built/admin/assets/{use-simple-pagination-CjYNxdwe.js → use-simple-pagination-DgcF69KI.js} +1 -1
  157. package/core/built/admin/assets/{use-tinybird-query-falHAtuK.js → use-tinybird-query-C1R_Kbmy.js} +1 -1
  158. package/core/built/admin/assets/{use-tinybird-token-D7-8ND1y.js → use-tinybird-token-C9fPjVM_.js} +1 -1
  159. package/core/built/admin/assets/{virtual-list-CvnC9zF2.js → virtual-list-BmTUzeoF.js} +1 -1
  160. package/core/built/admin/assets/{web-B_5GZRvH.js → web-BqW0b0_C.js} +1 -1
  161. package/core/built/admin/assets/web-Cy5GKMWM.js +2 -0
  162. package/core/built/admin/index.html +16 -16
  163. package/core/frontend/services/data/fetch-data.js +10 -5
  164. package/core/frontend/services/routing/api-adapter.js +115 -0
  165. package/core/frontend/services/routing/api-adapter.ts +157 -0
  166. package/core/frontend/services/routing/collection-router.js +5 -3
  167. package/core/frontend/services/routing/controllers/index.js +1 -1
  168. package/core/frontend/services/routing/controllers/rss.js +26 -31
  169. package/core/frontend/services/routing/controllers/rss.ts +66 -0
  170. package/core/frontend/services/routing/controllers/static.js +8 -7
  171. package/core/frontend/services/routing/parent-router.js +17 -4
  172. package/core/frontend/services/routing/permalink-adapter.js +26 -0
  173. package/core/frontend/services/routing/permalink-adapter.ts +23 -0
  174. package/core/frontend/services/routing/registry.js +59 -33
  175. package/core/frontend/services/routing/router-manager.js +9 -13
  176. package/core/frontend/services/routing/static-routes-router.js +4 -4
  177. package/core/frontend/services/routing/taxonomy-router.js +6 -2
  178. package/core/server/data/migrations/versions/6.56/2026-08-03-19-27-51-add-automation-run-step-id-to-automated-email-recipients.js +8 -0
  179. package/core/server/data/migrations/versions/6.56/2026-08-04-14-42-39-restrict-notification-add-permission-to-administrators.js +12 -0
  180. package/core/server/data/schema/fixtures/fixtures.json +2 -2
  181. package/core/server/data/schema/schema.js +1 -0
  182. package/core/server/models/post.js +10 -1
  183. package/core/server/services/automations/automations-repository.ts +3 -1
  184. package/core/server/services/automations/database-automations-repository.js +33 -14
  185. package/core/server/services/automations/database-automations-repository.ts +41 -15
  186. package/core/server/services/automations/get-scheduler-idempotency-key.js +13 -0
  187. package/core/server/services/automations/get-scheduler-idempotency-key.ts +8 -0
  188. package/core/server/services/automations/poll.js +3 -1
  189. package/core/server/services/automations/poll.ts +4 -1
  190. package/core/server/services/automations/service.js +5 -1
  191. package/core/server/services/automations/service.ts +5 -1
  192. package/core/server/services/gift-links/CONTEXT.md +9 -0
  193. package/core/server/services/gifts/CONTEXT.md +55 -0
  194. package/core/server/services/gifts/README.md +28 -0
  195. package/core/server/services/gifts/gift-bookshelf-repository.js +65 -45
  196. package/core/server/services/gifts/gift-bookshelf-repository.ts +203 -74
  197. package/core/server/services/gifts/gift-checkout-adapter.js +59 -0
  198. package/core/server/services/gifts/gift-checkout-offer.js +74 -0
  199. package/core/server/services/gifts/gift-checkout-offer.ts +127 -0
  200. package/core/server/services/gifts/gift-codec.js +63 -0
  201. package/core/server/services/gifts/gift-codec.ts +62 -0
  202. package/core/server/services/gifts/gift-controller.js +6 -31
  203. package/core/server/services/gifts/gift-controller.ts +6 -69
  204. package/core/server/services/gifts/gift-email-service.ts +3 -2
  205. package/core/server/services/gifts/gift-schema.js +34 -0
  206. package/core/server/services/gifts/gift-schema.ts +39 -0
  207. package/core/server/services/gifts/gift-service-wrapper.js +13 -11
  208. package/core/server/services/gifts/gift-service.js +265 -52
  209. package/core/server/services/gifts/gift-service.ts +431 -97
  210. package/core/server/services/gifts/gift.ts +16 -39
  211. package/core/server/services/link-tracking/link-click-repository.js +6 -1
  212. package/core/server/services/link-tracking/link-click-tracking-service.js +12 -3
  213. package/core/server/services/member-welcome-emails/member-welcome-email-renderer.js +4 -3
  214. package/core/server/services/member-welcome-emails/service.js +7 -3
  215. package/core/server/services/members/api.js +1 -2
  216. package/core/server/services/members/import-export/import/importer.ts +3 -2
  217. package/core/server/services/members/import-export/index.js +10 -2
  218. package/core/server/services/members/import-export/index.ts +14 -4
  219. package/core/server/services/members/members-api/controllers/router-controller.js +38 -36
  220. package/core/server/services/members/members-api/members-api.js +13 -7
  221. package/core/server/services/members/members-api/repositories/event-repository.js +4 -94
  222. package/core/server/services/members/members-api/services/member-bread-service.js +3 -3
  223. package/core/server/services/members/members-api/services/payments-service.js +6 -68
  224. package/core/server/services/members-custom-fields/schema.js +8 -1
  225. package/core/server/services/members-custom-fields/schema.ts +8 -0
  226. package/core/server/services/members-custom-fields/values-service.js +118 -2
  227. package/core/server/services/members-custom-fields/values-service.ts +134 -4
  228. package/core/server/services/oembed/oembed-service.js +44 -3
  229. package/core/server/services/posts/posts-service.js +11 -0
  230. package/core/server/services/route-settings/dynamic-routing-service.js +1 -3
  231. package/core/server/services/route-settings/route-settings-parser.js +25 -25
  232. package/core/server/services/route-settings/route-settings-parser.ts +27 -27
  233. package/core/server/services/route-settings/validation-errors.js +68 -4
  234. package/core/server/services/route-settings/validation-errors.ts +79 -4
  235. package/core/server/services/stats/posts-stats-service.js +27 -23
  236. package/core/server/services/stripe/services/webhook/charge-refunded-event-service.js +1 -1
  237. package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +16 -4
  238. package/core/server/services/stripe/stripe-api.js +10 -0
  239. package/core/server/web/gift-preview/controller.js +10 -25
  240. package/core/shared/labs.js +2 -2
  241. package/package.json +10 -9
  242. package/pnpm-lock.yaml +28 -18
  243. package/pnpm-workspace.yaml +5 -4
  244. package/components/tryghost-kg-default-nodes-2.1.3.tgz +0 -0
  245. package/core/built/admin/assets/activitypub/layout-qx-bUL1k.js +0 -1
  246. package/core/built/admin/assets/chunk.524.cffd399783a519e404a9.js +0 -25
  247. package/core/built/admin/assets/chunk.582.eebf0d0b2d202bb746a5.js +0 -27
  248. package/core/built/admin/assets/comments-DyUSMUdj.js +0 -1
  249. package/core/built/admin/assets/dist-CjY-f5Z1.js +0 -1
  250. package/core/built/admin/assets/domain-C0bV2UV8.js +0 -1
  251. package/core/built/admin/assets/editor-Dp865O-4.js +0 -8
  252. package/core/built/admin/assets/filter-sources-BV2rnpfA.js +0 -1
  253. package/core/built/admin/assets/filters-CUXJ2Nm9.js +0 -1
  254. package/core/built/admin/assets/filters-DfbIWc_l.js +0 -1
  255. package/core/built/admin/assets/index-9Cw8z3rA.css +0 -1
  256. package/core/built/admin/assets/index-BGG7NckO.js +0 -67
  257. package/core/built/admin/assets/input-group-BSgG_lVw.js +0 -1
  258. package/core/built/admin/assets/labels-CDSUt4J_.js +0 -1
  259. package/core/built/admin/assets/layout-yQEi2qDM.js +0 -1
  260. package/core/built/admin/assets/link-helpers-7EYqvvHs.js +0 -1
  261. package/core/built/admin/assets/member-custom-fields-yOMHyAg9.js +0 -1
  262. package/core/built/admin/assets/member-detail-BAq7gDaa.js +0 -1
  263. package/core/built/admin/assets/modals-ReORvWnu.js +0 -31
  264. package/core/built/admin/assets/newsletter-CJQvtHqN.js +0 -1
  265. package/core/built/admin/assets/newsletters-B3QQXfGT.js +0 -1
  266. package/core/built/admin/assets/nql-BsgFMd93.js +0 -1
  267. package/core/built/admin/assets/overview-CBfePxcr.js +0 -1
  268. package/core/built/admin/assets/post-analytics-header-Bmc9su6q.js +0 -1
  269. package/core/built/admin/assets/preferences-DJPfHEGu.js +0 -5
  270. package/core/built/admin/assets/profile-DqBQp-gT.js +0 -1
  271. package/core/built/admin/assets/select-C5_xEt5b.js +0 -1
  272. package/core/built/admin/assets/settings-BwiVIXau.js +0 -4
  273. package/core/built/admin/assets/social-urls-BQPFEk1_.js +0 -8
  274. package/core/built/admin/assets/textarea-Bjccvh_E.js +0 -1
  275. package/core/built/admin/assets/use-filter-params-Gpoq2E1L.js +0 -1
  276. package/core/built/admin/assets/web-jFYWCKDn.js +0 -2
  277. package/core/server/services/gifts/gift-repository.js +0 -2
  278. package/core/server/services/gifts/gift-repository.ts +0 -29
  279. package/core/server/services/route-settings/activation-bridge.js +0 -174
  280. package/core/server/services/route-settings/activation-bridge.ts +0 -250
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./dist-Ndy-PuGN.js";import{i,n as a,r as o,t as s}from"./tabs-CCEgKYzq.js";import{B as c,Hn as l,Ir as u,Jt as d,Lt as f,Rt as p,St as m,U as h,Vn as g,bt as _,et as v,ft as y,ir as b,js as x,rt as S,xt as C,ys as w,yt as T}from"./index-BGG7NckO.js";import"./layout-yQEi2qDM.js";var E=e(t(),1),D=n(),O=()=>{let{data:e,isLoading:t}=C(`index`),{data:n,isLoading:O}=m(`index`),k=t?[,,,,,].fill({apId:``,name:``,handle:``,avatarUrl:``}):e?.pages.flatMap(e=>e.accounts)??[],A=O?[,,,,,].fill({apId:``,name:``}):n?.pages.flatMap(e=>e.domains)??[],j=_(`index`),M=p(`index`),[N,P]=(0,E.useState)(new Set),F=T(`index`),I=f(`index`),[L,R]=(0,E.useState)(new Set),[z,B]=(0,E.useState)(null),V=d(),H=e=>{P(t=>{let n=new Set([...t]);return n.add(e.apId),n}),M.mutate(e),r.success(`User unblocked`)},U=e=>{P(t=>{let n=new Set([...t]);return n.delete(e.apId),n}),j.mutate(e),r.success(`User blocked`)},W=e=>{R(t=>{let n=new Set([...t]);return n.add(e.url),n}),I.mutate({url:e.url}),r.success(`Domain unblocked`)},G=e=>{R(t=>{let n=new Set([...t]);return n.delete(e.url),n}),F.mutate({url:e.url}),r.success(`Domain blocked`)};return(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`mx-auto max-w-[620px] py-[min(4vh,48px)]`,children:[(0,D.jsx)(`div`,{className:`flex items-center justify-between gap-8`,children:(0,D.jsx)(x,{children:`Moderation`})}),(0,D.jsx)(`div`,{className:`mt-6`,children:(0,D.jsxs)(s,{defaultValue:`blocked_users`,variant:`underline`,children:[(0,D.jsxs)(o,{children:[(0,D.jsx)(i,{value:`blocked_users`,children:`Blocked users`}),(0,D.jsx)(i,{value:`blocked_domains`,children:`Blocked domains`})]}),(0,D.jsx)(a,{className:`mt-2`,value:`blocked_users`,children:!t&&k.length===0?(0,D.jsxs)(g,{children:[(0,D.jsx)(l,{children:(0,D.jsx)(w,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block someone, they won't be able to follow you or interact with your content on the social web.`})})]}):k.map((e,n)=>(0,D.jsx)(S,{actor:e,isCurrentUser:!0,children:(0,D.jsx)(`div`,{children:(0,D.jsxs)(h,{onClick:t?void 0:()=>v(e.handle,V),children:[(0,D.jsx)(y,{author:{icon:{url:e.avatarUrl},name:e.name,handle:e.handle}}),(0,D.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:t?(0,D.jsx)(b,{className:`w-24`}):e.name}),(0,D.jsx)(`span`,{className:`block truncate text-sm text-gray-600`,children:t?(0,D.jsx)(b,{className:`w-40`}):e.handle})]}),N.has(e.apId)?(0,D.jsx)(u,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:t=>{t.stopPropagation(),U(e)},children:`Block`}):t?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(b,{})}):(0,D.jsx)(u,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:t=>{t.stopPropagation(),H(e)},onMouseEnter:()=>B(e.apId),onMouseLeave:()=>B(null),children:z===e.apId?`Unblock`:`Blocked`})]})})},e.apId?e.apId:`loading-${n}`))}),(0,D.jsx)(a,{className:`mt-[11px]`,value:`blocked_domains`,children:!O&&A.length===0?(0,D.jsxs)(g,{children:[(0,D.jsx)(l,{children:(0,D.jsx)(w,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block a domain, all users from that domain won't be able to follow you or interact with your content.`})})]}):A.map((e,t)=>(0,D.jsxs)(h,{children:[(0,D.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:O?(0,D.jsx)(b,{className:`w-48`}):new URL(e.url).hostname})}),L.has(e.url)?(0,D.jsx)(u,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:()=>G(e),children:`Block`}):O?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(b,{})}):(0,D.jsx)(u,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:()=>W(e),onMouseEnter:()=>B(e.url),onMouseLeave:()=>B(null),children:z===e.url?`Unblock`:`Blocked`})]},e.url?e.url:`loading-${t}`))})]})})]})})};export{O as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./dist-Ndy-PuGN.js";import{i,n as a,r as o,t as s}from"./tabs-D4y1gqUd.js";import{B as c,Hn as l,Ir as u,Jt as d,Lt as f,Ms as p,Rt as m,St as h,U as g,Vn as _,bs as v,bt as y,et as b,ft as x,ir as S,rt as C,xt as w,yt as T}from"./index-08n05-rc.js";import"./layout-B0YLh7R9.js";var E=e(t(),1),D=n(),O=()=>{let{data:e,isLoading:t}=w(`index`),{data:n,isLoading:O}=h(`index`),k=t?[,,,,,].fill({apId:``,name:``,handle:``,avatarUrl:``}):e?.pages.flatMap(e=>e.accounts)??[],A=O?[,,,,,].fill({apId:``,name:``}):n?.pages.flatMap(e=>e.domains)??[],j=y(`index`),M=m(`index`),[N,P]=(0,E.useState)(new Set),F=T(`index`),I=f(`index`),[L,R]=(0,E.useState)(new Set),[z,B]=(0,E.useState)(null),V=d(),H=e=>{P(t=>{let n=new Set([...t]);return n.add(e.apId),n}),M.mutate(e),r.success(`User unblocked`)},U=e=>{P(t=>{let n=new Set([...t]);return n.delete(e.apId),n}),j.mutate(e),r.success(`User blocked`)},W=e=>{R(t=>{let n=new Set([...t]);return n.add(e.url),n}),I.mutate({url:e.url}),r.success(`Domain unblocked`)},G=e=>{R(t=>{let n=new Set([...t]);return n.delete(e.url),n}),F.mutate({url:e.url}),r.success(`Domain blocked`)};return(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`mx-auto max-w-[620px] py-[min(4vh,48px)]`,children:[(0,D.jsx)(`div`,{className:`flex items-center justify-between gap-8`,children:(0,D.jsx)(p,{children:`Moderation`})}),(0,D.jsx)(`div`,{className:`mt-6`,children:(0,D.jsxs)(s,{defaultValue:`blocked_users`,variant:`underline`,children:[(0,D.jsxs)(o,{children:[(0,D.jsx)(i,{value:`blocked_users`,children:`Blocked users`}),(0,D.jsx)(i,{value:`blocked_domains`,children:`Blocked domains`})]}),(0,D.jsx)(a,{className:`mt-2`,value:`blocked_users`,children:!t&&k.length===0?(0,D.jsxs)(_,{children:[(0,D.jsx)(l,{children:(0,D.jsx)(v,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block someone, they won't be able to follow you or interact with your content on the social web.`})})]}):k.map((e,n)=>(0,D.jsx)(C,{actor:e,isCurrentUser:!0,children:(0,D.jsx)(`div`,{children:(0,D.jsxs)(g,{onClick:t?void 0:()=>b(e.handle,V),children:[(0,D.jsx)(x,{author:{icon:{url:e.avatarUrl},name:e.name,handle:e.handle}}),(0,D.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:t?(0,D.jsx)(S,{className:`w-24`}):e.name}),(0,D.jsx)(`span`,{className:`block truncate text-sm text-gray-600`,children:t?(0,D.jsx)(S,{className:`w-40`}):e.handle})]}),N.has(e.apId)?(0,D.jsx)(u,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:t=>{t.stopPropagation(),U(e)},children:`Block`}):t?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(S,{})}):(0,D.jsx)(u,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:t=>{t.stopPropagation(),H(e)},onMouseEnter:()=>B(e.apId),onMouseLeave:()=>B(null),children:z===e.apId?`Unblock`:`Blocked`})]})})},e.apId?e.apId:`loading-${n}`))}),(0,D.jsx)(a,{className:`mt-[11px]`,value:`blocked_domains`,children:!O&&A.length===0?(0,D.jsxs)(_,{children:[(0,D.jsx)(l,{children:(0,D.jsx)(v,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block a domain, all users from that domain won't be able to follow you or interact with your content.`})})]}):A.map((e,t)=>(0,D.jsxs)(g,{children:[(0,D.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:O?(0,D.jsx)(S,{className:`w-48`}):new URL(e.url).hostname})}),L.has(e.url)?(0,D.jsx)(u,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:()=>G(e),children:`Block`}):O?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(S,{})}):(0,D.jsx)(u,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:()=>W(e),onMouseEnter:()=>B(e.url),onMouseLeave:()=>B(null),children:z===e.url?`Unblock`:`Blocked`})]},e.url?e.url:`loading-${t}`))})]})})]})})};export{O as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r}from"./hooks-CixO01lL.js";import{n as i}from"./dist-Ndy-PuGN.js";import{i as a,r as o}from"./stats-C_lfxZAw.js";import{t as s}from"./posts-DhXE7b6r.js";import{o as c}from"./post-helpers-C5OQMBoi.js";import{m as l}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as u}from"./router-provider-BmEZf6c6.js";import{_ as d,f,m as p,p as m}from"./dist-Cb5RSHSg.js";import{i as h,r as g,t as _}from"./tabs-D4y1gqUd.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./card-aUHX0hyR.js";import{c as w,l as T,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./data-list-CupF7bjM.js";import{i as oe,n as se,o as E,r as D,t as ce}from"./use-simple-pagination-DgcF69KI.js";import{$i as O,$n as k,Cs as le,Fs as A,Hs as ue,Ia as de,Ir as j,Jn as M,Qi as N,Ur as P,Vr as F,ar as fe,er as I,nr as pe,oa as L,or as me,ts as R}from"./index-08n05-rc.js";import{t as he}from"./member-route-0Aa52Ntz.js";import{a as z,i as B,n as V,r as H,t as U}from"./kpi-card-CCt-qeWD.js";import{r as ge,t as _e}from"./post-analytics-header-pU2m9ZuV.js";import{n as ve}from"./post-analytics-context-D0Mw-Pmv.js";import{a as ye,i as be,n as W,o as G,r as xe}from"./link-helpers-D9LsDOkG.js";var K=r({dataType:`FeedbackResponseType`,path:e=>`/feedback/${e}/`}),q=e(t(),1),J=(e,t)=>{let{data:n,isLoading:r,error:i}=K(e,{searchParams:{limit:`50`,...t===void 0?{}:{score:t.toString()}}});return{feedback:(0,q.useMemo)(()=>n?.feedback?n.feedback:[],[n]),isLoading:r,error:i}},Y=n(),Se=({feedbackStats:e})=>{let{postId:t}=l(),n=u(),[r,i]=(0,q.useState)(`positive`),{feedback:a,isLoading:o}=J(t||``,+(r===`positive`)),{totalPages:s,paginatedData:c,nextPage:f,previousPage:w,hasNextPage:T,hasPreviousPage:ee}=ce({data:a,itemsPerPage:9}),te=o;return(0,Y.jsxs)(C,{children:[(0,Y.jsxs)(v,{className:`pb-5`,children:[(0,Y.jsx)(x,{children:`Feedback`}),(0,Y.jsx)(S,{children:`What did your readers think?`})]}),e.totalFeedback>0?(0,Y.jsxs)(b,{className:`pb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(_,{className:`pb-3`,defaultValue:`positive`,value:r,variant:`button`,onValueChange:e=>i(e),children:(0,Y.jsxs)(g,{className:`gap-1`,children:[(0,Y.jsx)(h,{className:`h-7`,value:`positive`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(N,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`More like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.positiveFeedback/e.totalFeedback)})]})}),(0,Y.jsx)(h,{className:`h-7`,value:`negative`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(O,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`Less like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.negativeFeedback/e.totalFeedback)})]})})]})}),(0,Y.jsx)(A,{className:`mr-2 mb-3 lg:hidden xl:visible! xl:block!`,children:`Date`})]}),(0,Y.jsx)(M,{}),te?(0,Y.jsx)(fe,{className:`mt-3`,lines:3}):c&&c.length>0?(0,Y.jsx)(`div`,{className:`flex w-full flex-col py-3`,children:c.map(e=>(0,Y.jsxs)(`div`,{className:`flex h-10 w-full items-center justify-between gap-3 rounded-sm border-none px-2 text-sm hover:cursor-pointer hover:bg-accent`,onClick:()=>{n(`/members/${e.member.id}`,{crossApp:!0})},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Y.jsxs)(k,{className:`size-7`,children:[e.member?.avatar_image&&(0,Y.jsx)(`img`,{className:`absolute aspect-square size-full`,src:e.member?.avatar_image}),(0,Y.jsx)(I,{className:`text-white`,style:{backgroundColor:`${d(F(e.member),`45`,`55`)}`},children:P(e.member)})]}),F(e.member)]}),(0,Y.jsx)(`div`,{className:`whitespace-nowrap text-muted-foreground`,children:p(e.created_at)})]},e.id))}):(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-8 text-center text-sm text-muted-foreground`,children:(0,Y.jsxs)(`div`,{children:[`No `,r===`positive`?`positive`:`negative`,` feedback yet`]})})]}):(0,Y.jsxs)(b,{className:`flex grow flex-col items-center justify-center text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:`No members have given feedback yet`}),(0,Y.jsx)(`div`,{children:`When someone does, you'll see their response here.`})]}),e.totalFeedback>0&&(0,Y.jsx)(y,{className:`grow-0`,children:(0,Y.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Y.jsxs)(j,{variant:`outline`,onClick:()=>{let e=`(feedback.post_id:'${t}'+feedback.score:1)`,i=`(feedback.post_id:'${t}'+feedback.score:0)`,a=`${encodeURIComponent(e)}&post=${t}`,o=`${encodeURIComponent(i)}&post=${t}`;n(`/members?filter=${r===`positive`?a:o}`,{crossApp:!0})},children:[`View all`,(0,Y.jsx)(L,{})]}),s>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!ee,onClick:w}),(0,Y.jsx)(oe,{disabled:!T,onClick:f})]})})]})})]})},Ce=e=>{let{data:t,isLoading:n}=s(e),{data:r,isLoading:i}=s(e,{searchParams:{include:`count.positive_feedback,count.negative_feedback`}}),c=(0,q.useMemo)(()=>t?.posts[0],[t]),l=(0,q.useMemo)(()=>r?.posts[0],[r]),u=(0,q.useMemo)(()=>c?{sent:c.email?.email_count||0,opened:c.email?.opened_count||0,clicked:c.count?.clicks||0,openedRate:c.email?.opened_count?c.email.opened_count/c.email.email_count:0,clickedRate:c.count?.clicks&&c.email?.email_count?c.count.clicks/c.email.email_count:0}:{sent:0,opened:0,clicked:0,openedRate:0,clickedRate:0},[c]),d=(0,q.useMemo)(()=>{if(!l?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=l.count.positive_feedback||0,t=l.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[l]),f=(0,q.useMemo)(()=>c?.newsletter?.id,[c]),{data:p,isLoading:m}=o({searchParams:f?{newsletter_id:f}:{},enabled:!!f}),h=(0,q.useMemo)(()=>p?.stats?p.stats.map(e=>e.post_id):[],[p]),{data:g,isLoading:_}=a({searchParams:f&&h.length>0?{newsletter_id:f,post_ids:h.join(`,`)}:{},enabled:!!f&&h.length>0}),v=(0,q.useMemo)(()=>{if(!p?.stats)return;let e=p.stats,t=g?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...p,stats:r}},[p,g]),y=m||_,{data:b,isLoading:x,refetch:S}=ye({searchParams:{filter:`post_id:'${e}'`}}),C=(0,q.useMemo)(()=>{if(!v||!v.stats)return{openRate:0,clickRate:0};let e=v.stats;if(e.length===0)return{openRate:0,clickRate:0};let t=e.reduce((e,t)=>e+(t.open_rate||0),0),n=e.reduce((e,t)=>e+(t.click_rate||0),0);return{openRate:Number((t/e.length).toFixed(2)),clickRate:Number((n/e.length).toFixed(2))}},[v]),w=(0,q.useMemo)(()=>xe(b),[b]);return{post:c,stats:u,feedbackStats:d,averageStats:(0,q.useMemo)(()=>({openedRate:C.openRate,clickedRate:C.clickRate}),[C]),topLinks:w,refetchTopLinks:S,isLoading:n||i||y||x}},we=({breakpoints:e={sm:1080,md:1280,lg:1360}}={})=>{let[t,n]=(0,q.useState)(`md`);return(0,q.useEffect)(()=>{let t=()=>{let t=window.innerWidth;t<e.sm?n(`sm`):t<e.md?n(`md`):n(`lg`)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),{chartSize:t,isSmall:t===`sm`,isMedium:t===`md`,isLarge:t===`lg`}},Te=()=>(0,Y.jsx)(`div`,{className:`absolute top-1/2 -right-4 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border bg-background text-muted-foreground md:visible! md:flex!`,children:(0,Y.jsx)(R,{className:`ml-0.5`,size:16,strokeWidth:1.5})}),Ee=({dataColor:e,value:t,avgValue:n})=>(0,Y.jsxs)(`div`,{className:`absolute top-6 left-1/2 z-50 flex w-[200px] -translate-x-1/2 flex-col items-stretch gap-1.5 rounded-md bg-background px-4 py-2 text-sm opacity-0 shadow-md transition-all group-hover/block:top-3 group-hover/block:opacity-100`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-blue opacity-50`,style:{backgroundColor:e}}),`This newsletter`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-gray opacity-80`}),`Average`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:n})]})]}),X=()=>{let e=u(),[t,n]=(0,q.useState)(null),[r,a]=(0,q.useState)(``),o=(0,q.useRef)(null),s=(0,q.useRef)(null),{chartSize:l}=we(),{appSettings:d}=ue(),{emailTrackClicks:p,emailTrackOpens:h}=d?.analytics||{},{post:g,isPostLoading:_,postId:O}=ve(),k=t=>e(he({filter:t}),{crossApp:!0}),N=g,P=c(N);(0,q.useEffect)(()=>{!_&&!P&&e(`/posts/analytics/${O}`)},[e,O,_,P]);let{stats:F,averageStats:I,topLinks:L,isLoading:R,refetchTopLinks:ye}=Ce(O),{mutate:xe}=be(),K=(0,q.useMemo)(()=>{if(!N?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=N.count.positive_feedback||0,t=N.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[N]),J=(0,q.useMemo)(()=>N?.newsletter?.feedback_enabled===!0,[N]),X=(0,q.useMemo)(()=>K.totalFeedback>0?!0:J,[K.totalFeedback,J]),De=e=>{let t=W(L,e);t&&(n(e),a(t.link.to))},Oe=()=>{if(!t)return;let e=W(L,t);if(!e)return;let o=r.trim();if(o===``||o===e.link.to){n(null),a(``);return}xe({originalUrl:e.link.originalTo,editedUrl:r,postId:O},{onSuccess:()=>{n(null),a(``),ye()},onError:()=>{i.error(`Couldn’t update the link. Please try again.`)}})},{totalPages:ke,paginatedData:Ae,nextPage:je,previousPage:Me,hasNextPage:Ne,hasPreviousPage:Pe}=ce({data:L,itemsPerPage:10});(0,q.useEffect)(()=>{if(t&&o.current){o.current.focus();let e=W(L,t),i=t=>{s.current&&!s.current.contains(t.target)&&r===e?.link.to&&(n(null),a(``))};return document.addEventListener(`mousedown`,i),()=>{document.removeEventListener(`mousedown`,i)}}},[t,r,L]);let Z=R||_,Fe=[{datatype:`Sent`,value:1,fill:`url(#gradientPurple)`,color:`var(--chart-purple)`}],Ie={percentage:{label:`O`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Le=[{datatype:`Average`,value:I.openedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],Re={percentage:{label:`Opened`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},ze=[{datatype:`Average`,value:I.clickedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`}],Be={percentage:{label:`Clicked`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Q=`grid-cols-3`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-[10/14] md:max-w-none lg:aspect-square`;return(!p||!h)&&(Q=`grid-cols-2`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-square md:max-w-none lg:aspect-[15/10]`),!p&&!h&&(Q=`grid-cols-1`,$=`aspect-square w-full sm:aspect-[16/10] md:max-w-[320px] md:max-h-[320px] lg:aspect-[12/10]`),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_e,{currentTab:`Newsletter`}),(0,Y.jsx)(ge,{children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 ${X&&p&&`lg:grid-cols-2`}`,children:[(0,Y.jsxs)(C,{className:X&&p?`lg:col-span-2`:``,children:[(0,Y.jsxs)(v,{className:`hidden`,children:[(0,Y.jsx)(x,{children:`Newsletters`}),(0,Y.jsx)(S,{children:`How did this post perform`})]}),Z?(0,Y.jsx)(b,{className:`h-[25vw] p-6`,children:(0,Y.jsx)(pe,{})}):(0,Y.jsxs)(b,{className:`p-0`,children:[(0,Y.jsxs)(`div`,{className:`grid ${Q} items-stretch border-b`,children:[(0,Y.jsxs)(U,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(B,{onClick:()=>{k(`emails.post_id:${O}`)},children:`View members →`}),(0,Y.jsxs)(H,{onClick:()=>{k(`emails.post_id:${O}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-purple opacity-50`}),`Sent`]}),(0,Y.jsx)(V,{children:(0,Y.jsx)(z,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.sent)})})]}),h&&(0,Y.jsxs)(U,{className:`p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(B,{onClick:()=>{k(`opened_emails.post_id:${O}`)},children:`View members →`}),(0,Y.jsxs)(H,{onClick:()=>{k(`opened_emails.post_id:${O}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-blue opacity-50`}),`Opened`]}),(0,Y.jsx)(V,{children:(0,Y.jsx)(z,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.opened)})})]}),p&&(0,Y.jsxs)(U,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(B,{onClick:()=>{k(`clicked_links.post_id:${O}`)},children:`View members →`}),(0,Y.jsxs)(H,{onClick:()=>{k(`clicked_links.post_id:${O}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-teal opacity-50`}),`Clicked`]}),(0,Y.jsx)(V,{children:(0,Y.jsx)(z,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.clicked)})})]})]}),(0,Y.jsxs)(`div`,{className:`$ mx-auto grid grid-cols-1 items-center justify-center gap-4 transition-all md:gap-0 ${Q===`grid-cols-2`&&`md:grid-cols-2`} ${Q===`grid-cols-3`&&`md:grid-cols-3`}`,children:[(0,Y.jsxs)(`div`,{className:`relative border-r-0 px-6 ${(h||p)&&`md:border-r`}`,children:[(0,Y.jsx)(G,{className:$,config:Ie,data:Fe,percentageLabel:`Sent`,percentageValue:m(1),size:l,tooltip:!1}),(h||p)&&(0,Y.jsx)(Te,{})]}),h&&(0,Y.jsxs)(`div`,{className:`group/block relative border-r-0 px-6 transition-all hover:bg-muted/25 ${p&&`md:border-r`}`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.openedRate),dataColor:`var(--chart-blue)`,value:m(F.openedRate)}),(0,Y.jsx)(G,{className:$,config:Re,data:Le,percentageLabel:`Open rate`,percentageValue:m(F.openedRate),size:l,tooltip:!1}),p&&(0,Y.jsx)(Te,{})]}),p&&(0,Y.jsxs)(`div`,{className:`group/block relative px-6 transition-all hover:bg-muted/25`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.clickedRate),dataColor:`var(--chart-teal)`,value:m(F.clickedRate)}),(0,Y.jsx)(G,{className:$,config:Be,data:ze,percentageLabel:`Click rate`,percentageValue:m(F.clickedRate),size:l,tooltip:!1})]})]})]})]}),X&&(0,Y.jsx)(Se,{feedbackStats:K}),p&&(0,Y.jsxs)(C,{className:`group/datalist overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-6`,children:[(0,Y.jsxs)(v,{className:`p-0`,children:[(0,Y.jsx)(x,{children:`Newsletter clicks`}),(0,Y.jsx)(S,{children:`Which links resonated with your readers`})]}),(0,Y.jsx)(A,{className:`mr-2`,children:`Members`})]}),Z?(0,Y.jsxs)(b,{className:`p-6 pt-0`,children:[(0,Y.jsx)(M,{}),(0,Y.jsx)(fe,{className:`mt-6`})]}):(0,Y.jsxs)(b,{className:`pb-0`,children:[(0,Y.jsx)(M,{}),L.length>0?(0,Y.jsx)(ie,{className:``,children:(0,Y.jsx)(ne,{children:Ae?.map(e=>{let n=F.clicked>0?e.count/F.clicked:0,i=e.link.link_id,c=e.link.title,l=e.link.to,u=e.link.edited;return(0,Y.jsxs)(ae,{children:[t!==i&&(0,Y.jsx)(ee,{style:{width:`${n?Math.round(n*100):0}%`}}),(0,Y.jsx)(te,{className:`w-full`,children:t===i?(0,Y.jsxs)(`div`,{ref:s,className:`flex w-full items-center gap-2`,children:[(0,Y.jsx)(me,{ref:o,className:`z-50 h-7 w-full border-border bg-background text-sm`,value:r,onChange:e=>a(e.target.value)}),(0,Y.jsx)(j,{size:`sm`,onClick:Oe,children:`Update`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(j,{className:`mr-2 shrink-0 bg-background`,size:`sm`,variant:`outline`,onClick:()=>De(i),children:(0,Y.jsx)(de,{})}),(0,Y.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:l,rel:`noreferrer`,target:`_blank`,title:c,children:c}),u&&(0,Y.jsx)(`span`,{className:`ml-1 text-gray-500`,children:`(edited)`})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(w,{children:f(e.count||0)}),(0,Y.jsx)(T,{children:m(n)})]})]},i)})})}):(0,Y.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]}),!Z&&L.length>1&&(0,Y.jsx)(y,{children:(0,Y.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 pl-4 text-sm text-green`,children:[(0,Y.jsx)(le,{size:20,strokeWidth:1.5}),`Sent a broken link? You can update it!`]}),ke>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!Pe,onClick:Me}),(0,Y.jsx)(oe,{disabled:!Ne,onClick:je})]})})]})})]})]})})]})};export{X as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r,g as i,i as a,r as o}from"./stats-C_lfxZAw.js";import{g as s}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as c,t as l}from"./router-provider-BmEZf6c6.js";import{f as u,l as d,p as f}from"./dist-Cb5RSHSg.js";import{g as p,n as m,o as h,r as g}from"./chart-BnXyfH11.js";import{a as _,c as v,i as y,l as b,n as x,t as ee,u as te}from"./chart-helpers-DV0FkdcD.js";import{n as ne,t as S}from"./sort-button-Df4t2AL8.js";import{r as re,t as ie}from"./tabs-D4y1gqUd.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./select-B0HteHrp.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-aUHX0hyR.js";import{t as F}from"./empty-indicator-WB1WgT9h.js";import{a as I,c as L,n as R,r as z,s as B,t as V}from"./table-DFj1wiYv.js";import{$a as H,Hr as U,Hs as W,Ir as ae,Jr as oe,Qr as G,Rr as se,Wr as K,Xr as ce,ar as le,eo as q,ii as ue,nr as J,p as Y}from"./index-08n05-rc.js";import{n as X,r as Z,t as de}from"./kpi-tabs-BlcUttpn.js";import{r as fe}from"./newsletters-BXJbJgA-.js";import{i as pe,n as me,r as he,t as ge}from"./stats-view-Cxot1iD8.js";import{t as _e}from"./use-analytics-data-C76v4LIp.js";var Q=e(t(),1),$=n(),ve=({active:e,payload:t})=>{if(!e||!t?.length)return null;let n=t[0].payload,r=typeof n.send_date==`string`?n.send_date:n.send_date.toISOString().split(`T`)[0];return(0,$.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,d(r)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,$.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:u(n.sent_to)})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_opens),` / `]}),f(n.open_rate)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_clicks),` / `]}),f(n.click_rate)]})]})]})},ye=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:i,initialTab:a=`total-subscribers`})=>{let[o,l]=(0,Q.useState)(a),[d,S]=(0,Q.useState)(!1),{range:C}=Y(),w=c(),[T]=s(),{appSettings:E}=W(),{emailTrackClicks:D,emailTrackOpens:O}=E?.analytics||{},{totalSubscribers:k,avgOpenRate:A,avgClickRate:j}=n,M=(0,Q.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=y(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:u(e.value),label:`Total Subscribers`}))},[e,C]),N=(0,Q.useMemo)(()=>ee(C,e||[]),[e,C]),P=(0,Q.useMemo)(()=>{if(!M||M.length<=1)return{direction:`same`,value:`0%`};let e=M[0]?.value??0,t=M[M.length-1]?.value??0,n=`same`;t>e?n=`up`:t<e&&(n=`down`);let r;if(e===0)r=t===0?`0%`:`+100%`;else{let n=(t-e)/e*100,i=Math.round(n*10)/10;r=`${n>=0?`+`:``}${i}%`}return{direction:n,value:r}},[M]);(0,Q.useEffect)(()=>{l(a)},[a]);let I=e=>{l(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},L={open_rate:{label:`Open rate`}},R=(0,Q.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:z,barTicks:B}=(0,Q.useMemo)(()=>{if(!t||t.length===0||o===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=R[o]?.datakey;if(!e)return{barDomain:[0,1],barTicks:[0,1]};let n=t.map(t=>t[e]).filter(e=>typeof e==`number`);if(n.length===0)return{barDomain:[0,1],barTicks:[0,1]};let r=o===`avg-open-rate`?A:j,i=Math.max(Math.max(...n),r),a;return a=i<.01?.01:i<.1?(Math.floor(i*100)+1)/100:(Math.floor(i*10)+1)/10,{barDomain:[0,a],barTicks:[0,a]}},[t,o,R,A,j]);if(r)return(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(J,{})});let V=`grid-cols-3`;(!D||!O)&&(V=`grid-cols-2`),!D&&!O&&(V=`grid-cols-1`);let H=o===`avg-open-rate`&&A>z[0]&&A<z[1]||o===`avg-click-rate`&&j>z[0]&&j<z[1],U=o===`avg-open-rate`?A:j;return(0,$.jsxs)(ie,{defaultValue:a,variant:`kpis`,children:[(0,$.jsxs)(re,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${V}`,children:[(0,$.jsx)(X,{className:`${!O&&!D&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{I(`total-subscribers`)},children:(0,$.jsx)(Z,{color:R[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:P.direction,diffValue:P.value,label:`Total subscribers`,value:u(k)})}),O&&(0,$.jsx)(X,{value:`avg-open-rate`,onClick:()=>{I(`avg-open-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)})}),D&&(0,$.jsx)(X,{value:`avg-click-rate`,onClick:()=>{I(`avg-click-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})})]}),(0,$.jsxs)(oe,{children:[(0,$.jsx)(ue,{className:`md:hidden`,asChild:!0,children:(0,$.jsxs)(de,{children:[o===`total-subscribers`&&(0,$.jsx)(Z,{color:R[`total-subscribers`].color,label:`Total subscribers`,value:u(k)}),o===`avg-open-rate`&&O&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)}),o===`avg-click-rate`&&D&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})]})}),(0,$.jsxs)(ce,{align:`end`,className:`w-56`,children:[(0,$.jsx)(G,{onClick:()=>I(`total-subscribers`),children:`Total subscribers`}),O&&(0,$.jsx)(G,{onClick:()=>I(`avg-open-rate`),children:`Avg. open rate`}),D&&(0,$.jsx)(G,{onClick:()=>I(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,$.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[o===`total-subscribers`&&(0,$.jsx)(_,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:R[`total-subscribers`].color,data:M,id:`mrr`,range:N}),(o===`avg-open-rate`&&O||o===`avg-click-rate`&&D)&&(0,$.jsx)($.Fragment,{children:i?(0,$.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,$.jsx)(J,{})}):t&&t.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:L,children:(0,$.jsxs)(ne,{className:d?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`,{crossApp:!0})},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:R[o].color,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:R[o].color,stopOpacity:.6})]})}),(0,$.jsx)(te,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(b,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(v,{axisLine:!1,domain:z,tickFormatter:e=>f(e),tickLine:!1,ticks:B,width:se(B,e=>f(e))}),(0,$.jsx)(g,{content:(0,$.jsx)(ve,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),H&&(0,$.jsx)(h,{label:{value:`${f(U)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:U}),(0,$.jsx)(p,{activeBar:{fillOpacity:1},dataKey:R[o].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,$.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,o===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(C)}`,children:(0,$.jsx)(q,{strokeWidth:1.5})})})]})]})},be=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=Y(),r=(0,Q.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Q.useEffect)(()=>{if(r.length>0&&!t){let e=r.find(e=>e.sort_order===0);n(e?e.id:r[0].id)}},[r,t,n]),r.length<=1?null:(0,$.jsxs)(k,{value:t||``,onValueChange:e=>{n(e)},children:[(0,$.jsxs)(E,{className:`w-auto`,children:[(0,$.jsx)(H,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,$.jsx)(O,{placeholder:`Select a newsletter`})]}),(0,$.jsx)(T,{align:`end`,children:(0,$.jsxs)(D,{children:[(0,$.jsx)(C,{children:`Newsletters`}),r.map(e=>(0,$.jsx)(w,{value:e.id,children:e.name},e.id))]})})]})},xe=(e,t,n=!0)=>{let i=e??30,{startDate:a,endDate:o}=(0,Q.useMemo)(()=>K(i),[i]),s=r({searchParams:(0,Q.useMemo)(()=>{let e={date_from:U(a),date_to:U(o)};return t&&(e.newsletter_id=t),e},[a,o,t]),enabled:n});return n?s:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:s.refetch}},Se=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:s,endDate:c}=(0,Q.useMemo)(()=>K(i),[i]),l=o({searchParams:(0,Q.useMemo)(()=>{let e={date_from:U(s),date_to:U(c),order:a};return n&&(e.newsletter_id=n),e},[s,c,a,n]),enabled:r});return r?l:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:l.refetch}},Ce=(e,t=[],n=!0)=>{let r=a({searchParams:(0,Q.useMemo)(()=>{let n={};return e&&(n.newsletter_id=e),t.length>0&&(n.post_ids=t.join(`,`)),n},[e,t]),enabled:n});return n?r:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:r.refetch}},we=(e,t,n,r=!0)=>{let i=Se(e,t,n,r),a=(0,Q.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=Ce(n,a,r&&a.length>0);return{data:(0,Q.useMemo)(()=>{if(!i.data?.stats)return;let e=i.data.stats,t=o.data?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...i.data,stats:r}},[i.data,o.data]),isLoading:i.isLoading,isClicksLoading:o.isLoading,error:i.error||o.error,isError:i.isError||o.isError,refetch:()=>{i.refetch(),o.refetch()}}},Te=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=c(),{settings:a}=_e(),o=String(a.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{data:s,isLoading:l,isClicksLoading:p}=we(e,r,t||void 0,!!n),{appSettings:m}=W(),{emailTrackClicks:h,emailTrackOpens:g}=m?.analytics||{},_=(0,Q.useMemo)(()=>s?.stats||[],[s]),v=g&&h?5:g||h?4:3,y=(0,Q.useMemo)(()=>(0,$.jsx)($.Fragment,{children:(0,$.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,$.jsx)(z,{className:`font-medium`,colSpan:v,children:(0,$.jsx)(le,{className:`mt-5`})})})}),[v]),b=(0,Q.useMemo)(()=>_.length>0?(0,$.jsx)($.Fragment,{children:_.map(e=>(0,$.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,$.jsx)(z,{className:`font-medium`,children:(0,$.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,$.jsx)(ae,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`,{crossApp:!0})},children:e.post_title}):(0,$.jsx)($.Fragment,{children:e.post_title})})}),(0,$.jsx)(z,{className:`text-sm whitespace-nowrap`,children:d(e.send_date,o)}),(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:u(e.sent_to)}),g&&(0,$.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.open_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_opens)})]}),h&&(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:p?(0,$.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.click_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_clicks)})]})})]},e.post_id))}):(0,$.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,$.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:v,children:(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(e)}`,children:(0,$.jsx)(q,{strokeWidth:1.5})})})}),[_,p,i,h,g,e]);return l||!s?y:b});Te.displayName=`NewsletterTableRows`;var Ee=Q.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Q.useMemo)(()=>(0,$.jsxs)(A,{children:[(0,$.jsx)(M,{children:`Top newsletters`}),(0,$.jsxs)(N,{children:[` Your best performing newsletters `,x(n)]})]}),[n]),{appSettings:i}=W(),{emailTrackClicks:a,emailTrackOpens:o}=i?.analytics||{};return(0,$.jsx)(B,{children:(0,$.jsxs)(L,{children:[(0,$.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,$.jsx)(I,{className:`w-[65px]`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),o&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),a&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ee.displayName=`NewsletterTableHeader`;var De=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Q.useState)(`open_rate desc`);return(0,$.jsx)(P,{className:`w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,"data-testid":`top-newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsxs)(V,{children:[(0,$.jsx)(Ee,{range:e,setSortBy:i,sortBy:r}),(0,$.jsx)(R,{children:(0,$.jsx)(Te,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});De.displayName=`TopNewslettersTable`;var Oe=()=>{let{range:e,selectedNewsletterId:t}=Y(),[n]=s(),{appSettings:r}=W(),a=n.get(`tab`)||`total-subscribers`,{data:o,isLoading:c}=fe({searchParams:{limit:`50`}}),u=!c&&o&&o.newsletters.length>0&&!!t,{data:d,isLoading:f}=xe(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=we(e,`date asc`,t||void 0,u||!1),g=(0,Q.useMemo)(()=>!o?.newsletters||!t?null:o.newsletters.find(e=>e.id===t)||null,[o,t]),_=(0,Q.useMemo)(()=>{let e=g?.count?.active_members||d?.stats?.[0]?.total||0,t=0,n=0;if(p?.stats&&p.stats.length>0){let e=p.stats,r=e.reduce((e,t)=>e+(t.open_rate||0),0),i=e.reduce((e,t)=>e+(t.click_rate||0),0);t=r/e.length,n=i/e.length}return{totalSubscribers:e,avgOpenRate:t,avgClickRate:n}},[g,d,p]),v=(0,Q.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=K(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Q.useMemo)(()=>p?.stats?p.stats.map(e=>({post_id:e.post_id,post_title:e.post_title,send_date:e.send_date,sent_to:e.sent_to,total_opens:e.total_opens,open_rate:e.open_rate,total_clicks:e.total_clicks||0,click_rate:e.click_rate||0})):[],[p]),b=f||h||m;return r&&!r.newslettersEnabled?(0,$.jsx)(l,{to:`/analytics`}):(0,$.jsxs)(me,{children:[(0,$.jsx)(he,{children:(0,$.jsxs)(i,{children:[(0,$.jsx)(be,{newsletters:o?.newsletters}),(0,$.jsx)(pe,{})]})}),(0,$.jsx)(ge,{isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{"data-testid":`newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsx)(ye,{avgsData:y,initialTab:a,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,$.jsx)(De,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{Oe as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-C1R4AZ2o.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,Wt as u,Z as d,et as f,ft as p,ir as m,rr as h,rt as g,xo as _,z as v}from"./index-BGG7NckO.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-DBDRtGu-.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=s(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(m,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(m,{className:`w-24`}),(0,w.jsx)(m,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(m,{}),(0,w.jsx)(m,{className:`w-4/5`}),(0,w.jsx)(m,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(m,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(m,{className:`w-52`}),(0,w.jsx)(m,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(l,{children:(0,w.jsx)(_,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(g,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(p,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{f(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:c(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:a(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(d,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(d,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(d,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:u(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(d,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:u(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(d,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:u(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(h,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-BmEZf6c6.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,So as u,Wt as d,Z as f,et as p,ft as m,ir as h,rr as g,rt as _,z as v}from"./index-08n05-rc.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-RLdPKRmS.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=s(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(h,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(h,{className:`w-24`}),(0,w.jsx)(h,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(h,{}),(0,w.jsx)(h,{className:`w-4/5`}),(0,w.jsx)(h,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(h,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(h,{className:`w-52`}),(0,w.jsx)(h,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(l,{children:(0,w.jsx)(u,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(_,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(m,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{p(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:c(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:a(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(f,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(f,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(f,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:d(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(f,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:d(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(f,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:d(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(g,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{f as r}from"./dist-DGzPJ_bO.js";import{$ as i,At as a,B as o,Ca as s,Gt as c,Ir as l,Jt as u,L as d,Li as f,Q as p,R as m,_s as h,bo as g,dt as _,et as v,ft as y,ir as b,lt as x,ns as S,nt as C,rr as w,rt as T,ut as E,xa as D,xs as O,z as k}from"./index-BGG7NckO.js";import"./layout-yQEi2qDM.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,c=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(f,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:c}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(g,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:c}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(D,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:c}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(s,{color:a,size:o,strokeWidth:c}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:c}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=u(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&v(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=u();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),v(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(E(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=u(),s=e=>{t(t=>({...t,[e]:!t[e]}))},f=()=>{},{data:g,error:T,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=g?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?s(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&v(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return T&&c(T)?(0,j.jsx)(d,{errorCode:T.code,statusCode:T.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(m,{children:(0,j.jsx)(h,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(b,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(y,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(y,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(l,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),s(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(S,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&v(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(y,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(_,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(b,{}),(0,j.jsx)(b,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(_,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(E(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.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:p({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(C,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:f})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(w,{size:`md`})})]})]})})};export{B as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{f as r}from"./dist-Cb5RSHSg.js";import{$ as i,At as a,B as o,Gt as s,Ir as c,Jt as l,L as u,Q as d,R as f,Ri as p,Sa as m,Ss as h,dt as g,et as _,ft as v,ir as y,lt as b,nt as x,rr as S,rs as C,rt as w,ut as T,vs as E,wa as D,xo as O,z as k}from"./index-08n05-rc.js";import"./layout-B0YLh7R9.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,s=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(p,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:s}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:s}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(m,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:s}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(D,{color:a,size:o,strokeWidth:s}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(h,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:s}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=l(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(w,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&_(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=l();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),_(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:b(T(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=l(),p=e=>{t(t=>({...t,[e]:!t[e]}))},m=()=>{},{data:h,error:w,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=h?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?p(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&_(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return w&&s(w)?(0,j.jsx)(u,{errorCode:w.code,statusCode:w.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(f,{children:(0,j.jsx)(E,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(y,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(v,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(v,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(c,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),p(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(C,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&_(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(v,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(g,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(y,{}),(0,j.jsx)(y,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(g,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:b(T(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.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:d({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(x,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:m})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(S,{size:`md`})})]})]})})};export{B as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{g as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as i,t as a}from"./router-provider-C1R4AZ2o.js";import{Cn as o,Ir as s,Tn as c,ba as l,kn as u,n as d,r as f,rs as p,vo as m,ws as h}from"./index-BGG7NckO.js";import{t as g}from"./share-modal-DsgW3wbg.js";var _=e(t(),1),v=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,y=``+new URL(`logo-loader-88VPEpXE.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:v,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:o}){let s=o.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${o.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:o.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:o.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(p,{className:`size-5`}):(0,b.jsx)(h,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(l,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(p,{className:`size-5`})})]}),f.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:f[t+1]?.id===n,isLast:t===f.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(s,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(s,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),c=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(g.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(g.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(g.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(g.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(g.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(g.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(m,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(g.Footer,{children:[(0,b.jsx)(g.SocialLinks,{links:c}),(0,b.jsx)(g.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),s=d(),l=u(),p=o(),m=(0,_.useRef)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(!1),x=String(c(l.data?.settings,`title`)||p.data?.site.title||`your publication`),S=String(c(l.data?.settings,`description`)||p.data?.site.description||``),E=String(c(l.data?.settings,`cover_image`)||``),D=p.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=s;if(N||p.isLoading||h||m.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{m.current=!0,g(!0);try{await t(),e(n,{replace:!0})}catch(e){m.current=!1,g(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=f.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:v,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{g as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as i,t as a}from"./router-provider-BmEZf6c6.js";import{Cn as o,Ir as s,Tn as c,Ts as l,is as u,kn as d,n as f,r as p,xa as m,yo as h}from"./index-08n05-rc.js";import{t as g}from"./share-modal-BeuydaBf.js";var _=e(t(),1),v=``+new URL(`logo-loader-dark-CuSPz-zc.mp4`,import.meta.url).href,y=``+new URL(`logo-loader-88VPEpXE.mp4`,import.meta.url).href,b=n();function x(){return(0,b.jsxs)(`div`,{className:`relative mb-6 size-20`,children:[(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`size-20 dark:hidden`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:y,type:`video/mp4`})}),(0,b.jsx)(`video`,{"aria-hidden":`true`,className:`hidden size-20 dark:block`,height:80,preload:`metadata`,role:`presentation`,tabIndex:-1,width:80,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,children:(0,b.jsx)(`source`,{src:v,type:`video/mp4`})}),(0,b.jsx)(`div`,{className:`pointer-events-none absolute inset-0 hidden bg-[hsl(216deg_11%_70%/1%)] dark:block`})]})}function S({complete:e,id:t,isBeforeNext:n,isLast:r,isNext:i,onClick:a,step:o}){let s=o.icon;return(0,b.jsxs)(`button`,{className:`group ${i?`relative z-10 -mx-8 flex w-[calc(100%+64px)] items-center justify-between rounded-md bg-background px-8 py-6 text-left shadow-[0_1px_0_rgba(17,17,26,0.05),0_0_8px_rgba(17,17,26,0.10)] transition-none dark:ring-1 dark:ring-border ${r?`-mb-[18px]`:`mb-1.5`}`:`relative flex w-full items-center justify-between bg-transparent py-6 text-left ${r||n||i?``:`after:absolute after:inset-x-0 after:bottom-0 after:h-px after:bg-border after:content-['']`}`}`,"data-testid":`onboarding-step-${o.id}`,id:t,type:`button`,onClick:a,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center ${e?`opacity-20 group-hover:opacity-25`:`group-hover:opacity-90`}`,children:[(0,b.jsx)(s,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsxs)(`span`,{className:`min-w-0 text-left`,children:[(0,b.jsx)(`span`,{className:`block truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:o.title}),i&&(0,b.jsx)(`span`,{className:`mt-1 block pr-8 text-[15px] leading-[1.4] text-muted-foreground`,children:o.description})]})]}),(0,b.jsx)(`span`,{className:`flex shrink-0 items-center transition-transform group-hover:translate-x-[5px] ${e?`text-green`:`text-purple`}`,children:e?(0,b.jsx)(u,{className:`size-5`}):(0,b.jsx)(l,{className:`size-3.5`})})]})}function C({allStepsCompleted:e,completedSteps:t,nextStep:n,onComplete:r,onDismiss:i,onStepClick:a,siteTitle:o}){let c=new Set(t);return(0,b.jsx)(`main`,{className:`relative flex min-h-screen flex-col items-center justify-center px-6 py-8`,children:(0,b.jsxs)(`section`,{className:`mt-[-48px] flex w-full flex-col items-center`,"data-test-dashboard":`onboarding-checklist`,"data-testid":`onboarding-checklist`,children:[(0,b.jsxs)(`div`,{className:`mb-8 flex flex-col items-center text-center`,children:[(0,b.jsx)(x,{}),e?(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`You're all set.`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`h1`,{className:`text-[32px] leading-[1.15] font-bold tracking-normal text-foreground max-[480px]:text-[24px]`,children:`Let's get started!`}),(0,b.jsxs)(`p`,{className:`mt-2 mb-0 text-[15px] text-muted-foreground max-[480px]:m-0 max-[480px]:text-[14px]`,children:[`Welcome! It's time to set up `,o,`.`]})]})]}),(0,b.jsxs)(`div`,{className:`w-full max-w-[540px] rounded-md border border-border bg-background px-6 pt-4 pb-1`,children:[(0,b.jsxs)(`div`,{className:`mt-[-12px] flex items-center justify-between py-6 ${n===`customize-design`?`border-b-0`:`border-b border-border`}`,children:[(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center opacity-20`,children:[(0,b.jsx)(m,{className:`mr-4 size-5 shrink-0 text-purple`}),(0,b.jsx)(`span`,{className:`truncate pr-8 text-[16px] leading-[1.3] font-bold text-foreground`,children:`Start a new Ghost publication`})]}),(0,b.jsx)(`span`,{className:`shrink-0 text-green`,children:(0,b.jsx)(u,{className:`size-5`})})]}),p.map((e,t)=>(0,b.jsx)(S,{complete:c.has(e.id),id:`ob-${e.id}`,isBeforeNext:p[t+1]?.id===n,isLast:t===p.length-1,isNext:n===e.id,step:e,onClick:()=>a(e.id)},e.id))]}),e&&(0,b.jsx)(s,{className:`mt-6 h-auto w-full max-w-[540px] p-3 text-[16px] max-[480px]:text-[15px]`,"data-testid":`onboarding-complete`,id:`ob-completed`,type:`button`,onClick:r,children:`Explore your dashboard`}),(0,b.jsxs)(`p`,{className:`mt-8 mb-0 text-[15px] text-muted-foreground max-[480px]:text-[14px]`,children:[`More questions? Check out our`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-[15px] text-green hover:text-green/90 max-[480px]:text-[14px]`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`https://ghost.org/help?utm_source=admin&utm_campaign=onboarding`,id:`ob-help-center`,rel:`noreferrer`,target:`_blank`,children:`Help Center`})}),`.`]}),!e&&(0,b.jsx)(s,{className:`mt-6 h-[38px] overflow-hidden px-3.5 py-px text-[15px] font-normal whitespace-nowrap text-muted-foreground hover:border-gray-300 hover:text-foreground`,"data-testid":`onboarding-skip`,id:`ob-skip`,type:`button`,variant:`outline`,onClick:i,children:`Skip onboarding`})]})})}function w({description:e,imageUrl:t,onOpenChange:n,open:r,siteTitle:i,siteUrl:a}){let o=encodeURIComponent(a),c=[{href:`https://twitter.com/intent/tweet?url=${o}`,id:`ob-share-on-x`,label:`Share your publication on X`,service:`x`},{href:`https://threads.net/intent/post?text=${o}`,id:`ob-share-on-threads`,label:`Share your publication on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${o}`,id:`ob-share-on-fb`,label:`Share your publication on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/feed/?shareActive=true&text=${o}`,id:`ob-share-on-li`,label:`Share your publication on LinkedIn`,service:`linkedin`}];return(0,b.jsx)(g.Root,{open:r,onOpenChange:n,children:(0,b.jsxs)(g.Content,{className:`dark:bg-surface-elevated`,"data-test-modal":`onboarding-share`,"data-testid":`onboarding-share-modal`,children:[(0,b.jsxs)(g.Header,{className:`flex-row items-center justify-between gap-4 space-y-0 text-left`,children:[(0,b.jsx)(g.Title,{className:`text-2xl`,children:`Share your publication`}),(0,b.jsx)(g.CloseButton,{id:`ob-close-share-modal`,onClick:()=>n(!1)})]}),(0,b.jsxs)(g.Preview,{className:`rounded-lg bg-card`,href:a,children:[t?(0,b.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${t})`}}):(0,b.jsx)(`div`,{className:`flex aspect-video items-center justify-center bg-muted text-muted-foreground`,children:(0,b.jsx)(h,{className:`size-8`})}),(0,b.jsxs)(`div`,{className:`p-5`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i}),e&&(0,b.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e})]})]}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Set your publication's cover image and description in`,` `,(0,b.jsx)(s,{className:`h-auto p-0 align-baseline text-sm text-green hover:text-green/90`,variant:`link`,asChild:!0,children:(0,b.jsx)(`a`,{href:`#/settings/design/edit?ref=setup`,id:`ob-share-modal-design-settings`,children:`Design settings`})}),`.`]}),(0,b.jsxs)(g.Footer,{children:[(0,b.jsx)(g.SocialLinks,{links:c}),(0,b.jsx)(g.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:a,"data-testid":`onboarding-copy-link`,icon:`link`,id:`ob-copy-publication-link`,label:`Copy link`})]})]})})}function T(e){return e&&/^\/analytics(?:\/|\?|$)/.test(e)?e:`/analytics`}function E(){let e=i(),[t]=r(),n=T(t.get(`returnTo`)),s=f(),l=d(),u=o(),m=(0,_.useRef)(!1),[h,g]=(0,_.useState)(!1),[v,y]=(0,_.useState)(!1),x=String(c(l.data?.settings,`title`)||u.data?.site.title||`your publication`),S=String(c(l.data?.settings,`description`)||u.data?.site.description||``),E=String(c(l.data?.settings,`cover_image`)||``),D=u.data?.site.url||`/`,{allStepsCompleted:O,completeChecklist:k,completedSteps:A,dismissChecklist:j,shouldShowChecklist:M,isLoading:N,markStepCompleted:P,nextStep:F}=s;if(N||u.isLoading||h||m.current)return null;if(!M)return(0,b.jsx)(a,{to:n,replace:!0});let I=async t=>{m.current=!0,g(!0);try{await t(),e(n,{replace:!0})}catch(e){m.current=!1,g(!1),console.error(e)}},L=async t=>{if(t===`share-publication`){await P(t),y(!0);return}await P(t);let n=p.find(({id:e})=>e===t);n?.route&&e(n.route)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(C,{allStepsCompleted:O,completedSteps:A,nextStep:F,siteTitle:x,onComplete:()=>{I(k)},onDismiss:()=>{I(j)},onStepClick:e=>{L(e)}}),(0,b.jsx)(w,{description:S,imageUrl:E,open:v,siteTitle:x,siteUrl:D,onOpenChange:y})]})}export{E as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{t as r}from"./use-tinybird-query-falHAtuK.js";import{f as i,g as a,s as o}from"./stats-Bjj_kmJ1.js";import{n as s}from"./posts-DhXE7b6r.js";import{t as c}from"./analytics-53FOa2wq.js";import{a as l,t as u}from"./post-helpers-C5OQMBoi.js";import{a as d}from"./router-provider-C1R4AZ2o.js";import{c as f,f as p,l as m,p as h,s as g}from"./dist-DGzPJ_bO.js";import{a as _,i as v,n as y,t as b}from"./chart-helpers-fjQKRVyY.js";import{a as x,n as S,o as C,r as w,s as T,t as E}from"./card-DGoDJzrn.js";import{t as D}from"./empty-indicator-oX1u1Pkn.js";import{Ba as O,Bo as k,Di as A,Fa as ee,Hr as j,Ir as M,Ms as N,Ni as te,Ri as P,So as F,Vs as I,Wr as ne,ar as L,ga as R,i as re,ir as z,is as ie,jo as B,ls as ae,nr as oe,p as V,pa as se,ro as H,ss as ce,u as U,vo as le,za as W,zr as G}from"./index-BGG7NckO.js";import{n as ue,r as de,t as fe}from"./kpi-card-DSap9rAy.js";import{i as K,n as pe,r as me,t as he}from"./stats-view-BxPbW6K1.js";import{t as ge}from"./use-growth-stats-CIaiHOVb.js";import{t as q}from"./use-analytics-data-S0FTd43s.js";import{n as _e}from"./audience-DjEWNhp3.js";import{n as J}from"./url-helpers-CCyfRrKj.js";import{t as ve}from"./post-share-modal-DFfO93_0.js";var Y=e(t(),1),ye=()=>{let{data:{posts:[e]}={posts:[]},isLoading:t}=s({searchParams:{filter:`status:[published,sent]`,order:`published_at DESC`,limit:`1`,include:`authors,email,count.clicks`}}),n=e,{data:r,isLoading:i}=o(n?.id||``,{enabled:!!n?.id});return{data:(0,Y.useMemo)(()=>{if(!n)return null;let e=r?.stats?.[0]||{id:n.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:n.id,uuid:n.uuid,title:n.title||``,slug:n.slug||``,feature_image:n.feature_image||null,published_at:n.published_at||``,url:n.url||``,excerpt:n.excerpt||``,email_only:n.email_only||!1,status:n.status,email:n.email,count:n.count,authors:n.authors||[],recipient_count:e.recipient_count,opened_count:e.opened_count,open_rate:e.open_rate,member_delta:e.member_delta,free_members:e.free_members,paid_members:e.paid_members,visitors:e.visitors,click_rate:null}},[n,r]),isLoading:t||!!n?.id&&i}},X=n(),be=e=>e.email_only?`Sent`:e.email?`Published and sent`:`Published`,xe=({latestPostStats:e,isLoading:t})=>{let n=d(),[r,i]=(0,Y.useState)(!1),{site:a,settings:o}=q(),{appSettings:s}=I(),{emailTrackClicks:l,emailTrackOpens:g,webAnalytics:_=!1,membersTrackSources:v=!1}=s?.analytics||{};(0,Y.useEffect)(()=>{r&&c(`Share Modal Opened`,{giftLinkShown:!1,source:`stats-overview`})},[r]);let y=a.title||String(o.find(e=>e.key===`title`)?.value||`Ghost Site`),b=String(o.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),T=e?u(e,{membersTrackSources:v}):null,k=`group mr-2 flex flex-col gap-1.5 hover:cursor-pointer`,A=!!e?.email,j=J({postId:e?.id,hasEmailData:A,analytics:{webAnalytics:_,membersTrackSources:v}}),N=j.startsWith(`/editor/`);return(0,X.jsxs)(E,{className:`group/card`,"data-testid":`latest-post`,children:[(0,X.jsxs)(x,{children:[(0,X.jsx)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:`Latest post performance`}),(0,X.jsx)(w,{className:`hidden`,children:`How your last post did`})]}),(0,X.jsxs)(S,{className:`flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3`,children:[t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-6 px-6 xl:col-span-2`,children:[(0,X.jsx)(`div`,{className:`w-full max-w-[232px] grow`,children:(0,X.jsx)(z,{className:`aspect-[16/10] rounded-md`})}),(0,X.jsxs)(`div`,{className:`w-full grow`,children:[(0,X.jsx)(z,{className:`w-full max-w-[420px]`}),(0,X.jsx)(z,{className:`w-1/2`})]})]}),(0,X.jsx)(`div`,{className:`flex flex-col items-stretch gap-2 px-6`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]})]})})]}),!t&&e&&T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2`,children:[e.feature_image&&(0,X.jsx)(`div`,{className:`aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]`,style:{backgroundImage:`url(${e.feature_image})`}}),(0,X.jsxs)(`div`,{className:`flex grow flex-col items-start justify-center self-stretch`,children:[(0,X.jsx)(`div`,{className:`text-md leading-tighter font-semibold tracking-tight hover:cursor-pointer hover:opacity-75`,onClick:()=>{!t&&e&&n(j,{crossApp:!0})},children:e.title}),(0,X.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.authors&&e.authors.length>0&&(0,X.jsxs)(`div`,{children:[`By `,e.authors.map(e=>e.name).join(`, `),` – `,m(e.published_at,b)]}),(0,X.jsx)(`div`,{className:`mt-0.5`,children:be(e)})]}),(0,X.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[!e.email_only&&(0,X.jsx)(ve,{author:e.authors?.map(e=>e.name).join(`, `)||``,description:``,faviconURL:a.icon||``,featureImageURL:e.feature_image||``,open:r,postExcerpt:e.excerpt||``,postTitle:e.title,postURL:e.url||``,siteTitle:y,onClose:()=>i(!1),onOpenChange:i,children:(0,X.jsxs)(M,{onClick:()=>i(!0),children:[(0,X.jsx)(se,{}),` Share post`]})}),(0,X.jsx)(M,{className:e.email_only?`w-full`:``,variant:`outline`,onClick:()=>{n(j,{crossApp:!0})},children:N?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Edit post`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:e.email_only?`Post analytics`:`Analytics`})]})})]})]})]}),(0,X.jsx)(`div`,{className:`-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 xl:h-full xl:max-w-none`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full`,children:[T.showWebMetrics&&_&&(0,X.jsxs)(`div`,{className:k,"data-testid":`latest-post-visitors`,onClick:()=>{n(`/posts/analytics/${e.id}/web`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(F,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Visitors`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:p(e.visitors)})]}),T.showMemberGrowth&&(0,X.jsxs)(`div`,{className:f(k,T.showEmailMetrics&&(!T.showWebMetrics||!_)&&`col-[1/2] row-[2/3]`),"data-testid":`latest-post-members`,onClick:()=>{n(`/posts/analytics/${e.id}/growth`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(P,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Members`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.member_delta?(0,X.jsxs)(X.Fragment,{children:[`+`,p(e.member_delta)]}):0})]}),T.showEmailMetrics&&e.email&&(0,X.jsxs)(X.Fragment,{children:[g&&(0,X.jsxs)(`div`,{className:k,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(H,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Opens`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count?h((e.email.opened_count||0)/e.email.email_count):`0%`})]}),l&&(0,X.jsxs)(`div`,{className:k,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(O,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Clicks`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count&&e.count?.clicks?h((e.count.clicks||0)/e.email.email_count):`0%`})]})]})]})})]}):!t&&(0,X.jsx)(D,{actions:(0,X.jsx)(M,{variant:`secondary`,onClick:()=>{n(`/editor/post`,{crossApp:!0})},children:`New post`}),className:`w-full pb-10 xl:col-span-3`,description:`Once it's live, you can track performance here`,title:`Publish your first post`,children:(0,X.jsx)(B,{strokeWidth:1.5})})]})]})},Se=()=>{let{config:e}=q();return{isLimited:t=>e?.hostSettings?.limits&&t===`limitAnalytics`?e.hostSettings.limits.limitAnalytics?.disabled===!0:!1}},Z=({title:e,iconName:t,description:n,color:r,diffDirection:i,diffValue:a,formattedValue:o,trendingFromValue:s,children:c,onClick:l})=>{let{range:u}=V(),d=t&&A[t],f=Y.useMemo(()=>{if(!i||i===`empty`||u===U.allTime.value||!a)return``;let e=i===`up`?`up`:i===`down`?`down`:`at`,t=y(u).replace(`in the `,``).replace(/^\(|\)$/g,``);return i===`same`?(0,X.jsxs)(`span`,{children:[`You're trending at the same level as `,(0,X.jsx)(`span`,{className:`font-semibold`,children:o}),` compared to the `,(0,X.jsx)(`span`,{className:`font-semibold`,children:t})]}):(0,X.jsxs)(`span`,{children:[`You're trending `,(0,X.jsxs)(`span`,{className:`font-semibold`,children:[e,` `,a]}),` from `,(0,X.jsx)(`span`,{className:`font-semibold`,children:s}),` compared to the `,t]})},[i,a,s,o,u]);return(0,X.jsxs)(E,{className:`group`,"data-testid":e,children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:e}),(0,X.jsx)(w,{children:n})]}),(0,X.jsxs)(fe,{className:`relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,X.jsxs)(ue,{className:l&&`transition-all group-hover:text-foreground`,children:[r&&(0,X.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r}}),d&&(0,X.jsx)(d,{size:16,strokeWidth:1.5}),e]}),(0,X.jsx)(de,{diffDirection:u===U.allTime.value?`hidden`:i,diffTooltip:f,diffValue:a,value:o})]}),l&&(0,X.jsx)(M,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:l,children:`View more`})]}),(0,X.jsx)(S,{children:c})]})},Ce=({kpiValues:e,visitorsChartData:t,visitorsChartRange:n,visitorsYRange:r,growthTotals:i,membersChartData:a,mrrChartData:o,growthChartRange:s,currencySymbol:c,isLoading:l})=>{let u=d(),{appSettings:f}=I(),m=Se().isLimited(`limitAnalytics`),h=`-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:cursor-pointer!`;if(l)return(0,X.jsx)(T,{className:`flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:cursor-pointer!`,children:(0,X.jsx)(oe,{})});let g=f?.analytics.webAnalytics,v=m&&!g,y=f?.paidMembersEnabled,b=[g,v,!0,y].filter(Boolean).length,O=`lg:grid-cols-3`;return b===2?O=`lg:grid-cols-2`:b===1&&(O=`lg:grid-cols-1`),(0,X.jsxs)(`div`,{className:`flex flex-col lg:grid ${O} gap-6`,children:[g&&!v&&(0,X.jsx)(Z,{description:`Number of individual people who visited your website`,diffDirection:`empty`,formattedValue:e.visits,iconName:`Globe`,linkto:`/analytics/web/`,title:`Unique visitors`,onClick:()=>{u(`/analytics/web/`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-blue)`,data:t,id:`visitors`,range:n,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`,yAxisRange:r})}),v&&(0,X.jsxs)(E,{children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:`Unlock web analytics`}),(0,X.jsx)(w,{children:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`})]}),(0,X.jsx)(S,{className:`flex h-full items-center justify-center p-6`,children:(0,X.jsx)(D,{actions:(0,X.jsx)(M,{variant:`outline`,onClick:()=>u(`/pro`,{crossApp:!0}),children:`Upgrade now`}),className:`py-10`,description:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`,title:`Unlock web analytics`,children:(0,X.jsx)(ie,{})})})]}),(0,X.jsx)(Z,{description:`How number of members of your publication changed over time`,diffDirection:i.directions.total,diffValue:i.percentChanges.total,formattedValue:p(i.totalMembers),iconName:`User`,linkto:`/analytics/growth/`,title:`Members`,trendingFromValue:`${p(a[0].value)}`,onClick:()=>{u(`/analytics/growth/?tab=total-members`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-darkblue)`,data:a,id:`members`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})}),y&&(0,X.jsx)(Z,{description:`Monthly recurring revenue changes over time`,diffDirection:i.directions.mrr,diffValue:i.percentChanges.mrr,formattedValue:`${c}${p(G(i.mrr))}`,iconName:`Coins`,linkto:`/analytics/growth/`,title:`MRR`,trendingFromValue:`${c}${p(o[0].value)}`,onClick:()=>{u(`/analytics/growth/?tab=mrr`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-teal)`,data:o,id:`mrr`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})})]})},we=({className:e})=>(0,X.jsx)(`div`,{className:f(`flex flex-col items-center justify-center gap-1 rounded-sm bg-muted p-6 dark:bg-surface-elevated-2`,e),children:(0,X.jsx)(le,{className:`text-muted-foreground/50`,size:18,strokeWidth:1.5})}),Q=({className:e,metrics:t,title:n})=>(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:f(`pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100`,e),children:[(0,X.jsx)(`div`,{className:`mb-1.5 border-b pr-10 pb-1.5 font-medium whitespace-nowrap text-muted-foreground`,children:n}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t?.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[e.icon,e.label]}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.metric})]},e.label))})]})}),Te=({topPostsData:e,isLoading:t})=>{let n=d(),{range:r}=V(),{settings:i}=q(),{appSettings:a}=I(),o=String(i.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{webAnalytics:s=!1,membersTrackSources:c=!1,emailTrackClicks:u=!1,emailTrackOpens:f=!1}=a?.analytics||{},h=`flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground`;return(0,X.jsxs)(E,{className:`group/card w-full lg:col-span-2`,"data-testid":`top-posts-card`,children:[(0,X.jsxs)(x,{children:[(0,X.jsxs)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:[`Top posts `,y(r)]}),(0,X.jsx)(w,{className:`hidden`,children:`Most viewed posts in this period`})]}),(0,X.jsx)(S,{children:t?(0,X.jsx)(L,{className:`mt-6`}):(0,X.jsxs)(X.Fragment,{children:[e?.stats?.map(e=>(0,X.jsxs)(`div`,{className:`group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-table-row-hover before:content-[""] first:border-border! hover:cursor-pointer hover:border-transparent hover:before:block md:items-center [&+div]:hover:border-transparent`,children:[(0,X.jsxs)(`div`,{className:`z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]`,onClick:()=>{n(J({postId:e.post_id,hasEmailData:e.sent_count!==null,analytics:{webAnalytics:s,membersTrackSources:c}}),{crossApp:!0})},children:[e.feature_image?(0,X.jsx)(`div`,{className:`hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:visible! sm:block! lg:w-[100px]`,style:{backgroundImage:`url(${e.feature_image})`}}):(0,X.jsx)(we,{className:`hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:visible! sm:flex! lg:w-[100px]`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 text-md font-semibold`,children:e.title}),(0,X.jsxs)(`span`,{className:`text text-muted-foreground`,children:[`By `,e.authors,` – `,m(e.published_at,o)]}),(0,X.jsx)(`span`,{className:`text text-muted-foreground`,children:l(e)})]})]}),(0,X.jsxs)(`div`,{className:`z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3`,children:[s&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-visitors`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/web`,{crossApp:!0})},children:[(0,X.jsx)(Q,{metrics:[{icon:(0,X.jsx)(F,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Unique visitors`,metric:p(e.views)}],title:`Web traffic`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(F,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.views)]})]}),e.sent_count!==null&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/newsletter`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`${c?``:`right-0 left-auto translate-x-0`}`,metrics:[{icon:(0,X.jsx)(R,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Sent`,metric:p(e.sent_count||0)},...f?[{icon:(0,X.jsx)(H,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Opens`,metric:p(e.opened_count||0)}]:[],...u?[{icon:(0,X.jsx)(W,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Clicks`,metric:p(e.clicked_count||0)}]:[]],title:`Newsletter performance`}),(0,X.jsx)(`div`,{className:h,children:f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.open_rate?`${Math.round(e.open_rate)}%`:`0%`]}):u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.click_rate?`${Math.round(e.click_rate)}%`:`0%`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.sent_count||0)]})})]}),c&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-members`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/growth`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`right-0 left-auto translate-x-0`,metrics:[{icon:(0,X.jsx)(te,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Free`,metric:e.free_members>0?`+${p(e.free_members)}`:`0`},...a?.paidMembersEnabled?[{icon:(0,X.jsx)(k,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Paid`,metric:e.paid_members>0?`+${p(e.paid_members)}`:`0`}]:[]],title:`New members`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(P,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.members>0?`+${p(e.members)}`:`0`]})]})]})]},e.post_id)),(!e?.stats||e.stats.length===0)&&(0,X.jsx)(D,{className:`w-full pb-10`,title:`No posts ${y(r)}`,children:(0,X.jsx)(B,{strokeWidth:1.5})})]})})]})},$=({className:e,title:t,description:n,url:r,children:i})=>(0,X.jsx)(`a`,{className:f(`group/card block rounded-xl border bg-card p-6 transition-all hover:bg-table-row-hover hover:shadow-xs`,e),href:r,rel:`noreferrer`,target:`_blank`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-6`,children:[i,(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-tight`,children:[(0,X.jsx)(`span`,{className:`text-base font-semibold`,children:t}),(0,X.jsx)(`span`,{className:`text-sm font-normal text-gray-700`,children:n})]})]})}),Ee=()=>{let{appSettings:e}=I(),{range:t}=V(),{statsConfig:n,isLoading:o}=q(),{startDate:s,endDate:c,timezone:l}=ne(t),{isLoading:u,chartData:d,totals:f,currencySymbol:m}=ge(t),{data:h,isLoading:g}=ye(),{data:_,isLoading:y}=i({searchParams:{date_from:j(s),date_to:j(c),limit:`5`,timezone:l}}),{data:x,loading:S}=r({endpoint:`api_kpis`,statsConfig:n,params:{site_uuid:n?.id||``,date_from:j(s),date_to:j(c),timezone:l,member_status:_e(re)}}),C=(0,Y.useMemo)(()=>v(x||[],t,`visits`,`sum`)?.map(e=>{let t=Number(e.visits),n=isNaN(t)?0:t;return{date:String(e.date),value:n,formattedValue:p(n),label:`Visitors`}}),[x,t]),w=(0,Y.useMemo)(()=>b(t,x||[],{fieldName:`visits`}),[x,t]),T=(0,Y.useMemo)(()=>{let e=[0,1];if(!C||C.length===0)return e;let t=C.map(e=>e.value).filter(e=>e>=0);return t.length===0?e:[0,Math.max(...t)||e[1]]},[C]),E=(0,Y.useMemo)(()=>b(t,d||[]),[d,t]),D=(0,Y.useMemo)(()=>{if(!d||d.length===0)return[];let e=[];return e=v(d,t,`value`,`exact`),e.map(e=>({date:e.date,value:e.free+e.paid,formattedValue:p(e.free+e.paid),label:`Members`}))},[d,t]),O=(0,Y.useMemo)(()=>{if(!e?.paidMembersEnabled||!d||d.length===0)return[];let n=[];return n=v(d,t,`mrr`,`exact`),n.map(e=>({date:e.date,value:G(e.mrr),formattedValue:`${m}${p(G(e.mrr))}`,label:`MRR`}))},[d,t,m,e]),k=(0,Y.useMemo)(()=>x?.length?{visits:p(x.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0))}:{visits:`0`},[x]);return(0,X.jsxs)(pe,{children:[(0,X.jsx)(me,{children:(0,X.jsx)(a,{children:(0,X.jsx)(K,{excludeRanges:[`today`]})})}),(0,X.jsxs)(he,{isLoading:o,loadingComponent:(0,X.jsx)(X.Fragment,{}),children:[(0,X.jsx)(Ce,{currencySymbol:m,growthChartRange:E,growthTotals:f,isLoading:S||u,kpiValues:k,membersChartData:D,mrrChartData:O,visitorsChartData:C,visitorsChartRange:w,visitorsYRange:T}),(0,X.jsx)(xe,{isLoading:g,latestPostStats:h}),(0,X.jsx)(Te,{isLoading:y,topPostsData:_}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,X.jsx)(N,{className:`mt-4 -mb-4 lg:col-span-2`,children:`Grow your audience`}),(0,X.jsx)($,{description:`Find out how to review the performance of your content and get the most out of post analytics in Ghost.`,title:`Understanding analytics in Ghost`,url:`https://ghost.org/help/native-analytics`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(ae,{className:`text-[#00BBA7]`,size:20,strokeWidth:1.5})})}),(0,X.jsx)($,{description:`Use these content distribution tactics to get more people to discover your work and increase engagement.`,title:`How to get your content seen online`,url:`https://ghost.org/resources/content-distribution/`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(F,{className:`text-[#FE9A00]`,size:20,strokeWidth:1.5})})})]})]})]})};export{Ee as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{t as r}from"./use-tinybird-query-C1R_Kbmy.js";import{f as i,g as a,s as o}from"./stats-C_lfxZAw.js";import{n as s}from"./posts-DhXE7b6r.js";import{t as c}from"./analytics-53FOa2wq.js";import{a as l,t as u}from"./post-helpers-C5OQMBoi.js";import{a as d}from"./router-provider-BmEZf6c6.js";import{c as f,f as p,l as m,p as h,s as g}from"./dist-Cb5RSHSg.js";import{a as _,i as v,n as y,t as b}from"./chart-helpers-DV0FkdcD.js";import{a as x,n as S,o as C,r as w,s as T,t as E}from"./card-aUHX0hyR.js";import{t as D}from"./empty-indicator-WB1WgT9h.js";import{Ba as O,Co as k,Di as A,Hr as j,Hs as M,Ia as ee,Ir as N,Mo as P,Ns as F,Pi as te,Va as ne,Vo as I,Wr as re,_a as L,ar as ie,as as ae,cs as oe,i as se,io as R,ir as z,ma as ce,nr as le,p as B,u as V,us as H,yo as U,zi as W,zr as G}from"./index-08n05-rc.js";import{n as ue,r as de,t as K}from"./kpi-card-BN-E6WYX.js";import{i as fe,n as pe,r as me,t as he}from"./stats-view-Cxot1iD8.js";import{t as ge}from"./use-growth-stats-aNXJOmQr.js";import{t as q}from"./use-analytics-data-C76v4LIp.js";import{n as _e}from"./audience-CkBb2LlO.js";import{n as J}from"./url-helpers-CCyfRrKj.js";import{t as ve}from"./post-share-modal-AcUZkbfL.js";var Y=e(t(),1),ye=()=>{let{data:{posts:[e]}={posts:[]},isLoading:t}=s({searchParams:{filter:`status:[published,sent]`,order:`published_at DESC`,limit:`1`,include:`authors,email,count.clicks`}}),n=e,{data:r,isLoading:i}=o(n?.id||``,{enabled:!!n?.id});return{data:(0,Y.useMemo)(()=>{if(!n)return null;let e=r?.stats?.[0]||{id:n.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:n.id,uuid:n.uuid,title:n.title||``,slug:n.slug||``,feature_image:n.feature_image||null,published_at:n.published_at||``,url:n.url||``,excerpt:n.excerpt||``,email_only:n.email_only||!1,status:n.status,email:n.email,count:n.count,authors:n.authors||[],recipient_count:e.recipient_count,opened_count:e.opened_count,open_rate:e.open_rate,member_delta:e.member_delta,free_members:e.free_members,paid_members:e.paid_members,visitors:e.visitors,click_rate:null}},[n,r]),isLoading:t||!!n?.id&&i}},X=n(),be=e=>e.email_only?`Sent`:e.email?`Published and sent`:`Published`,xe=({latestPostStats:e,isLoading:t})=>{let n=d(),[r,i]=(0,Y.useState)(!1),{site:a,settings:o}=q(),{appSettings:s}=M(),{emailTrackClicks:l,emailTrackOpens:g,webAnalytics:_=!1,membersTrackSources:v=!1}=s?.analytics||{};(0,Y.useEffect)(()=>{r&&c(`Share Modal Opened`,{giftLinkShown:!1,source:`stats-overview`})},[r]);let y=a.title||String(o.find(e=>e.key===`title`)?.value||`Ghost Site`),b=String(o.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),T=e?u(e,{membersTrackSources:v}):null,O=`group mr-2 flex flex-col gap-1.5 hover:cursor-pointer`,A=!!e?.email,j=J({postId:e?.id,hasEmailData:A,analytics:{webAnalytics:_,membersTrackSources:v}}),F=j.startsWith(`/editor/`);return(0,X.jsxs)(E,{className:`group/card`,"data-testid":`latest-post`,children:[(0,X.jsxs)(x,{children:[(0,X.jsx)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:`Latest post performance`}),(0,X.jsx)(w,{className:`hidden`,children:`How your last post did`})]}),(0,X.jsxs)(S,{className:`flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3`,children:[t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-6 px-6 xl:col-span-2`,children:[(0,X.jsx)(`div`,{className:`w-full max-w-[232px] grow`,children:(0,X.jsx)(z,{className:`aspect-[16/10] rounded-md`})}),(0,X.jsxs)(`div`,{className:`w-full grow`,children:[(0,X.jsx)(z,{className:`w-full max-w-[420px]`}),(0,X.jsx)(z,{className:`w-1/2`})]})]}),(0,X.jsx)(`div`,{className:`flex flex-col items-stretch gap-2 px-6`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(z,{className:`w-3/4`}),(0,X.jsx)(z,{className:`h-10 w-1/3`})]})]})})]}),!t&&e&&T?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2`,children:[e.feature_image&&(0,X.jsx)(`div`,{className:`aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]`,style:{backgroundImage:`url(${e.feature_image})`}}),(0,X.jsxs)(`div`,{className:`flex grow flex-col items-start justify-center self-stretch`,children:[(0,X.jsx)(`div`,{className:`text-md leading-tighter font-semibold tracking-tight hover:cursor-pointer hover:opacity-75`,onClick:()=>{!t&&e&&n(j,{crossApp:!0})},children:e.title}),(0,X.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.authors&&e.authors.length>0&&(0,X.jsxs)(`div`,{children:[`By `,e.authors.map(e=>e.name).join(`, `),` – `,m(e.published_at,b)]}),(0,X.jsx)(`div`,{className:`mt-0.5`,children:be(e)})]}),(0,X.jsxs)(`div`,{className:`mt-6 flex items-center gap-2`,children:[!e.email_only&&(0,X.jsx)(ve,{author:e.authors?.map(e=>e.name).join(`, `)||``,description:``,faviconURL:a.icon||``,featureImageURL:e.feature_image||``,open:r,postExcerpt:e.excerpt||``,postTitle:e.title,postURL:e.url||``,siteTitle:y,onClose:()=>i(!1),onOpenChange:i,children:(0,X.jsxs)(N,{onClick:()=>i(!0),children:[(0,X.jsx)(ce,{}),` Share post`]})}),(0,X.jsx)(N,{className:e.email_only?`w-full`:``,variant:`outline`,onClick:()=>{n(j,{crossApp:!0})},children:F?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Edit post`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:e.email_only?`Post analytics`:`Analytics`})]})})]})]})]}),(0,X.jsx)(`div`,{className:`-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 xl:h-full xl:max-w-none`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full`,children:[T.showWebMetrics&&_&&(0,X.jsxs)(`div`,{className:O,"data-testid":`latest-post-visitors`,onClick:()=>{n(`/posts/analytics/${e.id}/web`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(k,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Visitors`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:p(e.visitors)})]}),T.showMemberGrowth&&(0,X.jsxs)(`div`,{className:f(O,T.showEmailMetrics&&(!T.showWebMetrics||!_)&&`col-[1/2] row-[2/3]`),"data-testid":`latest-post-members`,onClick:()=>{n(`/posts/analytics/${e.id}/growth`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(W,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden md:visible! md:block!`,children:`Members`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.member_delta?(0,X.jsxs)(X.Fragment,{children:[`+`,p(e.member_delta)]}):0})]}),T.showEmailMetrics&&e.email&&(0,X.jsxs)(X.Fragment,{children:[g&&(0,X.jsxs)(`div`,{className:O,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(R,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Opens`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count?h((e.email.opened_count||0)/e.email.email_count):`0%`})]}),l&&(0,X.jsxs)(`div`,{className:O,onClick:()=>{n(`/posts/analytics/${e.id}/newsletter`,{crossApp:!0})},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground`,children:[(0,X.jsx)(ne,{size:16,strokeWidth:1.25}),(0,X.jsx)(`span`,{className:`hidden whitespace-nowrap md:visible! md:block!`,children:`Clicks`})]}),(0,X.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold tracking-tighter`,children:e.email.email_count&&e.count?.clicks?h((e.count.clicks||0)/e.email.email_count):`0%`})]})]})]})})]}):!t&&(0,X.jsx)(D,{actions:(0,X.jsx)(N,{variant:`secondary`,onClick:()=>{n(`/editor/post`,{crossApp:!0})},children:`New post`}),className:`w-full pb-10 xl:col-span-3`,description:`Once it's live, you can track performance here`,title:`Publish your first post`,children:(0,X.jsx)(P,{strokeWidth:1.5})})]})]})},Se=()=>{let{config:e}=q();return{isLimited:t=>e?.hostSettings?.limits&&t===`limitAnalytics`?e.hostSettings.limits.limitAnalytics?.disabled===!0:!1}},Z=({title:e,iconName:t,description:n,color:r,diffDirection:i,diffValue:a,formattedValue:o,trendingFromValue:s,children:c,onClick:l})=>{let{range:u}=B(),d=t&&A[t],f=Y.useMemo(()=>{if(!i||i===`empty`||u===V.allTime.value||!a)return``;let e=i===`up`?`up`:i===`down`?`down`:`at`,t=y(u).replace(`in the `,``).replace(/^\(|\)$/g,``);return i===`same`?(0,X.jsxs)(`span`,{children:[`You're trending at the same level as `,(0,X.jsx)(`span`,{className:`font-semibold`,children:o}),` compared to the `,(0,X.jsx)(`span`,{className:`font-semibold`,children:t})]}):(0,X.jsxs)(`span`,{children:[`You're trending `,(0,X.jsxs)(`span`,{className:`font-semibold`,children:[e,` `,a]}),` from `,(0,X.jsx)(`span`,{className:`font-semibold`,children:s}),` compared to the `,t]})},[i,a,s,o,u]);return(0,X.jsxs)(E,{className:`group`,"data-testid":e,children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:e}),(0,X.jsx)(w,{children:n})]}),(0,X.jsxs)(K,{className:`relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4`,children:[(0,X.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,X.jsxs)(ue,{className:l&&`transition-all group-hover:text-foreground`,children:[r&&(0,X.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r}}),d&&(0,X.jsx)(d,{size:16,strokeWidth:1.5}),e]}),(0,X.jsx)(de,{diffDirection:u===V.allTime.value?`hidden`:i,diffTooltip:f,diffValue:a,value:o})]}),l&&(0,X.jsx)(N,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:l,children:`View more`})]}),(0,X.jsx)(S,{children:c})]})},Ce=({kpiValues:e,visitorsChartData:t,visitorsChartRange:n,visitorsYRange:r,growthTotals:i,membersChartData:a,mrrChartData:o,growthChartRange:s,currencySymbol:c,isLoading:l})=>{let u=d(),{appSettings:f}=M(),m=Se().isLimited(`limitAnalytics`),h=`-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:cursor-pointer!`;if(l)return(0,X.jsx)(T,{className:`flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:cursor-pointer!`,children:(0,X.jsx)(le,{})});let g=f?.analytics.webAnalytics,v=m&&!g,y=f?.paidMembersEnabled,b=[g,v,!0,y].filter(Boolean).length,O=`lg:grid-cols-3`;return b===2?O=`lg:grid-cols-2`:b===1&&(O=`lg:grid-cols-1`),(0,X.jsxs)(`div`,{className:`flex flex-col lg:grid ${O} gap-6`,children:[g&&!v&&(0,X.jsx)(Z,{description:`Number of individual people who visited your website`,diffDirection:`empty`,formattedValue:e.visits,iconName:`Globe`,linkto:`/analytics/web/`,title:`Unique visitors`,onClick:()=>{u(`/analytics/web/`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-blue)`,data:t,id:`visitors`,range:n,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`,yAxisRange:r})}),v&&(0,X.jsxs)(E,{children:[(0,X.jsxs)(x,{className:`hidden`,children:[(0,X.jsx)(C,{children:`Unlock web analytics`}),(0,X.jsx)(w,{children:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`})]}),(0,X.jsx)(S,{className:`flex h-full items-center justify-center p-6`,children:(0,X.jsx)(D,{actions:(0,X.jsx)(N,{variant:`outline`,onClick:()=>u(`/pro`,{crossApp:!0}),children:`Upgrade now`}),className:`py-10`,description:`Get the full picture of what's working with detailed, cookie-free traffic analytics.`,title:`Unlock web analytics`,children:(0,X.jsx)(ae,{})})})]}),(0,X.jsx)(Z,{description:`How number of members of your publication changed over time`,diffDirection:i.directions.total,diffValue:i.percentChanges.total,formattedValue:p(i.totalMembers),iconName:`User`,linkto:`/analytics/growth/`,title:`Members`,trendingFromValue:`${p(a[0].value)}`,onClick:()=>{u(`/analytics/growth/?tab=total-members`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-darkblue)`,data:a,id:`members`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})}),y&&(0,X.jsx)(Z,{description:`Monthly recurring revenue changes over time`,diffDirection:i.directions.mrr,diffValue:i.percentChanges.mrr,formattedValue:`${c}${p(G(i.mrr))}`,iconName:`Coins`,linkto:`/analytics/growth/`,title:`MRR`,trendingFromValue:`${c}${p(o[0].value)}`,onClick:()=>{u(`/analytics/growth/?tab=mrr`)},children:(0,X.jsx)(_,{className:h,color:`var(--chart-teal)`,data:o,id:`mrr`,range:s,showHorizontalLines:!0,showYAxisValues:!1,syncId:`overview-charts`})})]})},we=({className:e})=>(0,X.jsx)(`div`,{className:f(`flex flex-col items-center justify-center gap-1 rounded-sm bg-muted p-6 dark:bg-surface-elevated-2`,e),children:(0,X.jsx)(U,{className:`text-muted-foreground/50`,size:18,strokeWidth:1.5})}),Q=({className:e,metrics:t,title:n})=>(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:f(`pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100`,e),children:[(0,X.jsx)(`div`,{className:`mb-1.5 border-b pr-10 pb-1.5 font-medium whitespace-nowrap text-muted-foreground`,children:n}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t?.map(e=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 whitespace-nowrap`,children:[e.icon,e.label]}),(0,X.jsx)(`span`,{className:`font-mono`,children:e.metric})]},e.label))})]})}),Te=({topPostsData:e,isLoading:t})=>{let n=d(),{range:r}=B(),{settings:i}=q(),{appSettings:a}=M(),o=String(i.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{webAnalytics:s=!1,membersTrackSources:c=!1,emailTrackClicks:u=!1,emailTrackOpens:f=!1}=a?.analytics||{},h=`flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground`;return(0,X.jsxs)(E,{className:`group/card w-full lg:col-span-2`,"data-testid":`top-posts-card`,children:[(0,X.jsxs)(x,{children:[(0,X.jsxs)(C,{className:`flex items-baseline justify-between leading-snug font-medium text-muted-foreground`,children:[`Top posts `,y(r)]}),(0,X.jsx)(w,{className:`hidden`,children:`Most viewed posts in this period`})]}),(0,X.jsx)(S,{children:t?(0,X.jsx)(ie,{className:`mt-6`}):(0,X.jsxs)(X.Fragment,{children:[e?.stats?.map(e=>(0,X.jsxs)(`div`,{className:`group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-table-row-hover before:content-[""] first:border-border! hover:cursor-pointer hover:border-transparent hover:before:block md:items-center [&+div]:hover:border-transparent`,children:[(0,X.jsxs)(`div`,{className:`z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]`,onClick:()=>{n(J({postId:e.post_id,hasEmailData:e.sent_count!==null,analytics:{webAnalytics:s,membersTrackSources:c}}),{crossApp:!0})},children:[e.feature_image?(0,X.jsx)(`div`,{className:`hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:visible! sm:block! lg:w-[100px]`,style:{backgroundImage:`url(${e.feature_image})`}}):(0,X.jsx)(we,{className:`hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:visible! sm:flex! lg:w-[100px]`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`line-clamp-2 text-md font-semibold`,children:e.title}),(0,X.jsxs)(`span`,{className:`text text-muted-foreground`,children:[`By `,e.authors,` – `,m(e.published_at,o)]}),(0,X.jsx)(`span`,{className:`text text-muted-foreground`,children:l(e)})]})]}),(0,X.jsxs)(`div`,{className:`z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3`,children:[s&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-visitors`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/web`,{crossApp:!0})},children:[(0,X.jsx)(Q,{metrics:[{icon:(0,X.jsx)(k,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Unique visitors`,metric:p(e.views)}],title:`Web traffic`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(k,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.views)]})]}),e.sent_count!==null&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/newsletter`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`${c?``:`right-0 left-auto translate-x-0`}`,metrics:[{icon:(0,X.jsx)(L,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Sent`,metric:p(e.sent_count||0)},...f?[{icon:(0,X.jsx)(R,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Opens`,metric:p(e.opened_count||0)}]:[],...u?[{icon:(0,X.jsx)(O,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Clicks`,metric:p(e.clicked_count||0)}]:[]],title:`Newsletter performance`}),(0,X.jsx)(`div`,{className:h,children:f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(R,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.open_rate?`${Math.round(e.open_rate)}%`:`0%`]}):u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(O,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.click_rate?`${Math.round(e.click_rate)}%`:`0%`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),g(e.sent_count||0)]})})]}),c&&(0,X.jsxs)(`div`,{className:`group/tooltip relative flex w-[66px] lg:w-[92px]`,"data-testid":`statistics-members`,onClick:t=>{t.stopPropagation(),n(`/posts/analytics/${e.post_id}/growth`,{crossApp:!0})},children:[(0,X.jsx)(Q,{className:`right-0 left-auto translate-x-0`,metrics:[{icon:(0,X.jsx)(te,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Free`,metric:e.free_members>0?`+${p(e.free_members)}`:`0`},...a?.paidMembersEnabled?[{icon:(0,X.jsx)(I,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),label:`Paid`,metric:e.paid_members>0?`+${p(e.paid_members)}`:`0`}]:[]],title:`New members`}),(0,X.jsxs)(`div`,{className:h,children:[(0,X.jsx)(W,{className:`text-muted-foreground group-hover:text-foreground`,size:16,strokeWidth:1.5}),e.members>0?`+${p(e.members)}`:`0`]})]})]})]},e.post_id)),(!e?.stats||e.stats.length===0)&&(0,X.jsx)(D,{className:`w-full pb-10`,title:`No posts ${y(r)}`,children:(0,X.jsx)(P,{strokeWidth:1.5})})]})})]})},$=({className:e,title:t,description:n,url:r,children:i})=>(0,X.jsx)(`a`,{className:f(`group/card block rounded-xl border bg-card p-6 transition-all hover:bg-table-row-hover hover:shadow-xs`,e),href:r,rel:`noreferrer`,target:`_blank`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-6`,children:[i,(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 leading-tight`,children:[(0,X.jsx)(`span`,{className:`text-base font-semibold`,children:t}),(0,X.jsx)(`span`,{className:`text-sm font-normal text-gray-700`,children:n})]})]})}),Ee=()=>{let{appSettings:e}=M(),{range:t}=B(),{statsConfig:n,isLoading:o}=q(),{startDate:s,endDate:c,timezone:l}=re(t),{isLoading:u,chartData:d,totals:f,currencySymbol:m}=ge(t),{data:h,isLoading:g}=ye(),{data:_,isLoading:y}=i({searchParams:{date_from:j(s),date_to:j(c),limit:`5`,timezone:l}}),{data:x,loading:S}=r({endpoint:`api_kpis`,statsConfig:n,params:{site_uuid:n?.id||``,date_from:j(s),date_to:j(c),timezone:l,member_status:_e(se)}}),C=(0,Y.useMemo)(()=>v(x||[],t,`visits`,`sum`)?.map(e=>{let t=Number(e.visits),n=isNaN(t)?0:t;return{date:String(e.date),value:n,formattedValue:p(n),label:`Visitors`}}),[x,t]),w=(0,Y.useMemo)(()=>b(t,x||[],{fieldName:`visits`}),[x,t]),T=(0,Y.useMemo)(()=>{let e=[0,1];if(!C||C.length===0)return e;let t=C.map(e=>e.value).filter(e=>e>=0);return t.length===0?e:[0,Math.max(...t)||e[1]]},[C]),E=(0,Y.useMemo)(()=>b(t,d||[]),[d,t]),D=(0,Y.useMemo)(()=>{if(!d||d.length===0)return[];let e=[];return e=v(d,t,`value`,`exact`),e.map(e=>({date:e.date,value:e.free+e.paid,formattedValue:p(e.free+e.paid),label:`Members`}))},[d,t]),O=(0,Y.useMemo)(()=>{if(!e?.paidMembersEnabled||!d||d.length===0)return[];let n=[];return n=v(d,t,`mrr`,`exact`),n.map(e=>({date:e.date,value:G(e.mrr),formattedValue:`${m}${p(G(e.mrr))}`,label:`MRR`}))},[d,t,m,e]),A=(0,Y.useMemo)(()=>x?.length?{visits:p(x.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0))}:{visits:`0`},[x]);return(0,X.jsxs)(pe,{children:[(0,X.jsx)(me,{children:(0,X.jsx)(a,{children:(0,X.jsx)(fe,{excludeRanges:[`today`]})})}),(0,X.jsxs)(he,{isLoading:o,loadingComponent:(0,X.jsx)(X.Fragment,{}),children:[(0,X.jsx)(Ce,{currencySymbol:m,growthChartRange:E,growthTotals:f,isLoading:S||u,kpiValues:A,membersChartData:D,mrrChartData:O,visitorsChartData:C,visitorsChartRange:w,visitorsYRange:T}),(0,X.jsx)(xe,{isLoading:g,latestPostStats:h}),(0,X.jsx)(Te,{isLoading:y,topPostsData:_}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:[(0,X.jsx)(F,{className:`mt-4 -mb-4 lg:col-span-2`,children:`Grow your audience`}),(0,X.jsx)($,{description:`Find out how to review the performance of your content and get the most out of post analytics in Ghost.`,title:`Understanding analytics in Ghost`,url:`https://ghost.org/help/native-analytics`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(H,{className:`text-[#00BBA7]`,size:20,strokeWidth:1.5})})}),(0,X.jsx)($,{description:`Use these content distribution tactics to get more people to discover your work and increase engagement.`,title:`How to get your content seen online`,url:`https://ghost.org/resources/content-distribution/`,children:(0,X.jsx)(`div`,{className:`flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100`,children:(0,X.jsx)(k,{className:`text-[#FE9A00]`,size:20,strokeWidth:1.5})})})]})]})]})};export{Ee as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{t as r}from"./use-tinybird-query-C1R_Kbmy.js";import{i,o as a}from"./post-helpers-C5OQMBoi.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as s}from"./router-provider-BmEZf6c6.js";import{f as c,p as l}from"./dist-Cb5RSHSg.js";import{a as u,i as d,t as f}from"./chart-helpers-DV0FkdcD.js";import{a as p,n as m,o as h,t as g}from"./card-aUHX0hyR.js";import{c as _,l as v,n as y,o as b,r as x,s as ee,t as S,u as C}from"./data-list-CupF7bjM.js";import{t as w}from"./empty-indicator-WB1WgT9h.js";import{Co as T,Fs as E,Gr as te,Hr as D,Hs as ne,Ir as O,Jn as k,Wr as re,eo as A,fa as ie,ir as j,nr as M,u as ae,uo as oe,wo as se}from"./index-08n05-rc.js";import{n as N,r as P,t as F}from"./kpi-card-BN-E6WYX.js";import{t as ce}from"./disabled-sources-indicator-DYAXW-6V.js";import{t as I}from"./use-analytics-data-C76v4LIp.js";import{a as L,n as R,r as z,t as B}from"./kpi-card-CCt-qeWD.js";import{n as le,r as ue,t as de}from"./post-analytics-header-pU2m9ZuV.js";import{t as fe}from"./gift-links-CsUhefWG.js";import{r as pe,t as me}from"./gift-link-modal-Buqh2vXh.js";import{n as he}from"./post-analytics-context-D0Mw-Pmv.js";import{n as ge,t as _e}from"./use-post-referrers-CG0SZioj.js";import{a as V,o as H,r as U,t as W}from"./link-helpers-D9LsDOkG.js";import{n as ve,r as G}from"./kpi-helpers-DlxTbTs4.js";var K=e(t(),1),q=n(),ye=({post:e,isNewsletterStatsLoading:t,isWebShown:n})=>{let{postId:r}=o(),i=s(),a=(0,K.useMemo)(()=>{let t=e.email?.opened_count||0,n=e.email?.email_count||0,r=e.count?.clicks||0;return{opened:t,clicked:r,openedRate:n>0?t/n:0,clickedRate:n>0?r/n:0,sent:n}},[e]),{data:u}=V({searchParams:{filter:`post_id:'${r}'`}}),d=(0,K.useMemo)(()=>U(u),[u]),f=[{datatype:`Clicked`,value:a.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`},{datatype:`Opened`,value:a.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],w={percentage:{label:`Opened`},Average:{label:`Clicked`},"This newsletter":{label:`Opened`}},T=e.email_only||!n;return(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${T&&`col-span-2`}`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(A,{size:16,strokeWidth:1.5}),`Newsletter performance`]})}),(0,q.jsx)(O,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{i(`/posts/analytics/${r}/newsletter`)},children:`View more`})]}),t?(0,q.jsx)(m,{children:(0,q.jsx)(`div`,{className:`mx-auto flex min-h-[250px] items-center justify-center xl:size-full`,children:(0,q.jsx)(M,{})})}):(0,q.jsxs)(m,{className:`${T&&`grid grid-cols-2`}`,children:[(0,q.jsxs)(`div`,{className:`${T&&`border-r pr-6`}`,children:[(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-blue)`,children:`Open rate`}),(0,q.jsx)(P,{value:l(a.openedRate)})]})}),(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-teal)`,children:`Click rate`}),(0,q.jsx)(P,{value:l(a.clickedRate)})]})})]}),!T&&(0,q.jsx)(k,{}),(0,q.jsx)(`div`,{className:`mx-auto my-6 h-[240px]`,children:(0,q.jsx)(H,{className:`pointer-events-none aspect-square h-[240px]`,config:w,data:f,tooltip:!1})})]}),(0,q.jsxs)(`div`,{className:`${T&&`pl-6`}`,children:[!T&&(0,q.jsx)(k,{}),(0,q.jsxs)(`div`,{className:T?``:`pt-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 ${T?`pb-3`:`py-3`}`,children:[(0,q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Top clicked links in this email`}),(0,q.jsx)(E,{children:`Members`})]}),d.length>0?(0,q.jsx)(S,{className:``,children:(0,q.jsx)(x,{children:d.slice(0,T?10:5).map(e=>{let t=a.clicked>0?e.count/a.clicked:0;return(0,q.jsxs)(C,{children:[(0,q.jsx)(y,{style:{width:`${t?Math.round(t*100):0}%`}}),(0,q.jsx)(b,{children:(0,q.jsxs)(`div`,{className:`flex items-center space-x-2 overflow-hidden`,children:[(0,q.jsx)(oe,{className:`shrink-0 text-muted-foreground`,size:16,strokeWidth:1.5}),(0,q.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:e.link.to,rel:`noreferrer`,target:`_blank`,title:e.link.to,children:W(e.link.to,!0)})]})}),(0,q.jsxs)(ee,{children:[(0,q.jsx)(_,{children:c(e.count||0)}),(0,q.jsx)(v,{children:l(t)})]})]},e.link.link_id)})})}):(0,q.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]})]})]})]})},be=({chartData:e,range:t,isLoading:n,visitors:r,sourcesData:i,isNewsletterShown:a=!0})=>{let{postId:l}=o(),d=s(),{site:f}=I(),_=f.url,v=f.icon,y=(0,K.useMemo)(()=>i?i.reduce((e,t)=>e+Number(t.visits||0),0):0,[i]);return(0,q.jsx)(q.Fragment,{children:(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${!a&&`col-span-2`}`,"data-testid":`web-performance`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(T,{size:16,strokeWidth:1.5}),`Web performance`]})}),(0,q.jsx)(O,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{d(`/posts/analytics/${l}/web`)},children:`View more`})]}),(0,q.jsxs)(m,{children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(F,{className:`group relative flex grow flex-row items-start justify-between gap-5 border-none px-0 pt-0`,"data-testid":`unique-visitors`,children:(0,q.jsxs)(`div`,{className:`flex grow flex-col gap-1.5 border-none pb-0`,children:[(0,q.jsx)(N,{color:`var(--chart-blue)`,children:`Unique visitors`}),(0,q.jsx)(P,{value:c(r)})]})}),(0,q.jsx)(k,{}),(0,q.jsx)(`div`,{className:`max-h-[288px] py-6 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:n?(0,q.jsx)(`div`,{className:`flex h-[16vw] min-h-[240px] items-center justify-center`,children:(0,q.jsx)(M,{})}):(0,q.jsx)(u,{className:`aspect-auto h-[240px] w-full`,color:`var(--chart-blue)`,data:e||[],id:`visitors`,range:t,syncId:`overview-charts`})})]}),a&&(0,q.jsxs)(`div`,{className:a?`border-t pt-3`:`-mt-3`,children:[(0,q.jsx)(`div`,{children:(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-3`,children:[(0,q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`How readers found this post`}),(0,q.jsx)(E,{children:`Visitors`})]})}),i&&i.length>0?(0,q.jsx)(G,{data:i,range:t,siteIcon:v,siteUrl:_,tableOnly:!0,topSourcesLimit:5,totalVisitors:y}):(0,q.jsx)(w,{className:`h-full py-10`,description:`Once someone visits this post, sources will show here`,title:`No visitors since you published this post`,children:(0,q.jsx)(T,{strokeWidth:1.5})})]})]})]})})},J=()=>{let e=s(),{statsConfig:t,isLoading:n}=I(),{post:o,isPostLoading:l,postId:u}=he(),{totals:_,isLoading:v,currencySymbol:y}=_e(u),{appSettings:b}=ne(),{emailTrackClicks:x,emailTrackOpens:ee}=b?.analytics||{},S=b?.analytics?.webAnalytics===!0,C=le(o),{token:w,isLoading:T,error:E}=fe(u,{enabled:C}),{usage:k,loading:A,error:oe}=pe({postUuid:o?.uuid,token:w,tokenLoading:T,tokenError:E,enabled:C}),[N,P]=(0,K.useState)(!1),F=(0,K.useMemo)(()=>o?.published_at?te(o.published_at):ae.allTime.value,[o?.published_at]),{startDate:V,endDate:H,timezone:U}=re(F),W=(0,K.useMemo)(()=>{let e={site_uuid:t?.id||``,date_from:D(V),date_to:D(H),timezone:U,post_uuid:``};return!l&&o?.uuid?{...e,post_uuid:o.uuid}:e},[l,o,t?.id,V,H,U]),{data:G,loading:J}=r({endpoint:`api_kpis`,statsConfig:t,params:W}),xe=(0,K.useMemo)(()=>G?.length?G.reduce((e,t)=>{let n=Number(t.visits);return e+(isNaN(n)?0:n)},0):0,[G]),Y=ve.visits,Se=f(F,G||[],{fieldName:Y.dataKey}),Ce=d(G||[],F,Y.dataKey,`sum`)?.map(e=>{let t=Number(e[Y.dataKey]);return{date:String(e.date),value:t,formattedValue:Y.formatter(t),label:Y.label}}),{data:we,loading:Te}=r({endpoint:`api_top_sources`,statsConfig:t,params:W}),Ee=n||v||l||J,De=l||n||J,X=a(o)&&ee&&x,Z=!o?.email_only&&S,Q=b?.analytics.membersTrackSources,$=!!(C&&o&&b?.analytics.webAnalytics);return(0,K.useEffect)(()=>{!l&&o&&i(o)&&!S&&Q&&e(`/posts/analytics/${u}/growth`,{replace:!0})},[l,o,S,e,u,Q]),l?(0,q.jsx)(M,{}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(de,{currentTab:`Overview`}),(0,q.jsx)(ue,{children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 lg:grid lg:grid-cols-2`,children:[Z&&(0,q.jsx)(be,{chartData:Ce,isLoading:De||Ee||Te,isNewsletterShown:X,range:Se,sourcesData:we,visitors:xe}),X&&(0,q.jsx)(ye,{isNewsletterStatsLoading:l,isWebShown:Z,post:o}),(Q||$)&&(0,q.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-6 lg:grid lg:grid-cols-3`,children:[Q&&(0,q.jsxs)(g,{className:`group overflow-hidden p-0 ${$?`lg:col-span-2`:`lg:col-span-3`}`,"data-testid":`growth`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(ie,{size:16,strokeWidth:1.5}),`Growth`]})}),(0,q.jsx)(O,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>{e(`/posts/analytics/${u}/growth`)},children:`View more`})]}),(0,q.jsx)(m,{className:`flex flex-col gap-6 px-0 md:grid md:grid-cols-3 md:items-stretch md:gap-0`,children:Ee?Array.from({length:3},(e,t)=>(0,q.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,q.jsx)(j,{className:`w-2/3`}),(0,q.jsx)(j,{className:`h-7 w-12`})]},t)):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`Free members`}),(0,q.jsx)(R,{children:(0,q.jsx)(L,{className:`text-[2.2rem]`,children:c(_?.free_members||0)})})]}),b?.paidMembersEnabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`Paid members`}),(0,q.jsx)(R,{children:(0,q.jsx)(L,{className:`text-[2.2rem]`,children:c(_?.paid_members||0)})})]}),(0,q.jsxs)(B,{className:`grow gap-1 py-0`,children:[(0,q.jsx)(z,{children:`MRR impact`}),(0,q.jsx)(R,{children:(0,q.jsxs)(L,{className:`text-[2.2rem]`,children:[y,c(ge(_?.mrr||0))]})})]})]})]})})]}),$&&(0,q.jsxs)(g,{className:`group/datalist overflow-hidden ${Q?`lg:col-span-1`:`lg:col-span-3`}`,"data-testid":`gift-link-card`,children:[(0,q.jsxs)(`div`,{className:`relative flex items-center justify-between gap-6`,children:[(0,q.jsx)(p,{children:(0,q.jsxs)(h,{className:`flex items-center gap-1.5 text-lg`,children:[(0,q.jsx)(se,{size:16,strokeWidth:1.5}),`Gift link`]})}),(0,q.jsx)(O,{className:`absolute right-6 translate-x-10 opacity-0 transition-all duration-300 group-hover/datalist:translate-x-0 group-hover/datalist:opacity-100 focus-visible:translate-x-0 focus-visible:opacity-100`,size:`sm`,variant:`outline`,onClick:()=>P(!0),children:`Share`})]}),!A&&!oe&&(0,q.jsxs)(m,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Visitors`}),(0,q.jsx)(`span`,{className:`text-[2.2rem] leading-none font-semibold`,"data-testid":`gift-link-card-visitors`,children:c(k?.visits??0)})]})]})]}),!Z&&!X&&!Q&&!$&&(0,q.jsx)(ce,{className:`col-span-2 py-20`})]})}),$&&(0,q.jsx)(me,{open:N,postId:u,source:`gift-link-card`,onOpenChange:P},u)]})};export{J as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r}from"./dist-DGzPJ_bO.js";import{t as i}from"./inline-EMAm3okk.js";import{t as a}from"./stack-xiN0eQ6Z.js";import{t as o}from"./text-DwtjwGkh.js";import{As as s,Jr as c,Xr as l,ii as u}from"./index-BGG7NckO.js";var d=e(t(),1),f=n();function p({className:e,children:t}){return(0,f.jsx)(i,{align:`center`,className:r(`pt-1 text-sm text-muted-foreground`,e),"data-page-header":`breadcrumb`,gap:`sm`,children:t})}function m({className:e,children:t}){return(0,f.jsx)(o,{as:`span`,className:r(`ml-1 text-base tabular-nums`,e),"data-page-header":`count`,tone:`secondary`,weight:`regular`,children:t})}function h({className:e,children:t}){return(0,f.jsx)(o,{as:`p`,className:e,"data-page-header":`description`,size:`sm`,tone:`secondary`,children:t})}function g({className:e,children:t}){return(0,f.jsx)(o,{as:`p`,className:r(`mt-0.5`,e),"data-page-header":`meta`,size:`sm`,tone:`secondary`,children:t})}function _({className:e,children:t}){let n=[],i=[];d.Children.forEach(t,e=>{if(!d.isValidElement(e)){n.push(e);return}switch(e.type){case h:case g:i.push(e);break;default:n.push(e)}});let o=(0,f.jsx)(s,{className:r(`text-lg font-semibold tracking-[0.1px] whitespace-nowrap`,e),"data-page-header":`title`,children:n});return i.length>0?(0,f.jsxs)(a,{"data-page-header":`title-body`,gap:`none`,children:[o,i]}):o}function v({className:e,children:t}){return(0,f.jsx)(a,{className:r(`h-full min-h-(--control-height) min-w-0`,e),"data-page-header":`left`,gap:`xs`,justify:`center`,children:t})}function y({children:e}){return(0,f.jsx)(f.Fragment,{children:e})}function b({children:e}){return(0,f.jsx)(c,{children:e})}function x({children:e,...t}){return(0,f.jsx)(u,{asChild:!0,...t,children:e})}function S({children:e,...t}){return(0,f.jsx)(l,{align:`end`,sideOffset:8,...t,children:e})}var C=640,w=e=>typeof window>`u`?!1:window.innerWidth<e,T=e=>{let[t,n]=d.useState(()=>w(e));return d.useEffect(()=>{let t=()=>{n(w(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t},E=Object.assign(function({className:e,children:t,mobileMenuBreakpoint:n=C}){let r=d.Children.toArray(t),a=[],o=null,s=null,c=T(n);return r.forEach(e=>{if(!d.isValidElement(e)){a.push(e);return}let t=e;if(t.type===b){o=t;return}if(t.type===y){s=t.props.children??null,a.push(t.props.children??null);return}a.push(t)}),o?c?(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,f.jsxs)(i,{align:`center`,className:`ml-auto`,"data-page-header":`action-group-mobile`,gap:`sm`,children:[o,s&&(0,f.jsx)(`div`,{"data-page-header":`action-group-mobile-primary`,children:s})]})}):(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,f.jsx)(i,{align:`center`,"data-page-header":`action-group-desktop`,gap:`sm`,justify:`end`,children:a})}):(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:t})},{Primary:y,MobileMenu:b,MobileMenuTrigger:x,MobileMenuContent:S});function D({className:e,children:t}){return(0,f.jsx)(i,{align:`center`,className:r(`min-h-(--control-height) shrink-0`,e),"data-page-header":`actions`,gap:`lg`,children:t})}var O=Object.assign(function({className:e,children:t,sticky:n=!0,blurredBackground:a=!0}){return(0,f.jsx)(`header`,{className:r(`flex flex-col`,n&&`sticky top-0 z-50`,a&&`bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md dark:bg-black`,e),"data-page-header":`page-header`,children:(0,f.jsx)(i,{align:`start`,className:`w-full`,"data-page-header":`main`,gap:`lg`,justify:`between`,children:t})})},{Left:v,Breadcrumb:p,Title:_,Count:m,Description:h,Meta:g,Actions:D,ActionGroup:E});export{O as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r}from"./dist-Cb5RSHSg.js";import{t as i}from"./inline-Cw-gigDW.js";import{t as a}from"./stack-CIfOAAVf.js";import{t as o}from"./text-DU9Hv33_.js";import{Jr as s,Xr as c,ii as l,js as u}from"./index-08n05-rc.js";var d=e(t(),1),f=n();function p({className:e,children:t}){return(0,f.jsx)(i,{align:`center`,className:r(`pt-1 text-sm text-muted-foreground`,e),"data-page-header":`breadcrumb`,gap:`sm`,children:t})}function m({className:e,children:t}){return(0,f.jsx)(o,{as:`span`,className:r(`ml-1 text-base tabular-nums`,e),"data-page-header":`count`,tone:`secondary`,weight:`regular`,children:t})}function h({className:e,children:t}){return(0,f.jsx)(o,{as:`p`,className:e,"data-page-header":`description`,size:`sm`,tone:`secondary`,children:t})}function g({className:e,children:t}){return(0,f.jsx)(o,{as:`p`,className:r(`mt-0.5`,e),"data-page-header":`meta`,size:`sm`,tone:`secondary`,children:t})}function _({className:e,children:t}){let n=[],i=[];d.Children.forEach(t,e=>{if(!d.isValidElement(e)){n.push(e);return}switch(e.type){case h:case g:i.push(e);break;default:n.push(e)}});let o=(0,f.jsx)(u,{className:r(`text-lg font-semibold tracking-[0.1px] whitespace-nowrap`,e),"data-page-header":`title`,children:n});return i.length>0?(0,f.jsxs)(a,{"data-page-header":`title-body`,gap:`none`,children:[o,i]}):o}function v({className:e,children:t}){return(0,f.jsx)(a,{className:r(`h-full min-h-(--control-height) min-w-0`,e),"data-page-header":`left`,gap:`xs`,justify:`center`,children:t})}function y({children:e}){return(0,f.jsx)(f.Fragment,{children:e})}function b({children:e}){return(0,f.jsx)(s,{children:e})}function x({children:e,...t}){return(0,f.jsx)(l,{asChild:!0,...t,children:e})}function S({children:e,...t}){return(0,f.jsx)(c,{align:`end`,sideOffset:8,...t,children:e})}var C=640,w=e=>typeof window>`u`?!1:window.innerWidth<e,T=e=>{let[t,n]=d.useState(()=>w(e));return d.useEffect(()=>{let t=()=>{n(w(e))};return t(),window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t)}},[e]),t},E=Object.assign(function({className:e,children:t,mobileMenuBreakpoint:n=C}){let r=d.Children.toArray(t),a=[],o=null,s=null,c=T(n);return r.forEach(e=>{if(!d.isValidElement(e)){a.push(e);return}let t=e;if(t.type===b){o=t;return}if(t.type===y){s=t.props.children??null,a.push(t.props.children??null);return}a.push(t)}),o?c?(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,f.jsxs)(i,{align:`center`,className:`ml-auto`,"data-page-header":`action-group-mobile`,gap:`sm`,children:[o,s&&(0,f.jsx)(`div`,{"data-page-header":`action-group-mobile-primary`,children:s})]})}):(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:(0,f.jsx)(i,{align:`center`,"data-page-header":`action-group-desktop`,gap:`sm`,justify:`end`,children:a})}):(0,f.jsx)(i,{align:`center`,className:e,"data-page-header":`action-group`,gap:`sm`,justify:`end`,children:t})},{Primary:y,MobileMenu:b,MobileMenuTrigger:x,MobileMenuContent:S});function D({className:e,children:t}){return(0,f.jsx)(i,{align:`center`,className:r(`min-h-(--control-height) shrink-0`,e),"data-page-header":`actions`,gap:`lg`,children:t})}var O=Object.assign(function({className:e,children:t,sticky:n=!0,blurredBackground:a=!0}){return(0,f.jsx)(`header`,{className:r(`flex flex-col`,n&&`sticky top-0 z-50`,a&&`bg-gradient-to-b from-background via-background/70 to-background/70 backdrop-blur-md dark:bg-black`,e),"data-page-header":`page-header`,children:(0,f.jsx)(i,{align:`start`,className:`w-full`,"data-page-header":`main`,gap:`lg`,justify:`between`,children:t})})},{Left:v,Breadcrumb:p,Title:_,Count:m,Description:h,Meta:g,Actions:D,ActionGroup:E});export{O as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./posts-DhXE7b6r.js";import{t as i}from"./analytics-53FOa2wq.js";import{r as a}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{t as o}from"./box-BWbhXh21.js";import{t as s}from"./container-BYz2Ed39.js";import{t as c}from"./use-analytics-data-S0FTd43s.js";import{t as l}from"./post-share-modal-DFfO93_0.js";var u=e(t(),1),d=n(),f=({children:e})=>(0,d.jsx)(o,{className:`size-full`,children:(0,d.jsx)(s,{className:`relative flex h-full flex-col`,size:`page`,children:(0,d.jsx)(`div`,{className:`grid w-full grow`,children:(0,d.jsx)(`div`,{className:`flex h-full flex-col px-8`,children:e})})})}),p=()=>{let[e,t]=(0,u.useState)(!1),[n,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(null),{site:s}=c(),{data:l}=r({searchParams:n?{filter:`id:${n.id}`,include:`authors,newsletter,email`}:{},enabled:!!n}),{data:d}=r({searchParams:{filter:`status:[published,sent]`,limit:`1`,fields:`id`},enabled:!!n}),f=l?.posts?.[0],p=e=>`${e.toLocaleString()} subscriber${e===1?``:`s`}`,m=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),h=e=>e?.map(e=>e.name).join(`, `)||``,g=(0,u.useMemo)(()=>{if(!f)return null;let n=!!a,r=()=>{let e=[];if(f.email_only?e.push(`Your email was sent to`):f.email?.email_count?e.push(`Your post was published on your site and sent to`):e.push(`Your post was published on your site`),f.email?.email_count){let t=p(f.email.email_count);e.push(` `),e.push(u.createElement(`strong`,{key:`subscriber-count`},t)),f.newsletter?.name&&(e.push(` of `),e.push(u.createElement(`strong`,{key:`newsletter-name`},f.newsletter.name))),e.push(`,`)}if(f.published_at){let t=new Date(f.published_at);t.toDateString()===new Date().toDateString()?(e.push(` `),e.push(u.createElement(`strong`,{key:`today`},`today`))):(e.push(` on `),e.push(u.createElement(`strong`,{key:`date`},t.toLocaleDateString(`en-US`,{month:`long`,day:`numeric`})))),e.push(` at `),e.push(u.createElement(`strong`,{key:`time`},m(f.published_at)))}return e.push(`.`),u.createElement(`span`,{},...e)},c=()=>{t(!1),i(null),o(null)};return{open:e,onOpenChange:e=>{e||c()},emailOnly:f.email_only,postURL:f.url||``,primaryTitle:`Boom! It's out there.`,secondaryTitle:n&&a?`That's ${a.toLocaleString()} post${a===1?``:`s`} published.`:`Spread the word!`,description:r(),featureImageURL:f.feature_image||``,postTitle:f.title||``,postExcerpt:f.excerpt||``,faviconURL:s?.icon||``,siteTitle:s?.title||``,author:h(f.authors),onClose:c}},[f,e,a,s?.title]);return(0,u.useEffect)(()=>{let e=()=>{try{let e=localStorage.getItem(`ghost-last-published-post`);if(e){let n=JSON.parse(e);i(n),t(!0),localStorage.removeItem(`ghost-last-published-post`)}}catch{}};e();let n=setTimeout(e,100);return()=>clearTimeout(n)},[]),(0,u.useEffect)(()=>{d?.meta?.pagination?.total&&o(d.meta.pagination.total)},[d]),{isModalOpen:e,post:f,postCount:a,showPostCount:!!a,closeModal:()=>{t(!1),i(null),o(null)},modalProps:g}},m=()=>{let{isModalOpen:e,modalProps:t}=p(),n=e&&!!t;return(0,u.useEffect)(()=>{n&&i(`Share Modal Opened`,{giftLinkShown:!1,source:`publish-flow`})},[n]),(0,d.jsxs)(f,{children:[(0,d.jsx)(a,{}),e&&t&&(0,d.jsx)(l,{...t})]})};export{m as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./posts-DhXE7b6r.js";import{t as i}from"./analytics-53FOa2wq.js";import{r as a}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{t as o}from"./box-By_EgGtm.js";import{t as s}from"./container-LiZf3XdY.js";import{t as c}from"./use-analytics-data-C76v4LIp.js";import{t as l}from"./post-share-modal-AcUZkbfL.js";var u=e(t(),1),d=n(),f=({children:e})=>(0,d.jsx)(o,{className:`size-full`,children:(0,d.jsx)(s,{className:`relative flex h-full flex-col`,size:`page`,children:(0,d.jsx)(`div`,{className:`grid w-full grow`,children:(0,d.jsx)(`div`,{className:`flex h-full flex-col px-8`,children:e})})})}),p=()=>{let[e,t]=(0,u.useState)(!1),[n,i]=(0,u.useState)(null),[a,o]=(0,u.useState)(null),{site:s}=c(),{data:l}=r({searchParams:n?{filter:`id:${n.id}`,include:`authors,newsletter,email`}:{},enabled:!!n}),{data:d}=r({searchParams:{filter:`status:[published,sent]`,limit:`1`,fields:`id`},enabled:!!n}),f=l?.posts?.[0],p=e=>`${e.toLocaleString()} subscriber${e===1?``:`s`}`,m=e=>new Date(e).toLocaleTimeString(`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),h=e=>e?.map(e=>e.name).join(`, `)||``,g=(0,u.useMemo)(()=>{if(!f)return null;let n=!!a,r=()=>{let e=[];if(f.email_only?e.push(`Your email was sent to`):f.email?.email_count?e.push(`Your post was published on your site and sent to`):e.push(`Your post was published on your site`),f.email?.email_count){let t=p(f.email.email_count);e.push(` `),e.push(u.createElement(`strong`,{key:`subscriber-count`},t)),f.newsletter?.name&&(e.push(` of `),e.push(u.createElement(`strong`,{key:`newsletter-name`},f.newsletter.name))),e.push(`,`)}if(f.published_at){let t=new Date(f.published_at);t.toDateString()===new Date().toDateString()?(e.push(` `),e.push(u.createElement(`strong`,{key:`today`},`today`))):(e.push(` on `),e.push(u.createElement(`strong`,{key:`date`},t.toLocaleDateString(`en-US`,{month:`long`,day:`numeric`})))),e.push(` at `),e.push(u.createElement(`strong`,{key:`time`},m(f.published_at)))}return e.push(`.`),u.createElement(`span`,{},...e)},c=()=>{t(!1),i(null),o(null)};return{open:e,onOpenChange:e=>{e||c()},emailOnly:f.email_only,postURL:f.url||``,primaryTitle:`Boom! It's out there.`,secondaryTitle:n&&a?`That's ${a.toLocaleString()} post${a===1?``:`s`} published.`:`Spread the word!`,description:r(),featureImageURL:f.feature_image||``,postTitle:f.title||``,postExcerpt:f.excerpt||``,faviconURL:s?.icon||``,siteTitle:s?.title||``,author:h(f.authors),onClose:c}},[f,e,a,s?.title]);return(0,u.useEffect)(()=>{let e=()=>{try{let e=localStorage.getItem(`ghost-last-published-post`);if(e){let n=JSON.parse(e);i(n),t(!0),localStorage.removeItem(`ghost-last-published-post`)}}catch{}};e();let n=setTimeout(e,100);return()=>clearTimeout(n)},[]),(0,u.useEffect)(()=>{d?.meta?.pagination?.total&&o(d.meta.pagination.total)},[d]),{isModalOpen:e,post:f,postCount:a,showPostCount:!!a,closeModal:()=>{t(!1),i(null),o(null)},modalProps:g}},m=()=>{let{isModalOpen:e,modalProps:t}=p(),n=e&&!!t;return(0,u.useEffect)(()=>{n&&i(`Share Modal Opened`,{giftLinkShown:!1,source:`publish-flow`})},[n]),(0,d.jsxs)(f,{children:[(0,d.jsx)(a,{}),e&&t&&(0,d.jsx)(l,{...t})]})};export{m as default};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r,o as i}from"./hooks-CixO01lL.js";import{h as ee,m as a,p as te,v as ne}from"./stats-C_lfxZAw.js";import{i as re}from"./posts-DhXE7b6r.js";import{t as o}from"./analytics-53FOa2wq.js";import{i as s,n as ie,o as ae,r as c}from"./post-helpers-C5OQMBoi.js";import{a as oe}from"./router-provider-BmEZf6c6.js";import{c as l,f as se,l as u,u as d}from"./dist-Cb5RSHSg.js";import{a as ce,i as le,n as f,o as ue,r as de,t as fe}from"./breadcrumb-DIfcF5ow.js";import{r as p}from"./users-Dkv8NQZe.js";import{Hs as pe,Ia as me,Ir as m,Jr as he,Lo as ge,Qr as h,Ro as _e,Xr as g,Yi as _,Zr as v,cr as y,dr as b,fr as x,ii as S,js as C,lr as w,ma as T,mr as E,ni as D,pr as O,sr as k,ur as A}from"./index-08n05-rc.js";import{t as j}from"./use-analytics-data-C76v4LIp.js";import{t as M}from"./post-share-modal-AcUZkbfL.js";import{t as N}from"./get-site-timezone-HgL0jI_F.js";import{i as P,t as F}from"./gift-link-modal-Buqh2vXh.js";import{n as ve}from"./post-analytics-context-D0Mw-Pmv.js";var I=e(t(),1),L=n(),R=(0,I.forwardRef)(({children:e,className:t,...n},r)=>(0,L.jsx)(`section`,{ref:r,className:l(`flex size-full grow flex-col gap-6 py-8`,t),...n,children:e}));R.displayName=`PostAnalyticsContent`;var z=e=>{let{data:t}=i();return!e||!t?!1:e.status===`published`&&!!e.visibility&&e.visibility!==`public`&&p(t)},B=({currentTab:e,children:t})=>{let n=oe(),{appSettings:i}=pe(),{mutateAsync:l}=re(),p=r(),[R,B]=(0,I.useState)(!1),[V,H]=(0,I.useState)(!1),[ye,U]=(0,I.useState)(!1),{settings:be,site:W,statsConfig:xe}=j(),{post:G,isPostLoading:K,postId:q}=ve(),J=z(G),Y=N(be),X=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!V){X.current=!1;return}X.current||(X.current=!0,o(`Share Modal Opened`,{giftLinkShown:J,source:`post-analytics`}))},[V,J]);let{activeVisitors:Z,isLoading:Q}=ne({postUuid:G?.uuid,statsConfig:xe,enabled:i?.analytics?.webAnalytics??!1}),$=(0,I.useMemo)(()=>{if(!G)return[];let e=[];return s(G)&&!i?.analytics.webAnalytics||(e.push(`Overview`),!G.email_only&&i?.analytics.webAnalytics&&e.push(`Web`)),ae(G)&&e.push(`Newsletter`),i?.analytics.membersTrackSources&&e.push(`Growth`),e},[G,i?.analytics.webAnalytics,i?.analytics.membersTrackSources]),Se=()=>{G&&B(!0)},Ce=async()=>{if(G)try{await l(q),B(!1),n(`/posts/`,{crossApp:!0})}catch(e){p(e)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`header`,{className:`z-50 -mx-8 bg-white/70 backdrop-blur-md dark:bg-background`,children:(0,L.jsx)(`div`,{className:`relative flex min-h-[102px] w-full items-start justify-between gap-5 px-8 pt-8 pb-0`,"data-header":`header`,children:(0,L.jsxs)(`div`,{className:`flex w-full flex-col gap-6`,children:[(0,L.jsxs)(`div`,{className:`flex w-full flex-col justify-between md:flex-row md:items-center`,children:[(0,L.jsx)(fe,{children:(0,L.jsxs)(le,{children:[(0,L.jsx)(f,{children:(0,L.jsx)(de,{asChild:!0,children:(0,L.jsx)(`button`,{className:`cursor-pointer rounded-sm focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden`,type:`button`,onClick:()=>n(`/analytics/`,{crossApp:!0}),children:`Analytics`})})}),(0,L.jsx)(ue,{}),(0,L.jsx)(f,{children:(0,L.jsx)(ce,{children:`Post analytics`})})]})}),(0,L.jsxs)(`div`,{className:`flex w-full items-center gap-2 md:w-auto`,children:[i?.analytics.webAnalytics&&!G?.email_only&&(0,L.jsx)(`div`,{className:`mr-3 flex grow items-center gap-2 md:grow-0`,children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,title:`Active readers in the last 5 minutes · Updates every 60 seconds`,children:[(0,L.jsxs)(`span`,{children:[Q?``:se(Z),` reading now`]}),(0,L.jsx)(`div`,{className:`size-2 rounded-full ${Q?`animate-pulse bg-muted`:Z?`bg-green-500`:`border border-muted-foreground`}`})]})}),!K&&(0,L.jsxs)(L.Fragment,{children:[!G?.email_only&&(0,L.jsx)(M,{author:G?.authors?.[0]?.name||``,canShareAsGift:J,description:``,faviconURL:W?.icon||``,featureImageURL:G?.feature_image,giftAccessLabel:P(G?.visibility),open:V,postExcerpt:G?.excerpt||``,postTitle:G?.title,postURL:G?.url,siteTitle:W?.title||``,onClose:()=>H(!1),onOpenChange:H,onShareAsGift:()=>{H(!1),U(!0)},children:(0,L.jsxs)(m,{variant:`outline`,onClick:()=>H(!0),children:[(0,L.jsx)(T,{}),` Share`]})}),(0,L.jsxs)(he,{children:[(0,L.jsx)(S,{asChild:!0,children:(0,L.jsx)(m,{variant:`outline`,children:(0,L.jsx)(_e,{})})}),(0,L.jsxs)(g,{align:`end`,children:[(0,L.jsxs)(v,{children:[(0,L.jsx)(h,{asChild:!0,children:(0,L.jsxs)(`a`,{href:G?.url,rel:`noopener noreferrer`,target:`_blank`,children:[(0,L.jsx)(ge,{}),`View in browser`]})}),(0,L.jsxs)(h,{onClick:()=>{n(`/editor/post/${q}`,{crossApp:!0})},children:[(0,L.jsx)(me,{}),`Edit post`]})]}),(0,L.jsx)(D,{}),(0,L.jsx)(v,{children:(0,L.jsxs)(h,{className:`text-destructive focus:text-destructive`,onClick:Se,children:[(0,L.jsx)(_,{}),`Delete post`]})})]})]})]})]})]}),!K&&(0,L.jsxs)(`div`,{className:`flex items-start gap-6 md:items-center`,children:[G?.feature_image&&(0,L.jsx)(`div`,{className:`aspect-[16/10] w-full max-w-[100px] rounded-md bg-cover bg-center md:max-w-[132px]`,style:{backgroundImage:`url(${G.feature_image})`}}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(C,{className:`-ml-px max-w-[920px] indent-0 !text-xl md:leading-[1.2em]`,"data-header":`header-title`,children:G?.title}),G?.published_at&&(0,L.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-start leading-[1.65em] text-muted-foreground`,children:[ie(G)&&`Sent on ${u(G.published_at,Y)} at ${d(G.published_at,Y)}`,s(G)&&`Published on your site on ${u(G.published_at,Y)} at ${d(G.published_at,Y)}`,c(G)&&`Published and sent on ${u(G.published_at,Y)} at ${d(G.published_at,Y)}`]})]})]})]})})}),(0,L.jsxs)(ee,{className:`sticky top-0 z-50 -mb-8 transform-gpu flex-col items-start gap-y-0 border-none bg-white/70 py-8 backdrop-blur-md lg:flex-row lg:items-center dark:bg-background`,children:[!K&&(0,L.jsxs)(te,{className:`min-h-[34px]`,defaultValue:e,responsive:!0,children:[$.includes(`Overview`)&&(0,L.jsx)(a,{value:`Overview`,onClick:()=>{n(`/posts/analytics/${q}`)},children:`Overview`}),$.includes(`Web`)&&(0,L.jsx)(a,{value:`Web`,onClick:()=>{n(`/posts/analytics/${q}/web`)},children:`Web traffic`}),$.includes(`Newsletter`)&&(0,L.jsx)(a,{value:`Newsletter`,onClick:()=>{n(`/posts/analytics/${q}/newsletter`)},children:`Newsletter`}),$.includes(`Growth`)&&(0,L.jsx)(a,{value:`Growth`,onClick:()=>{n(`/posts/analytics/${q}/growth`)},children:`Growth`})]}),t]}),J&&q&&(0,L.jsx)(F,{open:ye,postId:q,source:`share-modal`,onOpenChange:U},q),(0,L.jsx)(k,{open:R,onOpenChange:B,children:(0,L.jsxs)(A,{children:[(0,L.jsxs)(O,{children:[(0,L.jsx)(E,{children:`Are you sure you want to delete this post?`}),(0,L.jsxs)(b,{children:[`You're about to delete "`,(0,L.jsx)(`strong`,{children:G?.title}),`". This is permanent! We warned you, k?`]})]}),(0,L.jsxs)(x,{children:[(0,L.jsx)(w,{children:`Cancel`}),(0,L.jsx)(y,{className:`bg-red-600 text-white hover:bg-red-700`,onClick:()=>void Ce(),children:`Delete`})]})]})})]})};export{z as n,R as r,B as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./posts-DhXE7b6r.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a,u as o}from"./index-BGG7NckO.js";import{t as s}from"./post-analytics-context-D0Mw-Pmv.js";var c=e(t(),1),l=n(),u=({children:e})=>{let{postId:t}=i();if(!t)throw Error(`Post ID is required for PostAnalyticsProvider`);let[n,u]=(0,c.useState)(o.last30Days.value),{data:{posts:[d]}={posts:[]},isLoading:f}=r({searchParams:{filter:`id:${t}`,include:a}});return(0,l.jsx)(s.Provider,{value:{postId:t,post:d,isPostLoading:f,range:n,setRange:u},children:e})};export{u as default};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./posts-DhXE7b6r.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a,u as o}from"./index-08n05-rc.js";import{t as s}from"./post-analytics-context-D0Mw-Pmv.js";var c=e(t(),1),l=n(),u=({children:e})=>{let{postId:t}=i();if(!t)throw Error(`Post ID is required for PostAnalyticsProvider`);let[n,u]=(0,c.useState)(o.last30Days.value),{data:{posts:[d]}={posts:[]},isLoading:f}=r({searchParams:{filter:`id:${t}`,include:a}});return(0,l.jsx)(s.Provider,{value:{postId:t,post:d,isPostLoading:f,range:n,setRange:u},children:e})};export{u as default};
@@ -1 +1 @@
1
- import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{Ir as n,Ms as r}from"./index-BGG7NckO.js";import{t as i}from"./share-modal-DsgW3wbg.js";e();var a=t(),o=({author:e=``,canShareAsGift:t=!1,children:o,description:s=``,emailOnly:c=!1,faviconURL:l=``,featureImageURL:u=``,giftAccessLabel:d=``,onClose:f=()=>{},onShareAsGift:p=()=>{},postExcerpt:m=``,postTitle:h=``,postURL:g=``,primaryTitle:_=`Your post is published.`,secondaryTitle:v=`Spread the word!`,siteTitle:y=``,...b})=>{let x=encodeURIComponent(h),S=encodeURIComponent(g),C=encodeURIComponent(`${h} ${g}`),w=c?[]:[{href:`https://twitter.com/intent/tweet?text=${x}%0A${S}`,label:`Share on X`,service:`x`},{href:`https://threads.net/intent/post?text=${C}`,label:`Share on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${S}`,label:`Share on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/shareArticle?mini=true&title=${x}&url=${S}`,label:`Share on LinkedIn`,service:`linkedin`}];return(0,a.jsxs)(i.Root,{...b,children:[o&&(0,a.jsx)(i.Trigger,{children:o}),(0,a.jsxs)(i.Content,{children:[(0,a.jsx)(`div`,{className:`sticky top-0 ml-auto size-0`,children:(0,a.jsx)(i.CloseButton,{className:`absolute -top-5 -right-5`,onClick:f})}),(0,a.jsxs)(i.Header,{className:`relative -mt-5`,children:[(0,a.jsxs)(i.Title,{className:`text-3xl leading-[1.15em] font-bold`,children:[_&&(0,a.jsx)(`span`,{className:`text-state-success`,children:_}),_&&v&&(0,a.jsx)(`br`,{}),v&&(0,a.jsx)(`span`,{children:v})]}),s&&(0,a.jsx)(i.Description,{className:`mb-0 pt-1 pb-0 text-lg text-foreground`,children:s})]}),(0,a.jsxs)(i.Preview,{className:`rounded-md`,href:g,children:[u&&(0,a.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${u})`}}),(0,a.jsxs)(`div`,{className:`p-6 pt-5`,children:[(0,a.jsx)(r,{children:h}),m&&(0,a.jsx)(`p`,{className:`line-clamp-2`,children:m}),(0,a.jsxs)(`div`,{className:`mt-2 flex items-start gap-2`,children:[(0,a.jsx)(`div`,{className:`mt-0.5 size-4 bg-cover bg-center`,style:{backgroundImage:`url(${l})`}}),(0,a.jsxs)(`div`,{className:`flex gap-1`,children:[(0,a.jsx)(`strong`,{children:y}),(0,a.jsx)(`span`,{children:`•`}),(0,a.jsx)(`span`,{children:e})]})]})]})]}),(0,a.jsx)(i.Footer,{children:c?(0,a.jsx)(n,{className:`cursor-pointer`,type:`button`,onClick:f,children:`Close`}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.SocialLinks,{links:w}),(0,a.jsx)(i.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:g,icon:`link`})]})}),t&&!c&&(0,a.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[`Want to share full access to this `,d,` post?`,` `,(0,a.jsx)(n,{className:`h-auto p-0 align-baseline text-sm`,type:`button`,variant:`link`,onClick:p,children:`Share as a gift`}),`.`]})]})]})};export{o as t};
1
+ import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{Ir as n,Ns as r}from"./index-08n05-rc.js";import{t as i}from"./share-modal-BeuydaBf.js";e();var a=t(),o=({author:e=``,canShareAsGift:t=!1,children:o,description:s=``,emailOnly:c=!1,faviconURL:l=``,featureImageURL:u=``,giftAccessLabel:d=``,onClose:f=()=>{},onShareAsGift:p=()=>{},postExcerpt:m=``,postTitle:h=``,postURL:g=``,primaryTitle:_=`Your post is published.`,secondaryTitle:v=`Spread the word!`,siteTitle:y=``,...b})=>{let x=encodeURIComponent(h),S=encodeURIComponent(g),C=encodeURIComponent(`${h} ${g}`),w=c?[]:[{href:`https://twitter.com/intent/tweet?text=${x}%0A${S}`,label:`Share on X`,service:`x`},{href:`https://threads.net/intent/post?text=${C}`,label:`Share on Threads`,service:`threads`},{href:`https://www.facebook.com/sharer/sharer.php?u=${S}`,label:`Share on Facebook`,service:`facebook`},{href:`https://www.linkedin.com/shareArticle?mini=true&title=${x}&url=${S}`,label:`Share on LinkedIn`,service:`linkedin`}];return(0,a.jsxs)(i.Root,{...b,children:[o&&(0,a.jsx)(i.Trigger,{children:o}),(0,a.jsxs)(i.Content,{children:[(0,a.jsx)(`div`,{className:`sticky top-0 ml-auto size-0`,children:(0,a.jsx)(i.CloseButton,{className:`absolute -top-5 -right-5`,onClick:f})}),(0,a.jsxs)(i.Header,{className:`relative -mt-5`,children:[(0,a.jsxs)(i.Title,{className:`text-3xl leading-[1.15em] font-bold`,children:[_&&(0,a.jsx)(`span`,{className:`text-state-success`,children:_}),_&&v&&(0,a.jsx)(`br`,{}),v&&(0,a.jsx)(`span`,{children:v})]}),s&&(0,a.jsx)(i.Description,{className:`mb-0 pt-1 pb-0 text-lg text-foreground`,children:s})]}),(0,a.jsxs)(i.Preview,{className:`rounded-md`,href:g,children:[u&&(0,a.jsx)(`div`,{className:`aspect-video bg-cover bg-center`,style:{backgroundImage:`url(${u})`}}),(0,a.jsxs)(`div`,{className:`p-6 pt-5`,children:[(0,a.jsx)(r,{children:h}),m&&(0,a.jsx)(`p`,{className:`line-clamp-2`,children:m}),(0,a.jsxs)(`div`,{className:`mt-2 flex items-start gap-2`,children:[(0,a.jsx)(`div`,{className:`mt-0.5 size-4 bg-cover bg-center`,style:{backgroundImage:`url(${l})`}}),(0,a.jsxs)(`div`,{className:`flex gap-1`,children:[(0,a.jsx)(`strong`,{children:y}),(0,a.jsx)(`span`,{children:`•`}),(0,a.jsx)(`span`,{children:e})]})]})]})]}),(0,a.jsx)(i.Footer,{children:c?(0,a.jsx)(n,{className:`cursor-pointer`,type:`button`,onClick:f,children:`Close`}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.SocialLinks,{links:w}),(0,a.jsx)(i.CopyButton,{className:`ml-0! grow cursor-pointer`,copyURL:g,icon:`link`})]})}),t&&!c&&(0,a.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[`Want to share full access to this `,d,` post?`,` `,(0,a.jsx)(n,{className:`h-auto p-0 align-baseline text-sm`,type:`button`,variant:`link`,onClick:p,children:`Share as a gift`}),`.`]})]})]})};export{o as t};