ghost 6.54.1 → 6.55.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.
- package/components/tryghost-adapter-base-scheduling-0.2.0.tgz +0 -0
- package/components/tryghost-custom-field-types-0.0.0.tgz +0 -0
- package/components/tryghost-kg-default-cards-10.3.3.tgz +0 -0
- package/components/tryghost-kg-default-nodes-2.1.3.tgz +0 -0
- package/core/boot.js +3 -6
- package/core/built/admin/assets/{account-migration-BklF2I_I.js → account-migration-sjHLx5dy.js} +1 -1
- package/core/built/admin/assets/activitypub/{account-migration-CNovr6W-.js → account-migration-DoYXtnZ8.js} +4 -4
- package/core/built/admin/assets/activitypub/activitypub.js +1 -1
- package/core/built/admin/assets/activitypub/{bluesky-sharing-Ceslb1_M.js → bluesky-sharing-Bxeh6MKW.js} +4 -4
- package/core/built/admin/assets/activitypub/{dist-DHAjBcV3.js → dist-D8sFfdpC.js} +2 -2
- package/core/built/admin/assets/activitypub/{domain-C1qQvJ8C.js → domain-CWueFW6q.js} +5 -5
- package/core/built/admin/assets/activitypub/{edit-profile-BcH-jEfM.js → edit-profile-BGxPU7N5.js} +3 -3
- package/core/built/admin/assets/activitypub/{explore-AxwBh9dI.js → explore-DBK-u0Ch.js} +3 -3
- package/core/built/admin/assets/activitypub/{feed-BaOlbh7a.js → feed-Bcir5RQZ.js} +3 -3
- package/core/built/admin/assets/activitypub/{field-B7mYYQpN.js → field-BV-CIT3d.js} +2 -2
- package/core/built/admin/assets/activitypub/{inbox-vXez-5uJ.js → inbox-yC0nfvzl.js} +4 -4
- package/core/built/admin/assets/activitypub/{label-Chv5T8bw.js → label-DTRS9TDk.js} +2 -2
- package/core/built/admin/assets/activitypub/layout-qx-bUL1k.js +1 -0
- package/core/built/admin/assets/activitypub/{moderation-DtSM2i1I.js → moderation-Dwl9t0pb.js} +4 -4
- package/core/built/admin/assets/activitypub/{note-Dckp4S-2.js → note-B-zKsZ7r.js} +3 -3
- package/core/built/admin/assets/activitypub/{notifications-CG5T22vg.js → notifications-DjJZD54t.js} +3 -3
- package/core/built/admin/assets/activitypub/{preferences-D_799jdl.js → preferences-CoU8vs6d.js} +6 -6
- package/core/built/admin/assets/activitypub/{profile-D2JfXBQl.js → profile-BAsaJekx.js} +6 -6
- package/core/built/admin/assets/activitypub/{routes-CCHe2dQp.js → routes-CLH3OVTP.js} +18 -18
- package/core/built/admin/assets/activitypub/{settings-kx-9Enkz.js → settings-DA6pNJ-Q.js} +3 -3
- package/core/built/admin/assets/activitypub/{site-x4_IjVJ0.js → site-CQD42Pw5.js} +2 -2
- package/core/built/admin/assets/activitypub/{tabs-CyPRQQ1N.js → tabs-Cg0saow1.js} +7 -7
- package/core/built/admin/assets/activitypub/{use-reply-chain-data-BAB6fNGt.js → use-reply-chain-data-Br4aOWOh.js} +2 -2
- package/core/built/admin/assets/audience-DjEWNhp3.js +1 -0
- package/core/built/admin/assets/{automated-emails-of1MvVsv.js → automated-emails-DRy7qY-J.js} +2 -2
- package/core/built/admin/assets/{automations-DRFjW5fw.js → automations-Bx3VcFIL.js} +1 -1
- package/core/built/admin/assets/{automations-B7-y3dXt.js → automations-DhKeS_U5.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-BbbjWdzs.js → bluesky-sharing-ClMd0-Ft.js} +1 -1
- package/core/built/admin/assets/{breadcrumb-B-M9Ip_2.js → breadcrumb-BD0U2ygg.js} +1 -1
- package/core/built/admin/assets/{chart-helpers-xiSsW8r0.js → chart-helpers-fjQKRVyY.js} +1 -1
- package/core/built/admin/assets/{checkbox-EhJKHFdZ.js → checkbox-CWa28lgO.js} +1 -1
- package/core/built/admin/assets/{chunk.361.3cdb584b973959e52ccc.js → chunk.481.6c7395a49484bb4583aa.js} +41 -38
- package/core/built/admin/assets/{chunk.524.8365cd9280405c0f6216.js → chunk.524.cffd399783a519e404a9.js} +4 -4
- package/core/built/admin/assets/{chunk.582.61d078937e6102769f2c.js → chunk.582.eebf0d0b2d202bb746a5.js} +6 -6
- package/core/built/admin/assets/{code-editor-view-CZtJFGhR.js → code-editor-view-CCr0rBWS.js} +1 -1
- package/core/built/admin/assets/comments-DyUSMUdj.js +1 -0
- package/core/built/admin/assets/{date-range-select-CTlyo8zW.js → date-range-select-BFp58EMk.js} +1 -1
- package/core/built/admin/assets/{disabled-sources-indicator-qs2GfLvl.js → disabled-sources-indicator-CUxMfiPa.js} +1 -1
- package/core/built/admin/assets/domain-C0bV2UV8.js +1 -0
- package/core/built/admin/assets/{dropzone-BmCXnw6J.js → dropzone-DlK-K2DQ.js} +1 -1
- package/core/built/admin/assets/{edit-profile-SGrJve5M.js → edit-profile-BKT-REJw.js} +1 -1
- package/core/built/admin/assets/editor-Dp865O-4.js +8 -0
- package/core/built/admin/assets/{explore-CUYLv9G9.js → explore-ClUpJZOp.js} +1 -1
- package/core/built/admin/assets/{feed-CPdJMttL.js → feed-DF92dUMP.js} +1 -1
- package/core/built/admin/assets/field-Do7lieBA.js +1 -0
- package/core/built/admin/assets/{filter-sources-Bieps75g.js → filter-sources-BV2rnpfA.js} +1 -1
- package/core/built/admin/assets/filters-CUXJ2Nm9.js +1 -0
- package/core/built/admin/assets/{filters-CuB-A7ma.js → filters-DfbIWc_l.js} +1 -1
- package/core/built/admin/assets/{ghost-3063eae29e6c9cc6d6e7131928a27da0.css → ghost-a9c788f6f0b1ea6cf0f14ca4b13f4496.css} +1 -1
- package/core/built/admin/assets/{ghost-05f9a7182ed56903dba05878a5b8422b.js → ghost-c4057474943effc568c5659ccc4909d7.js} +190 -190
- package/core/built/admin/assets/{ghost-dark-c8d0ab7f515b2010c173e23e9b32ea8a.css → ghost-dark-db36d795d21c61426837df40af270966.css} +1 -1
- package/core/built/admin/assets/gift-link-modal-f9VIMNDv.js +1 -0
- package/core/built/admin/assets/{gift-links-nBxJjZiQ.js → gift-links-CsUhefWG.js} +1 -1
- package/core/built/admin/assets/growth-B3I6gNLm.js +1 -0
- package/core/built/admin/assets/growth-CVw1My4S.js +3 -0
- package/core/built/admin/assets/{hooks-BApwwBE0.js → hooks-CixO01lL.js} +1 -1
- package/core/built/admin/assets/{inbox-Xx1CdnfO.js → inbox-CFBSu4Ed.js} +13 -13
- package/core/built/admin/assets/index-9Cw8z3rA.css +1 -0
- package/core/built/admin/assets/index-BGG7NckO.js +67 -0
- package/core/built/admin/assets/{input-group-CGOXcy4l.js → input-group-BSgG_lVw.js} +1 -1
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +974 -937
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +28 -28
- package/core/built/admin/assets/koenig-lexical/style.css +1 -1
- package/core/built/admin/assets/{koenig-lexical-B61IALf5.js → koenig-lexical-f8vHRYvz.js} +28 -28
- package/core/built/admin/assets/{kpi-card-DCdlyaSS.js → kpi-card-DSap9rAy.js} +1 -1
- package/core/built/admin/assets/{kpi-card-BlZaG1Lo.js → kpi-card-DU0rn9Cj.js} +1 -1
- package/core/built/admin/assets/{kpi-helpers-DpAuS1Nb.js → kpi-helpers-Dz33AV6h.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-Dme44bQS.js → kpi-tabs-BtTTrKvJ.js} +1 -1
- package/core/built/admin/assets/{label-dSs5aepE.js → label-DS8Mi6G5.js} +1 -1
- package/core/built/admin/assets/label-picker-1DvSuLA1.js +1 -0
- package/core/built/admin/assets/labels-CDSUt4J_.js +1 -0
- package/core/built/admin/assets/layout-yQEi2qDM.js +1 -0
- package/core/built/admin/assets/{link-helpers-tOlxmuH5.js → link-helpers-7EYqvvHs.js} +1 -1
- package/core/built/admin/assets/member-custom-fields-yOMHyAg9.js +1 -0
- package/core/built/admin/assets/member-detail-BAq7gDaa.js +1 -0
- package/core/built/admin/assets/members-CQpVFJu4.js +10 -0
- package/core/built/admin/assets/modals-ReORvWnu.js +31 -0
- package/core/built/admin/assets/moderation-DySbgyUS.js +1 -0
- package/core/built/admin/assets/newsletter-CJQvtHqN.js +1 -0
- package/core/built/admin/assets/newsletters-B3QQXfGT.js +1 -0
- package/core/built/admin/assets/{newsletters-D1jbtV-h.js → newsletters-BXJbJgA-.js} +1 -1
- package/core/built/admin/assets/note-C8kxrz6w.js +1 -0
- package/core/built/admin/assets/notifications-CgtSfX7t.js +1 -0
- package/core/built/admin/assets/{offers-CrY6nSRR.js → offers-DEniVRD5.js} +1 -1
- package/core/built/admin/assets/onboarding-route-4qtziA9d.js +1 -0
- package/core/built/admin/assets/overview-Bf2sbznq.js +1 -0
- package/core/built/admin/assets/overview-CBfePxcr.js +1 -0
- package/core/built/admin/assets/{page-header-op0eN36I.js → page-header-B3Wb9Jqv.js} +1 -1
- package/core/built/admin/assets/{pages-BbNWFcGj.js → pages-B4goRPUn.js} +1 -1
- package/core/built/admin/assets/{post-analytics-WwRDEnrV.js → post-analytics-We-ko5Cb.js} +1 -1
- package/core/built/admin/assets/post-analytics-header-Bmc9su6q.js +1 -0
- package/core/built/admin/assets/post-analytics-provider-B6UynTGb.js +1 -0
- package/core/built/admin/assets/{post-share-modal-Dx-MEjhI.js → post-share-modal-DFfO93_0.js} +1 -1
- package/core/built/admin/assets/{posts-EWpZIjkr.js → posts-DhXE7b6r.js} +1 -1
- package/core/built/admin/assets/preferences-DJPfHEGu.js +5 -0
- package/core/built/admin/assets/profile-DqBQp-gT.js +1 -0
- package/core/built/admin/assets/{referrers-BCfFYSHc.js → referrers-pmJT4k3-.js} +1 -1
- package/core/built/admin/assets/{select-C1qDZnW4.js → select-C5_xEt5b.js} +1 -1
- package/core/built/admin/assets/settings-BwiVIXau.js +4 -0
- package/core/built/admin/assets/{settings-H6HxFgfI.js → settings-WXNeWyU1.js} +1 -1
- package/core/built/admin/assets/{share-modal-BJCadJyp.js → share-modal-DsgW3wbg.js} +1 -1
- package/core/built/admin/assets/social-urls-BQPFEk1_.js +8 -0
- package/core/built/admin/assets/{sort-button-DyYlfYp7.js → sort-button-Bb_FCl7e.js} +1 -1
- package/core/built/admin/assets/{source-icon-_ubRDbg_.js → source-icon-BeaRxUn9.js} +1 -1
- package/core/built/admin/assets/{stats-BQZMGMvn.js → stats-Bjj_kmJ1.js} +1 -1
- package/core/built/admin/assets/{stats-view-Doei-qCX.js → stats-view-BxPbW6K1.js} +1 -1
- package/core/built/admin/assets/{step-1-IKiLBPoC.js → step-1-B1e3-1F8.js} +1 -1
- package/core/built/admin/assets/{step-2-jJ41PsDN.js → step-2-C5WaeBJo.js} +1 -1
- package/core/built/admin/assets/{step-3-CaqFAEqf.js → step-3-B46iVPwu.js} +2 -2
- package/core/built/admin/assets/{switch-t-WyENU2.js → switch-z5Y6Uzt6.js} +1 -1
- package/core/built/admin/assets/{table-DxUL78jU.js → table-CB-4_HBJ.js} +1 -1
- package/core/built/admin/assets/tabs-CCEgKYzq.js +1 -0
- package/core/built/admin/assets/{tags-CNujGwkT.js → tags-Cg2VJGmG.js} +1 -1
- package/core/built/admin/assets/{tiers-BgYLWRJv.js → tiers-DYsa4DCo.js} +1 -1
- package/core/built/admin/assets/{toggle-group-BeEpQ69p.js → toggle-group-b3IlxvhV.js} +1 -1
- package/core/built/admin/assets/{topic-filter-Bb5MOD-1.js → topic-filter-DAFT87tQ.js} +1 -1
- package/core/built/admin/assets/{use-analytics-data-Cds6XDjg.js → use-analytics-data-S0FTd43s.js} +1 -1
- package/core/built/admin/assets/use-filter-params-Gpoq2E1L.js +1 -0
- package/core/built/admin/assets/{use-growth-stats-D8uf98-G.js → use-growth-stats-CIaiHOVb.js} +1 -1
- package/core/built/admin/assets/{use-post-referrers-CRtgyuXB.js → use-post-referrers-Cq2vBPrA.js} +1 -1
- package/core/built/admin/assets/{use-reply-chain-data-DbKYX50v.js → use-reply-chain-data-DBDRtGu-.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-DC01kpo0.js → use-simple-pagination-CjYNxdwe.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-query-C7bQRJWw.js → use-tinybird-query-falHAtuK.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-token-Az4tam7_.js → use-tinybird-token-D7-8ND1y.js} +1 -1
- package/core/built/admin/assets/{users-CcSCQFcQ.js → users-Dkv8NQZe.js} +1 -1
- package/core/built/admin/assets/{virtual-list-Dhuh9fGx.js → virtual-list-CvnC9zF2.js} +1 -1
- package/core/built/admin/assets/web-B_5GZRvH.js +1 -0
- package/core/built/admin/assets/web-jFYWCKDn.js +2 -0
- package/core/built/admin/index.html +9 -9
- package/core/frontend/services/proxy.js +7 -8
- package/core/frontend/services/routing/router-manager.js +14 -14
- package/core/frontend/services/routing/static-routes-router.js +8 -10
- package/core/server/api/endpoints/automation-action-links.js +68 -0
- package/core/server/api/endpoints/automation-action-links.ts +46 -0
- package/core/server/api/endpoints/index.js +4 -0
- package/core/server/api/endpoints/settings.js +0 -2
- package/core/server/api/endpoints/utils/serializers/output/utils/url.js +11 -1
- package/core/server/data/migrations/versions/6.55/2026-07-27-11-25-44-add-to-hash-to-redirects.js +51 -0
- package/core/server/data/migrations/versions/6.55/2026-07-28-12-08-00-remove-routes-hash-from-settings.js +5 -0
- package/core/server/data/schema/commands.js +5 -0
- package/core/server/data/schema/default-settings/default-settings.json +0 -4
- package/core/server/data/schema/schema.js +5 -1
- package/core/server/services/automations/automations-api.js +15 -0
- package/core/server/services/automations/automations-api.ts +19 -0
- package/core/server/services/automations/automations-repository.ts +18 -0
- package/core/server/services/automations/database-automations-repository.js +109 -26
- package/core/server/services/automations/database-automations-repository.ts +110 -7
- package/core/server/services/automations/database-date.js +10 -0
- package/core/server/services/automations/database-date.ts +5 -0
- package/core/server/services/automations/poll.js +5 -2
- package/core/server/services/automations/poll.ts +7 -2
- package/core/server/services/automations/scheduler-poll-time.js +40 -0
- package/core/server/services/automations/scheduler-poll-time.ts +38 -0
- package/core/server/services/automations/service.js +15 -3
- package/core/server/services/automations/service.ts +16 -3
- package/core/server/services/comments/comments-service-emails.js +10 -7
- package/core/server/services/comments/comments-service.js +9 -4
- package/core/server/services/email-rendering/partials/email-wrapper.hbs +3 -1
- package/core/server/services/email-service/email-service-wrapper.js +6 -1
- package/core/server/services/email-service/email-templates/partials/styles.hbs +8 -0
- package/core/server/services/email-service/newsletter-email-event-storage.js +41 -10
- package/core/server/services/lib/dynamic-redirect-manager.js +12 -3
- package/core/server/services/link-redirection/link-redirect-repository.js +41 -4
- package/core/server/services/link-redirection/link-redirect.js +2 -0
- package/core/server/services/link-redirection/link-redirect.ts +3 -1
- package/core/server/services/link-redirection/link-redirects-service.js +38 -2
- package/core/server/services/link-tracking/click-event.js +3 -0
- package/core/server/services/link-tracking/index.js +38 -6
- package/core/server/services/link-tracking/link-click-repository.js +30 -9
- package/core/server/services/link-tracking/link-click-tracking-service.js +44 -3
- package/core/server/services/member-attribution/outbound-link-tagger.js +3 -1
- package/core/server/services/member-welcome-emails/member-welcome-email-renderer.js +19 -4
- package/core/server/services/member-welcome-emails/service.js +11 -3
- package/core/server/services/members/import-export/csv/formula.js +16 -0
- package/core/server/services/members/import-export/csv/formula.ts +14 -0
- package/core/server/services/members/import-export/csv/index.js +3 -1
- package/core/server/services/members/import-export/csv/index.ts +1 -0
- package/core/server/services/members/import-export/import/completion-email.js +22 -3
- package/core/server/services/members/import-export/import/completion-email.ts +29 -7
- package/core/server/services/members/import-export/import/importer.js +25 -4
- package/core/server/services/members/import-export/import/importer.ts +42 -4
- package/core/server/services/members/import-export/index.js +9 -0
- package/core/server/services/members/import-export/index.ts +20 -1
- package/core/server/services/members/service.js +8 -1
- package/core/server/services/members-custom-fields/values-service.js +19 -7
- package/core/server/services/members-custom-fields/values-service.ts +19 -7
- package/core/server/services/mentions/service.js +5 -1
- package/core/server/services/route-settings/activation-bridge.js +59 -49
- package/core/server/services/route-settings/activation-bridge.ts +91 -51
- package/core/server/services/route-settings/dynamic-routing-service.js +22 -51
- package/core/server/services/route-settings/index.js +1 -16
- package/core/server/services/settings/settings-service.js +0 -18
- package/core/server/services/url/url-service-facade.js +1 -1
- package/core/server/services/url/url-service-facade.ts +8 -1
- package/core/server/web/api/endpoints/admin/routes.js +1 -0
- package/package.json +7 -7
- package/pnpm-lock.yaml +8 -8
- package/pnpm-workspace.yaml +5 -4
- package/core/built/admin/assets/Growth-BTP1LthE.js +0 -3
- package/core/built/admin/assets/Newsletters-CSEX0myc.js +0 -1
- package/core/built/admin/assets/Overview-BjACEsJF.js +0 -1
- package/core/built/admin/assets/Web-CxxxjCcv.js +0 -2
- package/core/built/admin/assets/activitypub/layout-CziktJXo.js +0 -1
- package/core/built/admin/assets/audience-X_XsZivI.js +0 -1
- package/core/built/admin/assets/comments-CvyXxOyN.js +0 -1
- package/core/built/admin/assets/constants-c-JNF9c2.js +0 -1
- package/core/built/admin/assets/domain-CPNXKVOV.js +0 -1
- package/core/built/admin/assets/editor-BOG2YPUm.js +0 -8
- package/core/built/admin/assets/field-D0XISCK2.js +0 -1
- package/core/built/admin/assets/filters-bXkkWro8.js +0 -1
- package/core/built/admin/assets/gift-link-modal-su8MsRdg.js +0 -1
- package/core/built/admin/assets/growth-Ba6S5FQX.js +0 -1
- package/core/built/admin/assets/index-D8PbzuT9.css +0 -1
- package/core/built/admin/assets/index-ukW_0Uie.js +0 -67
- package/core/built/admin/assets/label-picker-Uq91atex.js +0 -1
- package/core/built/admin/assets/labels-Cyayfd-e.js +0 -1
- package/core/built/admin/assets/layout-WUcz6tu1.js +0 -1
- package/core/built/admin/assets/member-custom-fields-NCzrMuba.js +0 -1
- package/core/built/admin/assets/member-detail-DPWDtYnN.js +0 -1
- package/core/built/admin/assets/members-B9rO7qr4.js +0 -10
- package/core/built/admin/assets/modals-CxRaan1J.js +0 -31
- package/core/built/admin/assets/moderation-D8zon60E.js +0 -1
- package/core/built/admin/assets/multi-select-combobox-1wYm3nle.js +0 -1
- package/core/built/admin/assets/newsletter-DbYMRxRS.js +0 -1
- package/core/built/admin/assets/note-PiWPnnrh.js +0 -1
- package/core/built/admin/assets/notifications-DEgqqB9G.js +0 -1
- package/core/built/admin/assets/onboarding-route-BzF6HeVn.js +0 -1
- package/core/built/admin/assets/overview-DixLeIqY.js +0 -1
- package/core/built/admin/assets/post-analytics-header-DsMoLx0R.js +0 -1
- package/core/built/admin/assets/post-analytics-provider-BJCPLMIb.js +0 -1
- package/core/built/admin/assets/preferences-D7-j6A4C.js +0 -5
- package/core/built/admin/assets/profile-Dl69QPp0.js +0 -1
- package/core/built/admin/assets/settings-BbmC_Iqq.js +0 -4
- package/core/built/admin/assets/social-urls-BPL1nADp.js +0 -8
- package/core/built/admin/assets/tabs-BQcJQ1ke.js +0 -1
- package/core/built/admin/assets/use-filter-params-DjXkhO54.js +0 -1
- package/core/built/admin/assets/web-LtHNiNBV.js +0 -1
- package/core/server/services/route-settings/default-settings-manager.js +0 -63
- package/core/server/services/route-settings/route-settings.js +0 -170
- package/core/server/services/route-settings/settings-loader.js +0 -60
- package/core/server/services/route-settings/settings-path-manager.js +0 -47
- package/core/server/services/route-settings/validate.js +0 -440
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./hooks-CixO01lL.js";import{t as a}from"./use-tinybird-query-falHAtuK.js";import{n as o}from"./posts-DhXE7b6r.js";import{t as s}from"./analytics-53FOa2wq.js";import{f as c}from"./dist-DGzPJ_bO.js";import{Ar as l,Bs as u,Dr as d,Er as f,Ir as p,Or as m,Tn as h,Zn as g,kn as _,kr as v,s as y,wr as b}from"./index-BGG7NckO.js";import{t as x}from"./share-modal-DsgW3wbg.js";import{t as S}from"./pages-B4goRPUn.js";import{n as C,r as w}from"./gift-links-CsUhefWG.js";var T=e(n(),1);function E(e,t){return!e||!t?``:`${e}?gift=${encodeURIComponent(t)}`}var D={members:`members-only`,paid:`paid-members-only`,tiers:`paid-members-only`};function O(e){return e&&D[e]||``}var k=({postUuid:e,token:t,tokenLoading:n=!1,tokenError:r=null,enabled:i=!0})=>{let{data:o,isLoading:s}=u(),c=o?.config?.stats,{data:l,isLoading:d}=_(),f=h(l?.settings??null,`web_analytics_enabled`)??!1,p=(0,T.useMemo)(()=>({site_uuid:c?.id||``,post_uuid:e||``,gift_link:t||``}),[c?.id,e,t]),{data:m,loading:g,error:v}=a({endpoint:`api_gift_link_visits`,statsConfig:c||{id:``},params:p,enabled:i&&f&&!!c?.id&&!!e&&!!t}),y=g||s||d||n,b=v||r||null;return{usage:(0,T.useMemo)(()=>{if(!f||!t||b||!Array.isArray(m))return;let e=m[0];return{visits:Number(e?.visits)||0,views:Number(e?.views)||0}},[m,t,b,f]),loading:y,error:b}},A=({postId:e,resource:t=`posts`,enabled:n=!0})=>{let r=t===`posts`,{data:i,isLoading:a}=o({searchParams:{filter:`id:${e}`,include:y},enabled:n&&r}),{data:s,isLoading:c}=S({searchParams:{filter:`id:${e}`},enabled:n&&!r});if(r){let e=i?.posts?.[0];return{post:e&&{url:e.url,title:e.title,visibility:e.visibility,uuid:e.uuid},isLoading:a}}let l=s?.pages?.[0];return{post:l&&{url:l.url,title:l.title,visibility:l.visibility,uuid:l.uuid},isLoading:c}},j=t({default:()=>P}),M=r();function N(e){return e===0?`No visitors yet`:`${c(e)} ${e===1?`visitor`:`visitors`}`}var P=({open:e,onOpenChange:t,postId:n,resource:r=`posts`,source:a})=>{let o=i(),{mutateAsync:c}=w(),{mutateAsync:u}=C(),{post:h}=A({postId:n,resource:r,enabled:e}),[_,y]=(0,T.useState)(void 0),[S,D]=(0,T.useState)(`idle`),[O,j]=(0,T.useState)(!1),[P,F]=(0,T.useState)(!1),I=(0,T.useRef)(null),L=(0,T.useRef)(null),{usage:R}=k({postUuid:h?.uuid,token:_,enabled:e});(0,T.useEffect)(()=>{if(!e){L.current=null,F(!1);return}let t=L.current;(t?.postId!==n||t.resource!==r)&&(t={postId:n,resource:r,request:c({id:n,resource:r})},L.current=t);let i=!1;return F(!0),t.request.then(e=>{i||y(e.gift_links[0]?.token)}).catch(e=>{i||o(e)}).finally(()=>{i||F(!1)}),()=>{i=!0}},[e,n,r,c,o]),(0,T.useEffect)(()=>{S===`confirm`&&I.current?.focus()},[S]);let z=r===`pages`?`page`:`post`,B=h?.visibility??`unknown`,V=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!e){V.current=!1;return}V.current||!h||(V.current=!0,s(`Gift Link Modal Opened`,{postType:z,visibility:B,source:a}))},[e,h,z,B,a]);let H=E(h?.url,_),U=`Anyone you share this link with will be able to access this ${z} without becoming a ${h?.visibility===`members`?`member`:`paid member`}.`,W=(0,T.useCallback)(async()=>{if(!O){j(!0);try{let e=await u({id:n,resource:r});y(e.gift_links[0]?.token),D(`idle`),s(`Gift Link Reset`,{postType:z,visibility:B,source:a})}catch(e){o(e)}finally{j(!1)}}},[O,u,n,r,o,z,B,a]),G=(0,T.useCallback)(e=>{e||D(`idle`),t(e)},[t]);return(0,M.jsx)(b,{open:e,onOpenChange:G,children:(0,M.jsxs)(f,{className:`max-w-lg gap-5`,children:[S===`idle`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{className:`gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(l,{className:`text-xl leading-none`,children:`Gift link`}),R&&(0,M.jsx)(g,{"data-testid":`gift-link-views`,variant:`secondary`,children:N(R.visits)})]}),(0,M.jsx)(d,{className:`text-sm leading-5`,children:U})]}),(0,M.jsx)(x.CopyURLBox,{className:`w-full min-w-0`,copyURL:P?`Generating link…`:H,children:(0,M.jsx)(x.CopyButton,{className:`shrink-0`,copyURL:H,"data-testid":`copy-gift-link`,disabled:P||!H,icon:`link`,size:`sm`,onClick:()=>s(`Gift Link Copied`,{postType:z,visibility:B,source:a})})}),(0,M.jsxs)(m,{className:`sm:items-center sm:justify-between`,children:[(0,M.jsx)(p,{className:`border-destructive/20 text-destructive hover:border-destructive hover:bg-transparent hover:text-destructive dark:border-state-danger/50 dark:text-state-danger dark:hover:border-state-danger dark:hover:bg-transparent dark:hover:text-state-danger`,"data-testid":`reset-gift-link`,disabled:!H,variant:`outline`,onClick:()=>D(`confirm`),children:`Reset`}),(0,M.jsx)(p,{variant:`outline`,onClick:()=>G(!1),children:`Close`})]})]}),S===`confirm`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(v,{children:[(0,M.jsx)(l,{children:`Reset gift link`}),(0,M.jsxs)(d,{children:[`Are you sure you want to reset this link? Anyone with the current link will lose access to this `,z,`.`]})]}),(0,M.jsxs)(m,{children:[(0,M.jsx)(p,{ref:I,disabled:O,variant:`outline`,onClick:()=>D(`idle`),children:`Cancel`}),(0,M.jsx)(p,{"data-testid":`confirm-reset-gift-link`,disabled:O,variant:`destructive`,onClick:()=>{W()},children:O?`Resetting`:`Reset link`})]})]})]})})};export{O as i,j as n,k as r,P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./hooks-
|
|
1
|
+
import{i as e,n as t}from"./hooks-CixO01lL.js";var n=`GiftLinksResponseType`,r=({id:e,resource:t=`posts`})=>`/${t}/${e}/gift_links/`,i=e({dataType:n,path:e=>r({id:e})}),a=(e,t)=>{let n=i(e,t),r=n.data?.gift_links?.[0];return{...n,giftLink:r,token:r?.token}},o=t({method:`PUT`,path:r,invalidateQueries:{dataType:n}}),s=t({method:`POST`,path:r,invalidateQueries:{dataType:n}}),c=t({method:`PUT`,path:()=>`/gift_links/remove_all/`,invalidateQueries:{dataType:n}});export{c as i,s as n,o as r,a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r,n as i,t as a}from"./source-icon-BeaRxUn9.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as s}from"./router-provider-C1R4AZ2o.js";import{c,f as l}from"./dist-DGzPJ_bO.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./card-DGoDJzrn.js";import{t as g}from"./empty-indicator-oX1u1Pkn.js";import{a as _,c as v,n as y,r as b,s as x,t as S}from"./table-CB-4_HBJ.js";import{Bn as C,Fn as w,Ho as T,In as E,Ir as D,Jn as O,Ln as k,Ni as A,Ri as ee,Rn as j,Vs as M,aa as N,ar as P,ir as F,ji as I,zn as L}from"./index-BGG7NckO.js";import{t as R}from"./disabled-sources-indicator-CUxMfiPa.js";import{t as z}from"./use-analytics-data-S0FTd43s.js";import{t as B}from"./member-route-0Aa52Ntz.js";import{a as V,i as H,n as U,r as W,t as G}from"./kpi-card-DU0rn9Cj.js";import{r as K,t as q}from"./post-analytics-header-Bmc9su6q.js";import{n as J,t as Y}from"./use-post-referrers-Cq2vBPrA.js";var X=e(t(),1),Z=n(),Q=`https://www.google.com/s2/favicons?domain=ghost.org&sz=64`,$=({headerStyle:e=`table`,children:t=`Source`,data:n,mode:r,defaultSourceIconUrl:i=Q})=>{let{appSettings:o}=M();if(r===`growth`)return(0,Z.jsxs)(S,{children:[(0,Z.jsx)(x,{children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(_,{className:`min-w-[320px]`,variant:e===`table`?`default`:`cardhead`,children:t}),(0,Z.jsx)(_,{className:`w-[110px] text-right`,children:`Free members`}),o?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(_,{className:`w-[110px] text-right`,children:`Paid members`}),(0,Z.jsx)(_,{className:`w-[100px] text-right`,children:`MRR impact`})]})]})}),(0,Z.jsx)(y,{children:n?.map(e=>(0,Z.jsxs)(v,{className:`last:border-none`,children:[(0,Z.jsx)(b,{children:e.linkUrl?(0,Z.jsxs)(`a`,{className:`group flex items-center gap-2`,href:e.linkUrl,rel:`noreferrer`,target:`_blank`,children:[(0,Z.jsx)(a,{defaultSourceIconUrl:i,displayName:e.displayName,iconSrc:e.iconSrc}),(0,Z.jsx)(`span`,{className:`group-hover:underline`,children:e.displayName})]}):(0,Z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(a,{defaultSourceIconUrl:i,displayName:e.displayName,iconSrc:e.iconSrc}),(0,Z.jsx)(`span`,{children:e.displayName})]})}),(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+`,l(e.free_members||0)]}),o?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+`,l(e.paid_members||0)]}),(0,Z.jsxs)(b,{className:`text-right font-mono text-sm`,children:[`+$`,l((e=>Math.round(e/100))(e.mrr||0))]})]})]},e.source))})]})},te=({title:e=`Top sources`,description:t,data:n,mode:a=`visits`,range:o=30,totalVisitors:s=0,siteUrl:l,siteIcon:_,defaultSourceIconUrl:v=Q,getPeriodText:y,className:b})=>{let{appSettings:x}=M(),S=X.useMemo(()=>r({data:n,mode:a,siteUrl:l,siteIcon:_,defaultSourceIconUrl:v}),[n,l,_,a,v]),T=X.useMemo(()=>i({processedData:S,totalVisitors:s,mode:a}),[S,s,a]),O=T.slice(0,10),A=t||(a===`growth`?`Where did your growth come from?`:`How readers found your ${o?`site`:`post`}${o&&y?` ${y(o)}`:``}`),P=a===`growth`?`Sources`:`Top sources`,F=a===`growth`?`Where did your growth come from?`:`How readers found your ${o?`site`:`post`}${o&&y?` ${y(o)}`:``}`;return(0,Z.jsxs)(h,{className:c(`group/datalist w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,b),"data-testid":`top-sources-card`,children:[O.length<=0&&(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:e}),(0,Z.jsx)(m,{children:A})]}),(0,Z.jsx)(f,{children:a===`growth`&&!x?.analytics.membersTrackSources?(0,Z.jsx)(R,{className:`py-10`}):O.length>0?(0,Z.jsx)($,{data:O,defaultSourceIconUrl:v,getPeriodText:y,headerStyle:`card`,mode:a,range:o,children:(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:e}),(0,Z.jsx)(m,{children:A})]})}):(0,Z.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:(0,Z.jsx)(g,{className:`h-full`,description:a===`growth`&&`Once someone signs up on this post, sources will show here`,title:`No sources data available ${y?y(o):``}`,children:(0,Z.jsx)(ee,{strokeWidth:1.5})})})}),T.length>10&&(0,Z.jsx)(d,{children:(0,Z.jsxs)(w,{children:[(0,Z.jsx)(C,{asChild:!0,children:(0,Z.jsxs)(D,{variant:`outline`,children:[`View all `,(0,Z.jsx)(N,{})]})}),(0,Z.jsxs)(E,{className:`overflow-y-auto pt-0 sm:max-w-[420px]`,children:[(0,Z.jsxs)(j,{className:`sticky top-0 z-40 -mx-6 bg-surface-elevated/60 p-6 backdrop-blur`,children:[(0,Z.jsx)(L,{children:P}),(0,Z.jsx)(k,{children:F})]}),(0,Z.jsx)(`div`,{className:`group/datalist`,children:(0,Z.jsx)($,{data:T,defaultSourceIconUrl:v,getPeriodText:y,mode:a,range:o})})]})]})})]})},ne=()=>{let{site:e}=z(),{postId:t}=o(),{stats:n,totals:r,isLoading:i,currencySymbol:a}=Y(t||``),{appSettings:c}=M(),d=s(),g=e=>d(B({filter:e})),_=e.url,v=e.icon,y=`flex flex-col items-stretch gap-6`,b=``;return c?.paidMembersEnabled||(y=`grid grid-cols-1 border rounded-md`,b=`border-none hover:shadow-none`),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{currentTab:`Growth`}),(0,Z.jsx)(K,{children:i?(0,Z.jsxs)(`div`,{className:y,children:[(0,Z.jsx)(h,{className:b,children:(0,Z.jsx)(f,{className:`grid grid-cols-3 p-0`,children:Array.from({length:3},(e,t)=>(0,Z.jsxs)(`div`,{className:`h-[98px] gap-1 border-r px-6 py-5 last:border-r-0`,children:[(0,Z.jsx)(F,{className:`w-2/3`}),(0,Z.jsx)(F,{className:`h-7 w-12`})]},t))})}),(0,Z.jsxs)(h,{className:b,children:[(0,Z.jsxs)(u,{children:[(0,Z.jsx)(p,{children:`Top sources`}),(0,Z.jsx)(m,{children:`Where did your growth come from?`})]}),(0,Z.jsxs)(f,{children:[(0,Z.jsx)(O,{}),(0,Z.jsx)(P,{className:`pt-6`})]})]})]}):(0,Z.jsxs)(`div`,{className:y,children:[(0,Z.jsxs)(h,{className:b,"data-testid":`members-card`,children:[(0,Z.jsxs)(u,{className:`hidden`,children:[(0,Z.jsx)(p,{children:`Newsletters`}),(0,Z.jsx)(m,{children:`How did this post perform`})]}),(0,Z.jsx)(f,{className:`p-0`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col md:grid md:items-stretch ${c?.paidMembersEnabled?`md:grid-cols-3`:`md:grid-cols-1`}`,children:[(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsx)(H,{onClick:()=>{g(`signup:'${t}'+conversion:-'${t}'`)},children:`View members →`}),(0,Z.jsxs)(W,{onClick:()=>{g(`signup:'${t}'+conversion:-'${t}'`)},children:[(0,Z.jsx)(A,{strokeWidth:1.5}),`Free members`]}),(0,Z.jsx)(U,{children:(0,Z.jsx)(V,{children:l(r?.free_members||0)})})]}),c?.paidMembersEnabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsx)(H,{onClick:()=>{g(`conversion:'${t}'`)},children:`View members →`}),(0,Z.jsxs)(W,{onClick:()=>{g(`conversion:'${t}'`)},children:[(0,Z.jsx)(I,{strokeWidth:1.5}),`Paid members`]}),(0,Z.jsx)(U,{children:(0,Z.jsx)(V,{children:l(r?.paid_members||0)})})]}),(0,Z.jsxs)(G,{className:`grow`,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(T,{strokeWidth:1.5}),`MRR`]}),(0,Z.jsx)(U,{children:(0,Z.jsxs)(V,{children:[`+`,a,J(r?.mrr||0)]})})]})]})]})})]}),!c?.paidMembersEnabled&&(0,Z.jsx)(O,{}),(0,Z.jsx)(te,{className:b,data:n,mode:`growth`,siteIcon:v,siteUrl:_})]})})]})};export{ne as default};
|
|
@@ -0,0 +1,3 @@
|
|
|
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{d as r,g as i,l as a,n as o}from"./stats-Bjj_kmJ1.js";import{t as s}from"./currency-CQsJu8iC.js";import{r as c,t as l}from"./source-icon-BeaRxUn9.js";import{g as u}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as d}from"./router-provider-C1R4AZ2o.js";import{b as f,f as p,l as m,x as h,y as g}from"./dist-DGzPJ_bO.js";import{E as _}from"./_baseAssignValue-C_vooEQc.js";import{$ as v,C as y,E as b,I as x,J as S,K as C,P as w,Q as T,S as E,Y as D,Z as ee,_ as te,a as ne,at as re,b as ie,ct as ae,dt as oe,et as se,g as ce,i as le,it as ue,n as de,nt as fe,ot as O,r as pe,st as me,ut as he,w as ge,x as _e,y as ve}from"./chart-BuRT2Y6p.js";import{n as ye,t as be}from"./PolarAngleAxis-BGjf7sBu.js";import{a as xe,c as Se,i as k,l as Ce,n as A,r as we,t as Te,u as Ee}from"./chart-helpers-fjQKRVyY.js";import{n as De,t as j}from"./sort-button-Bb_FCl7e.js";import{i as Oe,r as ke,t as Ae}from"./tabs-CCEgKYzq.js";import{i as je,n as Me,o as Ne,s as Pe,t as Fe}from"./select-C5_xEt5b.js";import{a as Ie,n as M,o as Le,r as Re,t as N}from"./card-DGoDJzrn.js";import{t as P}from"./empty-indicator-oX1u1Pkn.js";import{a as F,c as I,i as ze,n as L,r as R,s as Be,t as Ve}from"./table-CB-4_HBJ.js";import{Bn as He,Br as z,Fn as Ue,Hr as B,In as We,Ir as Ge,Jn as Ke,Jr as qe,Ln as Je,Qr as Ye,Rn as Xe,Vs as Ze,Wr as Qe,Xr as $e,aa as et,cs as tt,i as nt,ii as rt,ir as it,jo as at,ls as ot,nr as st,os as ct,p as lt,u as V,zn as ut,zr as H}from"./index-BGG7NckO.js";import{n as dt,r as U,t as ft}from"./kpi-tabs-BtTTrKvJ.js";import{a as pt}from"./tiers-DYsa4DCo.js";import{i as mt,n as ht,r as gt,t as _t}from"./stats-view-BxPbW6K1.js";import{t as vt}from"./disabled-sources-indicator-CUxMfiPa.js";import{t as yt}from"./use-growth-stats-CIaiHOVb.js";import{t as bt}from"./use-analytics-data-S0FTd43s.js";import{n as xt}from"./audience-DjEWNhp3.js";import{n as St}from"./referrers-pmJT4k3-.js";import{i as Ct,r as wt,t as W}from"./content-helpers-CNBPrwsi.js";import{t as Tt}from"./url-helpers-CCyfRrKj.js";var G=e(t()),Et=e(oe()),Dt=e(x()),K=e(he()),q=e(_()),Ot;function J(e){"@babel/helpers - typeof";return J=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},J(e)}function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(this,arguments)}function kt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kt(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function At(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function jt(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Bt(r.key),r)}}function Mt(e,t,n){return t&&jt(e.prototype,t),n&&jt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nt(e,t,n){return t=Lt(t),Pt(e,It()?Reflect.construct(t,n||[],Lt(e).constructor):t.apply(e,n))}function Pt(e,t){if(t&&(J(t)===`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return Ft(e)}function Ft(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function It(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(It=function(){return!!e})()}function Lt(e){return Lt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lt(e)}function Rt(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&zt(e,t)}function zt(e,t){return zt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zt(e,t)}function Z(e,t,n){return t=Bt(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bt(e){var t=Vt(e,`string`);return J(t)==`symbol`?t:t+``}function Vt(e,t){if(J(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(J(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Q=function(e){function t(e){var n;return At(this,t),n=Nt(this,t,[e]),Z(n,`pieRef`,null),Z(n,`sectorRefs`,[]),Z(n,`id`,ae(`recharts-pie-`)),Z(n,`handleAnimationEnd`,function(){var e=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),(0,q.default)(e)&&e()}),Z(n,`handleAnimationStart`,function(){var e=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),(0,q.default)(e)&&e()}),n.state={isAnimationFinished:!e.isAnimationActive,prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,sectorToFocus:0},n}return Rt(t,e),Mt(t,[{key:`isActiveIndex`,value:function(e){var t=this.props.activeIndex;return Array.isArray(t)?t.indexOf(e)!==-1:e===t}},{key:`hasActiveIndex`,value:function(){var e=this.props.activeIndex;return Array.isArray(e)?e.length!==0:e||e===0}},{key:`renderLabels`,value:function(e){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var n=this.props,r=n.label,i=n.labelLine,a=n.dataKey,o=n.valueKey,s=v(this.props,!1),c=v(r,!1),l=v(i,!1),u=r&&r.offsetRadius||20,d=e.map(function(e,n){var d=(e.startAngle+e.endAngle)/2,f=b(e.cx,e.cy,e.outerRadius+u,d),p=X(X(X(X({},s),e),{},{stroke:`none`},c),{},{index:n,textAnchor:t.getTextAnchor(f.x,e.cx)},f),m=X(X(X(X({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:n,points:[b(e.cx,e.cy,e.outerRadius,d),f]}),h=a;return(0,K.default)(a)&&(0,K.default)(o)?h=`value`:(0,K.default)(a)&&(h=o),G.createElement(T,{key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${n}`},i&&t.renderLabelLineItem(i,m,`line`),t.renderLabelItem(r,p,w(e,h)))});return G.createElement(T,{className:`recharts-pie-labels`},d)}},{key:`renderSectorsStatically`,value:function(e){var t=this,n=this.props,r=n.activeShape,i=n.blendStroke,a=n.inactiveShape;return e.map(function(n,o){if(n?.startAngle===0&&n?.endAngle===0&&e.length!==1)return null;var s=t.isActiveIndex(o),c=a&&t.hasActiveIndex()?a:null,l=s?r:c,u=X(X({},n),{},{stroke:i?n.fill:n.stroke,tabIndex:-1});return G.createElement(T,Y({ref:function(e){e&&!t.sectorRefs.includes(e)&&t.sectorRefs.push(e)},tabIndex:-1,className:`recharts-pie-sector`},fe(t.props,n,o),{key:`sector-${n?.startAngle}-${n?.endAngle}-${n.midAngle}-${o}`}),G.createElement(te,Y({option:l,isActive:s,shapeType:`sector`},u)))})}},{key:`renderSectorsWithAnimation`,value:function(){var e=this,t=this.props,n=t.sectors,r=t.isAnimationActive,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.animationId,c=this.state,l=c.prevSectors,u=c.prevIsAnimationActive;return G.createElement(ve,{begin:i,duration:a,isActive:r,easing:o,from:{t:0},to:{t:1},key:`pie-${s}-${u}`,onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(t){var r=t.t,i=[],a=(n&&n[0]).startAngle;return n.forEach(function(e,t){var n=l&&l[t],o=t>0?(0,Et.default)(e,`paddingAngle`,0):0;if(n){var s=re(n.endAngle-n.startAngle,e.endAngle-e.startAngle),c=X(X({},e),{},{startAngle:a+o,endAngle:a+s(r)+o});i.push(c),a=c.endAngle}else{var u=e.endAngle,d=e.startAngle,f=re(0,u-d)(r),p=X(X({},e),{},{startAngle:a+o,endAngle:a+f+o});i.push(p),a=p.endAngle}}),G.createElement(T,null,e.renderSectorsStatically(i))})}},{key:`attachKeyboardHandlers`,value:function(e){var t=this;e.onkeydown=function(e){if(!e.altKey)switch(e.key){case`ArrowLeft`:var n=++t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[n].focus(),t.setState({sectorToFocus:n});break;case`ArrowRight`:var r=--t.state.sectorToFocus<0?t.sectorRefs.length-1:t.state.sectorToFocus%t.sectorRefs.length;t.sectorRefs[r].focus(),t.setState({sectorToFocus:r});break;case`Escape`:t.sectorRefs[t.state.sectorToFocus].blur(),t.setState({sectorToFocus:0});break;default:}}}},{key:`renderSectors`,value:function(){var e=this.props,t=e.sectors,n=e.isAnimationActive,r=this.state.prevSectors;return n&&t&&t.length&&(!r||!(0,Dt.default)(r,t))?this.renderSectorsWithAnimation():this.renderSectorsStatically(t)}},{key:`componentDidMount`,value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:`render`,value:function(){var e=this,t=this.props,n=t.hide,r=t.sectors,i=t.className,a=t.label,o=t.cx,s=t.cy,c=t.innerRadius,l=t.outerRadius,u=t.isAnimationActive,d=this.state.isAnimationFinished;if(n||!r||!r.length||!O(o)||!O(s)||!O(c)||!O(l))return null;var f=h(`recharts-pie`,i);return G.createElement(T,{tabIndex:this.props.rootTabIndex,className:f,ref:function(t){e.pieRef=t}},this.renderSectors(),a&&this.renderLabels(r),E.renderCallByParent(this.props,null,!1),(!u||d)&&_e.renderCallByParent(this.props,r,!1))}}],[{key:`getDerivedStateFromProps`,value:function(e,t){return t.prevIsAnimationActive===e.isAnimationActive?e.isAnimationActive&&e.animationId!==t.prevAnimationId?{prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:t.curSectors,isAnimationFinished:!0}:e.sectors===t.curSectors?null:{curSectors:e.sectors,isAnimationFinished:!0}:{prevIsAnimationActive:e.isAnimationActive,prevAnimationId:e.animationId,curSectors:e.sectors,prevSectors:[],isAnimationFinished:!0}}},{key:`getTextAnchor`,value:function(e,t){return e>t?`start`:e<t?`end`:`middle`}},{key:`renderLabelLineItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);if((0,q.default)(e))return e(t);var r=h(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className);return G.createElement(ie,Y({},t,{key:n,type:`linear`,className:r}))}},{key:`renderLabelItem`,value:function(e,t,n){if(G.isValidElement(e))return G.cloneElement(e,t);var r=n;if((0,q.default)(e)&&(r=e(t),G.isValidElement(r)))return r;var i=h(`recharts-pie-label-text`,typeof e!=`boolean`&&!(0,q.default)(e)?e.className:``);return G.createElement(C,Y({},t,{alignmentBaseline:`middle`,className:i}),r)}}])}(G.PureComponent);Ot=Q,Z(Q,`displayName`,`Pie`),Z(Q,`defaultProps`,{stroke:`#fff`,fill:`#808080`,legendType:`rect`,cx:`50%`,cy:`50%`,startAngle:0,endAngle:360,innerRadius:0,outerRadius:`80%`,paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!D.isSsr,animationBegin:400,animationDuration:1500,animationEasing:`ease`,nameKey:`name`,blendStroke:!1,rootTabIndex:0}),Z(Q,`parseDeltaAngle`,function(e,t){return me(t-e)*Math.min(Math.abs(t-e),360)}),Z(Q,`getRealPieData`,function(e){var t=e.data,n=e.children,r=v(e,!1),i=se(n,S);return t&&t.length?t.map(function(e,t){return X(X(X({payload:e},r),e),i&&i[t]&&i[t].props)}):i&&i.length?i.map(function(e){return X(X({},r),e.props)}):[]}),Z(Q,`parseCoordinateOfPie`,function(e,t){var n=t.top,r=t.left,i=t.width,a=t.height,o=ge(i,a);return{cx:r+ue(e.cx,i,i/2),cy:n+ue(e.cy,a,a/2),innerRadius:ue(e.innerRadius,o,0),outerRadius:ue(e.outerRadius,o,o*.8),maxRadius:e.maxRadius||Math.sqrt(i*i+a*a)/2}}),Z(Q,`getComposedData`,function(e){var t=e.item,n=e.offset,r=t.type.defaultProps===void 0?t.props:X(X({},t.type.defaultProps),t.props),i=Ot.getRealPieData(r);if(!i||!i.length)return null;var a=r.cornerRadius,o=r.startAngle,s=r.endAngle,c=r.paddingAngle,l=r.dataKey,u=r.nameKey,d=r.valueKey,f=r.tooltipType,p=Math.abs(r.minAngle),m=Ot.parseCoordinateOfPie(r,n),h=Ot.parseDeltaAngle(o,s),g=Math.abs(h),_=l;(0,K.default)(l)&&(0,K.default)(d)?(ee(!1,`Use "dataKey" to specify the value of pie,
|
|
2
|
+
the props "valueKey" will be deprecated in 1.1.0`),_=`value`):(0,K.default)(l)&&(ee(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),_=d);var v=i.filter(function(e){return w(e,_,0)!==0}).length,y=(g>=360?v:v-1)*c,x=g-v*p-y,S=i.reduce(function(e,t){var n=w(t,_,0);return e+(O(n)?n:0)},0),C;if(S>0){var T;C=i.map(function(e,t){var n=w(e,_,0),r=w(e,u,t),i=(O(n)?n:0)/S,s=t?T.endAngle+me(h)*c*(n===0?0:1):o,l=s+me(h)*((n===0?0:p)+i*x),d=(s+l)/2,g=(m.innerRadius+m.outerRadius)/2;return T=X(X(X({percent:i,cornerRadius:a,name:r,tooltipPayload:[{name:r,value:n,payload:e,dataKey:_,type:f}],midAngle:d,middleRadius:g,tooltipPosition:b(m.cx,m.cy,g,d)},e),m),{},{value:w(e,_),startAngle:s,endAngle:l,payload:e,paddingAngle:me(h)*c}),T})}return X(X({},m),{},{sectors:C,data:i})});var Ht=ne({chartName:`PieChart`,GraphicalChild:Q,validateTooltipEventTypes:[`item`],defaultTooltipEventType:`item`,legendContent:`children`,axisComponents:[{axisType:`angleAxis`,AxisComp:be},{axisType:`radiusAxis`,AxisComp:ye}],formatAxisMap:y,defaultProps:{layout:`centric`,startAngle:0,endAngle:360,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`}}),$=n(),Ut=e=>e===`total-members`||e===`free-members`||e===`paid-members`||e===`mrr`,Wt=({active:e,payload:t,range:n,color:r,showBreakdown:i})=>{if(!e||!t?.length)return null;let a=t[0].payload,{date:o,formattedValue:s,label:c,comped:l,gift:u}=a,d=a.value-(l||0)-(u||0);return(0,$.jsxs)(`div`,{className:`min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[o&&(0,$.jsx)(`div`,{className:`mb-1 text-sm text-foreground`,children:z(o,n||0)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Paid subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:p(d)})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Gift subscriptions`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:u!==void 0&&u>0?p(u):`0`})]})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Complimentary`}),(0,$.jsx)(`div`,{className:`font-mono text-xs`,children:l!==void 0&&l>0?p(l):`0`})]})}),(0,$.jsx)(Ke,{})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`inline-block size-2 rounded-full opacity-50`,style:{backgroundColor:r||`var(--chart-purple)`}}),(0,$.jsxs)(`div`,{className:`flex grow items-center justify-between gap-5`,children:[c&&(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:c}),(0,$.jsx)(`div`,{className:`font-mono font-medium`,children:s})]})]})]})]})},Gt=({chartData:e,totals:t,initialTab:n,currencySymbol:r,isLoading:i,onTabChange:a})=>{let o=Ut(n)?n:`total-members`,[s,c]=(0,G.useState)(o),{range:l}=lt(),{appSettings:f}=Ze(),m=d(),[h]=u();(0,G.useEffect)(()=>{c(o)},[o]);let g=e=>{c(e);let t=new URLSearchParams(h);t.set(`tab`,e),m(`?${t.toString()}`,{replace:!0}),a&&a(e)},{totalMembers:_,freeMembers:v,paidMembers:y,mrr:b,percentChanges:x,directions:S}=t,{chartData:C,chartRange:w}=(0,G.useMemo)(()=>{if(!e||e.length===0)return{chartData:[],chartRange:l};let t=[],n=`value`;switch(s){case`free-members`:n=`free`;break;case`paid-members`:n=`paid`;break;case`mrr`:n=`mrr`;break;default:n=`value`}t=k(e,l,n,`exact`);let i=[];switch(s){case`free-members`:i=t.map(e=>({...e,value:e.free,formattedValue:p(e.free),label:`Free members`}));break;case`paid-members`:i=t.map(e=>({...e,value:e.paid,formattedValue:p(e.paid),label:`Paid members`,comped:e.comped,gift:e.gift,paid_subscribed:e.paid_subscribed}));break;case`mrr`:i=t.map(e=>({...e,value:H(e.mrr),formattedValue:`${r}${p(H(e.mrr))}`,label:`MRR`}));break;default:i=t.map(e=>{let t=e.free+e.paid;return{...e,value:t,formattedValue:p(t),label:`Total members`}})}return{chartData:i,chartRange:Te(l,e,{fieldName:n})}},[s,e,l,r]),T={"total-members":{color:`var(--chart-darkblue)`},"free-members":{color:`var(--chart-blue)`},"paid-members":{color:`var(--chart-purple)`},mrr:{color:`var(--chart-teal)`}};return i?(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(st,{})}):(0,$.jsxs)(Ae,{defaultValue:o,variant:`kpis`,children:[(0,$.jsxs)(ke,{className:`-mx-6 ${f?.paidMembersEnabled?`hidden grid-cols-4 lg:visible! lg:grid!`:`grid grid-cols-4`}`,children:[(0,$.jsx)(dt,{className:f?.paidMembersEnabled?``:`cursor-auto after:hidden`,value:`total-members`,onClick:()=>{f?.paidMembersEnabled&&g(`total-members`)},children:(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)})}),f?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(dt,{value:`free-members`,onClick:()=>{g(`free-members`)},children:(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)})}),(0,$.jsx)(dt,{value:`paid-members`,onClick:()=>{g(`paid-members`)},children:(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)})}),(0,$.jsx)(dt,{value:`mrr`,onClick:()=>{g(`mrr`)},children:(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})})]})]}),f?.paidMembersEnabled&&(0,$.jsxs)(qe,{children:[(0,$.jsx)(rt,{className:`lg:hidden`,asChild:!0,children:(0,$.jsxs)(ft,{children:[s===`total-members`&&(0,$.jsx)(U,{color:`var(--chart-darkblue)`,diffDirection:l===V.allTime.value?`hidden`:S.total,diffValue:x.total,label:`Total members`,value:p(_)}),s===`free-members`&&(0,$.jsx)(U,{color:`var(--chart-blue)`,diffDirection:l===V.allTime.value?`hidden`:S.free,diffValue:x.free,label:`Free members`,value:p(v)}),s===`paid-members`&&(0,$.jsx)(U,{color:`var(--chart-purple)`,diffDirection:l===V.allTime.value?`hidden`:S.paid,diffValue:x.paid,label:`Paid members`,value:p(y)}),s===`mrr`&&(0,$.jsx)(U,{color:`var(--chart-teal)`,diffDirection:l===V.allTime.value?`hidden`:S.mrr,diffValue:x.mrr,label:`MRR`,value:`${r}${p(H(b))}`})]})}),(0,$.jsxs)($e,{align:`end`,className:`w-56`,children:[(0,$.jsx)(Ye,{onClick:()=>g(`total-members`),children:`Total members`}),(0,$.jsx)(Ye,{onClick:()=>g(`free-members`),children:`Free members`}),(0,$.jsx)(Ye,{onClick:()=>g(`paid-members`),children:`Paid members`}),(0,$.jsx)(Ye,{onClick:()=>g(`mrr`),children:`MRR`})]})]}),(0,$.jsx)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:(0,$.jsx)(xe,{className:`-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]`,color:T[s].color,data:C,dataFormatter:s===`mrr`?e=>`${r}${p(e)}`:p,id:s,range:w,tooltipContent:s===`paid-members`?(0,$.jsx)(Wt,{color:T[`paid-members`].color,range:w,showBreakdown:!0}):void 0})})]})},Kt=(e,t=`signups desc`,n=50)=>{let{startDate:r,endDate:i,timezone:a}=Qe(e),o={date_from:B(r),date_to:B(i),member_status:xt(nt),order:t,limit:n.toString()};return a&&(o.timezone=a),St({searchParams:o})},qt=({data:e,currencySymbol:t,limit:n,defaultSourceIconUrl:r})=>{let i=n?e.slice(0,n):e,{appSettings:a}=Ze();return(0,$.jsx)(L,{children:i.map(e=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{className:`font-medium`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(l,{defaultSourceIconUrl:r,displayName:e.displayName,iconSrc:e.iconSrc}),e.linkUrl?(0,$.jsx)(`a`,{className:`hover:underline`,href:e.linkUrl,rel:`noreferrer`,target:`_blank`,children:e.displayName}):(0,$.jsx)(`span`,{children:e.displayName})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.free_members)]}),a?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[`+`,t,p(H(e.mrr))]})]})]},e.source))})},Jt=({range:e,limit:t=20,showViewAll:n=!1,sortBy:r,setSortBy:i})=>{let{site:a}=bt(),{data:l}=o(),{appSettings:u}=Ze(),[d,f]=(0,G.useState)(`free_members desc`),p=r||d,m=i||f,{data:h,isLoading:g}=Kt(e,p.replace(`free_members`,`signups`).replace(`paid_members`,`paid_conversions`),t),_=a.url,v=`https://www.google.com/s2/favicons?domain=ghost.org&sz=64`,y=G.useMemo(()=>{if(l?.stats&&l?.meta?.totals){let e=l.meta.totals,t=e[0];if(!t)return s(`usd`);for(let n of e)n.mrr>t.mrr&&(t=n);return s(t.currency)}return s(`usd`)},[l]),b=G.useMemo(()=>h?.stats?h.stats.map(e=>{let t=e.source||`Direct`,{domain:n}=c(t,_),r=n?`https://www.faviconextractor.com/favicon/${n}?larger=true`:v,i=n&&t!==`Direct`?`https://${n}`:void 0;return{source:t,free_members:e.signups,paid_members:e.paid_conversions,mrr:e.mrr,iconSrc:r,displayName:t,linkUrl:i}}):[],[h,_]),x=`Where did your growth come from ${A(e)}`;return u?.analytics.membersTrackSources?g?(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(it,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})})}):(0,$.jsxs)($.Fragment,{children:[b.length>0?(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v,limit:t}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(at,{strokeWidth:1.5})})})})}),n&&b.length>t&&(0,$.jsx)(ze,{className:`border-none bg-transparent hover:bg-transparent!`,children:(0,$.jsx)(I,{children:(0,$.jsx)(R,{className:`border-none bg-transparent px-0 pb-0 hover:bg-transparent!`,colSpan:4,children:(0,$.jsxs)(Ue,{children:[(0,$.jsx)(He,{asChild:!0,children:(0,$.jsxs)(Ge,{variant:`outline`,children:[`View all `,(0,$.jsx)(et,{})]})}),(0,$.jsxs)(We,{className:`overflow-y-auto pt-0 sm:max-w-[420px]`,children:[(0,$.jsxs)(Xe,{className:`sticky top-0 z-40 -mx-6 bg-surface-elevated/60 p-6 backdrop-blur`,children:[(0,$.jsx)(ut,{children:`Top sources`}),(0,$.jsx)(Je,{children:x})]}),(0,$.jsx)(`div`,{className:`group/datalist`,children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{children:[(0,$.jsx)(F,{children:`Source`}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`free_members desc`,children:`Free members`})}),u?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[110px] text-right`,children:(0,$.jsx)(j,{activeSortBy:p,setSortBy:m,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),(0,$.jsx)(qt,{currencySymbol:y,data:b,defaultSourceIconUrl:v})]})})]})]})})})})]}):(0,$.jsx)(L,{children:(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:u?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})};f();var Yt=({active:e,payload:t})=>{if(e&&t&&t.length){let e=t[0];return(0,$.jsx)(`div`,{className:`rounded-lg border bg-background p-2 shadow-sm`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.payload.color}}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,$.jsx)(`span`,{className:`font-mono`,children:p(e.value)})]})})}return null},Xt=({isLoading:e,range:t})=>{let{data:n}=a(),{data:{tiers:r=[]}={}}=pt(),[i,o]=(0,G.useState)(`billing-period`),{startDate:s,endDate:c}=(0,G.useMemo)(()=>Qe(t),[t]),l=(0,G.useMemo)(()=>B(s),[s]),u=(0,G.useMemo)(()=>B(c),[c]),d=(0,G.useMemo)(()=>r.filter(e=>e.type===`paid`&&e.active).map(e=>({id:e.id,name:e.name})),[r]),f=(0,G.useMemo)(()=>{if(!n?.stats)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.cadence;return e[n]||(e[n]=0),e[n]+=t.signups,e},{});return Object.entries(r).map(([e,t],n)=>{let r=e,i=`url(#gradientPurple)`,a=`var(--chart-purple)`;return e===`month`?(r=`Monthly`,i=`url(#gradientPurple)`,a=`var(--chart-purple)`):e===`year`&&(r=`Annual`,i=`url(#gradientTeal)`,a=`var(--chart-teal)`),{id:`cadence-${n}`,name:r,count:t,fill:i,color:a}})},[n,l,u]),m=(0,G.useMemo)(()=>{if(!n?.stats||d.length===0)return[];let e=g(l),t=g(u),r=n.stats.filter(n=>{let r=g(n.date);return r.isSameOrAfter(e)&&r.isSameOrBefore(t)}).reduce((e,t)=>{let n=t.tier;return e[n]||(e[n]=0),e[n]+=t.signups,e},{}),i=[{gradient:`url(#gradientPurple)`,solid:`var(--chart-purple)`},{gradient:`url(#gradientTeal)`,solid:`var(--chart-teal)`},{gradient:`url(#gradientBlue)`,solid:`var(--chart-blue)`},{gradient:`url(#gradientRose)`,solid:`var(--chart-rose)`},{gradient:`url(#gradientOrange)`,solid:`var(--chart-orange)`},{gradient:`url(#gradientGreen)`,solid:`var(--chart-green)`},{gradient:`url(#gradientAmber)`,solid:`var(--chart-amber)`},{gradient:`url(#gradientYellow)`,solid:`var(--chart-yellow)`},{gradient:`url(#gradientDarkblue)`,solid:`var(--chart-darkblue)`},{gradient:`url(#gradientGray)`,solid:`var(--chart-darkgray)`}];return[...d.map(e=>{let t=r[e.id]||0;return{id:e.id,name:e.name,count:t}})].sort((e,t)=>t.count-e.count).map((e,t)=>{let n=t%i.length;return{...e,fill:i[n].gradient,color:i[n].solid}})},[n,d,l,u]),h=i===`billing-period`?f:m,_=(0,G.useMemo)(()=>h.reduce((e,t)=>e+t.count,0),[h]),v=(0,G.useMemo)(()=>{let e={count:{label:`Subscriptions`}};return h.forEach(t=>{e[t.id]={label:t.name,color:t.color}}),e},[h]),y=(0,G.useMemo)(()=>_===0?[]:h.map(e=>({label:e.name,count:e.count,percentage:e.count/_*100,color:e.color})),[h,_]);if(e||!n?.stats)return null;let b=h.length>0&&_>0;return(0,$.jsxs)(N,{children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscription breakdown`}),(0,$.jsxs)(Re,{children:[`New paid subscriptions `,A(t)]})]}),d.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>o(e),children:[(0,$.jsx)(Ne,{className:`w-full`,children:(0,$.jsx)(Pe,{})}),(0,$.jsxs)(Me,{align:`end`,children:[(0,$.jsx)(je,{value:`billing-period`,children:`Billing period`}),(0,$.jsx)(je,{value:`tiers`,children:`Tiers`})]})]})})]})}),(0,$.jsx)(M,{children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(de,{className:`mx-auto aspect-square h-[250px] min-h-[250px] w-full`,config:v,children:(0,$.jsxs)(Ht,{children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`linearGradient`,{id:`gradientPurple`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-purple)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-purple)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientTeal`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-teal)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-teal)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientRose`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-rose)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-rose)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientBlue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-blue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-blue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientOrange`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-orange)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-orange)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGreen`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-green)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-green)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientAmber`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-amber)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-amber)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientYellow`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-yellow)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-yellow)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientDarkblue`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkblue)`,stopOpacity:.6})]}),(0,$.jsxs)(`linearGradient`,{id:`gradientGray`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--chart-darkgray)`,stopOpacity:.6})]})]}),(0,$.jsx)(pe,{content:(0,$.jsx)(Yt,{}),cursor:!1}),(0,$.jsx)(Q,{animationBegin:0,animationDuration:1e3,data:h,dataKey:`count`,innerRadius:70,nameKey:`name`,stroke:`var(--card)`,strokeWidth:5,children:(0,$.jsx)(E,{content:({viewBox:e})=>{if(e&&`cx`in e&&`cy`in e)return(0,$.jsxs)(`text`,{dominantBaseline:`middle`,textAnchor:`middle`,x:e.cx,y:e.cy,children:[(0,$.jsx)(`tspan`,{className:`fill-foreground text-2xl font-semibold tracking-tight`,x:e.cx,y:e.cy,children:p(_)}),(0,$.jsx)(`tspan`,{className:`fill-muted-foreground`,x:e.cx,y:(e.cy||0)+20,children:`Total`})]})}})})]})}),y.length>0&&(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground`,children:y.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:e.color}}),(0,$.jsx)(`span`,{className:`max-w-[150px] truncate whitespace-nowrap`,title:e.label,children:e.label}),(0,$.jsxs)(`span`,{className:`font-medium text-foreground`,children:[Math.round(Number(e.percentage)||0),`%`]})]},e.label))})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No new paid subscriptions ${A(t)}.`,title:`No new subscribers`,children:(0,$.jsx)(ct,{strokeWidth:1.5})})})})]})};f();var Zt=(e,t,n)=>{if(t===1){let t=g().format(`YYYY-MM-DD`),n=e.find(e=>e.date===t);return[{date:t,signups:n?.signups||0,cancellations:n?.cancellations||0}]}let{startDate:r,endDate:i}=Qe(t),a=g(r).format(`YYYY-MM-DD`),o=new Map(e.map(e=>[e.date,e])),s=[],c=new Set;if(n===`monthly`){let e=g(r).startOf(`month`),t=g(i).startOf(`month`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`month`)}}else if(n===`weekly`){let e=g(r).startOf(`week`),t=g(i).startOf(`week`);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=t<a?a:t;if(!c.has(n)){c.add(n);let e=o.get(n);e?s.push(e):s.push({date:n,signups:0,cancellations:0})}e.add(1,`week`)}}else{let e=g(r),t=g(i);for(;e.isSameOrBefore(t);){let t=e.format(`YYYY-MM-DD`),n=o.get(t);n?s.push(n):s.push({date:t,signups:0,cancellations:0}),e.add(1,`day`)}}return s},Qt=e=>{let t=we(e);return t<30?[`daily`]:t>=91?[`weekly`,`monthly`]:[`daily`,`weekly`]},$t=e=>{let t=we(e);return t<30?`daily`:t>=91?`monthly`:`weekly`},en=({subscriptionData:e,memberData:t,range:n,isLoading:r})=>{let[i,a]=(0,G.useState)(()=>$t(n));(0,G.useEffect)(()=>{a($t(n))},[n]);let o=(0,G.useMemo)(()=>Qt(n),[n]),s=(0,G.useMemo)(()=>{switch(i){case`daily`:return`none`;case`weekly`:return`weekly`;case`monthly`:return`monthly`}},[i]),c=(0,G.useMemo)(()=>Te(n,[],{overrideStrategy:s}),[n,s]),l=(0,G.useMemo)(()=>{if(e&&e.length>0){if(n===1){let t=g().format(`YYYY-MM-DD`),r=e.find(e=>e.date===t);return[{date:z(t,n),rawDate:t,new:r?.signups||0,cancelled:-(r?.cancellations||0)}]}let t=k(e,n,`signups`,`sum`,s),r=k(e,n,`cancellations`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=t.map(e=>({date:e.date,signups:e.signups||0,cancellations:i.get(e.date)?.cancellations||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,signups:0,cancellations:e.cancellations||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),Zt(a,n,s).map(e=>({date:z(e.date,c),rawDate:e.date,new:e.signups||0,cancelled:-(e.cancellations||0)}))}else{if(!t||t.length===0)return[];if(n===1){let e=g().format(`YYYY-MM-DD`),r=t.find(t=>t.date===e);return[{date:z(e,n),rawDate:e,new:r?.paid_subscribed||0,cancelled:-(r?.paid_canceled||0)}]}let e=k(t,n,`paid_subscribed`,`sum`,s),r=k(t,n,`paid_canceled`,`sum`,s),i=new Map(r.map(e=>[e.date,e])),a=e.map(e=>({date:e.date,paid_subscribed:e.paid_subscribed||0,paid_canceled:i.get(e.date)?.paid_canceled||0})),o=new Set(a.map(e=>e.date));return r.forEach(e=>{o.has(e.date)||a.push({date:e.date,paid_subscribed:0,paid_canceled:e.paid_canceled||0})}),a.sort((e,t)=>new Date(e.date).getTime()-new Date(t.date).getTime()),a.map(e=>({date:z(e.date,c),rawDate:e.date,new:e.paid_subscribed||0,cancelled:-(e.paid_canceled||0)}))}},[t,e,n,s,c]),u={new:{label:`New`,color:`var(--chart-teal)`},cancelled:{label:`Cancelled`,color:`var(--chart-rose)`}},d=(0,G.useMemo)(()=>({new:l.reduce((e,t)=>e+t.new,0),cancelled:l.reduce((e,t)=>e+Math.abs(t.cancelled),0)}),[l]);if(r)return null;let f=l.length>0&&(d.new>0||d.cancelled>0),m=e=>e.charAt(0).toUpperCase()+e.slice(1);return(0,$.jsxs)(N,{"data-testid":`paid-members-change-card`,children:[(0,$.jsx)(Ie,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Le,{children:`Paid subscriptions`}),(0,$.jsxs)(Re,{children:[`New and cancelled paid subscriptions `,A(n)]})]}),o.length>1&&(0,$.jsx)(`div`,{children:(0,$.jsxs)(Fe,{value:i,onValueChange:e=>a(e),children:[(0,$.jsx)(Ne,{className:`w-[110px]`,children:(0,$.jsx)(Pe,{})}),(0,$.jsx)(Me,{align:`end`,children:o.map(e=>(0,$.jsx)(je,{value:e,children:m(e)},e))})]})})]})}),(0,$.jsx)(M,{children:f?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(de,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]`,config:u,children:(0,$.jsxs)(De,{data:l,stackOffset:`sign`,children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`tealGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-new)`,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-new)`,stopOpacity:.6})]})}),(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`roseGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`var(--color-cancelled)`,stopOpacity:.6}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`var(--color-cancelled)`,stopOpacity:.8})]})}),(0,$.jsx)(Ee,{stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(Ce,{axisLine:!1,dataKey:`date`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(Se,{axisLine:!1,tickFormatter:e=>p(e<0?e*-1:e),tickLine:!1}),(0,$.jsx)(pe,{content:(0,$.jsx)(le,{className:`min-w-[120px]! px-3 py-2`,formatter:(e,t,n,r)=>{let i=Number(e),a=`0`;a=i===0?`0`:p(i<0?i*-1:i);let o=n?.payload,s=Number(o?.new||0)+Number(o?.cancelled||0),l=s===0?`0`:s>0?`+${p(s)}`:p(s),d=o?.date,f=o?.rawDate;return f&&(d=z(f,c)),(0,$.jsxs)(`div`,{className:`flex w-full flex-col`,children:[r===0&&(0,$.jsx)(`div`,{className:`mb-1 text-sm font-medium text-foreground`,children:d}),(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`div`,{className:`size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50`,style:{"--color-bg":`var(--color-${t})`}}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:u[t]?.label||t})]}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:a})]}),r===1&&(0,$.jsxs)(`div`,{className:`mt-1 flex w-full items-center justify-between gap-4 border-t pt-1`,children:[(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Net change`}),(0,$.jsx)(`div`,{className:`ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums`,children:l})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`new`,fill:`url(#tealGradient)`,fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:`a`}),(0,$.jsx)(ce,{activeBar:{fillOpacity:1},dataKey:`cancelled`,fill:`url(#roseGradient)`,fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:`a`})]})}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.new.color}}),(0,$.jsx)(`span`,{children:`New`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.new)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`size-2 rounded-full opacity-50`,style:{backgroundColor:u.cancelled.color}}),(0,$.jsx)(`span`,{children:`Cancelled`}),(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:p(d.cancelled)})]})]})]}):(0,$.jsx)(`div`,{className:`py-12`,children:(0,$.jsx)(P,{description:`No paid subscription changes ${A(n)}.`,title:`No paid member changes`,children:(0,$.jsx)(tt,{strokeWidth:1.5})})})})]})},tn=(e,t,n)=>{let i=e??30,a=t??`mrr desc`,{startDate:o,endDate:s}=(0,G.useMemo)(()=>Qe(i),[i]),c=(0,G.useMemo)(()=>{let e={date_from:B(o),date_to:B(s),order:a};return n===`posts`?e.post_type=`post`:n===`pages`&&(e.post_type=`page`),e},[o,s,a,n]);return r({searchParams:Object.fromEntries(Object.entries(c).filter(([,e])=>e!==void 0))})},nn=()=>{let{range:e}=lt(),{site:t,settings:n}=bt(),r=String(n.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),a=d(),[o,s]=(0,G.useState)(`free_members desc`),[c,l]=(0,G.useState)(W.POSTS_AND_PAGES),[f]=u(),{appSettings:h}=Ze(),g=f.get(`tab`)||`total-members`,[_,v]=(0,G.useState)(g);(0,G.useEffect)(()=>{g!==_&&v(g)},[g]);let{isLoading:y,chartData:b,totals:x,currencySymbol:S,subscriptionData:C}=yt(e),{data:w,isLoading:T}=tn(e,o,c),E=(0,G.useMemo)(()=>{let e=(w?.stats||[]).reduce((e,t)=>{let n=t.post_id||(t.title&&t.title.trim()!==``?t.title:t.attribution_url);if(!n)return e;if(!e.has(n))e.set(n,t);else{let r=e.get(n);r.free_members+=t.free_members,r.paid_members+=t.paid_members,r.mrr+=t.mrr,e.set(n,r)}return e},new Map),t=Array.from(e.values()),n=t.reduce((e,t)=>e+t.free_members,0),r=t.reduce((e,t)=>e+t.paid_members,0),i=t.reduce((e,t)=>e+t.mrr,0);return t.map(e=>{let t=0;return o.includes(`free_members`)&&n>0?t=e.free_members/n:o.includes(`paid_members`)&&r>0?t=e.paid_members/r:o.includes(`mrr`)&&i>0&&(t=e.mrr/i),{title:e.title||e.attribution_url,post_id:e.post_id,attribution_url:e.attribution_url,attribution_type:e.attribution_type,attribution_id:e.attribution_id,free_members:e.free_members,paid_members:e.paid_members,mrr:e.mrr,percentage:t,published_at:e.published_at,url_exists:e.url_exists??!0}})},[w,o]),D=y,ee=y||T;return(0,$.jsxs)(ht,{children:[(0,$.jsx)(gt,{children:(0,$.jsx)(i,{children:(0,$.jsx)(mt,{})})}),(0,$.jsxs)(_t,{data:D?void 0:b,isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:[(0,$.jsx)(N,{"data-testid":`total-members-card`,children:(0,$.jsx)(M,{children:(0,$.jsx)(Gt,{chartData:b,currencySymbol:S,initialTab:g,isLoading:D,totals:x,onTabChange:v})})}),h?.paidMembersEnabled&&_===`paid-members`&&(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]`,children:[(0,$.jsx)(en,{isLoading:D,memberData:b,range:e,subscriptionData:C}),(0,$.jsx)(Xt,{isLoading:D,range:e})]}),(0,$.jsxs)(N,{className:`w-full overflow-x-auto`,"data-testid":`top-content-card`,children:[(0,$.jsxs)(Ie,{children:[(0,$.jsx)(Le,{children:wt(c)}),(0,$.jsx)(Re,{children:Ct(c,e,A)})]}),(0,$.jsx)(M,{children:(0,$.jsxs)(Ve,{children:[(0,$.jsx)(Be,{children:(0,$.jsxs)(I,{className:`[&>th]:h-auto [&>th]:pt-0 [&>th]:pb-2`,children:[(0,$.jsx)(F,{className:`min-w-[320px] pl-0`,children:(0,$.jsx)(Ae,{defaultValue:c,variant:`button-sm`,onValueChange:e=>{l(e)},children:(0,$.jsxs)(ke,{children:[(0,$.jsx)(Oe,{value:W.POSTS_AND_PAGES,children:`Posts & pages`}),(0,$.jsx)(Oe,{value:W.POSTS,children:`Posts`}),(0,$.jsx)(Oe,{value:W.PAGES,children:`Pages`}),(0,$.jsx)(Oe,{value:W.SOURCES,children:`Sources`})]})})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:h?.paidMembersEnabled?(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`free_members desc`,children:`Free members`}):(0,$.jsx)($.Fragment,{children:`Free members`})}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`paid_members desc`,children:`Paid members`})}),(0,$.jsx)(F,{className:`w-[140px] text-right`,children:(0,$.jsx)(j,{activeSortBy:o,setSortBy:s,sortBy:`mrr desc`,children:`MRR impact`})})]})]})}),c===W.SOURCES?(0,$.jsx)(Jt,{limit:20,range:e,setSortBy:e=>s(e),showViewAll:!0,sortBy:o}):(0,$.jsx)(L,{children:ee?(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-2`,colSpan:1,children:(0,$.jsx)(it,{containerClassName:`space-y-2`,count:5,maxWidth:75,randomize:!0})})}):h?.analytics.membersTrackSources?E.length>0?E.map((e,n)=>(0,$.jsxs)(I,{className:`last:border-none`,children:[(0,$.jsx)(R,{children:(0,$.jsxs)(`div`,{className:`group/link inline-flex flex-col items-start gap-px`,children:[e.post_id&&e.attribution_type===`post`?(0,$.jsx)(Ge,{className:`h-auto p-0 text-left leading-tight font-medium whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:Tt(e.attribution_url,e.post_id,t.url||``,a,e.attribution_type),children:e.title}):(0,$.jsx)(`span`,{className:`font-medium`,children:e.title}),e.published_at&&m&&new Date(e.published_at).getTime()>0&&(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Published on `,m(e.published_at,r)]})]})}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.free_members>0&&`+`,p(e.free_members)]}),h?.paidMembersEnabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.paid_members>0&&`+`,p(e.paid_members)]}),(0,$.jsxs)(R,{className:`text-right font-mono text-sm`,children:[e.mrr>0&&`+`,S,p(H(e.mrr))]})]})]},`${c}-${e.post_id||`${e.title}-${n}`}`)):(0,$.jsx)(I,{className:`border-none`,children:(0,$.jsx)(R,{className:`py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(P,{description:`Try adjusting your date range to see more data.`,title:`No conversions ${A(e)}`,children:(0,$.jsx)(ot,{strokeWidth:1.5})})})}):(0,$.jsx)(I,{className:`last:border-none`,children:(0,$.jsx)(R,{className:`border-none py-12 group-hover:bg-transparent!`,colSpan:h?.paidMembersEnabled?4:2,children:(0,$.jsx)(vt,{})})})})]})})]})]})]})};export{nn as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
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,E as i,S as a,T as o,_ as s,a as c,b as l,c as u,d,f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,u as S,v as C,w,x as T,y as E}from"./framework-provider-CmtnPXIT.js";import{n as D}from"./dist-Ndy-PuGN.js";var O=class extends i{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=f(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),k(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return A(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return A(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof E(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!T(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&j(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||E(this.options.enabled,this.#t)!==E(t.enabled,this.#t)||l(this.options.staleTime,this.#t)!==l(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||E(this.options.enabled,this.#t)!==E(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return te(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(s)),t}#g(){this.#b();let e=l(this.options.staleTime,this.#t);if(y.isServer()||this.#r.isStale||!p(e))return;let t=r(this.#r.dataUpdatedAt,e)+1;this.#d=w.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(y.isServer()||E(this.options.enabled,this.#t)===!1||!p(this.#p)||this.#p===0)&&(this.#f=w.setInterval(()=>{(this.options.refetchIntervalInBackground||o.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(w.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(w.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},d=!1,p;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&k(e,t),o=i&&j(e,n,t,r);(a||o)&&(l={...l,...u(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:m,errorUpdatedAt:h,status:g}=l;p=l.data;let _=!1;if(t.placeholderData!==void 0&&p===void 0&&g===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,_=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(g=`success`,p=C(i?.data,e,t),d=!0)}if(t.select&&p!==void 0&&!_)if(i&&p===a?.data&&t.select===this.#c)p=this.#l;else try{this.#c=t.select,p=t.select(p),p=C(i?.data,p,t),this.#l=p,this.#s=null}catch(e){this.#s=e}this.#s&&(m=this.#s,p=this.#l,h=Date.now(),g=`error`);let v=l.fetchStatus===`fetching`,y=g===`pending`,b=g===`error`,x=y&&v,S=p!==void 0,w={status:g,fetchStatus:l.fetchStatus,isPending:y,isSuccess:g===`success`,isError:b,isInitialLoading:x,isLoading:x,data:p,dataUpdatedAt:l.dataUpdatedAt,error:m,errorUpdatedAt:h,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:v,isRefetching:v&&!y,isLoadingError:b&&!S,isPaused:l.fetchStatus===`paused`,isPlaceholderData:d,isRefetchError:b&&S,isStale:M(e,t),refetch:this.refetch,promise:this.#o,isEnabled:E(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=w.data!==void 0,r=w.status===`error`&&!t,i=e=>{r?e.reject(w.error):t&&e.resolve(w.data)},a=()=>{let e=this.#o=w.promise=f();i(e)},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||w.data!==o.value)&&a();break;case`rejected`:(!r||w.error!==o.reason)&&a();break}}return w}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!T(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){d.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function ee(e,t){return E(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&E(t.retryOnMount,e)===!1)}function k(e,t){return ee(e,t)||e.state.data!==void 0&&A(e,t,t.refetchOnMount)}function A(e,t,n){if(E(t.enabled,e)!==!1&&l(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&M(e,t)}return!1}function j(e,t,n,r){return(e!==t||E(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&M(e,n)}function M(e,t){return E(t.enabled,e)!==!1&&e.isStaleByTime(l(t.staleTime,e))}function te(e,t){return!T(e.getCurrentResult(),t)}var ne=class extends O{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:h(t,n.data),hasPreviousPage:S(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},re=class extends i{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),T(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&g(t.mutationKey)!==g(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??x();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){d.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};n();var N=e(t(),1),ie=N.createContext(!1),ae=()=>N.useContext(ie);ie.Provider;function oe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var se=N.createContext(oe()),ce=()=>N.useContext(se),le=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?a(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ue=e=>{N.useEffect(()=>{e.clearReset()},[e])},de=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||a(n,[e.error,r])),fe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},pe=(e,t)=>e.isLoading&&e.isFetching&&!t,me=(e,t)=>e?.suspense&&t.isPending,P=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function F(e,t,n){let r=ae(),i=ce(),a=v(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=a.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:l?`optimistic`:void 0,fe(o),le(o,i,c),ue(i);let u=!a.getQueryCache().get(o.queryHash),[f]=N.useState(()=>new t(a,o)),p=f.getOptimisticResult(o),m=!r&&l;if(N.useSyncExternalStore(N.useCallback(e=>{let t=m?f.subscribe(d.batchCalls(e)):s;return f.updateResult(),t},[f,m]),()=>f.getCurrentResult(),()=>f.getCurrentResult()),N.useEffect(()=>{f.setOptions(o)},[o,f]),me(o,p))throw P(o,f,i);if(de({result:p,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw p.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,p),o.experimental_prefetchInRender&&!y.isServer()&&pe(p,r)&&(u?P(o,f,i):c?.promise)?.catch(s).finally(()=>{f.updateResult()}),o.notifyOnChangeProps?p:f.trackResult(p)}function I(e,t){return F(e,O,t)}function L(e,t){let n=v(t),[r]=N.useState(()=>new re(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(d.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=N.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(i.error&&a(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}function R(e,t){return F(e,ne,t)}var z=class extends Error{response;data;constructor(e,t,n,r){!n&&e&&e.url.includes(`/ghost/api/admin/`)&&(n=`Something went wrong while loading ${e.url.replace(/.+\/ghost\/api\/admin\//,``).replace(/\W.*/,``).replace(`_`,` `)}, please try again.`),super(n||`Something went wrong, please try again.`,r),this.response=e,this.data=t}},B=class extends z{data;constructor(e,t,n,r){super(e,t,n,r),this.data=t}},he=class extends B{constructor(e,t,n){super(e,t,`API server is running a newer version of Ghost, please upgrade.`,n)}},V=class extends z{constructor(e){super(void 0,void 0,`Something went wrong, please try again.`,e)}},ge=class extends z{constructor(e){super(void 0,void 0,`Request timed out, please try again.`,e)}},H=class extends z{constructor(e,t,n){super(e,t,`Request is larger than the maximum file size the server allows`,n)}},_e=class extends z{constructor(e,t,n){super(e,t,`Request contains an unknown or unsupported file type.`,n)}},U=class extends z{constructor(e,t,n){super(e,t,`Ghost is currently undergoing maintenance, please wait a moment then retry.`,n)}},W=class extends z{constructor(e,t,n){super(e,t,`You are not authorised to make this request.`,n)}},G=class extends W{},ve=class extends B{constructor(e,t,n){super(e,t,`Theme is not compatible or contains errors.`,n)}},K=class extends B{constructor(e,t,n){super(e,t,`A hosting plan limit was reached or exceeded.`,n)}},ye=class extends B{constructor(e,t,n){super(e,t,`Please verify your email settings`,n)}},q=class extends B{constructor(e,t,n){super(e,t,t.errors[0].message,n)}};function J(e,t){return e instanceof q&&e.data?.errors[0]?e.data.errors[0].context||e.data.errors[0].message:t}var be=class extends Error{constructor(e){super(e)}};function xe(e){D.dismiss(),D.error(e)}var Y=()=>{let{sentryDSN:e}=_();return(0,N.useCallback)((t,{withToast:n=!0}={})=>{console.error(t),e&&!(t instanceof G)&&c(e=>{t instanceof z&&t.response&&(e.setTag(`api_url`,t.response.url),e.setTag(`api_response_status`,t.response.status)),b(t)}),n&&(t instanceof z&&t.response?.status===418||t instanceof G?D.dismiss():t instanceof z?xe(J(t,t.message)):xe(`Something went wrong, please try again.`))},[e])};function X(){let e=window.location.pathname,t=e.substr(0,e.search(`/ghost/`));return{subdir:t,adminRoot:`${t}/ghost/`,assetRoot:`${t}/ghost/assets/`,apiRoot:`${t}/ghost/api/admin`,activityPubRoot:`${t}/.ghost/activitypub`}}function Se(e){let t=document.getElementById(`iframeDownload`);t||(t=document.createElement(`iframe`),t.id=`iframeDownload`,t.style.display=`none`,document.body.append(t)),t.setAttribute(`src`,e)}function Ce(e){Se(`${X().apiRoot}${e}`)}function we(e){if(!e)return;let t=e.match(/filename\*=([^;]+)/i);if(t?.[1]){let e=t[1].trim(),n=e.indexOf(`'`),r=n===-1?-1:e.indexOf(`'`,n+1),i=r===-1?e:e.slice(r+1);try{return decodeURIComponent(i.replace(/^["']|["']$/g,``))}catch{}}let n=e.match(/filename="([^"]*)"/i);if(n?.[1])return n[1].trim();let r=e.match(/filename=([^;]+)/i);if(r?.[1])return r[1].trim()}async function Te(e,t){let n=await fetch(e,{method:`GET`});if(!n.ok)throw Error(`Download failed: ${n.status} ${n.statusText}`);let r=we(n.headers.get(`content-disposition`))??t??`download`,i=await n.blob(),a=window.URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=r,document.body.appendChild(o),o.click(),o.remove(),window.URL.revokeObjectURL(a)}async function Ee(e,t){return Te(`${X().apiRoot}${e}`,t)}var De=async e=>{if(e.status===0)throw new V;if(e.status===503)throw new U(e,await e.text());if(e.status===415)throw new _e(e,await e.text());if(e.status===413)throw new H(e,await e.text());if(e.status===401)throw e.headers.get(`content-type`)?.includes(`json`)?new W(e,await e.json()):new W(e,await e.text());if(!e.ok){if(!e.headers.get(`content-type`)?.includes(`json`))throw new z(e,await e.text());let t=await e.json();throw e.status===403&&t.errors?.[0]?.message===`Authorization failed`?new W(e,t):t.errors?.[0]?.type===`VersionMismatchError`?new he(e,t):t.errors?.[0]?.type===`ValidationError`||t.errors?.[0]?.type===`NoPermissionError`?new q(e,t):t.errors?.[0]?.type===`ThemeValidationError`?new ve(e,t):t.errors?.[0]?.type===`HostLimitError`?new K(e,t):t.errors?.[0]?.type===`EmailError`?new ye(e,t):new B(e,t)}else if(e.status===204)return;else if(e.headers.get(`content-type`)?.includes(`text/csv`))return await e.text();else return await e.json()},Oe=e=>{let t=new Headers,n=e.getAllResponseHeaders()?.split(`\r
|
|
2
|
-
`)||[];for(let e of n){let n=e.indexOf(`:`);if(n===-1)continue;let r=e.slice(0,n),i=e.slice(n+1).trim();t.append(r,i)}return t},ke=e=>new Response(e.response,{status:e.status,statusText:e.statusText,headers:Oe(e)}),Ae=/\/ghost\/api\//,je=/\/ghost\/api\/admin\/session([/?#]|$)/,Me=/^#\/(?:reset|setup|signin|signup)(?:[/?]|$)/,Ne=!1,Pe=e=>window.location.pathname===e&&(!window.location.hash||window.location.hash===`#/`||Me.test(window.location.hash)),Fe=e=>{let t=e.toString();return Ae.test(t)&&!je.test(t)},Ie=()=>{let{adminRoot:e}=X();!Ne&&!Pe(e)&&(Ne=!0,window.location.replace(e))},Le=(e,t,{method:n,headers:r,credentials:i,body:a,signal:o})=>new Promise((s,c)=>{let l=()=>{c(new DOMException(`Aborted`,`AbortError`))};if(o.aborted){l();return}let u=new XMLHttpRequest;switch(u.open(n,t.toString(),!0),i){case`omit`:throw Error(`"omit" credentials cannot be represented with legacy XMLHttpRequest. Consider "same-origin".`);case`same-origin`:u.withCredentials=!1;break;case`include`:u.withCredentials=!0;break;default:throw Error(i)}u.responseType=`arraybuffer`;for(let[e,t]of Object.entries(r))u.setRequestHeader(e,t);u.upload.onprogress=t=>{t.lengthComputable&&e(t.loaded/t.total*100)},u.onload=()=>{s(ke(u))},u.onerror=()=>{c(TypeError(`Network request failed`))},u.onabort=l;let d=()=>u.abort();o.addEventListener(`abort`,d),u.onloadend=()=>{o.removeEventListener(`abort`,d)},u.send(a)}),Z=()=>{let{ghostVersion:e,sentryDSN:t}=_();return(0,N.useCallback)(async(n,{method:r=`GET`,headers:i={},body:a,credentials:o=`include`,timeout:s,retry:c=!0,onUploadProgress:l}={})=>{let u=new AbortController,d={method:r,headers:{"app-pragma":`no-cache`,...e?{"x-ghost-version":e}:{},...typeof a==`string`?{"content-type":`application/json`}:{},...i},credentials:o,mode:`cors`,body:a,signal:u.signal},f=0,p=0,h=Date.now(),g=[500,1e3],_=[V,U,TypeError],v=(e,t)=>{let r={errorName:e?.name,attempts:f,totalSeconds:p/1e3,endpoint:n.toString()};return n.toString().includes(`/ghost/api/`)&&(r.server=t?.headers.get(`server`)),r},y=l?Le.bind(null,l):fetch,b=s?setTimeout(()=>u.abort(),s):void 0;try{for(;f===0||c;)try{return await De(await y(n,d))}catch(e){if(p=Date.now()-h,c&&_.some(t=>e instanceof t)&&p<=15e3){await new Promise(e=>{setTimeout(e,g[f]||g[g.length-1])}),f+=1;continue}if(f!==0&&t&&m(`Request failed after multiple attempts`,{extra:v()}),e&&typeof e==`object`&&`name`in e&&e.name===`AbortError`)throw new ge;if(e instanceof W&&Fe(n))throw Ie(),new G(e.response,e.data,{cause:e});let r=e;throw e instanceof z||(r=new V({cause:e})),r}}finally{clearTimeout(b)}},[e,t])},{apiRoot:Re,activityPubRoot:ze}=X(),Q=(e,t={},n=!1)=>{let r=new URL(`${n?ze:Re}${e}`,window.location.origin);return r.search=new URLSearchParams(t).toString(),r.toString()},Be=`UsersResponseType`,Ve=Q(`/users/me/`,{include:`roles`}),He=[Be,Ve],Ue=()=>{let e=Z(),t=Y(),n=I({queryKey:He,queryFn:()=>e(Ve),select:e=>e.users[0]});return(0,N.useEffect)(()=>{n.error&&t(n.error)},[t,n.error]),n},We=e=>{let{data:t}=Ue();if(!e||e.length===0)return!0;let n=t?.roles.map(e=>e.name);return n?e.some(e=>n.includes(e)):!1},$=e=>({searchParams:t,...n}={})=>{let r=Q(e.path,t||e.defaultSearchParams,e?.useActivityPub),i=Z(),a=Y(),o=We(e.permissions),s=I({...n,enabled:o&&(n.enabled??!0),queryKey:[e.dataType,r],queryFn:()=>i(r,{...e})}),c=(0,N.useMemo)(()=>s.data&&e.returnData?e.returnData(s.data):s.data,[s.data]);return(0,N.useEffect)(()=>{s.error&&n.defaultErrorHandler!==!1&&a(s.error)},[a,s.error,n.defaultErrorHandler]),{...s,data:c}},Ge=e=>({searchParams:t,getNextPageParams:n,...r}={})=>{let i=Z(),a=Y(),o=We(e.permissions),s=n||e.defaultNextPageParams||(()=>({})),c=R({...r,enabled:o&&(r.enabled??!0),queryKey:[e.dataType,Q(e.path,t||e.defaultSearchParams,e?.useActivityPub)],queryFn:({pageParam:n})=>i(Q(e.path,n||t||e.defaultSearchParams,e?.useActivityPub)),initialPageParam:void 0,getNextPageParam:n=>s(n,t||e.defaultSearchParams||{})}),l=(0,N.useMemo)(()=>c.data&&e.returnData(c.data),[c.data]);return(0,N.useEffect)(()=>{c.error&&r.defaultErrorHandler!==!1&&a(c.error)},[a,c.error,r.defaultErrorHandler]),{...c,data:l}},Ke=e=>(t,{searchParams:n,...r}={})=>$({...e,path:e.path(t)})({searchParams:n||e.defaultSearchParams,...r}),qe=({fetchApi:e,path:t,payload:n,searchParams:r,options:i})=>{let{defaultSearchParams:a,body:o,...s}=i,c=Q(t,r||a,i?.useActivityPub),l=n&&o?.(n),u;return l instanceof FormData?u=l:l&&(u=JSON.stringify(l)),e(c,{body:u,...s})},Je=({path:e,searchParams:t,defaultSearchParams:n,updateQueries:r,invalidateQueries:i,...a})=>()=>{let o=Z(),s=v(),{onUpdate:c,onInvalidate:l,onDelete:u}=_();return L({mutationFn:r=>qe({fetchApi:o,path:e(r),payload:r,searchParams:t?.(r)||n,options:a}),onSuccess:(0,N.useCallback)((e,t)=>{if(i&&`dataType`in i?(s.invalidateQueries({queryKey:[i.dataType]}),l(i.dataType)):i&&s.invalidateQueries(i.filters,i.options),r){if(s.setQueriesData({queryKey:[r.dataType]},n=>r.update(e,n,t)),r.emberUpdateType===`createOrUpdate`)c(r.dataType,e);else if(r.emberUpdateType===`delete`){if(typeof t!=`string`)throw Error(`Expected delete mutation to have a string (ID) payload. Either change the payload or update the createMutation hook`);u(r.dataType,t)}}},[l,c,u,s])})};export{
|
|
2
|
+
`)||[];for(let e of n){let n=e.indexOf(`:`);if(n===-1)continue;let r=e.slice(0,n),i=e.slice(n+1).trim();t.append(r,i)}return t},ke=e=>new Response(e.response,{status:e.status,statusText:e.statusText,headers:Oe(e)}),Ae=/\/ghost\/api\//,je=/\/ghost\/api\/admin\/session([/?#]|$)/,Me=/^#\/(?:reset|setup|signin|signup)(?:[/?]|$)/,Ne=!1,Pe=e=>window.location.pathname===e&&(!window.location.hash||window.location.hash===`#/`||Me.test(window.location.hash)),Fe=e=>{let t=e.toString();return Ae.test(t)&&!je.test(t)},Ie=()=>{let{adminRoot:e}=X();!Ne&&!Pe(e)&&(Ne=!0,window.location.replace(e))},Le=(e,t,{method:n,headers:r,credentials:i,body:a,signal:o})=>new Promise((s,c)=>{let l=()=>{c(new DOMException(`Aborted`,`AbortError`))};if(o.aborted){l();return}let u=new XMLHttpRequest;switch(u.open(n,t.toString(),!0),i){case`omit`:throw Error(`"omit" credentials cannot be represented with legacy XMLHttpRequest. Consider "same-origin".`);case`same-origin`:u.withCredentials=!1;break;case`include`:u.withCredentials=!0;break;default:throw Error(i)}u.responseType=`arraybuffer`;for(let[e,t]of Object.entries(r))u.setRequestHeader(e,t);u.upload.onprogress=t=>{t.lengthComputable&&e(t.loaded/t.total*100)},u.onload=()=>{s(ke(u))},u.onerror=()=>{c(TypeError(`Network request failed`))},u.onabort=l;let d=()=>u.abort();o.addEventListener(`abort`,d),u.onloadend=()=>{o.removeEventListener(`abort`,d)},u.send(a)}),Z=()=>{let{ghostVersion:e,sentryDSN:t}=_();return(0,N.useCallback)(async(n,{method:r=`GET`,headers:i={},body:a,credentials:o=`include`,timeout:s,retry:c=!0,onUploadProgress:l}={})=>{let u=new AbortController,d={method:r,headers:{"app-pragma":`no-cache`,...e?{"x-ghost-version":e}:{},...typeof a==`string`?{"content-type":`application/json`}:{},...i},credentials:o,mode:`cors`,body:a,signal:u.signal},f=0,p=0,h=Date.now(),g=[500,1e3],_=[V,U,TypeError],v=(e,t)=>{let r={errorName:e?.name,attempts:f,totalSeconds:p/1e3,endpoint:n.toString()};return n.toString().includes(`/ghost/api/`)&&(r.server=t?.headers.get(`server`)),r},y=l?Le.bind(null,l):fetch,b=s?setTimeout(()=>u.abort(),s):void 0;try{for(;f===0||c;)try{return await De(await y(n,d))}catch(e){if(p=Date.now()-h,c&&_.some(t=>e instanceof t)&&p<=15e3){await new Promise(e=>{setTimeout(e,g[f]||g[g.length-1])}),f+=1;continue}if(f!==0&&t&&m(`Request failed after multiple attempts`,{extra:v()}),e&&typeof e==`object`&&`name`in e&&e.name===`AbortError`)throw new ge;if(e instanceof W&&Fe(n))throw Ie(),new G(e.response,e.data,{cause:e});let r=e;throw e instanceof z||(r=new V({cause:e})),r}}finally{clearTimeout(b)}},[e,t])},{apiRoot:Re,activityPubRoot:ze}=X(),Q=(e,t={},n=!1)=>{let r=new URL(`${n?ze:Re}${e}`,window.location.origin);return r.search=new URLSearchParams(t).toString(),r.toString()},Be=`UsersResponseType`,Ve=Q(`/users/me/`,{include:`roles`}),He=[Be,Ve],Ue=()=>{let e=Z(),t=Y(),n=I({queryKey:He,queryFn:()=>e(Ve),select:e=>e.users[0]});return(0,N.useEffect)(()=>{n.error&&t(n.error)},[t,n.error]),n},We=e=>{let{data:t}=Ue();if(!e||e.length===0)return!0;let n=t?.roles.map(e=>e.name);return n?e.some(e=>n.includes(e)):!1},$=e=>({searchParams:t,...n}={})=>{let r=Q(e.path,t||e.defaultSearchParams,e?.useActivityPub),i=Z(),a=Y(),o=We(e.permissions),s=I({...n,enabled:o&&(n.enabled??!0),queryKey:[e.dataType,r],queryFn:()=>i(r,{...e})}),c=(0,N.useMemo)(()=>s.data&&e.returnData?e.returnData(s.data):s.data,[s.data]);return(0,N.useEffect)(()=>{s.error&&n.defaultErrorHandler!==!1&&a(s.error)},[a,s.error,n.defaultErrorHandler]),{...s,data:c}},Ge=e=>({searchParams:t,getNextPageParams:n,...r}={})=>{let i=Z(),a=Y(),o=We(e.permissions),s=n||e.defaultNextPageParams||(()=>({})),c=R({...r,enabled:o&&(r.enabled??!0),queryKey:[e.dataType,Q(e.path,t||e.defaultSearchParams,e?.useActivityPub)],queryFn:({pageParam:n})=>i(Q(e.path,n||t||e.defaultSearchParams,e?.useActivityPub)),initialPageParam:void 0,getNextPageParam:n=>s(n,t||e.defaultSearchParams||{})}),l=(0,N.useMemo)(()=>c.data&&e.returnData(c.data),[c.data]);return(0,N.useEffect)(()=>{c.error&&r.defaultErrorHandler!==!1&&a(c.error)},[a,c.error,r.defaultErrorHandler]),{...c,data:l}},Ke=e=>(t,{searchParams:n,...r}={})=>$({...e,path:e.path(t)})({searchParams:n||e.defaultSearchParams,...r}),qe=({fetchApi:e,path:t,payload:n,searchParams:r,options:i})=>{let{defaultSearchParams:a,body:o,...s}=i,c=Q(t,r||a,i?.useActivityPub),l=n&&o?.(n),u;return l instanceof FormData?u=l:l&&(u=JSON.stringify(l)),e(c,{body:u,...s})},Je=({path:e,searchParams:t,defaultSearchParams:n,updateQueries:r,invalidateQueries:i,...a})=>()=>{let o=Z(),s=v(),{onUpdate:c,onInvalidate:l,onDelete:u}=_();return L({mutationFn:r=>qe({fetchApi:o,path:e(r),payload:r,searchParams:t?.(r)||n,options:a}),onSuccess:(0,N.useCallback)((e,t)=>{if(i&&`dataType`in i?(s.invalidateQueries({queryKey:[i.dataType]}),l(i.dataType)):i&&s.invalidateQueries(i.filters,i.options),r){if(s.setQueriesData({queryKey:[r.dataType]},n=>r.update(e,n,t)),r.emberUpdateType===`createOrUpdate`)c(r.dataType,e);else if(r.emberUpdateType===`delete`){if(typeof t!=`string`)throw Error(`Expected delete mutation to have a string (ID) payload. Either change the payload or update the createMutation hook`);u(r.dataType,t)}}},[l,c,u,s])})};export{L as C,R as S,K as _,He as a,q as b,Q as c,Se as d,Ce as f,be as g,z as h,Ke as i,Z as l,Y as m,Je as n,Ue as o,X as p,$ as r,Be as s,Ge as t,Ee as u,B as v,I as w,J as x,H as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a}from"./router-provider-C1R4AZ2o.js";import{a as o}from"./shade-app-B3heOAfz-CGXQwWeO.js";import{t as s}from"./empty-indicator-oX1u1Pkn.js";import{$ as c,
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{t as n}from"./react-Bb3IsNbi.js";import{t as r}from"./jsx-runtime-DX3WBWVO.js";import{m as i}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as a}from"./router-provider-C1R4AZ2o.js";import{a as o}from"./shade-app-B3heOAfz-CGXQwWeO.js";import{t as s}from"./empty-indicator-oX1u1Pkn.js";import{$ as c,Ar as l,B as u,Da as d,Dr as f,Er as p,Gt as m,H as h,Ha as g,Ir as _,It as v,Jn as ee,Jt as y,Kt as b,L as x,Tt as S,Wt as C,Z as w,at as T,ct as E,dt as te,et as D,ft as O,gr as k,ho as A,ir as j,it as M,kr as N,kt as ne,nt as re,ot as P,qt as F,rr as ie,rt as ae,st as I,tt as oe,vr as L,wr as se,yr as R}from"./index-BGG7NckO.js";import"./layout-yQEi2qDM.js";import{t as z}from"./topic-filter-DAFT87tQ.js";import{i as ce,n as le,r as ue,t as de}from"./use-reply-chain-data-DBDRtGu-.js";var B=e(n(),1),V=r(),H=[`1.5rem`,`1.6rem`,`1.7rem`,`1.8rem`,`2rem`],U={BACKGROUND_COLOR:`ghost-ap-background-color`,FONT_SIZE:`ghost-ap-font-size`,FONT_FAMILY:`ghost-ap-font-family`,FONT_STYLE:`ghost-ap-font-style`},W={SYSTEM:{id:`system`,color:`#fff`,background:`bg-white dark:bg-black`,button:`bg-white dark:bg-black`,border:`border-black/[8%] dark:border-gray-950`},SEPIA:{id:`sepia`,color:`#FCF8F1`,background:`bg-[#FCF8F1]`,button:`bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black`,border:`border-black/[8%]`},LIGHT:{id:`light`,color:`#fff`,background:`bg-white`,button:`hover:bg-black/[3%] text-black hover:text-black`,border:`border-black/[8%] dark:border-gray-950`},DARK:{id:`dark`,color:`#15171a`,background:`bg-black`,button:`text-white dark:bg-black dark:hover:bg-gray-900`,border:`border-black/[8%] dark:border-gray-950`}},fe=()=>{let[e,t]=(0,B.useState)(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||`SYSTEM`),[n,r]=(0,B.useState)(()=>{let e=localStorage.getItem(U.FONT_SIZE);return e?parseInt(e):2}),[i,a]=(0,B.useState)(()=>localStorage.getItem(U.FONT_STYLE)||`sans`);return(0,B.useEffect)(()=>{localStorage.setItem(U.FONT_SIZE,n.toString())},[n]),(0,B.useEffect)(()=>{localStorage.setItem(U.FONT_STYLE,i)},[i]),{backgroundColor:e,currentFontSizeIndex:n,fontStyle:i,handleColorChange:e=>{t(e),localStorage.setItem(U.BACKGROUND_COLOR,W[e].id)},setFontStyle:a,increaseFontSize:()=>{r(e=>Math.min(e+1,H.length-1))},decreaseFontSize:()=>{r(e=>Math.max(e-1,0))},resetFontSize:()=>r(2),fontSize:H[n]}},pe=({backgroundColor:e,currentFontSizeIndex:t,fontStyle:n,onColorChange:r,onFontStyleChange:i,onDecreaseFontSize:a,onIncreaseFontSize:o,onResetFontSize:s,onOpenChange:c})=>(0,V.jsx)(G,{backgroundColor:e,currentFontSizeIndex:t,fontStyle:n,isActiveColor:t=>e===t,isActiveFont:e=>n===e,onColorChange:r,onDecreaseFontSize:a,onFontStyleChange:i,onIncreaseFontSize:o,onOpenChange:c,onResetFontSize:s}),G=({backgroundColor:e,isActiveColor:t,isActiveFont:n,onColorChange:r,onFontStyleChange:i,currentFontSizeIndex:a,onDecreaseFontSize:s,onIncreaseFontSize:c,onResetFontSize:l,onOpenChange:u})=>(0,V.jsxs)(k,{modal:!1,onOpenChange:u,children:[(0,V.jsx)(R,{asChild:!0,children:(0,V.jsx)(_,{className:`size-9 rounded-full ${W[e].button}`,variant:`ghost`,children:(0,V.jsx)(o.Typography,{className:`size-[18px]!`})})}),(0,V.jsx)(L,{align:`end`,className:`w-[224px]`,onCloseAutoFocus:e=>e.preventDefault(),onOpenAutoFocus:e=>e.preventDefault(),children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-[6px]`,children:[(0,V.jsx)(_,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${t(`SYSTEM`)?`outline-2 outline-green`:``}`,variant:`secondary`,onClick:()=>r(`SYSTEM`),children:`Auto`}),(0,V.jsx)(_,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${t(`SEPIA`)?`outline-2 outline-green`:`border border-[#ece6d9]`}`,onClick:()=>r(`SEPIA`)}),(0,V.jsx)(_,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${t(`LIGHT`)?`outline-2 outline-green`:`border border-gray-200`}`,onClick:()=>r(`LIGHT`)}),(0,V.jsx)(_,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-950 ${t(`DARK`)?`outline-2 outline-green`:``}`,onClick:()=>r(`DARK`)})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(_,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 ${n(`sans`)&&`outline-2 outline-green`}`,variant:`secondary`,onClick:()=>i(`sans`),children:[(0,V.jsx)(`span`,{className:`text-[2rem] leading-none font-bold`,children:`Aa`}),(0,V.jsx)(`span`,{className:`text-[1.1rem]`,children:`System`})]}),(0,V.jsxs)(_,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 ${n(`serif`)&&`outline-2 outline-green`}`,variant:`secondary`,onClick:()=>i(`serif`),children:[(0,V.jsx)(`span`,{className:`pt-1 font-serif text-[2rem] leading-none font-bold`,children:`Aa`}),(0,V.jsx)(`span`,{className:`font-serif text-[1.2rem]`,children:`Serif`})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(_,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]`,disabled:a===0,variant:`secondary`,onClick:s,children:(0,V.jsx)(g,{})}),(0,V.jsx)(_,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900`,variant:`secondary`,onClick:l,children:(0,V.jsx)(`span`,{className:`text-[1.6rem] font-bold`,children:`Aa`})}),(0,V.jsx)(_,{className:`h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-300 dark:bg-gray-950 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]`,disabled:a===H.length-1,variant:`secondary`,onClick:c,children:(0,V.jsx)(d,{})})]})]})})]}),me=({tocItems:e,iframeElement:t,modalRef:n,className:r=`visible! absolute inset-y-0 right-7 z-40 hidden lg:block!`,onOpenChange:i})=>{let[a,o]=(0,B.useState)(null),s=B.useRef(!1);return(0,B.useEffect)(()=>{if(!t?.contentDocument||e.length<=1)return;let r=n.current;if(!r)return;let i=()=>{if(s.current)return;let n=t.contentDocument;if(!n)return;let i=r.scrollTop,a=e.map(e=>n.getElementById(e.id)).filter(e=>e!==null).map(e=>({id:e.id,top:e.offsetTop}));if(!a.length)return;let c=a.reduce((e,t)=>t.top-100<=i?t:e);o(c?.id||null)},a=()=>{requestAnimationFrame(i)};return r.addEventListener(`scroll`,a),i(),()=>{r.removeEventListener(`scroll`,a)}},[t,e,n]),e.length<=1?null:(0,V.jsx)(`div`,{className:r,children:(0,V.jsx)(`div`,{className:`sticky top-1/2 -translate-y-1/2`,children:(0,V.jsx)(K,{activeHeading:a||``,items:e,onItemClick:e=>{if(!t?.contentDocument)return;let r=t.contentDocument.getElementById(e);r&&n.current&&(s.current=!0,o(e),n.current.scrollTo({top:r.offsetTop-20,behavior:`smooth`}),setTimeout(()=>{s.current=!1},1e3))},onOpenChange:i})})})},he={1:`w-3`,2:`w-2`,3:`w-1`},ge={1:`pl-2`,2:`pl-6`,3:`pl-10`},K=({items:e,activeHeading:t,onItemClick:n,onOpenChange:r})=>{let[i,a]=(0,B.useState)(!1),o=B.useRef();if(B.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),e.length===0)return null;let s=e=>Math.min(e,3),c=e=>he[s(e)],l=e=>ge[s(e)],u=()=>{o.current&&clearTimeout(o.current),a(!0),r?.(!0)},d=()=>{o.current=setTimeout(()=>{a(!1),r?.(!1)},100)};return(0,V.jsxs)(k,{modal:!1,open:i,onOpenChange:a,children:[(0,V.jsx)(R,{asChild:!0,children:(0,V.jsx)(`div`,{className:`absolute top-1/2 right-2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black`,onMouseEnter:u,onMouseLeave:d,children:e.map(e=>(0,V.jsx)(`div`,{className:`h-[2px] rounded-sm ${t===e.id?`bg-black dark:bg-white`:`bg-gray-400 dark:bg-gray-700`} pr-1 transition-all ${c(e.level)}`},e.id))})}),(0,V.jsx)(L,{align:`center`,className:`w-[240px] p-2`,side:`left`,sideOffset:-28,onCloseAutoFocus:e=>e.preventDefault(),onMouseEnter:u,onMouseLeave:d,onOpenAutoFocus:e=>e.preventDefault(),children:(0,V.jsx)(`nav`,{"aria-label":`Table of contents navigation`,className:`max-h-[60vh] overflow-y-auto`,role:`navigation`,children:e.map(e=>(0,V.jsx)(`button`,{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${t===e.id?`text-black dark:text-white`:`text-gray-700 dark:text-gray-600`} hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-grey-950 dark:hover:text-white ${l(e.level)}`,type:`button`,onClick:()=>n(e.id),children:(0,V.jsx)(`span`,{className:`line-clamp-2`,children:e.text})},e.id))})})]})},_e=()=>`<style>
|
|
2
2
|
|
|
3
3
|
/* Variables */
|
|
4
4
|
|
|
@@ -3883,10 +3883,10 @@ a.kg-cta-button {
|
|
|
3883
3883
|
|
|
3884
3884
|
`),rt=Object.values(tt).map(e=>e.default).join(`
|
|
3885
3885
|
|
|
3886
|
-
`),it=({postUrl:e,heading:t,image:n,excerpt:r,authors:i,html:a,backgroundColor:o,fontSize:s,fontStyle:c,onHeadingsExtracted:l,onIframeLoad:u,onLoadingChange:d,isPopoverOpen:f})=>{let p=(0,B.useRef)(null),[m,h]=(0,B.useState)(!0),[
|
|
3887
|
-
<html class="has-${
|
|
3886
|
+
`),it=({postUrl:e,heading:t,image:n,excerpt:r,authors:i,html:a,backgroundColor:o,fontSize:s,fontStyle:c,onHeadingsExtracted:l,onIframeLoad:u,onLoadingChange:d,isPopoverOpen:f})=>{let p=(0,B.useRef)(null),[m,h]=(0,B.useState)(!0),[g,_]=(0,B.useState)(`0px`),v=document.documentElement.classList.contains(`dark`)&&o===`SYSTEM`||o===`DARK`,ee=_e(),y=typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: none) and (pointer: coarse)`).matches,b=(0,B.useMemo)(()=>E(I(y?M(a):a)),[a,y]),x=`
|
|
3887
|
+
<html class="has-${v?`light`:`dark`}-text has-${c}-body ${o===`SEPIA`&&`has-sepia-bg`}">
|
|
3888
3888
|
<head>
|
|
3889
|
-
${
|
|
3889
|
+
${ee}
|
|
3890
3890
|
<style>
|
|
3891
3891
|
:root {
|
|
3892
3892
|
--font-size: ${s};
|
|
@@ -3977,14 +3977,14 @@ a.kg-cta-button {
|
|
|
3977
3977
|
</head>
|
|
3978
3978
|
<body>
|
|
3979
3979
|
<header class='gh-article-header gh-canvas'>
|
|
3980
|
-
<h1 class='gh-article-title is-title' data-test-article-heading>${
|
|
3981
|
-
${r?`<p class='gh-article-excerpt'>${
|
|
3982
|
-
<a href="${e&&
|
|
3980
|
+
<h1 class='gh-article-title is-title' data-test-article-heading>${T(t)}</h1>
|
|
3981
|
+
${r?`<p class='gh-article-excerpt'>${T(r)}</p>`:``}
|
|
3982
|
+
<a href="${e&&P(e)?T(e):`#`}" target="_blank" rel="noopener noreferrer" class="gh-article-meta">
|
|
3983
3983
|
${i&&i.length>0?`
|
|
3984
3984
|
<div class="gh-article-author-image">
|
|
3985
3985
|
${i.map(e=>`
|
|
3986
3986
|
<span>
|
|
3987
|
-
${e.profile_image?`<img src="${
|
|
3987
|
+
${e.profile_image?`<img src="${T(e.profile_image)}" alt="${T(e.name)}">`:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="24" width="24"><path d="M6.75 6a5.25 5.25 0 1 0 10.5 0 5.25 5.25 0 1 0 -10.5 0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path><path d="M2.25 23.25a9.75 9.75 0 0 1 19.5 0" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"></path></svg>`}
|
|
3988
3988
|
</span>
|
|
3989
3989
|
`).join(``)}
|
|
3990
3990
|
</div>
|
|
@@ -3992,20 +3992,20 @@ a.kg-cta-button {
|
|
|
3992
3992
|
<div class="gh-article-meta-wrapper">
|
|
3993
3993
|
${i&&i.length>0?`
|
|
3994
3994
|
<span class="gh-article-author-name">
|
|
3995
|
-
${i.length>1?`${
|
|
3995
|
+
${i.length>1?`${T(i[0].name)} and ${i.length-1} ${i.length-1==1?`other`:`others`}`:T(i[0].name)}
|
|
3996
3996
|
</span>
|
|
3997
3997
|
`:``}
|
|
3998
|
-
<span class="gh-article-source">${e&&
|
|
3998
|
+
<span class="gh-article-source">${e&&P(e)?T(new URL(e).hostname):``} <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-external-link-icon lucide-external-link"><path d="M15 3h6v6"/><path d="M10 14 21 3"/><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/></svg></span>
|
|
3999
3999
|
</div>
|
|
4000
4000
|
</a>
|
|
4001
4001
|
${n?`
|
|
4002
4002
|
<figure class='gh-article-image'>
|
|
4003
|
-
<img src='${
|
|
4003
|
+
<img src='${T(n)}' alt='${T(t)}' />
|
|
4004
4004
|
</figure>
|
|
4005
4005
|
`:``}
|
|
4006
4006
|
</header>
|
|
4007
4007
|
<div class='gh-content gh-canvas is-body'>
|
|
4008
|
-
${
|
|
4008
|
+
${b}
|
|
4009
4009
|
</div>
|
|
4010
4010
|
<script>
|
|
4011
4011
|
(function () {
|
|
@@ -4025,4 +4025,4 @@ a.kg-cta-button {
|
|
|
4025
4025
|
<\/script>
|
|
4026
4026
|
</body>
|
|
4027
4027
|
</html>
|
|
4028
|
-
`;return(0,B.useEffect)(()=>{let e=p.current;if(!e)return;e.srcdoc||=b;let t=t=>{if(t.data.type===`resize`){let n=`${t.data.bodyHeight+24}px`;g(n),e.style.height=n,t.data.isLoaded&&h(!1)}},n=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();let t=new KeyboardEvent(`keydown`,{key:`Escape`,code:`Escape`,keyCode:27,which:27,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}},r=()=>{let t=e.contentWindow;t&&t.addEventListener(`keydown`,n)};return e.addEventListener(`load`,r),window.addEventListener(`message`,t),()=>{window.removeEventListener(`message`,t),e.removeEventListener(`load`,r);let i=e.contentWindow;i&&i.removeEventListener(`keydown`,n)}},[b]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=e.contentDocument||e.contentWindow?.document;if(!t)return;let n=t.documentElement;n.style.setProperty(`--font-size`,s),n.classList.remove(`has-sans-body`,`has-serif-body`),n.classList.add(`has-${c}-body`),n.classList.remove(`has-dark-text`,`has-light-text`),n.classList.add(`has-${_?`light`:`dark`}-text`),o===`SEPIA`?n.classList.add(`has-sepia-bg`):n.classList.remove(`has-sepia-bg`);let r=e.contentWindow;if(r&&typeof r.resizeIframe==`function`)r.resizeIframe();else{let e=new Event(`resize`);t.dispatchEvent(e)}},[s,c,o,_]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{if(!e.contentDocument)return;let t=Array.from(e.contentDocument.querySelectorAll(`.gh-content > :is(h2, h3, h4, h5, h6)[id]`));if(t.length===0)return;let n=Math.min(...t.map(e=>parseInt(e.tagName[1]))),r=t.map((e,t)=>{let r=`heading-${t}`;e.id=r;let i=parseInt(e.tagName[1])-n+1;return{id:r,text:e.textContent||``,level:i,element:e}});l?.(r),u?.(e)};return e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[l,u]),(0,B.useEffect)(()=>{d?.(m)},[m,d]),(0,V.jsx)(`div`,{className:`w-full pb-6`,children:(0,V.jsxs)(`div`,{className:`relative -mx-6`,children:[m&&(0,V.jsxs)(`div`,{className:`mx-auto mt-6 w-full max-w-[640px] max-lg:px-4`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(P,{className:`h-8`}),(0,V.jsx)(P,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(P,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(P,{className:`mt-8 h-[400px]`}),(0,V.jsx)(P,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]}),(0,V.jsx)(`iframe`,{ref:p,id:`gh-ap-article-iframe`,style:{width:`100%`,border:`none`,height:ee,overflow:`hidden`,opacity:+!m,transition:`opacity 0.2s ease-in-out`,pointerEvents:f?`none`:`auto`},title:`Embedded Content`})]})})},at=()=>(0,V.jsx)(`div`,{className:`h-px bg-black/[8%] dark:bg-gray-950`}),$=new Map,ot=({postId:e=null,onClose:t})=>{let{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,fontSize:a,handleColorChange:o,setFontStyle:s,increaseFontSize:u,decreaseFontSize:d,resetFontSize:f}=fe(),p=(0,B.useRef)(null),[m,h]=(0,B.useState)(!1),[ee,y]=(0,B.useState)(!1),[te,ne]=(0,B.useState)(new Set),[x,C]=(0,B.useState)(new Set),[E,D]=(0,B.useState)(new Set),[O,k]=(0,B.useState)(!1),A=(0,B.useRef)(null),j=(0,B.useRef)(null),{post:M,processedReplies:N,isLoading:F,loadMoreChildren:I,loadMoreChildReplies:L,hasMoreChildren:R,hasMoreChildReplies:z}=de(e??``,{includeAncestors:!1}),H=M,U=H?.object,G=H?.actor,he=H?.object?.metadata?.ghostAuthors,ge=U?.replyCount??0;(0,B.useEffect)(()=>{if(!R)return;A.current&&A.current.disconnect();let e=p.current;if(e)return A.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&R&&!O){k(!0);try{await I()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{k(!1)}}},{root:e,rootMargin:`200px`}),j.current&&A.current.observe(j.current),()=>{A.current&&A.current.disconnect()}},[R,O,I]);function K(){}function _e(e){ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),C(t=>{let n=new Set(t);return n.add(e),n})),n})}async function ve(e,t){if(!E.has(e)){D(t=>new Set(t).add(e));try{L&&await L(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{D(t=>{let n=new Set(t);return n.delete(e),n})}}}let ye=()=>{},be=(0,B.useRef)(null),q=`640px`,[xe,Se]=(0,B.useState)(0),[J,Ce]=(0,B.useState)(!0),[Y]=l(Se,100);(0,B.useEffect)(()=>{let e=p.current,t=document.getElementById(`object-content`),n=()=>{if(J||!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(n.height<=r.height){Y(100);return}let i=Math.max(0,r.top-n.top),a=t.offsetHeight-e.offsetHeight,o=Math.min(Math.max(i/a*100,0),100),s=Math.round(o/1)*1;Y(s)};if(J)return;let r=new MutationObserver(n);return t&&r.observe(t,{childList:!0,subtree:!0,characterData:!0}),e?.addEventListener(`scroll`,n),n(),()=>{e?.removeEventListener(`scroll`,n),r.disconnect()}},[J,Y]);let[X,we]=(0,B.useState)([]),[Te,Ee]=(0,B.useState)(null),[Z,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{we(e)},[]),ke=(0,B.useCallback)(e=>{De(e)},[]);(0,B.useEffect)(()=>{if(!Z?.contentDocument||!X.length)return;let e=setTimeout(()=>{let e=p.current;if(!e)return;let t=()=>{let t=Z.contentDocument;if(!t||!t.documentElement)return;let n=e.scrollTop,r=X.map(e=>t.getElementById(e.id)).filter(e=>e!==null).map(e=>({element:e,id:e.id,top:e.offsetTop}));if(!r.length)return;let i=null;for(let e of r)if(e.top-100<=n)i=e;else break;Ee(i?.id||null)};return e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`scroll`,t)}},100);return()=>clearTimeout(e)},[Z,X,Te]);let Q=v();return(0,B.useEffect)(()=>{let t=p.current;return()=>{t&&e&&$.set(e,t.scrollTop)}},[e]),(0,B.useEffect)(()=>{if(!J&&!F&&e&&p.current){let t=$.get(e);t!==void 0&&t>0&&setTimeout(()=>{p.current&&(p.current.scrollTop=t)},100)}},[J,F,e]),F?(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(g,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:[(0,V.jsx)(P,{className:`size-10 rounded-full`}),(0,V.jsxs)(`div`,{className:`grow pt-1`,children:[(0,V.jsx)(P,{className:`w-full`}),(0,V.jsx)(P,{className:`w-2/3`})]})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:d,onFontStyleChange:s,onIncreaseFontSize:u,onOpenChange:h,onResetFontSize:f})})]})}),(0,V.jsx)(`div`,{className:`relative flex-1 max-lg:px-4`,children:(0,V.jsxs)(`div`,{className:`mx-auto mt-11 w-full max-w-[640px]`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(P,{className:`h-8`}),(0,V.jsx)(P,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(P,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(P,{className:`mt-8 h-[400px]`}),(0,V.jsx)(P,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]})})]})})}):M?(0,V.jsx)(`div`,{ref:p,className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,"data-scrollable-container":!0,children:(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(g,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center justify-between gap-3 max-md:hidden`,children:[(0,V.jsx)(oe,{actor:G,isCurrentUser:U.authored,children:(0,V.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`relative z-10 pt-0.5`,children:(0,V.jsx)(se,{author:G})}),(0,V.jsxs)(`div`,{className:`relative z-10 mt-0.5 flex min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>b(G,Q,e),children:[(0,V.jsx)(`div`,{className:`flex w-full`,children:(0,V.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap text-black hover:underline dark:text-white`,children:F?(0,V.jsx)(P,{className:`w-20`}):G.name})}),(0,V.jsxs)(`div`,{className:`flex w-full`,children:[!F&&(0,V.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:re(G)}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:F?(0,V.jsx)(P,{className:`w-[120px]`}):ie(U,!U.authored)})]})]})]})}),!U.authored&&!F&&(0,V.jsx)(ae,{following:G.followedByMe??!1,handle:re(G)})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:d,onFontStyleChange:s,onIncreaseFontSize:u,onOpenChange:h,onResetFontSize:f})})]})}),(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(me,{iframeElement:Z,modalRef:p,tocItems:X,onOpenChange:y}),!F&&(0,V.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto px-6 pt-5 pb-10`,style:{maxWidth:`904px`},children:[(0,V.jsxs)(`div`,{className:`flex flex-col items-center pb-8`,id:`object-content`,children:[(0,V.jsx)(it,{authors:he,backgroundColor:n,excerpt:U.summary??``,fontSize:a,fontStyle:i,heading:U.name,html:U.content??``,image:typeof U.image==`string`?U.image:U.image?.url,isPopoverOpen:m||ee,postUrl:U?.url||``,onHeadingsExtracted:Oe,onIframeLoad:ke,onLoadingChange:Ce}),(0,V.jsx)(`div`,{className:`-ml-3 w-full`,style:{maxWidth:q},children:(0,V.jsx)(T,{actor:G,commentCount:ge,layout:`modal`,likeCount:U.likeCount??0,object:U,repostCount:U.repostCount??0,onLikeClick:ye})})]}),U.type===`Tombstone`&&(0,V.jsx)(ue,{last:!0}),(0,V.jsxs)(`div`,{className:`mx-auto w-full border-t border-black/[8%] dark:border-gray-950`,style:{maxWidth:q},children:[(0,V.jsx)(ce,{object:U}),(0,V.jsx)(at,{})]}),F&&(0,V.jsx)(w,{size:`lg`}),(0,V.jsxs)(`div`,{ref:be,className:`mx-auto w-full`,style:{maxWidth:q},children:[N.map((t,n)=>{let r=n===N.length-1,i=t.mainReply.id,a=te.has(i),o=x.has(i),s=E.has(i),c=t.chain.length>0;return(0,V.jsxs)(B.Fragment,{children:[(0,V.jsx)(S,{actor:t.mainReply.actor,allowDelete:t.mainReply.object.authored,commentCount:t.mainReply.object.replyCount??0,isChainParent:c,isPending:_(t.mainReply.id),last:!c,layout:`reply`,likeCount:t.mainReply.object.likeCount??0,object:t.mainReply.object,parentId:U.id,repostCount:t.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{let n=p.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.mainReply.id)}`)},onDelete:K}),c&&t.chain[0]&&(0,V.jsx)(S,{actor:t.chain[0].actor,allowDelete:t.chain[0].object.authored,commentCount:t.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:_(t.chain[0].id),last:t.chain.length===1,layout:`reply`,likeCount:t.chain[0].object.likeCount??0,object:t.chain[0].object,parentId:U.id,repostCount:t.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{let n=p.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.chain[0].id)}`)},onDelete:K},t.chain[0].id),c&&a&&t.chain.slice(1).map((r,i)=>{let a=i===t.chain.slice(1).length-1,o=z&&z(n),s=a&&o;return(0,V.jsx)(S,{actor:r.actor,allowDelete:r.object.authored,commentCount:r.object.replyCount??0,isChainContinuation:!0,isPending:_(r.id),last:a&&!s,layout:`reply`,likeCount:r.object.likeCount??0,object:r.object,parentId:U.id,repostCount:r.object.repostCount??0,type:`Note`,onClick:()=>{let t=p.current;t&&e&&$.set(e,t.scrollTop),Q(`/notes/${encodeURIComponent(r.id)}`)},onDelete:K},r.id)}),c&&t.chain.length>1&&!a&&(0,V.jsx)(le,{variant:`expand`,onClick:()=>_e(i)}),c&&a&&o&&z&&z(n)&&(0,V.jsx)(le,{loading:s,variant:`loadMore`,onClick:()=>ve(i,n)}),!r&&(0,V.jsx)(at,{})]},t.mainReply.id)}),O&&(0,V.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,V.jsx)(w,{size:`md`})})]}),R&&(0,V.jsx)(`div`,{ref:j,className:`h-1`})]})})]})]}),!F&&(0,V.jsxs)(`div`,{className:`pointer-events-none visible! sticky bottom-0 hidden items-end justify-between px-10 pb-[42px] lg:flex!`,children:[(0,V.jsx)(`div`,{className:`pointer-events-auto text-gray-600`,children:c(U.content??``)}),(0,V.jsxs)(`div`,{className:`pointer-events-auto min-w-10 text-right text-gray-600 transition-all duration-200 ease-out`,children:[xe,`%`]},xe)]})]})})}):(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsx)(`div`,{className:`relative flex-1`,children:(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(g,{className:W[n].button,onClick:t})}),(0,V.jsx)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:(0,V.jsx)(`div`,{className:`grow text-center`,children:(0,V.jsx)(`span`,{children:`Error loading article.`})})})]})})})})})},st=({isLoading:e,activities:t,currentTopic:n,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:c,onTopicChange:l})=>{let d=v(),{canGoBack:p,goBack:h}=a(),[g,b]=(0,B.useState)(!1),x=i(),{topicsQuery:re}=te(),{data:ie}=re,C=ie&&ie.topics.length>0;(0,B.useEffect)(()=>{b(!!x.postId)},[x.postId]);let T=(0,B.useRef)(null),D=(0,B.useRef)(null),O=(0,B.useRef)(null);(0,B.useEffect)(()=>(T.current&&T.current.disconnect(),T.current=new IntersectionObserver(e=>{e[0].isIntersecting&&o&&!c&&r()}),D.current&&T.current.observe(D.current),O.current&&T.current.observe(O.current),()=>{T.current&&T.current.disconnect()}),[o,c,r]);let k=Math.max(0,Math.floor(t.length*.75)-1);return(0,V.jsxs)(ne,{children:[C&&(0,V.jsx)(z,{currentTopic:n,excludeTopics:[`top`],onTopicChange:l}),(0,V.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,V.jsx)(`div`,{className:`w-full`,children:t.length>0?(0,V.jsx)(`div`,{className:`my-4`,children:(0,V.jsx)(`div`,{className:`mx-auto flex min-h-[calc(100dvh_-_117px)] items-start gap-11`,children:(0,V.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center`,children:(0,V.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start`,children:[(0,V.jsxs)(`ul`,{className:`mx-auto flex w-full flex-col`,"data-testid":`inbox-list`,children:[t.map((n,r)=>(0,V.jsxs)(`li`,{"data-testid":`inbox-item`,"data-test-view-article":!0,children:[(0,V.jsx)(S,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isLoading:e,isPending:_(n.id),layout:`inbox`,likeCount:n.object.likeCount??0,object:n.object,repostCount:n.object.repostCount??0,type:n.type,onClick:()=>{d(`/reader/${encodeURIComponent(n.id)}`)}}),r<t.length-1&&(0,V.jsx)(ee,{}),r===k&&(0,V.jsx)(`div`,{ref:D,className:`h-1`})]},`${n.id}-${n.type}-${r}`)),c&&(0,V.jsx)(`li`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:(0,V.jsx)(w,{size:`md`})})]}),(0,V.jsx)(`div`,{ref:O,className:`h-1`})]})})})}):n===`following`?(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{actions:C?(0,V.jsx)(y,{onClick:()=>d(`/explore`),children:`Find accounts to follow →`}):(0,V.jsx)(y,{asChild:!0,children:(0,V.jsx)(`a`,{href:`https://explore.ghost.org/social-web`,rel:`noopener noreferrer`,target:`_blank`,children:`Find accounts to follow →`})}),description:`Start following publishers to see their long-form posts here.`,title:`Your Reader is empty`,children:(0,V.jsx)(E,{})})}):(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{description:`Explore other topics for more content.`,title:`Nothing here yet`,children:(0,V.jsx)(E,{})})})})}),(0,V.jsx)(L,{open:g,onOpenChange:e=>{e||(p?h():d(`/reader`)),b(e)},children:(0,V.jsxs)(u,{className:`inset-y-3 h-[calc(100vh-24px)] w-screen max-w-[calc(100vw-24px)] animate-none! p-0 focus:outline-hidden dark:bg-gray-950`,children:[(0,V.jsxs)(m,{className:`hidden`,children:[(0,V.jsx)(f,{children:`Reader`}),(0,V.jsx)(I,{children:`Ghost reader for long form articles`})]}),x.postId&&(0,V.jsx)(ot,{postId:x.postId,onClose:()=>{p?h():d(`/reader`)}})]})})]})},ct=()=>{let[e,t]=(0,B.useState)(`following`),{inboxQuery:n}=p({enabled:e===`following`}),{discoveryFeedQuery:r}=d({enabled:e!==`following`,topic:e}),{data:i,error:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l}=e===`following`?n:r,u=a&&x(a)&&a.statusCode===404&&e!==`following`;return a&&x(a)&&!u?(0,V.jsx)(h,{errorCode:a.code,statusCode:a.statusCode}):(0,V.jsx)(st,{activities:u?[]:i?.pages.flatMap(e=>e.posts)??Array.from({length:5},(e,t)=>({id:`placeholder-${t}`,object:{}})),currentTopic:e,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l,onTopicChange:t})};export{ct as default};
|
|
4028
|
+
`;return(0,B.useEffect)(()=>{let e=p.current;if(!e)return;e.srcdoc||=x;let t=t=>{if(t.data.type===`resize`){let n=`${t.data.bodyHeight+24}px`;_(n),e.style.height=n,t.data.isLoaded&&h(!1)}},n=e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation();let t=new KeyboardEvent(`keydown`,{key:`Escape`,code:`Escape`,keyCode:27,which:27,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}},r=()=>{let t=e.contentWindow;t&&t.addEventListener(`keydown`,n)};return e.addEventListener(`load`,r),window.addEventListener(`message`,t),()=>{window.removeEventListener(`message`,t),e.removeEventListener(`load`,r);let i=e.contentWindow;i&&i.removeEventListener(`keydown`,n)}},[x]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=e.contentDocument||e.contentWindow?.document;if(!t)return;let n=t.documentElement;n.style.setProperty(`--font-size`,s),n.classList.remove(`has-sans-body`,`has-serif-body`),n.classList.add(`has-${c}-body`),n.classList.remove(`has-dark-text`,`has-light-text`),n.classList.add(`has-${v?`light`:`dark`}-text`),o===`SEPIA`?n.classList.add(`has-sepia-bg`):n.classList.remove(`has-sepia-bg`);let r=e.contentWindow;if(r&&typeof r.resizeIframe==`function`)r.resizeIframe();else{let e=new Event(`resize`);t.dispatchEvent(e)}},[s,c,o,v]),(0,B.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{if(!e.contentDocument)return;let t=Array.from(e.contentDocument.querySelectorAll(`.gh-content > :is(h2, h3, h4, h5, h6)[id]`));if(t.length===0)return;let n=Math.min(...t.map(e=>parseInt(e.tagName[1]))),r=t.map((e,t)=>{let r=`heading-${t}`;e.id=r;let i=parseInt(e.tagName[1])-n+1;return{id:r,text:e.textContent||``,level:i,element:e}});l?.(r),u?.(e)};return e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t)},[l,u]),(0,B.useEffect)(()=>{d?.(m)},[m,d]),(0,V.jsx)(`div`,{className:`w-full pb-6`,children:(0,V.jsxs)(`div`,{className:`relative -mx-6`,children:[m&&(0,V.jsxs)(`div`,{className:`mx-auto mt-6 w-full max-w-[640px] max-lg:px-4`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(j,{className:`h-8`}),(0,V.jsx)(j,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(j,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(j,{className:`mt-8 h-[400px]`}),(0,V.jsx)(j,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]}),(0,V.jsx)(`iframe`,{ref:p,id:`gh-ap-article-iframe`,style:{width:`100%`,border:`none`,height:g,overflow:`hidden`,opacity:+!m,transition:`opacity 0.2s ease-in-out`,pointerEvents:f?`none`:`auto`},title:`Embedded Content`})]})})},at=()=>(0,V.jsx)(`div`,{className:`h-px bg-black/[8%] dark:bg-gray-950`}),$=new Map,ot=({postId:e=null,onClose:t})=>{let{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,fontSize:a,handleColorChange:o,setFontStyle:s,increaseFontSize:l,decreaseFontSize:u,resetFontSize:d}=fe(),f=(0,B.useRef)(null),[p,m]=(0,B.useState)(!1),[g,_]=(0,B.useState)(!1),[v,ee]=(0,B.useState)(new Set),[x,S]=(0,B.useState)(new Set),[T,E]=(0,B.useState)(new Set),[k,A]=(0,B.useState)(!1),M=(0,B.useRef)(null),N=(0,B.useRef)(null),{post:ne,processedReplies:P,isLoading:I,loadMoreChildren:L,loadMoreChildReplies:se,hasMoreChildren:R,hasMoreChildReplies:z}=de(e??``,{includeAncestors:!1}),H=ne,U=H?.object,G=H?.actor,he=H?.object?.metadata?.ghostAuthors,ge=U?.replyCount??0;(0,B.useEffect)(()=>{if(!R)return;M.current&&M.current.disconnect();let e=f.current;if(e)return M.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&R&&!k){A(!0);try{await L()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{A(!1)}}},{root:e,rootMargin:`200px`}),N.current&&M.current.observe(N.current),()=>{M.current&&M.current.disconnect()}},[R,k,L]);function K(){}function _e(e){ee(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),S(t=>{let n=new Set(t);return n.add(e),n})),n})}async function ve(e,t){if(!T.has(e)){E(t=>new Set(t).add(e));try{se&&await se(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{E(t=>{let n=new Set(t);return n.delete(e),n})}}}let ye=()=>{},be=(0,B.useRef)(null),q=`640px`,[xe,Se]=(0,B.useState)(0),[J,Ce]=(0,B.useState)(!0),[Y]=h(Se,100);(0,B.useEffect)(()=>{let e=f.current,t=document.getElementById(`object-content`),n=()=>{if(J||!e||!t)return;let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(n.height<=r.height){Y(100);return}let i=Math.max(0,r.top-n.top),a=t.offsetHeight-e.offsetHeight,o=Math.min(Math.max(i/a*100,0),100),s=Math.round(o/1)*1;Y(s)};if(J)return;let r=new MutationObserver(n);return t&&r.observe(t,{childList:!0,subtree:!0,characterData:!0}),e?.addEventListener(`scroll`,n),n(),()=>{e?.removeEventListener(`scroll`,n),r.disconnect()}},[J,Y]);let[X,we]=(0,B.useState)([]),[Te,Ee]=(0,B.useState)(null),[Z,De]=(0,B.useState)(null),Oe=(0,B.useCallback)(e=>{we(e)},[]),ke=(0,B.useCallback)(e=>{De(e)},[]);(0,B.useEffect)(()=>{if(!Z?.contentDocument||!X.length)return;let e=setTimeout(()=>{let e=f.current;if(!e)return;let t=()=>{let t=Z.contentDocument;if(!t||!t.documentElement)return;let n=e.scrollTop,r=X.map(e=>t.getElementById(e.id)).filter(e=>e!==null).map(e=>({element:e,id:e.id,top:e.offsetTop}));if(!r.length)return;let i=null;for(let e of r)if(e.top-100<=n)i=e;else break;Ee(i?.id||null)};return e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`scroll`,t)}},100);return()=>clearTimeout(e)},[Z,X,Te]);let Q=y();return(0,B.useEffect)(()=>{let t=f.current;return()=>{t&&e&&$.set(e,t.scrollTop)}},[e]),(0,B.useEffect)(()=>{if(!J&&!I&&e&&f.current){let t=$.get(e);t!==void 0&&t>0&&setTimeout(()=>{f.current&&(f.current.scrollTop=t)},100)}},[J,I,e]),I?(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:[(0,V.jsx)(j,{className:`size-10 rounded-full`}),(0,V.jsxs)(`div`,{className:`grow pt-1`,children:[(0,V.jsx)(j,{className:`w-full`}),(0,V.jsx)(j,{className:`w-2/3`})]})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:m,onResetFontSize:d})})]})}),(0,V.jsx)(`div`,{className:`relative flex-1 max-lg:px-4`,children:(0,V.jsxs)(`div`,{className:`mx-auto mt-11 w-full max-w-[640px]`,children:[(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,V.jsx)(j,{className:`h-8`}),(0,V.jsx)(j,{className:`h-8 w-full max-w-md`})]}),(0,V.jsx)(j,{className:`mt-2 h-4`,count:4,randomize:!0}),(0,V.jsx)(j,{className:`mt-8 h-[400px]`}),(0,V.jsx)(j,{className:`mt-2 h-4`,containerClassName:`block mt-7 mb-4`,count:8,randomize:!0})]})})]})})}):ne?(0,V.jsx)(`div`,{ref:f,className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,"data-scrollable-container":!0,children:(0,V.jsx)(V.Fragment,{children:(0,V.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center justify-between gap-3 max-md:hidden`,children:[(0,V.jsx)(ae,{actor:G,isCurrentUser:U.authored,children:(0,V.jsxs)(`div`,{className:`flex cursor-pointer items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`relative z-10 pt-0.5`,children:(0,V.jsx)(O,{author:G})}),(0,V.jsxs)(`div`,{className:`relative z-10 mt-0.5 flex min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>D(G,Q,e),children:[(0,V.jsx)(`div`,{className:`flex w-full`,children:(0,V.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap text-black hover:underline dark:text-white`,children:I?(0,V.jsx)(j,{className:`w-20`}):G.name})}),(0,V.jsxs)(`div`,{className:`flex w-full`,children:[!I&&(0,V.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:b(G)}),(0,V.jsx)(`span`,{className:`text-gray-700`,children:I?(0,V.jsx)(j,{className:`w-[120px]`}):c(U,!U.authored)})]})]})]})}),!U.authored&&!I&&(0,V.jsx)(te,{following:G.followedByMe??!1,handle:b(G)})]}),(0,V.jsx)(`div`,{className:`col-[3/4] flex items-center justify-end gap-2`,children:(0,V.jsx)(pe,{backgroundColor:n,currentFontSizeIndex:r,fontStyle:i,onColorChange:o,onDecreaseFontSize:u,onFontStyleChange:s,onIncreaseFontSize:l,onOpenChange:m,onResetFontSize:d})})]})}),(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(me,{iframeElement:Z,modalRef:f,tocItems:X,onOpenChange:_}),!I&&(0,V.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,V.jsxs)(`div`,{className:`mx-auto px-6 pt-5 pb-10`,style:{maxWidth:`904px`},children:[(0,V.jsxs)(`div`,{className:`flex flex-col items-center pb-8`,id:`object-content`,children:[(0,V.jsx)(it,{authors:he,backgroundColor:n,excerpt:U.summary??``,fontSize:a,fontStyle:i,heading:U.name,html:U.content??``,image:typeof U.image==`string`?U.image:U.image?.url,isPopoverOpen:p||g,postUrl:U?.url||``,onHeadingsExtracted:Oe,onIframeLoad:ke,onLoadingChange:Ce}),(0,V.jsx)(`div`,{className:`-ml-3 w-full`,style:{maxWidth:q},children:(0,V.jsx)(re,{actor:G,commentCount:ge,layout:`modal`,likeCount:U.likeCount??0,object:U,repostCount:U.repostCount??0,onLikeClick:ye})})]}),U.type===`Tombstone`&&(0,V.jsx)(ue,{last:!0}),(0,V.jsxs)(`div`,{className:`mx-auto w-full border-t border-black/[8%] dark:border-gray-950`,style:{maxWidth:q},children:[(0,V.jsx)(ce,{object:U}),(0,V.jsx)(at,{})]}),I&&(0,V.jsx)(ie,{size:`lg`}),(0,V.jsxs)(`div`,{ref:be,className:`mx-auto w-full`,style:{maxWidth:q},children:[P.map((t,n)=>{let r=n===P.length-1,i=t.mainReply.id,a=v.has(i),o=x.has(i),s=T.has(i),c=t.chain.length>0;return(0,V.jsxs)(B.Fragment,{children:[(0,V.jsx)(w,{actor:t.mainReply.actor,allowDelete:t.mainReply.object.authored,commentCount:t.mainReply.object.replyCount??0,isChainParent:c,isPending:C(t.mainReply.id),last:!c,layout:`reply`,likeCount:t.mainReply.object.likeCount??0,object:t.mainReply.object,parentId:U.id,repostCount:t.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.mainReply.id)}`)},onDelete:K}),c&&t.chain[0]&&(0,V.jsx)(w,{actor:t.chain[0].actor,allowDelete:t.chain[0].object.authored,commentCount:t.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:C(t.chain[0].id),last:t.chain.length===1,layout:`reply`,likeCount:t.chain[0].object.likeCount??0,object:t.chain[0].object,parentId:U.id,repostCount:t.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{let n=f.current;n&&e&&$.set(e,n.scrollTop),Q(`/notes/${encodeURIComponent(t.chain[0].id)}`)},onDelete:K},t.chain[0].id),c&&a&&t.chain.slice(1).map((r,i)=>{let a=i===t.chain.slice(1).length-1,o=z&&z(n),s=a&&o;return(0,V.jsx)(w,{actor:r.actor,allowDelete:r.object.authored,commentCount:r.object.replyCount??0,isChainContinuation:!0,isPending:C(r.id),last:a&&!s,layout:`reply`,likeCount:r.object.likeCount??0,object:r.object,parentId:U.id,repostCount:r.object.repostCount??0,type:`Note`,onClick:()=>{let t=f.current;t&&e&&$.set(e,t.scrollTop),Q(`/notes/${encodeURIComponent(r.id)}`)},onDelete:K},r.id)}),c&&t.chain.length>1&&!a&&(0,V.jsx)(le,{variant:`expand`,onClick:()=>_e(i)}),c&&a&&o&&z&&z(n)&&(0,V.jsx)(le,{loading:s,variant:`loadMore`,onClick:()=>ve(i,n)}),!r&&(0,V.jsx)(at,{})]},t.mainReply.id)}),k&&(0,V.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),R&&(0,V.jsx)(`div`,{ref:N,className:`h-1`})]})})]})]}),!I&&(0,V.jsxs)(`div`,{className:`pointer-events-none visible! sticky bottom-0 hidden items-end justify-between px-10 pb-[42px] lg:flex!`,children:[(0,V.jsx)(`div`,{className:`pointer-events-auto text-gray-600`,children:oe(U.content??``)}),(0,V.jsxs)(`div`,{className:`pointer-events-auto min-w-10 text-right text-gray-600 transition-all duration-200 ease-out`,children:[xe,`%`]},xe)]})]})})}):(0,V.jsx)(`div`,{className:`max-h-full overflow-auto rounded-md ${n===`DARK`&&`dark`} ${(n===`LIGHT`||n===`SEPIA`)&&`light`} ${W[n].background}`,children:(0,V.jsx)(`div`,{className:`flex h-full flex-col`,children:(0,V.jsx)(`div`,{className:`relative flex-1`,children:(0,V.jsx)(`div`,{className:`sticky top-0 z-50 flex h-[102px] items-center justify-center rounded-t-md border-b max-md:h-[68px] ${W[n].background} ${W[n].border}`,children:(0,V.jsxs)(`div`,{className:`grid w-full px-8 max-lg:px-4`,style:{gridTemplateColumns:`1fr minmax(0,${q}) 1fr`},children:[(0,V.jsx)(`div`,{className:`flex items-center`,children:(0,V.jsx)(F,{className:W[n].button,onClick:t})}),(0,V.jsx)(`div`,{className:`col-[2/3] mx-auto flex w-full items-center gap-3 max-md:hidden`,children:(0,V.jsx)(`div`,{className:`grow text-center`,children:(0,V.jsx)(`span`,{children:`Error loading article.`})})})]})})})})})},st=({isLoading:e,activities:t,currentTopic:n,fetchNextPage:r,hasNextPage:o,isFetchingNextPage:c,onTopicChange:d})=>{let m=y(),{canGoBack:h,goBack:g}=a(),[b,x]=(0,B.useState)(!1),S=i(),{topicsQuery:T}=v(),{data:E}=T,te=E&&E.topics.length>0;(0,B.useEffect)(()=>{x(!!S.postId)},[S.postId]);let D=(0,B.useRef)(null),O=(0,B.useRef)(null),k=(0,B.useRef)(null);(0,B.useEffect)(()=>(D.current&&D.current.disconnect(),D.current=new IntersectionObserver(e=>{e[0].isIntersecting&&o&&!c&&r()}),O.current&&D.current.observe(O.current),k.current&&D.current.observe(k.current),()=>{D.current&&D.current.disconnect()}),[o,c,r]);let j=Math.max(0,Math.floor(t.length*.75)-1);return(0,V.jsxs)(u,{children:[te&&(0,V.jsx)(z,{currentTopic:n,excludeTopics:[`top`],onTopicChange:d}),(0,V.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,V.jsx)(`div`,{className:`w-full`,children:t.length>0?(0,V.jsx)(`div`,{className:`my-4`,children:(0,V.jsx)(`div`,{className:`mx-auto flex min-h-[calc(100dvh_-_117px)] items-start gap-11`,children:(0,V.jsx)(`div`,{className:`flex w-full min-w-0 flex-col items-center`,children:(0,V.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start`,children:[(0,V.jsxs)(`ul`,{className:`mx-auto flex w-full flex-col`,"data-testid":`inbox-list`,children:[t.map((n,r)=>(0,V.jsxs)(`li`,{"data-testid":`inbox-item`,"data-test-view-article":!0,children:[(0,V.jsx)(w,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isLoading:e,isPending:C(n.id),layout:`inbox`,likeCount:n.object.likeCount??0,object:n.object,repostCount:n.object.repostCount??0,type:n.type,onClick:()=>{m(`/reader/${encodeURIComponent(n.id)}`)}}),r<t.length-1&&(0,V.jsx)(ee,{}),r===j&&(0,V.jsx)(`div`,{ref:O,className:`h-1`})]},`${n.id}-${n.type}-${r}`)),c&&(0,V.jsx)(`li`,{className:`flex flex-col items-center justify-center gap-4 text-center`,children:(0,V.jsx)(ie,{size:`md`})})]}),(0,V.jsx)(`div`,{ref:k,className:`h-1`})]})})})}):n===`following`?(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{actions:te?(0,V.jsx)(_,{onClick:()=>m(`/explore`),children:`Find accounts to follow →`}):(0,V.jsx)(_,{asChild:!0,children:(0,V.jsx)(`a`,{href:`https://explore.ghost.org/social-web`,rel:`noopener noreferrer`,target:`_blank`,children:`Find accounts to follow →`})}),description:`Start following publishers to see their long-form posts here.`,title:`Your Reader is empty`,children:(0,V.jsx)(A,{})})}):(0,V.jsx)(`div`,{className:`mt-[24vh]`,children:(0,V.jsx)(s,{description:`Explore other topics for more content.`,title:`Nothing here yet`,children:(0,V.jsx)(A,{})})})})}),(0,V.jsx)(se,{open:b,onOpenChange:e=>{e||(h?g():m(`/reader`)),x(e)},children:(0,V.jsxs)(p,{className:`inset-y-3 h-[calc(100vh-24px)] w-screen max-w-[calc(100vw-24px)] animate-none! p-0 focus:outline-hidden dark:bg-gray-950`,children:[(0,V.jsxs)(N,{className:`hidden`,children:[(0,V.jsx)(l,{children:`Reader`}),(0,V.jsx)(f,{children:`Ghost reader for long form articles`})]}),S.postId&&(0,V.jsx)(ot,{postId:S.postId,onClose:()=>{h?g():m(`/reader`)}})]})})]})},ct=()=>{let[e,t]=(0,B.useState)(`following`),{inboxQuery:n}=ne({enabled:e===`following`}),{discoveryFeedQuery:r}=S({enabled:e!==`following`,topic:e}),{data:i,error:a,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l}=e===`following`?n:r,u=a&&m(a)&&a.statusCode===404&&e!==`following`;return a&&m(a)&&!u?(0,V.jsx)(x,{errorCode:a.code,statusCode:a.statusCode}):(0,V.jsx)(st,{activities:u?[]:i?.pages.flatMap(e=>e.posts)??Array.from({length:5},(e,t)=>({id:`placeholder-${t}`,object:{}})),currentTopic:e,fetchNextPage:o,hasNextPage:s,isFetchingNextPage:c,isLoading:l,onTopicChange:t})};export{ct as default};
|