ghost 6.57.0 → 6.57.1
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.1.tgz +0 -0
- package/components/tryghost-kg-converters-1.2.4.tgz +0 -0
- package/components/tryghost-kg-default-cards-10.3.4.tgz +0 -0
- package/components/tryghost-kg-default-nodes-2.1.5.tgz +0 -0
- package/components/tryghost-kg-default-transforms-1.3.3.tgz +0 -0
- package/components/tryghost-kg-html-to-lexical-1.3.3.tgz +0 -0
- package/components/tryghost-kg-lexical-html-renderer-1.4.3.tgz +0 -0
- package/core/built/admin/assets/{about-C7O-AgRZ.js → about-BNojRaxf.js} +1 -1
- package/core/built/admin/assets/{account-migration-Cv_ol1ko.js → account-migration-DMS8JsM-.js} +1 -1
- package/core/built/admin/assets/{add-integration-modal-m9Dv6f77.js → add-integration-modal-DU9ghGLS.js} +1 -1
- package/core/built/admin/assets/{add-newsletter-modal-CPSVZL2H.js → add-newsletter-modal-DFxuQrYu.js} +1 -1
- package/core/built/admin/assets/{add-recommendation-modal-Ci9Z5yat.js → add-recommendation-modal-D-3LOrdd.js} +1 -1
- package/core/built/admin/assets/{analytics-DqSCVV8U.js → analytics-DTIMRhWw.js} +1 -1
- package/core/built/admin/assets/{announcement-bar-modal-DU3avV7d.js → announcement-bar-modal-DGCcezB6.js} +1 -1
- package/core/built/admin/assets/{api-keys-BK0LylyK.js → api-keys-Dx4NeNpK.js} +1 -1
- package/core/built/admin/assets/{audience-DTJtXXWY.js → audience-DkknNqhZ.js} +1 -1
- package/core/built/admin/assets/{automations-dtQ_MRZ7.js → automations-DvSU7QhW.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-B8Es3AuV.js → bluesky-sharing-yZ9A_jL8.js} +1 -1
- package/core/built/admin/assets/{breadcrumb-tg5zL--z.js → breadcrumb-CjOH7LCU.js} +1 -1
- package/core/built/admin/assets/{chart-helpers-CZElTGYL.js → chart-helpers-DGxvWnBT.js} +1 -1
- package/core/built/admin/assets/{checkbox-Cyo-x7mC.js → checkbox-BSUcnNq_.js} +1 -1
- package/core/built/admin/assets/{chunk.873.b8fc05a8ab877fb819ed.js → chunk.424.4a27628efdade15c2dab.js} +3 -3
- package/core/built/admin/assets/chunk.524.dce1c51e0bc30fb2718e.js +25 -0
- package/core/built/admin/assets/{chunk.211.6f7328d63c41536451b3.js → chunk.571.40f093ed6d883993714e.js} +5 -5
- package/core/built/admin/assets/chunk.582.3a430d5c6a744fd475b6.js +27 -0
- package/core/built/admin/assets/{code-editor-view-Dq1rQ4tS.js → code-editor-view-BcyKABrG.js} +1 -1
- package/core/built/admin/assets/{color-picker-field-BonBgxhU.js → color-picker-field-8NoSnhNI.js} +1 -1
- package/core/built/admin/assets/{color-utils-BsrwXuDz.js → color-utils-Dzeeuj1F.js} +1 -1
- package/core/built/admin/assets/{combobox-uX5r_paI.js → combobox-5rdgDrDV.js} +1 -1
- package/core/built/admin/assets/{command-DxwBO2pF.js → command-BOYMbZa_.js} +1 -1
- package/core/built/admin/assets/{comments-Dn-RO-nU.js → comments-BhNM5CYl.js} +1 -1
- package/core/built/admin/assets/{confirmation-modal-B6D6mk6R.js → confirmation-modal-CYD7x3UQ.js} +1 -1
- package/core/built/admin/assets/{content-api-modal-BxQ-7T6u.js → content-api-modal-BtW4Z1-1.js} +1 -1
- package/core/built/admin/assets/{copy-field-BAxL4Zqn.js → copy-field-CEp_XieW.js} +1 -1
- package/core/built/admin/assets/{custom-integration-modal---d_l7lc.js → custom-integration-modal-bk3lNEuQ.js} +1 -1
- package/core/built/admin/assets/{date-range-select-PB2n1HZf.js → date-range-select-B3Ij1Rqg.js} +1 -1
- package/core/built/admin/assets/{debounce-Dg2fW5Rg.js → debounce-Cx5B_9OI.js} +1 -1
- package/core/built/admin/assets/{design-and-theme-modal-DYRT207a.js → design-and-theme-modal-B2xYKS1I.js} +3 -3
- package/core/built/admin/assets/{dirty-confirm-dialog-BnDJ39ao.js → dirty-confirm-dialog-YE9L21gY.js} +1 -1
- package/core/built/admin/assets/{disabled-sources-indicator-iMHrkyV3.js → disabled-sources-indicator-uIzbWL7K.js} +1 -1
- package/core/built/admin/assets/{dist-D5vhMdXf.js → dist-ARN6XTcR.js} +1 -1
- package/core/built/admin/assets/{dist-cFzKLG7y.js → dist-Bg8bSvLA.js} +1 -1
- package/core/built/admin/assets/{dist-WeOIvSYM.js → dist-CsvXCJSe.js} +1 -1
- package/core/built/admin/assets/{domain-BR8FIdjD.js → domain-DzrOAPY8.js} +1 -1
- package/core/built/admin/assets/{dropzone-hNxmUvwD.js → dropzone-CzhP33wa.js} +1 -1
- package/core/built/admin/assets/{edit-profile-CENrkY0l.js → edit-profile-oufs4R4n.js} +1 -1
- package/core/built/admin/assets/{editor-B18D0lm8.js → editor-BBKrunMK.js} +3 -3
- package/core/built/admin/assets/{embed-signup-form-modal-BsCYUMvQ.js → embed-signup-form-modal-Ch3s6lqA.js} +1 -1
- package/core/built/admin/assets/{explore-BmrnljWw.js → explore-CA-R01Br.js} +1 -1
- package/core/built/admin/assets/{feed-Dy4li6i8.js → feed-ClC8_Gld.js} +1 -1
- package/core/built/admin/assets/{field-Dh_lwk13.js → field-B3OPenbP.js} +1 -1
- package/core/built/admin/assets/{filter-sources-D2zDuJH5.js → filter-sources-CiPLnG9A.js} +1 -1
- package/core/built/admin/assets/{filters-3JBQcNtJ.js → filters-Bz0HsRie.js} +1 -1
- package/core/built/admin/assets/{filters-CFt_BDe4.js → filters-yFvybRMe.js} +1 -1
- package/core/built/admin/assets/{first-promoter-modal-D6Rjxugw.js → first-promoter-modal-BC0UpYCD.js} +1 -1
- package/core/built/admin/assets/{gift-link-modal-zMtlJhLQ.js → gift-link-modal-BKRuqo-k.js} +1 -1
- package/core/built/admin/assets/{global-data-provider-B949LDXJ.js → global-data-provider-RzW6Bnlf.js} +1 -1
- package/core/built/admin/assets/{growth-CFws67_i.js → growth-ClNAldfL.js} +1 -1
- package/core/built/admin/assets/{growth-C38Xtp8D.js → growth-Dz8OSG06.js} +1 -1
- package/core/built/admin/assets/{history-modal-ILAOkbxH.js → history-modal-DIVuQ5Ct.js} +1 -1
- package/core/built/admin/assets/{html-field-9a9Id_2q.js → html-field-CVZ2sMxw.js} +1 -1
- package/core/built/admin/assets/{images-CrQKVc9Q.js → images-Ok8FFJ3A.js} +1 -1
- package/core/built/admin/assets/{inbox-BrSRzyvz.js → inbox-CMUVI6qb.js} +1 -1
- package/core/built/admin/assets/{index-BHy2DZX-.js → index-DUXM0NlS.js} +2 -2
- package/core/built/admin/assets/{input-group-6vEPvX9S.js → input-group-2XU-iuh_.js} +1 -1
- package/core/built/admin/assets/{invite-user-modal-5xDCEw90.js → invite-user-modal-DrZ7xxrZ.js} +1 -1
- package/core/built/admin/assets/{koenig-editor-base-BWLEB9Vf.js → koenig-editor-base-BPj4S760.js} +1 -1
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +9254 -9251
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +124 -124
- package/core/built/admin/assets/{koenig-lexical-Cj62r_y9.js → koenig-lexical-Cdjv-m3_.js} +98 -98
- package/core/built/admin/assets/{kpi-card-IHDo8Q56.js → kpi-card-J8Mj1sDX.js} +1 -1
- package/core/built/admin/assets/{kpi-card-DOUnkZcN.js → kpi-card-awos0BMH.js} +1 -1
- package/core/built/admin/assets/{kpi-helpers-CjUdECAK.js → kpi-helpers-SEhvH-8E.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-X3DkOYbI.js → kpi-tabs-R6BjsKhd.js} +1 -1
- package/core/built/admin/assets/{label-Dq6QaOuS.js → label-BMC3dzLI.js} +1 -1
- package/core/built/admin/assets/{label-picker-8YlhS2U3.js → label-picker-Bnlru5tO.js} +1 -1
- package/core/built/admin/assets/layout-yR9rlvEw.js +1 -0
- package/core/built/admin/assets/{limit-modal-BRPsit_B.js → limit-modal-COmLevuY.js} +1 -1
- package/core/built/admin/assets/{member-custom-fields-CmvsuuV_.js → member-custom-fields-BvFKEpxJ.js} +1 -1
- package/core/built/admin/assets/{member-detail-DCvRrkmJ.js → member-detail-CWdPAe3p.js} +1 -1
- package/core/built/admin/assets/{members-DxbSKngD.js → members-Bnt0ih2R.js} +1 -1
- package/core/built/admin/assets/{moderation-Da5lhhWh.js → moderation-mPjYHgZW.js} +1 -1
- package/core/built/admin/assets/{multi-select-combobox-CYdkH7KQ.js → multi-select-combobox-CsoyHAiX.js} +1 -1
- package/core/built/admin/assets/{navigation-modal-BIoTwtMy.js → navigation-modal-D_c0badj.js} +1 -1
- package/core/built/admin/assets/{newsletter-BptlVoJm.js → newsletter-DR49NyGS.js} +1 -1
- package/core/built/admin/assets/{newsletter-detail-modal-BIvxqE0N.js → newsletter-detail-modal-B45pL1pb.js} +1 -1
- package/core/built/admin/assets/{newsletter-emails-Bf8IZLsP.js → newsletter-emails-B-OLfrvr.js} +1 -1
- package/core/built/admin/assets/{newsletters-BgrIZk0V.js → newsletters-DGs5BaKH.js} +1 -1
- package/core/built/admin/assets/{note-DYcLOmDb.js → note-CSVsUKBm.js} +1 -1
- package/core/built/admin/assets/{notifications-B2SPFIV9.js → notifications-DV9FRtDw.js} +1 -1
- package/core/built/admin/assets/{offers-container-modal-BZnZITMw.js → offers-container-modal-B0hFS8nk.js} +1 -1
- package/core/built/admin/assets/{onboarding-route-DgdfxkQh.js → onboarding-route--jL5KLPD.js} +1 -1
- package/core/built/admin/assets/{overview-Dt2_mR6U.js → overview-B-ZPNqMo.js} +1 -1
- package/core/built/admin/assets/{overview-BYQJXSog.js → overview-D96iwoJi.js} +1 -1
- package/core/built/admin/assets/{page-header-CpmxJj5B.js → page-header-DAvDYKO9.js} +1 -1
- package/core/built/admin/assets/{pintura-modal-B4MuBuuO.js → pintura-modal-jiUCxX0Q.js} +1 -1
- package/core/built/admin/assets/{portal-frame-BF0NBIji.js → portal-frame-D4D4nEO6.js} +1 -1
- package/core/built/admin/assets/{portal-modal-DMVbm0oy.js → portal-modal-BLFdYeDH.js} +1 -1
- package/core/built/admin/assets/{post-analytics-CXWBOGyP.js → post-analytics-BhAtiFJp.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-ChzjXVPt.js → post-analytics-header-DK27VjJm.js} +1 -1
- package/core/built/admin/assets/{post-analytics-provider-Cgw4U_fw.js → post-analytics-provider-DGg0FUqs.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-B9Vmk_XM.js → post-share-modal-DtFAC132.js} +1 -1
- package/core/built/admin/assets/{preferences-BfzJmnsd.js → preferences-CuWLISHa.js} +1 -1
- package/core/built/admin/assets/{preview-modal-Dw_HtD6S.js → preview-modal-DctYx20m.js} +1 -1
- package/core/built/admin/assets/{profile-BT5vtv9b.js → profile-BsKYYtuL.js} +1 -1
- package/core/built/admin/assets/{radio-group-I7ou7PoJ.js → radio-group-CI5_Kf_d.js} +1 -1
- package/core/built/admin/assets/{select-D9oU1IoM.js → select-CkXqNJDJ.js} +1 -1
- package/core/built/admin/assets/settings-B4vM-rgV.js +4 -0
- package/core/built/admin/assets/{settings-CpvHWix7.js → settings-ZCj-W56o.js} +1 -1
- package/core/built/admin/assets/{settings-breadcrumbs-K0USP2nw.js → settings-breadcrumbs-DIq31FwA.js} +1 -1
- package/core/built/admin/assets/{share-modal-ClIyPzc5.js → share-modal-BNj14g79.js} +1 -1
- package/core/built/admin/assets/{slack-modal-1XXqOfiw.js → slack-modal-C6SpMQ-q.js} +1 -1
- package/core/built/admin/assets/{sort-button-CdBsm40v.js → sort-button-B-k54ow2.js} +1 -1
- package/core/built/admin/assets/{source-icon-CEYmVLXR.js → source-icon-Cej3sZM6.js} +1 -1
- package/core/built/admin/assets/{stats-D8nZCTy5.js → stats-B2KW8E2y.js} +1 -1
- package/core/built/admin/assets/{stats-view-CugFVf0g.js → stats-view-CVzU2-p5.js} +1 -1
- package/core/built/admin/assets/{step-1-DOYjrORn.js → step-1-Dbn1iIMU.js} +1 -1
- package/core/built/admin/assets/{step-2-vA6RsarH.js → step-2-BahnSuN6.js} +1 -1
- package/core/built/admin/assets/{step-3-BtIBxMId.js → step-3-CW04e2ZJ.js} +1 -1
- package/core/built/admin/assets/{stripe-button-UFP4QRXd.js → stripe-button-BkBZqaGG.js} +1 -1
- package/core/built/admin/assets/{stripe-connect-modal-C_L3uM6n.js → stripe-connect-modal-CYDDrSJm.js} +1 -1
- package/core/built/admin/assets/{table-TMCgCQK7.js → table-BtLcEi1M.js} +1 -1
- package/core/built/admin/assets/{tabs-Dd6oOKbv.js → tabs-BaWRfg8j.js} +1 -1
- package/core/built/admin/assets/{tag-detail-D3l-UJPR.js → tag-detail-CmqiC32L.js} +1 -1
- package/core/built/admin/assets/{tags-WdKQGWR8.js → tags-BbygUvNB.js} +1 -1
- package/core/built/admin/assets/{testimonials-modal-CqWp-xXJ.js → testimonials-modal--bdzppyh.js} +1 -1
- package/core/built/admin/assets/{tier-detail-modal-BkcR2u0A.js → tier-detail-modal-BZmAsIy4.js} +1 -1
- package/core/built/admin/assets/{toggle-group-Guorw93z.js → toggle-group-CVl-Xigr.js} +1 -1
- package/core/built/admin/assets/{topic-filter-CbgoWIHn.js → topic-filter-BoRHRbL1.js} +1 -1
- package/core/built/admin/assets/{transistor-modal-DuNnnpal.js → transistor-modal-CBPDqEGy.js} +1 -1
- package/core/built/admin/assets/{unsplash-modal-y2bVwTHH.js → unsplash-modal-CixoRAO2.js} +1 -1
- package/core/built/admin/assets/{use-analytics-data-B-b4wNSC.js → use-analytics-data-BiWvcf1u.js} +1 -1
- package/core/built/admin/assets/{use-check-theme-limit-error-m09J38Mq.js → use-check-theme-limit-error-B14lZukR.js} +1 -1
- package/core/built/admin/assets/use-feature-flag-BmJoc5WN.js +1 -0
- package/core/built/admin/assets/{use-filter-params-BnbBDc7T.js → use-filter-params-ChoV72Hw.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-DPU5rt3W.js → use-growth-stats-Dom8xVzo.js} +1 -1
- package/core/built/admin/assets/{use-limiter-BkN3E4gw.js → use-limiter-Dwg8ivgQ.js} +1 -1
- package/core/built/admin/assets/{use-pintura-config-C_z8HTG2.js → use-pintura-config-Bj4QmiVk.js} +1 -1
- package/core/built/admin/assets/{use-pintura-editor-DNgbkhGp.js → use-pintura-editor-DvrslmPE.js} +1 -1
- package/core/built/admin/assets/{use-post-referrers-C2mXyrp-.js → use-post-referrers-pxIHTXFs.js} +1 -1
- package/core/built/admin/assets/{use-reply-chain-data-DaK8q2qQ.js → use-reply-chain-data-CmFe0N6F.js} +1 -1
- package/core/built/admin/assets/{use-setting-group-YlYcoNyP.js → use-setting-group-Cmp_sy-d.js} +1 -1
- package/core/built/admin/assets/{use-settings-navigation-Bf1g1rEh.js → use-settings-navigation-BmROPrls.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-D9ckKo5-.js → use-simple-pagination-D5rL3YwO.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-query-GSa32hVw.js → use-tinybird-query-DP2dMaq7.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-token-CKLOZFsw.js → use-tinybird-token-DrK_skPQ.js} +1 -1
- package/core/built/admin/assets/{use-url-input-z-p0Kewm.js → use-url-input-ChrUZBFf.js} +1 -1
- package/core/built/admin/assets/{user-detail-modal-BMxOA4Sv.js → user-detail-modal-XODpOqNC.js} +1 -1
- package/core/built/admin/assets/{virtual-list-RHeEL05L.js → virtual-list-Dnoafqbk.js} +1 -1
- package/core/built/admin/assets/{web-xJtcwMy4.js → web-D71mjB2r.js} +1 -1
- package/core/built/admin/assets/{web-Bw2QMO5u.js → web-z71lA1Y3.js} +1 -1
- package/core/built/admin/assets/{zapier-modal-BP2f4-vY.js → zapier-modal-Bp507Um7.js} +1 -1
- package/core/built/admin/index.html +5 -5
- package/core/frontend/web/middleware/admin-toolbar.js +1 -1
- package/core/frontend/web/middleware/serve-indexnow-key.js +1 -7
- package/core/server/api/endpoints/index.js +2 -2
- package/core/server/api/endpoints/themes.js +6 -1
- package/core/server/models/base/plugins/overrides.js +7 -5
- package/core/server/services/adapter-manager/adapter-paths.js +16 -12
- package/core/server/services/adapter-manager/adapter-paths.ts +17 -12
- package/core/server/services/audience-feedback/audience-feedback-controller.js +10 -1
- package/core/server/services/audience-feedback/feedback-repository.js +4 -1
- package/core/server/services/auth/session/session-service.js +18 -3
- package/core/server/services/automations/database-automations-repository.js +5 -5
- package/core/server/services/automations/database-automations-repository.ts +12 -12
- package/core/server/services/automations/database-date.js +52 -3
- package/core/server/services/automations/database-date.ts +23 -2
- package/core/server/services/email-analytics/email-analytics-service-wrapper.js +1 -1
- package/core/server/services/email-analytics/email-analytics-service.js +3 -2
- package/core/server/services/email-analytics/index.js +2 -3
- package/core/server/services/email-analytics/index.ts +1 -2
- package/core/server/services/email-analytics/lib/queries.js +91 -124
- package/core/server/services/email-analytics/lib/queries.ts +341 -0
- package/core/server/services/indexnow-ping/index.js +0 -2
- package/core/server/services/indexnow-ping/index.ts +0 -2
- package/core/server/services/indexnow-ping/indexnow-ping-service.js +5 -7
- package/core/server/services/indexnow-ping/indexnow-ping-service.ts +7 -13
- package/core/server/services/members/members-api/repositories/member-repository.js +51 -0
- package/core/server/services/slack-notifications/slack-notifications.js +2 -2
- package/core/server/services/slack-ping/index.js +1 -1
- package/core/server/services/slack-ping/index.ts +1 -1
- package/core/server/services/slack-ping/slack-ping-service.js +1 -0
- package/core/server/services/slack-ping/slack-ping-service.ts +1 -0
- package/core/server/services/stats/members-stats-service.js +0 -7
- package/core/server/services/themes/storage.js +19 -2
- package/core/server/services/webhooks/serialize.js +10 -1
- package/core/server/web/api/endpoints/admin/routes.js +2 -2
- package/core/shared/custom-theme-settings-cache/custom-theme-settings-bread-service.js +4 -0
- package/core/shared/custom-theme-settings-cache/custom-theme-settings-service.js +39 -0
- package/core/shared/labs.js +1 -1
- package/package.json +11 -11
- package/pnpm-lock.yaml +41 -41
- package/pnpm-workspace.yaml +18 -18
- package/components/tryghost-adapter-base-scheduling-0.2.0.tgz +0 -0
- package/components/tryghost-kg-converters-1.2.3.tgz +0 -0
- package/components/tryghost-kg-default-cards-10.3.3.tgz +0 -0
- package/components/tryghost-kg-default-nodes-2.1.4.tgz +0 -0
- package/core/built/admin/assets/chunk.524.cd5498dd4e195f679266.js +0 -25
- package/core/built/admin/assets/chunk.582.6f92ec1f03734bf2ea3f.js +0 -27
- package/core/built/admin/assets/layout-TMj4P-vv.js +0 -1
- package/core/built/admin/assets/settings-CfZFbyu_.js +0 -4
- package/core/built/admin/assets/use-feature-flag-ud0Qz8vt.js +0 -1
- package/core/server/services/email-analytics/jobs/update-member-email-analytics/index.js +0 -14
- /package/core/built/admin/assets/{chunk.211.6f7328d63c41536451b3.js.LICENSE.txt → chunk.571.40f093ed6d883993714e.js.LICENSE.txt} +0 -0
- /package/core/server/api/endpoints/{gift-reminders.js → gifts.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./dist-Ndy-PuGN.js";import{i,n as a,r as o,t as s}from"./tabs-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{n as r}from"./dist-Ndy-PuGN.js";import{i,n as a,r as o,t as s}from"./tabs-BaWRfg8j.js";import{B as c,Jt as l,Lt as u,Pr as d,Rt as f,St as p,U as m,Un as h,Wn as g,bt as _,et as v,ft as y,js as b,or as x,rt as S,xt as C,ys as w,yt as T}from"./index-DUXM0NlS.js";import"./layout-yR9rlvEw.js";var E=e(t(),1),D=n(),O=()=>{let{data:e,isLoading:t}=C(`index`),{data:n,isLoading:O}=p(`index`),k=t?[,,,,,].fill({apId:``,name:``,handle:``,avatarUrl:``}):e?.pages.flatMap(e=>e.accounts)??[],A=O?[,,,,,].fill({apId:``,name:``}):n?.pages.flatMap(e=>e.domains)??[],j=_(`index`),M=f(`index`),[N,P]=(0,E.useState)(new Set),F=T(`index`),I=u(`index`),[L,R]=(0,E.useState)(new Set),[z,B]=(0,E.useState)(null),V=l(),H=e=>{P(t=>{let n=new Set([...t]);return n.add(e.apId),n}),M.mutate(e),r.success(`User unblocked`)},U=e=>{P(t=>{let n=new Set([...t]);return n.delete(e.apId),n}),j.mutate(e),r.success(`User blocked`)},W=e=>{R(t=>{let n=new Set([...t]);return n.add(e.url),n}),I.mutate({url:e.url}),r.success(`Domain unblocked`)},G=e=>{R(t=>{let n=new Set([...t]);return n.delete(e.url),n}),F.mutate({url:e.url}),r.success(`Domain blocked`)};return(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`mx-auto max-w-[620px] py-[min(4vh,48px)]`,children:[(0,D.jsx)(`div`,{className:`flex items-center justify-between gap-8`,children:(0,D.jsx)(b,{children:`Moderation`})}),(0,D.jsx)(`div`,{className:`mt-6`,children:(0,D.jsxs)(s,{defaultValue:`blocked_users`,variant:`underline`,children:[(0,D.jsxs)(o,{children:[(0,D.jsx)(i,{value:`blocked_users`,children:`Blocked users`}),(0,D.jsx)(i,{value:`blocked_domains`,children:`Blocked domains`})]}),(0,D.jsx)(a,{className:`mt-2`,value:`blocked_users`,children:!t&&k.length===0?(0,D.jsxs)(h,{children:[(0,D.jsx)(g,{children:(0,D.jsx)(w,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block someone, they won't be able to follow you or interact with your content on the social web.`})})]}):k.map((e,n)=>(0,D.jsx)(S,{actor:e,isCurrentUser:!0,children:(0,D.jsx)(`div`,{children:(0,D.jsxs)(m,{onClick:t?void 0:()=>v(e.handle,V),children:[(0,D.jsx)(y,{author:{icon:{url:e.avatarUrl},name:e.name,handle:e.handle}}),(0,D.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:t?(0,D.jsx)(x,{className:`w-24`}):e.name}),(0,D.jsx)(`span`,{className:`block truncate text-sm text-gray-600`,children:t?(0,D.jsx)(x,{className:`w-40`}):e.handle})]}),N.has(e.apId)?(0,D.jsx)(d,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:t=>{t.stopPropagation(),U(e)},children:`Block`}):t?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(x,{})}):(0,D.jsx)(d,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:t=>{t.stopPropagation(),H(e)},onMouseEnter:()=>B(e.apId),onMouseLeave:()=>B(null),children:z===e.apId?`Unblock`:`Blocked`})]})})},e.apId?e.apId:`loading-${n}`))}),(0,D.jsx)(a,{className:`mt-[11px]`,value:`blocked_domains`,children:!O&&A.length===0?(0,D.jsxs)(h,{children:[(0,D.jsx)(g,{children:(0,D.jsx)(w,{})}),(0,D.jsx)(`div`,{className:`mt-2 flex max-w-[400px] flex-col items-center gap-1 text-center`,children:(0,D.jsx)(`p`,{children:`When you block a domain, all users from that domain won't be able to follow you or interact with your content.`})})]}):A.map((e,t)=>(0,D.jsxs)(m,{children:[(0,D.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,D.jsx)(`span`,{className:`block truncate font-semibold text-black dark:text-white`,children:O?(0,D.jsx)(x,{className:`w-48`}):new URL(e.url).hostname})}),L.has(e.url)?(0,D.jsx)(d,{className:`ml-auto min-w-[90px] text-red hover:bg-red/5! hover:text-red-400`,variant:`outline`,onClick:()=>G(e),children:`Block`}):O?(0,D.jsx)(`div`,{className:`ml-auto w-16`,children:(0,D.jsx)(x,{})}):(0,D.jsx)(d,{className:`ml-auto min-w-[90px]`,variant:`destructive`,onClick:()=>W(e),onMouseEnter:()=>B(e.url),onMouseLeave:()=>B(null),children:z===e.url?`Unblock`:`Blocked`})]},e.url?e.url:`loading-${t}`))})]})})]})})};export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r}from"./dist-Cb5RSHSg.js";import{a as i,c as a,i as o,o as s,r as c,s as ee,t as l}from"./command-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r}from"./dist-Cb5RSHSg.js";import{a as i,c as a,i as o,o as s,r as c,s as ee,t as l}from"./command-BOYMbZa_.js";import{rs as u,so as d}from"./index-DUXM0NlS.js";var f=e(t(),1),p=n(),m={searchPlaceholder:`Search...`,noResultsFound:`No results found.`,loading:`Loading...`,loadMore:`Load more`};function h(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.detail?.toLowerCase().includes(n)):e}function g(e,t,n,r,i,a,o){if(e)return{...e,shouldClientFilter:o??e.shouldClientFilter};let s=!!t,c=t?.useOptions({query:r,selectedValues:i});return{options:s?c?.options??[]:n??[],isInitialLoad:s?c?.isInitialLoad??!1:a&&(n?.length??0)===0,isSearching:s?c?.isSearching??!1:a&&(n?.length??0)>0,hasMore:s?c?.hasMore??!1:!1,isLoadingMore:s?c?.isLoadingMore??!1:!1,loadMore:s?c?.loadMore??(()=>{}):()=>{},shouldClientFilter:o??!s}}function _({optionSource:e,options:t,values:n,onChange:_,valueSource:v,searchable:y=!0,isLoading:b=!1,maxSelections:x,isMultiSelect:S=!0,onClose:C,autoCloseOnSelect:w=!1,className:T,searchInputClassName:E,shouldFilter:D,onSearchChange:O,i18n:k,renderItem:A,groupBy:j,header:M,footer:N}){let P=(0,f.useMemo)(()=>({...m,...k}),[k]),[F,I]=(0,f.useState)(``),L=(0,f.useCallback)(t=>{I(t),e?.onSearchChange?.(t),O?.(t)},[O,e]),R=g(e,v,t,F,n,b,D),z=R.options,[B,V]=(0,f.useState)([]),H=(0,f.useMemo)(()=>z.filter(e=>n.includes(e.value)),[z,n]);(0,f.useEffect)(()=>{if(n.length===0){V([]);return}H.length>0&&V(e=>{let t=[];for(let r of n){let n=H.find(e=>e.value===r)??e.find(e=>e.value===r);n&&t.push(n)}return t})},[H,n]);let U=(0,f.useMemo)(()=>n.length===0?[]:B.length>0?B:H,[B,n.length,H]),W=(0,f.useMemo)(()=>h(U,F),[F,U]),G=(0,f.useMemo)(()=>z.filter(e=>!n.includes(e.value)),[z,n]),K=(0,f.useMemo)(()=>{let e=new Map;for(let t of G){let n=j?.(t),r=typeof n==`string`?n:n?.key,i=typeof n==`string`?n:n?.label,a=e.get(r);e.set(r,{label:i,options:[...a?.options??[],t]})}return[...e.entries()].map(([e,t])=>({key:e,...t}))},[j,G]),q=(0,f.useCallback)(e=>{_(n.filter(t=>t!==e.value))},[_,n]),J=e=>{_([]),C?.()},Y=e=>{let t=[...n,e.value];x&&t.length>x||(_(t),w&&C?.())},X=e=>{_([e.value]),C?.()},Z=S?q:J,Q=S?Y:X,te=(0,f.useCallback)(()=>L(``),[L]),ne=(e,t)=>{if(t)return;let n=e.detail?` - ${e.detail}`:``;return e.label+n},$=A??(({option:e,isSelected:t,onSelect:n})=>(0,p.jsxs)(s,{className:`group flex items-center gap-2`,value:ne(e,t),onSelect:n,children:[e.icon,(0,p.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,p.jsx)(`span`,{className:`truncate text-accent-foreground`,title:e.label,children:e.label}),e.detail&&(0,p.jsx)(`span`,{className:`truncate text-sm text-muted-foreground`,title:e.detail,children:e.detail})]}),(0,p.jsx)(u,{className:r(`ms-auto text-primary`,!t&&`opacity-0`)})]},String(e.value)));return(0,p.jsx)(`div`,{className:r(`w-full`,T),children:(0,p.jsxs)(l,{shouldFilter:R.shouldClientFilter,children:[M?.({selectedOptions:U,onDeselect:q}),y&&(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(i,{className:r(`h-(--control-height) pr-8`,E),placeholder:P.searchPlaceholder,value:F,onValueChange:L}),R.isSearching&&(0,p.jsx)(d,{className:`pointer-events-none absolute top-1/2 right-3 size-4 -translate-y-1/2 animate-spin text-muted-foreground`})]}),(0,p.jsxs)(ee,{className:`outline-hidden`,children:[R.isInitialLoad?(0,p.jsxs)(`div`,{className:`flex items-center justify-center py-6 text-sm text-muted-foreground`,children:[(0,p.jsx)(d,{className:`mr-2 size-4 animate-spin`}),P.loading]}):(0,p.jsx)(c,{children:P.noResultsFound}),W.length>0&&(0,p.jsx)(o,{heading:P.selectedHeading,children:W.map(e=>$({option:e,isSelected:!0,onSelect:()=>Z(e)}))}),G.length>0&&(0,p.jsxs)(p.Fragment,{children:[W.length>0&&(0,p.jsx)(a,{}),K.map(e=>(0,p.jsx)(o,{heading:e.label,children:e.options.map(e=>$({option:e,isSelected:!1,onSelect:()=>Q(e)}))},e.key===void 0?`ungrouped`:`group:${e.key}`))]}),R.hasMore&&(0,p.jsxs)(p.Fragment,{children:[(W.length>0||G.length>0)&&(0,p.jsx)(a,{}),(0,p.jsx)(`div`,{className:`p-1.5`,children:(0,p.jsxs)(`button`,{className:`flex w-full items-center justify-center rounded-xs px-2 py-1.5 text-sm text-muted-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-50`,disabled:R.isLoadingMore,type:`button`,onClick:R.loadMore,children:[R.isLoadingMore&&(0,p.jsx)(d,{className:`mr-2 size-4 animate-spin`}),R.isLoadingMore?P.loading:P.loadMore]})})]})]}),N?.({searchInput:F,clearSearch:te})]})})}export{_ as t};
|
package/core/built/admin/assets/{navigation-modal-BIoTwtMy.js → navigation-modal-D_c0badj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{x as r}from"./dist-Cb5RSHSg.js";import{t as i}from"./inline-Cw-gigDW.js";import{i as a,n as o,r as s,t as c}from"./tabs-
|
|
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{x as r}from"./dist-Cb5RSHSg.js";import{t as i}from"./inline-Cw-gigDW.js";import{i as a,n as o,r as s,t as c}from"./tabs-BaWRfg8j.js";import{o as l,t as u}from"./use-settings-navigation-BmROPrls.js";import{i as d,o as f,t as p}from"./field-B3OPenbP.js";import{i as m,n as h,t as g}from"./use-url-input-ChrUZBFf.js";import{Da as _,On as v,Pr as y,Yi as b,cr as x}from"./index-DUXM0NlS.js";import{t as S}from"./validator-Cr0sMKuW.js";import{t as C}from"./use-setting-group-Cmp_sy-d.js";import{t as w}from"./format-url-C-t8G6Qd.js";var T=e(S(),1),E=e(t(),1),D=e=>!!(e.label&&!e.label.match(/^\s*$/)||e.url!==`/`),O=({items:e,setItems:t})=>{let n=h({items:(0,E.useMemo)(()=>e.map(e=>({...e,errors:{}})),[e]),setItems:(0,E.useCallback)(e=>{t(e.map(({url:e,label:t})=>({url:e,label:t})))},[t]),blank:{url:`/`,label:``,errors:{}},canAddNewItem:D}),r=new RegExp(/^(\/|#|[a-zA-Z0-9-]+:)/),i=e=>{let t={};return(!e.label||e.label.match(/^\s*$/))&&(t.label=`You must specify a label`),(!e.url||e.url.match(/\s/)||!T.default.isURL(e.url,{require_protocol:!0})&&!e.url.match(r))&&(t.url=`You must specify a valid URL or relative path`),t},a=(e,t)=>{let r=n.items.find(t=>t.id===e);n.updateItem(e,{...r.item,...t})},o=()=>{let e=i(n.newItem);Object.values(e).some(e=>e)?n.setNewItem({...n.newItem,errors:e}):n.addItem()},s=e=>{n.removeItem(e)},c=(e,t)=>{n.moveItem(e,t)},l=(e,t)=>{if(e===`new`)n.setNewItem({...n.newItem,errors:{...n.newItem.errors,[t]:void 0}});else{let r=n.items.find(t=>t.id===e).item;n.updateItem(e,{...r,errors:{...r.errors,[t]:void 0}})}};return{items:n.items.map(({item:e,id:t})=>({...e,id:t})),updateItem:a,addItem:o,removeItem:s,moveItem:c,newItem:{...n.newItem,id:`new`},setNewItem:e=>n.setNewItem({...n.newItem,...e}),clearError:l,validate:()=>{let e=!0;if(n.items.forEach(({item:t,id:r})=>{let a=i(t);Object.values(a).some(e=>e)&&(e=!1,n.updateItem(r,{...t,errors:a}))}),D(n.newItem)){let t=i(n.newItem);Object.values(t).some(e=>e)&&(e=!1,n.setNewItem({...n.newItem,errors:t}))}return e}}},k=n(),A=({baseUrl:e,item:t,updateItem:n,addItem:a,clearError:o,labelPlaceholder:s,unstyled:c,textFieldClasses:l,action:u,className:m,...h})=>{let _=g({baseUrl:e,nullable:!0,value:t.url,onChange:e=>n?.({url:e||``})});return(0,k.jsxs)(`div`,{className:r(`flex w-full items-start gap-3`,m),"data-testid":`navigation-item-editor`,...h,children:[(0,k.jsx)(`div`,{className:`flex flex-1 pt-1`,children:(0,k.jsxs)(p,{className:`grow`,"data-invalid":!!t.errors.label||void 0,children:[(0,k.jsx)(f,{className:`sr-only`,htmlFor:`navigation-label-${t.id}`,children:`Label`}),(0,k.jsx)(x,{"aria-invalid":!!t.errors.label||void 0,className:r(c&&`border-0 bg-transparent shadow-none focus-visible:ring-0`,l),id:`navigation-label-${t.id}`,placeholder:s,value:t.label,onChange:e=>n?.({label:e.target.value}),onKeyDown:e=>{n?.({label:e.target.value}),e.key===`Enter`&&(e.preventDefault(),a?.()),t.errors.label&&o?.(`label`)}}),t.errors.label&&(0,k.jsx)(d,{children:t.errors.label})]})}),(0,k.jsxs)(p,{className:`flex-1 pt-1`,"data-invalid":!!t.errors.url||void 0,children:[(0,k.jsx)(f,{className:`sr-only`,htmlFor:`navigation-url-${t.id}`,children:`URL`}),(0,k.jsx)(x,{"aria-invalid":!!t.errors.url||void 0,className:l,id:`navigation-url-${t.id}`,value:_.displayValue,onBlur:_.commitValue,onChange:e=>_.setDisplayValue(e.target.value),onFocus:_.handleFocus,onKeyDown:t=>{_.handleKeyDown(t);let r=w(t.target.value,e,!0);n?.({url:r.save||``})},onKeyUp:r=>{if(r.key===`Enter`){r.preventDefault();let t=w(r.target.value,e,!0);n?.({url:t.save||``}),a?.()}t.errors.url&&o?.(`url`)}}),t.errors.url&&(0,k.jsx)(d,{children:t.errors.url})]}),u&&(0,k.jsx)(i,{align:`center`,className:`h-[calc(var(--control-height)+0.25rem)] shrink-0 translate-y-px pt-1`,children:u})]})},j=({baseUrl:e,navigation:t})=>(0,k.jsxs)(`div`,{className:`w-full pt-2`,children:[(0,k.jsx)(m,{dragHandleClass:`translate-y-0.5`,getDragHandleLabel:e=>`Reorder ${e.label||`navigation item`}`,items:t.items,itemSeparator:!1,renderItem:n=>(0,k.jsx)(A,{action:(0,k.jsx)(y,{"aria-label":`Delete navigation item`,size:`icon`,type:`button`,variant:`ghost`,onClick:()=>t.removeItem(n.id),children:(0,k.jsx)(b,{})}),baseUrl:e,clearError:e=>t.clearError(n.id,e),item:n,updateItem:e=>t.updateItem(n.id,e)}),onMove:t.moveItem}),(0,k.jsxs)(i,{align:`start`,gap:`md`,children:[(0,k.jsx)(i,{align:`center`,className:`h-[calc(var(--control-height)+0.5rem)] shrink-0 translate-y-0.5 pt-2`,children:(0,k.jsx)(_,{className:`size-4 text-muted-foreground`})}),(0,k.jsx)(A,{action:(0,k.jsx)(y,{"aria-label":`Add navigation item`,"data-testid":`add-button`,size:`icon`,type:`button`,variant:`ghost`,onClick:t.addItem,children:(0,k.jsx)(_,{})}),addItem:t.addItem,baseUrl:e,className:`mt-1`,clearError:e=>t.clearError(t.newItem.id,e),"data-testid":`new-navigation-item`,item:t.newItem,labelPlaceholder:`New item label`,updateItem:t.setNewItem})]})]});function M(){let{updateRoute:e}=u(),{localSettings:t,updateSetting:n,saveState:r,handleSave:i,siteData:d}=C(),[f,p]=v(t,[`navigation`,`secondary_navigation`]),m=(0,E.useMemo)(()=>JSON.parse(f||`[]`),[f]),h=(0,E.useMemo)(()=>JSON.parse(p||`[]`),[p]),g=(0,E.useCallback)(e=>{n(`navigation`,JSON.stringify(e))},[n]),_=(0,E.useCallback)(e=>{n(`secondary_navigation`,JSON.stringify(e))},[n]),y=O({items:m,setItems:g}),b=O({items:h,setItems:_}),[x,S]=(0,E.useState)(`primary-nav`);return(0,k.jsx)(l,{buttonsDisabled:r===`saving`,cancelLabel:`Close`,dirty:t.some(e=>e.dirty),okLabel:r===`saving`?`Saving...`:`Save`,scrolling:!0,size:`lg`,stickyFooter:!0,testId:`navigation-modal`,title:`Navigation`,onClose:()=>{e(`navigation`)},onOk:async()=>{y.validate()&&b.validate()&&(await i(),e(`navigation`))},children:(0,k.jsx)(`div`,{className:`mt-6 mb-1`,children:(0,k.jsxs)(c,{value:x,variant:`underline`,onValueChange:S,children:[(0,k.jsxs)(s,{children:[(0,k.jsx)(a,{value:`primary-nav`,children:`Primary`}),(0,k.jsx)(a,{value:`secondary-nav`,children:`Secondary`})]}),(0,k.jsx)(o,{value:`primary-nav`,children:(0,k.jsx)(j,{baseUrl:d.url,navigation:y})}),(0,k.jsx)(o,{value:`secondary-nav`,children:(0,k.jsx)(j,{baseUrl:d.url,navigation:b})})]})})})}export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{i as a,r as o}from"./stats-D8nZCTy5.js";import{t as s}from"./posts-CxG7v0-M.js";import{o as c}from"./post-helpers-C5OQMBoi.js";import{m as l}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as u}from"./router-provider-DSQfprxH.js";import{_ as d,f,m as p,p as m}from"./dist-Cb5RSHSg.js";import{i as h,r as g,t as _}from"./tabs-Dd6oOKbv.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./card-aUHX0hyR.js";import{c as w,l as T,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./data-list-CupF7bjM.js";import{i as oe,n as se,o as E,r as D,t as O}from"./use-simple-pagination-D9ckKo5-.js";import{Fa as ce,Gr as k,Pr as A,Ps as le,Qi as j,Ss as ue,Ur as M,Vs as de,Xn as N,Zi as P,aa as F,cr as fe,es as I,ir as pe,nr as L,sr as me,tr as he}from"./index-BHy2DZX-.js";import{t as ge}from"./member-route-0Aa52Ntz.js";import{a as R,i as z,n as B,r as V,t as H}from"./kpi-card-IHDo8Q56.js";import{r as _e,t as ve}from"./post-analytics-header-ChzjXVPt.js";import{n as ye}from"./post-analytics-context-D0Mw-Pmv.js";import{a as be,i as xe,n as U,o as W,r as G}from"./link-helpers-Bzkk68GD.js";var K=r({dataType:`FeedbackResponseType`,path:e=>`/feedback/${e}/`}),q=e(t(),1),J=(e,t)=>{let{data:n,isLoading:r,error:i}=K(e,{searchParams:{limit:`50`,...t===void 0?{}:{score:t.toString()}}});return{feedback:(0,q.useMemo)(()=>n?.feedback?n.feedback:[],[n]),isLoading:r,error:i}},Y=n(),Se=({feedbackStats:e})=>{let{postId:t}=l(),n=u(),[r,i]=(0,q.useState)(`positive`),{feedback:a,isLoading:o}=J(t||``,+(r===`positive`)),{totalPages:s,paginatedData:c,nextPage:f,previousPage:w,hasNextPage:T,hasPreviousPage:ee}=O({data:a,itemsPerPage:9}),te=o;return(0,Y.jsxs)(C,{children:[(0,Y.jsxs)(v,{className:`pb-5`,children:[(0,Y.jsx)(x,{children:`Feedback`}),(0,Y.jsx)(S,{children:`What did your readers think?`})]}),e.totalFeedback>0?(0,Y.jsxs)(b,{className:`pb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(_,{className:`pb-3`,defaultValue:`positive`,value:r,variant:`button`,onValueChange:e=>i(e),children:(0,Y.jsxs)(g,{className:`gap-1`,children:[(0,Y.jsx)(h,{className:`h-7`,value:`positive`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(P,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`More like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.positiveFeedback/e.totalFeedback)})]})}),(0,Y.jsx)(h,{className:`h-7`,value:`negative`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(j,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`Less like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.negativeFeedback/e.totalFeedback)})]})})]})}),(0,Y.jsx)(le,{className:`mr-2 mb-3 lg:hidden xl:visible! xl:block!`,children:`Date`})]}),(0,Y.jsx)(N,{}),te?(0,Y.jsx)(me,{className:`mt-3`,lines:3}):c&&c.length>0?(0,Y.jsx)(`div`,{className:`flex w-full flex-col py-3`,children:c.map(e=>(0,Y.jsxs)(`div`,{className:`flex h-10 w-full items-center justify-between gap-3 rounded-sm border-none px-2 text-sm hover:cursor-pointer hover:bg-accent`,onClick:()=>{n(`/members/${e.member.id}`,{crossApp:!0})},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Y.jsxs)(he,{className:`size-7`,children:[e.member?.avatar_image&&(0,Y.jsx)(`img`,{className:`absolute aspect-square size-full`,src:e.member?.avatar_image}),(0,Y.jsx)(L,{className:`text-white`,style:{backgroundColor:`${d(M(e.member),`45`,`55`)}`},children:k(e.member)})]}),M(e.member)]}),(0,Y.jsx)(`div`,{className:`whitespace-nowrap text-muted-foreground`,children:p(e.created_at)})]},e.id))}):(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-8 text-center text-sm text-muted-foreground`,children:(0,Y.jsxs)(`div`,{children:[`No `,r===`positive`?`positive`:`negative`,` feedback yet`]})})]}):(0,Y.jsxs)(b,{className:`flex grow flex-col items-center justify-center text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:`No members have given feedback yet`}),(0,Y.jsx)(`div`,{children:`When someone does, you'll see their response here.`})]}),e.totalFeedback>0&&(0,Y.jsx)(y,{className:`grow-0`,children:(0,Y.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Y.jsxs)(A,{variant:`outline`,onClick:()=>{let e=`(feedback.post_id:'${t}'+feedback.score:1)`,i=`(feedback.post_id:'${t}'+feedback.score:0)`,a=`${encodeURIComponent(e)}&post=${t}`,o=`${encodeURIComponent(i)}&post=${t}`;n(`/members?filter=${r===`positive`?a:o}`,{crossApp:!0})},children:[`View all`,(0,Y.jsx)(F,{})]}),s>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!ee,onClick:w}),(0,Y.jsx)(oe,{disabled:!T,onClick:f})]})})]})})]})},Ce=e=>{let{data:t,isLoading:n}=s(e),{data:r,isLoading:i}=s(e,{searchParams:{include:`count.positive_feedback,count.negative_feedback`}}),c=(0,q.useMemo)(()=>t?.posts[0],[t]),l=(0,q.useMemo)(()=>r?.posts[0],[r]),u=(0,q.useMemo)(()=>c?{sent:c.email?.email_count||0,opened:c.email?.opened_count||0,clicked:c.count?.clicks||0,openedRate:c.email?.opened_count?c.email.opened_count/c.email.email_count:0,clickedRate:c.count?.clicks&&c.email?.email_count?c.count.clicks/c.email.email_count:0}:{sent:0,opened:0,clicked:0,openedRate:0,clickedRate:0},[c]),d=(0,q.useMemo)(()=>{if(!l?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=l.count.positive_feedback||0,t=l.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[l]),f=(0,q.useMemo)(()=>c?.newsletter?.id,[c]),{data:p,isLoading:m}=o({searchParams:f?{newsletter_id:f}:{},enabled:!!f}),h=(0,q.useMemo)(()=>p?.stats?p.stats.map(e=>e.post_id):[],[p]),{data:g,isLoading:_}=a({searchParams:f&&h.length>0?{newsletter_id:f,post_ids:h.join(`,`)}:{},enabled:!!f&&h.length>0}),v=(0,q.useMemo)(()=>{if(!p?.stats)return;let e=p.stats,t=g?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...p,stats:r}},[p,g]),y=m||_,{data:b,isLoading:x,refetch:S}=be({searchParams:{filter:`post_id:'${e}'`}}),C=(0,q.useMemo)(()=>{if(!v||!v.stats)return{openRate:0,clickRate:0};let e=v.stats;if(e.length===0)return{openRate:0,clickRate:0};let t=e.reduce((e,t)=>e+(t.open_rate||0),0),n=e.reduce((e,t)=>e+(t.click_rate||0),0);return{openRate:Number((t/e.length).toFixed(2)),clickRate:Number((n/e.length).toFixed(2))}},[v]),w=(0,q.useMemo)(()=>G(b),[b]);return{post:c,stats:u,feedbackStats:d,averageStats:(0,q.useMemo)(()=>({openedRate:C.openRate,clickedRate:C.clickRate}),[C]),topLinks:w,refetchTopLinks:S,isLoading:n||i||y||x}},we=({breakpoints:e={sm:1080,md:1280,lg:1360}}={})=>{let[t,n]=(0,q.useState)(`md`);return(0,q.useEffect)(()=>{let t=()=>{let t=window.innerWidth;t<e.sm?n(`sm`):t<e.md?n(`md`):n(`lg`)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),{chartSize:t,isSmall:t===`sm`,isMedium:t===`md`,isLarge:t===`lg`}},Te=()=>(0,Y.jsx)(`div`,{className:`absolute top-1/2 -right-4 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border bg-background text-muted-foreground md:visible! md:flex!`,children:(0,Y.jsx)(I,{className:`ml-0.5`,size:16,strokeWidth:1.5})}),Ee=({dataColor:e,value:t,avgValue:n})=>(0,Y.jsxs)(`div`,{className:`absolute top-6 left-1/2 z-50 flex w-[200px] -translate-x-1/2 flex-col items-stretch gap-1.5 rounded-md bg-background px-4 py-2 text-sm opacity-0 shadow-md transition-all group-hover/block:top-3 group-hover/block:opacity-100`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-blue opacity-50`,style:{backgroundColor:e}}),`This newsletter`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-gray opacity-80`}),`Average`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:n})]})]}),X=()=>{let e=u(),[t,n]=(0,q.useState)(null),[r,a]=(0,q.useState)(``),o=(0,q.useRef)(null),s=(0,q.useRef)(null),{chartSize:l}=we(),{appSettings:d}=de(),{emailTrackClicks:p,emailTrackOpens:h}=d?.analytics||{},{post:g,isPostLoading:_,postId:k}=ye(),j=t=>e(ge({filter:t}),{crossApp:!0}),M=g,P=c(M);(0,q.useEffect)(()=>{!_&&!P&&e(`/posts/analytics/${k}`)},[e,k,_,P]);let{stats:F,averageStats:I,topLinks:L,isLoading:he,refetchTopLinks:be}=Ce(k),{mutate:G}=xe(),K=(0,q.useMemo)(()=>{if(!M?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=M.count.positive_feedback||0,t=M.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[M]),J=(0,q.useMemo)(()=>M?.newsletter?.feedback_enabled===!0,[M]),X=(0,q.useMemo)(()=>K.totalFeedback>0?!0:J,[K.totalFeedback,J]),De=e=>{let t=U(L,e);t&&(n(e),a(t.link.to))},Oe=()=>{if(!t)return;let e=U(L,t);if(!e)return;let o=r.trim();if(o===``||o===e.link.to){n(null),a(``);return}G({originalUrl:e.link.originalTo,editedUrl:r,postId:k},{onSuccess:()=>{n(null),a(``),be()},onError:()=>{i.error(`Couldn’t update the link. Please try again.`)}})},{totalPages:ke,paginatedData:Ae,nextPage:je,previousPage:Me,hasNextPage:Ne,hasPreviousPage:Pe}=O({data:L,itemsPerPage:10});(0,q.useEffect)(()=>{if(t&&o.current){o.current.focus();let e=U(L,t),i=t=>{s.current&&!s.current.contains(t.target)&&r===e?.link.to&&(n(null),a(``))};return document.addEventListener(`mousedown`,i),()=>{document.removeEventListener(`mousedown`,i)}}},[t,r,L]);let Z=he||_,Fe=[{datatype:`Sent`,value:1,fill:`url(#gradientPurple)`,color:`var(--chart-purple)`}],Ie={percentage:{label:`O`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Le=[{datatype:`Average`,value:I.openedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],Re={percentage:{label:`Opened`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},ze=[{datatype:`Average`,value:I.clickedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`}],Be={percentage:{label:`Clicked`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Q=`grid-cols-3`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-[10/14] md:max-w-none lg:aspect-square`;return(!p||!h)&&(Q=`grid-cols-2`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-square md:max-w-none lg:aspect-[15/10]`),!p&&!h&&(Q=`grid-cols-1`,$=`aspect-square w-full sm:aspect-[16/10] md:max-w-[320px] md:max-h-[320px] lg:aspect-[12/10]`),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ve,{currentTab:`Newsletter`}),(0,Y.jsx)(_e,{children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 ${X&&p&&`lg:grid-cols-2`}`,children:[(0,Y.jsxs)(C,{className:X&&p?`lg:col-span-2`:``,children:[(0,Y.jsxs)(v,{className:`hidden`,children:[(0,Y.jsx)(x,{children:`Newsletters`}),(0,Y.jsx)(S,{children:`How did this post perform`})]}),Z?(0,Y.jsx)(b,{className:`h-[25vw] p-6`,children:(0,Y.jsx)(pe,{})}):(0,Y.jsxs)(b,{className:`p-0`,children:[(0,Y.jsxs)(`div`,{className:`grid ${Q} items-stretch border-b`,children:[(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-purple opacity-50`}),`Sent`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.sent)})})]}),h&&(0,Y.jsxs)(H,{className:`p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-blue opacity-50`}),`Opened`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.opened)})})]}),p&&(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-teal opacity-50`}),`Clicked`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.clicked)})})]})]}),(0,Y.jsxs)(`div`,{className:`$ mx-auto grid grid-cols-1 items-center justify-center gap-4 transition-all md:gap-0 ${Q===`grid-cols-2`&&`md:grid-cols-2`} ${Q===`grid-cols-3`&&`md:grid-cols-3`}`,children:[(0,Y.jsxs)(`div`,{className:`relative border-r-0 px-6 ${(h||p)&&`md:border-r`}`,children:[(0,Y.jsx)(W,{className:$,config:Ie,data:Fe,percentageLabel:`Sent`,percentageValue:m(1),size:l,tooltip:!1}),(h||p)&&(0,Y.jsx)(Te,{})]}),h&&(0,Y.jsxs)(`div`,{className:`group/block relative border-r-0 px-6 transition-all hover:bg-muted/25 ${p&&`md:border-r`}`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.openedRate),dataColor:`var(--chart-blue)`,value:m(F.openedRate)}),(0,Y.jsx)(W,{className:$,config:Re,data:Le,percentageLabel:`Open rate`,percentageValue:m(F.openedRate),size:l,tooltip:!1}),p&&(0,Y.jsx)(Te,{})]}),p&&(0,Y.jsxs)(`div`,{className:`group/block relative px-6 transition-all hover:bg-muted/25`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.clickedRate),dataColor:`var(--chart-teal)`,value:m(F.clickedRate)}),(0,Y.jsx)(W,{className:$,config:Be,data:ze,percentageLabel:`Click rate`,percentageValue:m(F.clickedRate),size:l,tooltip:!1})]})]})]})]}),X&&(0,Y.jsx)(Se,{feedbackStats:K}),p&&(0,Y.jsxs)(C,{className:`group/datalist overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-6`,children:[(0,Y.jsxs)(v,{className:`p-0`,children:[(0,Y.jsx)(x,{children:`Newsletter clicks`}),(0,Y.jsx)(S,{children:`Which links resonated with your readers`})]}),(0,Y.jsx)(le,{className:`mr-2`,children:`Members`})]}),Z?(0,Y.jsxs)(b,{className:`p-6 pt-0`,children:[(0,Y.jsx)(N,{}),(0,Y.jsx)(me,{className:`mt-6`})]}):(0,Y.jsxs)(b,{className:`pb-0`,children:[(0,Y.jsx)(N,{}),L.length>0?(0,Y.jsx)(ie,{className:``,children:(0,Y.jsx)(ne,{children:Ae?.map(e=>{let n=F.clicked>0?e.count/F.clicked:0,i=e.link.link_id,c=e.link.title,l=e.link.to,u=e.link.edited;return(0,Y.jsxs)(ae,{children:[t!==i&&(0,Y.jsx)(ee,{style:{width:`${n?Math.round(n*100):0}%`}}),(0,Y.jsx)(te,{className:`w-full`,children:t===i?(0,Y.jsxs)(`div`,{ref:s,className:`flex w-full items-center gap-2`,children:[(0,Y.jsx)(fe,{ref:o,className:`z-50 h-7 w-full border-border bg-background text-sm`,value:r,onChange:e=>a(e.target.value)}),(0,Y.jsx)(A,{size:`sm`,onClick:Oe,children:`Update`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{className:`mr-2 shrink-0 bg-background`,size:`sm`,variant:`outline`,onClick:()=>De(i),children:(0,Y.jsx)(ce,{})}),(0,Y.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:l,rel:`noreferrer`,target:`_blank`,title:c,children:c}),u&&(0,Y.jsx)(`span`,{className:`ml-1 text-gray-500`,children:`(edited)`})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(w,{children:f(e.count||0)}),(0,Y.jsx)(T,{children:m(n)})]})]},i)})})}):(0,Y.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]}),!Z&&L.length>1&&(0,Y.jsx)(y,{children:(0,Y.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 pl-4 text-sm text-green`,children:[(0,Y.jsx)(ue,{size:20,strokeWidth:1.5}),`Sent a broken link? You can update it!`]}),ke>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!Pe,onClick:Me}),(0,Y.jsx)(oe,{disabled:!Ne,onClick:je})]})})]})})]})]})})]})};export{X as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{i as r}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{i as a,r as o}from"./stats-B2KW8E2y.js";import{t as s}from"./posts-CxG7v0-M.js";import{o as c}from"./post-helpers-C5OQMBoi.js";import{m as l}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as u}from"./router-provider-DSQfprxH.js";import{_ as d,f,m as p,p as m}from"./dist-Cb5RSHSg.js";import{i as h,r as g,t as _}from"./tabs-BaWRfg8j.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./card-aUHX0hyR.js";import{c as w,l as T,n as ee,o as te,r as ne,s as re,t as ie,u as ae}from"./data-list-CupF7bjM.js";import{i as oe,n as se,o as E,r as D,t as O}from"./use-simple-pagination-D5rL3YwO.js";import{Fa as ce,Gr as k,Pr as A,Ps as le,Qi as j,Ss as ue,Ur as M,Vs as de,Xn as N,Zi as P,aa as F,cr as fe,es as I,ir as pe,nr as L,sr as me,tr as he}from"./index-DUXM0NlS.js";import{t as ge}from"./member-route-0Aa52Ntz.js";import{a as R,i as z,n as B,r as V,t as H}from"./kpi-card-J8Mj1sDX.js";import{r as _e,t as ve}from"./post-analytics-header-DK27VjJm.js";import{n as ye}from"./post-analytics-context-D0Mw-Pmv.js";import{a as be,i as xe,n as U,o as W,r as G}from"./link-helpers-Bzkk68GD.js";var K=r({dataType:`FeedbackResponseType`,path:e=>`/feedback/${e}/`}),q=e(t(),1),J=(e,t)=>{let{data:n,isLoading:r,error:i}=K(e,{searchParams:{limit:`50`,...t===void 0?{}:{score:t.toString()}}});return{feedback:(0,q.useMemo)(()=>n?.feedback?n.feedback:[],[n]),isLoading:r,error:i}},Y=n(),Se=({feedbackStats:e})=>{let{postId:t}=l(),n=u(),[r,i]=(0,q.useState)(`positive`),{feedback:a,isLoading:o}=J(t||``,+(r===`positive`)),{totalPages:s,paginatedData:c,nextPage:f,previousPage:w,hasNextPage:T,hasPreviousPage:ee}=O({data:a,itemsPerPage:9}),te=o;return(0,Y.jsxs)(C,{children:[(0,Y.jsxs)(v,{className:`pb-5`,children:[(0,Y.jsx)(x,{children:`Feedback`}),(0,Y.jsx)(S,{children:`What did your readers think?`})]}),e.totalFeedback>0?(0,Y.jsxs)(b,{className:`pb-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Y.jsx)(_,{className:`pb-3`,defaultValue:`positive`,value:r,variant:`button`,onValueChange:e=>i(e),children:(0,Y.jsxs)(g,{className:`gap-1`,children:[(0,Y.jsx)(h,{className:`h-7`,value:`positive`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(P,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`More like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.positiveFeedback/e.totalFeedback)})]})}),(0,Y.jsx)(h,{className:`h-7`,value:`negative`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-xs`,children:[(0,Y.jsx)(j,{size:14,strokeWidth:1.25}),(0,Y.jsx)(`span`,{className:`hidden font-medium sm:visible! sm:inline!`,children:`Less like this`}),(0,Y.jsx)(`span`,{className:`font-semibold tracking-tight`,children:m(e.negativeFeedback/e.totalFeedback)})]})})]})}),(0,Y.jsx)(le,{className:`mr-2 mb-3 lg:hidden xl:visible! xl:block!`,children:`Date`})]}),(0,Y.jsx)(N,{}),te?(0,Y.jsx)(me,{className:`mt-3`,lines:3}):c&&c.length>0?(0,Y.jsx)(`div`,{className:`flex w-full flex-col py-3`,children:c.map(e=>(0,Y.jsxs)(`div`,{className:`flex h-10 w-full items-center justify-between gap-3 rounded-sm border-none px-2 text-sm hover:cursor-pointer hover:bg-accent`,onClick:()=>{n(`/members/${e.member.id}`,{crossApp:!0})},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,Y.jsxs)(he,{className:`size-7`,children:[e.member?.avatar_image&&(0,Y.jsx)(`img`,{className:`absolute aspect-square size-full`,src:e.member?.avatar_image}),(0,Y.jsx)(L,{className:`text-white`,style:{backgroundColor:`${d(M(e.member),`45`,`55`)}`},children:k(e.member)})]}),M(e.member)]}),(0,Y.jsx)(`div`,{className:`whitespace-nowrap text-muted-foreground`,children:p(e.created_at)})]},e.id))}):(0,Y.jsx)(`div`,{className:`flex h-full items-center justify-center py-8 text-center text-sm text-muted-foreground`,children:(0,Y.jsxs)(`div`,{children:[`No `,r===`positive`?`positive`:`negative`,` feedback yet`]})})]}):(0,Y.jsxs)(b,{className:`flex grow flex-col items-center justify-center text-center text-sm text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:`No members have given feedback yet`}),(0,Y.jsx)(`div`,{children:`When someone does, you'll see their response here.`})]}),e.totalFeedback>0&&(0,Y.jsx)(y,{className:`grow-0`,children:(0,Y.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,Y.jsxs)(A,{variant:`outline`,onClick:()=>{let e=`(feedback.post_id:'${t}'+feedback.score:1)`,i=`(feedback.post_id:'${t}'+feedback.score:0)`,a=`${encodeURIComponent(e)}&post=${t}`,o=`${encodeURIComponent(i)}&post=${t}`;n(`/members?filter=${r===`positive`?a:o}`,{crossApp:!0})},children:[`View all`,(0,Y.jsx)(F,{})]}),s>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!ee,onClick:w}),(0,Y.jsx)(oe,{disabled:!T,onClick:f})]})})]})})]})},Ce=e=>{let{data:t,isLoading:n}=s(e),{data:r,isLoading:i}=s(e,{searchParams:{include:`count.positive_feedback,count.negative_feedback`}}),c=(0,q.useMemo)(()=>t?.posts[0],[t]),l=(0,q.useMemo)(()=>r?.posts[0],[r]),u=(0,q.useMemo)(()=>c?{sent:c.email?.email_count||0,opened:c.email?.opened_count||0,clicked:c.count?.clicks||0,openedRate:c.email?.opened_count?c.email.opened_count/c.email.email_count:0,clickedRate:c.count?.clicks&&c.email?.email_count?c.count.clicks/c.email.email_count:0}:{sent:0,opened:0,clicked:0,openedRate:0,clickedRate:0},[c]),d=(0,q.useMemo)(()=>{if(!l?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=l.count.positive_feedback||0,t=l.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[l]),f=(0,q.useMemo)(()=>c?.newsletter?.id,[c]),{data:p,isLoading:m}=o({searchParams:f?{newsletter_id:f}:{},enabled:!!f}),h=(0,q.useMemo)(()=>p?.stats?p.stats.map(e=>e.post_id):[],[p]),{data:g,isLoading:_}=a({searchParams:f&&h.length>0?{newsletter_id:f,post_ids:h.join(`,`)}:{},enabled:!!f&&h.length>0}),v=(0,q.useMemo)(()=>{if(!p?.stats)return;let e=p.stats,t=g?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...p,stats:r}},[p,g]),y=m||_,{data:b,isLoading:x,refetch:S}=be({searchParams:{filter:`post_id:'${e}'`}}),C=(0,q.useMemo)(()=>{if(!v||!v.stats)return{openRate:0,clickRate:0};let e=v.stats;if(e.length===0)return{openRate:0,clickRate:0};let t=e.reduce((e,t)=>e+(t.open_rate||0),0),n=e.reduce((e,t)=>e+(t.click_rate||0),0);return{openRate:Number((t/e.length).toFixed(2)),clickRate:Number((n/e.length).toFixed(2))}},[v]),w=(0,q.useMemo)(()=>G(b),[b]);return{post:c,stats:u,feedbackStats:d,averageStats:(0,q.useMemo)(()=>({openedRate:C.openRate,clickedRate:C.clickRate}),[C]),topLinks:w,refetchTopLinks:S,isLoading:n||i||y||x}},we=({breakpoints:e={sm:1080,md:1280,lg:1360}}={})=>{let[t,n]=(0,q.useState)(`md`);return(0,q.useEffect)(()=>{let t=()=>{let t=window.innerWidth;t<e.sm?n(`sm`):t<e.md?n(`md`):n(`lg`)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),{chartSize:t,isSmall:t===`sm`,isMedium:t===`md`,isLarge:t===`lg`}},Te=()=>(0,Y.jsx)(`div`,{className:`absolute top-1/2 -right-4 z-10 hidden size-8 -translate-y-1/2 items-center justify-center rounded-full border bg-background text-muted-foreground md:visible! md:flex!`,children:(0,Y.jsx)(I,{className:`ml-0.5`,size:16,strokeWidth:1.5})}),Ee=({dataColor:e,value:t,avgValue:n})=>(0,Y.jsxs)(`div`,{className:`absolute top-6 left-1/2 z-50 flex w-[200px] -translate-x-1/2 flex-col items-stretch gap-1.5 rounded-md bg-background px-4 py-2 text-sm opacity-0 shadow-md transition-all group-hover/block:top-3 group-hover/block:opacity-100`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-blue opacity-50`,style:{backgroundColor:e}}),`This newsletter`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:t})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,Y.jsx)(`div`,{className:`size-2 rounded-full bg-chart-gray opacity-80`}),`Average`]}),(0,Y.jsx)(`div`,{className:`text-right font-mono`,children:n})]})]}),X=()=>{let e=u(),[t,n]=(0,q.useState)(null),[r,a]=(0,q.useState)(``),o=(0,q.useRef)(null),s=(0,q.useRef)(null),{chartSize:l}=we(),{appSettings:d}=de(),{emailTrackClicks:p,emailTrackOpens:h}=d?.analytics||{},{post:g,isPostLoading:_,postId:k}=ye(),j=t=>e(ge({filter:t}),{crossApp:!0}),M=g,P=c(M);(0,q.useEffect)(()=>{!_&&!P&&e(`/posts/analytics/${k}`)},[e,k,_,P]);let{stats:F,averageStats:I,topLinks:L,isLoading:he,refetchTopLinks:be}=Ce(k),{mutate:G}=xe(),K=(0,q.useMemo)(()=>{if(!M?.count)return{positiveFeedback:0,negativeFeedback:0,totalFeedback:0};let e=M.count.positive_feedback||0,t=M.count.negative_feedback||0;return{positiveFeedback:e,negativeFeedback:t,totalFeedback:e+t}},[M]),J=(0,q.useMemo)(()=>M?.newsletter?.feedback_enabled===!0,[M]),X=(0,q.useMemo)(()=>K.totalFeedback>0?!0:J,[K.totalFeedback,J]),De=e=>{let t=U(L,e);t&&(n(e),a(t.link.to))},Oe=()=>{if(!t)return;let e=U(L,t);if(!e)return;let o=r.trim();if(o===``||o===e.link.to){n(null),a(``);return}G({originalUrl:e.link.originalTo,editedUrl:r,postId:k},{onSuccess:()=>{n(null),a(``),be()},onError:()=>{i.error(`Couldn’t update the link. Please try again.`)}})},{totalPages:ke,paginatedData:Ae,nextPage:je,previousPage:Me,hasNextPage:Ne,hasPreviousPage:Pe}=O({data:L,itemsPerPage:10});(0,q.useEffect)(()=>{if(t&&o.current){o.current.focus();let e=U(L,t),i=t=>{s.current&&!s.current.contains(t.target)&&r===e?.link.to&&(n(null),a(``))};return document.addEventListener(`mousedown`,i),()=>{document.removeEventListener(`mousedown`,i)}}},[t,r,L]);let Z=he||_,Fe=[{datatype:`Sent`,value:1,fill:`url(#gradientPurple)`,color:`var(--chart-purple)`}],Ie={percentage:{label:`O`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Le=[{datatype:`Average`,value:I.openedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.openedRate,fill:`url(#gradientBlue)`,color:`var(--chart-blue)`}],Re={percentage:{label:`Opened`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},ze=[{datatype:`Average`,value:I.clickedRate,fill:`url(#gradientGray)`,color:`var(--chart-gray)`},{datatype:`This newsletter`,value:F.clickedRate,fill:`url(#gradientTeal)`,color:`var(--chart-teal)`}],Be={percentage:{label:`Clicked`},Average:{label:`Average`},"This newsletter":{label:`This newsletter`}},Q=`grid-cols-3`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-[10/14] md:max-w-none lg:aspect-square`;return(!p||!h)&&(Q=`grid-cols-2`,$=`aspect-[16/10] w-full max-w-[320px] sm:aspect-[2/1] md:aspect-square md:max-w-none lg:aspect-[15/10]`),!p&&!h&&(Q=`grid-cols-1`,$=`aspect-square w-full sm:aspect-[16/10] md:max-w-[320px] md:max-h-[320px] lg:aspect-[12/10]`),(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ve,{currentTab:`Newsletter`}),(0,Y.jsx)(_e,{children:(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 ${X&&p&&`lg:grid-cols-2`}`,children:[(0,Y.jsxs)(C,{className:X&&p?`lg:col-span-2`:``,children:[(0,Y.jsxs)(v,{className:`hidden`,children:[(0,Y.jsx)(x,{children:`Newsletters`}),(0,Y.jsx)(S,{children:`How did this post perform`})]}),Z?(0,Y.jsx)(b,{className:`h-[25vw] p-6`,children:(0,Y.jsx)(pe,{})}):(0,Y.jsxs)(b,{className:`p-0`,children:[(0,Y.jsxs)(`div`,{className:`grid ${Q} items-stretch border-b`,children:[(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-purple opacity-50`}),`Sent`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.sent)})})]}),h&&(0,Y.jsxs)(H,{className:`p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`opened_emails.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-blue opacity-50`}),`Opened`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.opened)})})]}),p&&(0,Y.jsxs)(H,{className:`group relative isolate grow p-3 md:px-6 md:py-5`,children:[(0,Y.jsx)(z,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:`View members →`}),(0,Y.jsxs)(V,{onClick:()=>{j(`clicked_links.post_id:${k}`)},children:[(0,Y.jsx)(`div`,{className:`ml-0.5 size-[9px] rounded-full bg-chart-teal opacity-50`}),`Clicked`]}),(0,Y.jsx)(B,{children:(0,Y.jsx)(R,{className:`text-xl leading-none sm:text-2xl md:text-[2.6rem]`,children:f(F.clicked)})})]})]}),(0,Y.jsxs)(`div`,{className:`$ mx-auto grid grid-cols-1 items-center justify-center gap-4 transition-all md:gap-0 ${Q===`grid-cols-2`&&`md:grid-cols-2`} ${Q===`grid-cols-3`&&`md:grid-cols-3`}`,children:[(0,Y.jsxs)(`div`,{className:`relative border-r-0 px-6 ${(h||p)&&`md:border-r`}`,children:[(0,Y.jsx)(W,{className:$,config:Ie,data:Fe,percentageLabel:`Sent`,percentageValue:m(1),size:l,tooltip:!1}),(h||p)&&(0,Y.jsx)(Te,{})]}),h&&(0,Y.jsxs)(`div`,{className:`group/block relative border-r-0 px-6 transition-all hover:bg-muted/25 ${p&&`md:border-r`}`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.openedRate),dataColor:`var(--chart-blue)`,value:m(F.openedRate)}),(0,Y.jsx)(W,{className:$,config:Re,data:Le,percentageLabel:`Open rate`,percentageValue:m(F.openedRate),size:l,tooltip:!1}),p&&(0,Y.jsx)(Te,{})]}),p&&(0,Y.jsxs)(`div`,{className:`group/block relative px-6 transition-all hover:bg-muted/25`,children:[(0,Y.jsx)(Ee,{avgValue:m(I.clickedRate),dataColor:`var(--chart-teal)`,value:m(F.clickedRate)}),(0,Y.jsx)(W,{className:$,config:Be,data:ze,percentageLabel:`Click rate`,percentageValue:m(F.clickedRate),size:l,tooltip:!1})]})]})]})]}),X&&(0,Y.jsx)(Se,{feedbackStats:K}),p&&(0,Y.jsxs)(C,{className:`group/datalist overflow-hidden`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between p-6`,children:[(0,Y.jsxs)(v,{className:`p-0`,children:[(0,Y.jsx)(x,{children:`Newsletter clicks`}),(0,Y.jsx)(S,{children:`Which links resonated with your readers`})]}),(0,Y.jsx)(le,{className:`mr-2`,children:`Members`})]}),Z?(0,Y.jsxs)(b,{className:`p-6 pt-0`,children:[(0,Y.jsx)(N,{}),(0,Y.jsx)(me,{className:`mt-6`})]}):(0,Y.jsxs)(b,{className:`pb-0`,children:[(0,Y.jsx)(N,{}),L.length>0?(0,Y.jsx)(ie,{className:``,children:(0,Y.jsx)(ne,{children:Ae?.map(e=>{let n=F.clicked>0?e.count/F.clicked:0,i=e.link.link_id,c=e.link.title,l=e.link.to,u=e.link.edited;return(0,Y.jsxs)(ae,{children:[t!==i&&(0,Y.jsx)(ee,{style:{width:`${n?Math.round(n*100):0}%`}}),(0,Y.jsx)(te,{className:`w-full`,children:t===i?(0,Y.jsxs)(`div`,{ref:s,className:`flex w-full items-center gap-2`,children:[(0,Y.jsx)(fe,{ref:o,className:`z-50 h-7 w-full border-border bg-background text-sm`,value:r,onChange:e=>a(e.target.value)}),(0,Y.jsx)(A,{size:`sm`,onClick:Oe,children:`Update`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(A,{className:`mr-2 shrink-0 bg-background`,size:`sm`,variant:`outline`,onClick:()=>De(i),children:(0,Y.jsx)(ce,{})}),(0,Y.jsx)(`a`,{className:`block truncate font-medium hover:underline`,href:l,rel:`noreferrer`,target:`_blank`,title:c,children:c}),u&&(0,Y.jsx)(`span`,{className:`ml-1 text-gray-500`,children:`(edited)`})]})}),(0,Y.jsxs)(re,{children:[(0,Y.jsx)(w,{children:f(e.count||0)}),(0,Y.jsx)(T,{children:m(n)})]})]},i)})})}):(0,Y.jsx)(`div`,{className:`py-20 text-center text-sm text-gray-700`,children:`You have no links in your post.`})]}),!Z&&L.length>1&&(0,Y.jsx)(y,{children:(0,Y.jsxs)(`div`,{className:`flex w-full items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`mt-2 flex items-start gap-2 pl-4 text-sm text-green`,children:[(0,Y.jsx)(ue,{size:20,strokeWidth:1.5}),`Sent a broken link? You can update it!`]}),ke>1&&(0,Y.jsx)(se,{className:`pb-0`,children:(0,Y.jsxs)(D,{children:[(0,Y.jsx)(E,{disabled:!Pe,onClick:Me}),(0,Y.jsx)(oe,{disabled:!Ne,onClick:je})]})})]})})]})]})})]})};export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{t as a}from"./use-form-vRjI0Kwk.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{x as s}from"./dist-Cb5RSHSg.js";import{t as c}from"./inline-Cw-gigDW.js";import{t as l}from"./stack-CIfOAAVf.js";import{i as u,n as d,r as f,t as p}from"./tabs-Dd6oOKbv.js";import{t as m}from"./switch-CE2NuMn-.js";import{i as h,n as g,o as _,s as v,t as y}from"./select-D9oU1IoM.js";import{s as b,t as x}from"./use-settings-navigation-Bf1g1rEh.js";import{a as S,c as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./field-Dh_lwk13.js";import{t as A}from"./textarea-d9qEkMOP.js";import{n as ee,t as j}from"./toggle-group-Guorw93z.js";import{r as te}from"./components-CwL6a6As-B0E0-NBJ.js";import{Dn as M,Ir as N,Lr as P,Ls as F,On as I,Pr as L,Qi as R,Rs as ne,Ui as z,Wi as B,Xn as V,Zi as re,bo as ie,ca as ae,cr as H,hs as oe,ma as se,na as ce,qa as le,qo as ue,sa as U,ta as de,zr as fe,zs as pe}from"./index-BHy2DZX-.js";import{i as me,r as he}from"./newsletters-Du0lzskS.js";import{t as ge}from"./validator-Cr0sMKuW.js";import{n as _e}from"./confirmation-modal-B6D6mk6R.js";import{t as ve}from"./limit-modal-BRPsit_B.js";import{n as ye,t as be}from"./use-limiter-BkN3E4gw.js";import{n as W}from"./global-data-provider-B949LDXJ.js";import{t as xe}from"./use-setting-group-YlYcoNyP.js";import{t as Se}from"./use-feature-flag-ud0Qz8vt.js";import{t as G}from"./color-picker-field-BonBgxhU.js";import{i as Ce,r as we,t as K}from"./newsletter-emails-Bf8IZLsP.js";import{t as Te}from"./html-field-9a9Id_2q.js";import{t as q}from"./color-utils-BsrwXuDz.js";import{t as Ee}from"./preview-modal-Dw_HtD6S.js";``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href,``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href,``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href,``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href;var J=n(),De=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:c,showExcerpt:l,titleAlignment:u,titleFontCategory:d,titleFontWeight:f,bodyFontCategory:p,authorPlaceholder:m,showCommentCta:h,showFeatureImage:g,showFeedback:_,showShareButton:v,showLatestPosts:y,showSubscriptionDetails:b,siteTitle:x,footerContent:S,showBadge:C,backgroundColor:w,headerBackgroundColor:T,accentColor:E,textColor:D,secondaryTextColor:O,headerTextColor:k,secondaryHeaderTextColor:A,postTitleColor:ee,sectionTitleColor:j,dividerColor:M,buttonColor:N,buttonTextColor:P,linkColor:F,buttonCorners:I,buttonStyle:L,imageCorners:z,linkStyle:B,dividerStyle:V})=>{let ie=i||a,{config:ae}=W(),H=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),oe=new Date().getFullYear(),ce=S?S.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,ue;ue=ne(ae)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`From: `}),(0,J.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`Reply-to: `}),n||t]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:e}),(0,J.jsxs)(`span`,{children:[` `,t]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let U=`mb-5 text-pretty leading-[1.7] text-black`;return U=d===`serif`&&p===`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):d!==`serif`&&p===`serif`?s(U,`mb-8 text-[1.7rem] leading-tight tracking-tight`):d===`serif`&&p!==`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):s(U,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(U=s(U,`text-center`)),(0,J.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,J.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`mx-auto my-0 flex max-h-full w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm`,children:[(0,J.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-grey-200 bg-white px-6 text-grey-700`,children:ue}),(0,J.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:w},children:[(0,J.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:T},children:[r&&(0,J.jsx)(`div`,{children:(0,J.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),ie&&(0,J.jsxs)(`div`,{className:`py-3`,children:[i&&(0,J.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,J.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-grey-900 uppercase`,style:{color:k},children:a}),o&&(0,J.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-grey-700`,style:{color:A},children:o})]}),c&&(0,J.jsxs)(`div`,{className:s(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,J.jsx)(`h2`,{className:s(`text-4xl leading-supertight font-bold text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:ee},children:`Your email newsletter`}),l&&(0,J.jsx)(`p`,{className:U,style:{color:k},children:`A subtitle to highlight key points and engage your readers.`}),(0,J.jsxs)(`div`,{className:s(`flex w-full justify-between text-center text-md leading-none text-grey-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,J.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:A},children:[`By `,m,(0,J.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:H})]}),(0,J.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:A},children:(0,J.jsx)(`span`,{children:`View in browser`})})]})]}),g&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:s(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,c?``:`pt-6`),children:(0,J.jsx)(`img`,{alt:`Feature`,className:s(`min-h-full min-w-full shrink-0`,z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,J.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700`,style:{color:A},children:`Feature image caption`})]})]}),(0,J.jsxs)(`div`,{className:s(`px-[7rem]`,T!==`transparent`&&`pt-10`),children:[(0,J.jsxs)(`div`,{className:s(`max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`,p===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,g||c?``:`pt-8`),style:{borderColor:M},children:[(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`This is what your content will look like when you send one of your posts as an email newsletter to your subscribers.`}),(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`Over there on the right you'll see some settings that allow you to customize the look and feel of this template – from colors and typography to layout and buttons – to make it perfectly suited to your brand.`}),(0,J.jsx)(`p`,{className:`mb-[52px]`,style:{color:D},children:`Email templates are exceptionally finnicky to make, but we've spent a long time optimising this one to make it work beautifully across devices, email clients and content types. So, you can trust that every email you send with Ghost will look great and work well. Just like the rest of your site.`}),(0,J.jsx)(`hr`,{className:s(`my-[52px] border-[#e0e7eb]`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:M}}),(0,J.jsx)(`h3`,{className:s(`mb-[13px] text-[2.6rem] leading-supertight`,d===`serif`&&`font-serif`,d===`sans_serif`&&`font-sans`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Need inspiration?`}),(0,J.jsxs)(`p`,{className:`mb-[27px]`,style:{color:D},children:[`We've put together a `,(0,J.jsx)(`a`,{className:s(B===`underline`&&`underline`,B===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:F||E},target:`_blank`,children:`quick guide`}),` that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,J.jsx)(`a`,{className:s(`inline-block border px-[18px] py-2 font-sans text-[15px]`,I===`rounded`&&`rounded-[6px]`,I===`pill`&&`rounded-full`,I===`square`&&`rounded-none`,L===`outline`?`bg-transparent`:`border-transparent text-white`,B===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:L===`outline`?{borderColor:N||E,color:N||E}:{backgroundColor:N||E,color:P},target:`_blank`,children:`Learn more`})]}),(_||h||v)&&(0,J.jsx)(`div`,{className:s(`grid gap-5 border-b border-grey-200 px-6 py-5`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:(0,J.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(re,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`More like this`})]}),(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(R,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Less like this`})]})]}),h&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(le,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Comment`})]}),v&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(se,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Share`})]})]})}),y&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-6`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h3`,{className:`mt-2 mb-4 pb-1 text-[1.2rem] font-semibold tracking-wide text-black uppercase`,style:{color:D},children:`Keep reading`}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`The three latest posts published on your site`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Posts sent as an email only will never be shown here.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Displayed at the bottom of each newsletter`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Giving your readers one more place to discover your stories.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`To keep your work front and center`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Making sure that your audience stays engaged.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),b&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-8`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:D},children:`Subscription details`}),(0,J.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:D},children:[`You are receiving this because you are a paid subscriber to `,x,`. Your subscription will renew on 17 Jul 2024.`]}),(0,J.jsxs)(`div`,{className:`flex`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,J.jsx)(`p`,{style:{color:D},children:`Name: Jamie Larson`}),(0,J.jsx)(`p`,{style:{color:D},children:`Email: jamie@example.com`}),(0,J.jsx)(`p`,{style:{color:D},children:`Member since: 17 July 2023`})]}),(0,J.jsx)(`span`,{className:s(`w-full self-end text-right text-base whitespace-nowrap`,B===`underline`&&`underline`,B===`bold`&&`font-bold`),style:{color:F||E},children:`Manage subscription`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,J.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ce||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-grey-700 [&_a]:underline`,style:{color:O}}),(0,J.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-grey-700`,children:[(0,J.jsxs)(`span`,{style:{color:O},children:[x,` © `,oe,` — `]}),(0,J.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:O},children:`Unsubscribe`})]}),C&&(0,J.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,J.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-grey-900`,href:`https://ghost.org`,style:{color:D},children:[(0,J.jsx)(te,{className:`mr-[6px] size-4`}),(0,J.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},Y=e(t(),1),Oe=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=W(),[a,o,s,c,l]=I(n,[`title`,`icon`,`comments_enabled`,`support_email_address`,`default_email_address`]),u=null;e.show_header_title?u=a||null:e.show_header_name&&(u=e.name);let d=e.show_header_title&&e.show_header_name?e.name:void 0,f=e.show_comment_cta&&s!==`off`,p=e.feedback_enabled,m=e.show_share_button,h=()=>{let t=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`#ffffff`},g=()=>{let t=e.header_background_color;return!t||t===`transparent`?`transparent`:/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`transparent`},_=()=>{let t=e.button_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===null?q(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return q(n).hex()},y=()=>{let t=e.link_color===void 0?`accent`:e.link_color;return t===`accent`?r.accent_color:/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:q(h()).hex()},b=()=>{let t=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(t||``))return t;if(t===`accent`)return r.accent_color;let n=g();return q(n===`transparent`?h():n).hex()},x=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:q(h()).hex()},S=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},C=q(h()).hex(),w=q(h()).alpha(.5).toString(),T=g()===`transparent`?C:q(g()).hex(),E=g()===`transparent`?w:q(g()).alpha(.5).toString(),D={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:x()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:S()||void 0,textColor:C,secondaryTextColor:w,headerTextColor:T,secondaryHeaderTextColor:E};return(0,J.jsx)(De,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:D.backgroundColor||`#ffffff`,bodyFontCategory:e.body_font_category,buttonCorners:e.button_corners||`rounded`,buttonStyle:e.button_style||`fill`,dividerStyle:e.divider_style||`solid`,footerContent:e.footer_content,headerBackgroundColor:D.headerBackgroundColor||`transparent`,headerIcon:e.show_header_icon?o:void 0,headerImage:e.header_image,headerSubtitle:d,headerTitle:u,imageCorners:e.image_corners||`square`,linkStyle:e.link_style||`underline`,senderEmail:we(e,i,l),senderName:e.sender_name||a,senderReplyTo:K(e,i,c,l),showBadge:e.show_badge,showCommentCta:f,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:p,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showShareButton:m,showSubscriptionDetails:e.show_subscription_details,siteTitle:a,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||`bold`,...D})},X=e(ge(),1),Z=({label:e,value:t,options:n,onValueChange:r})=>(0,J.jsx)(j,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,J.jsxs)(N,{children:[(0,J.jsx)(fe,{asChild:!0,children:(0,J.jsx)(ee,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,J.jsx)(P,{children:e.label})]},e.value))}),ke=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=W(),[o,s]=I(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,Y.useState)(K(e,a,s,o)||``),u=we(e,a,o),d=(0,Y.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,J.jsxs)(k,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,J.jsx)(H,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=K(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,J.jsx)(w,{children:n.sender_reply_to})]})},Ae=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:a,errors:o,clearError:s})=>{let{updateRoute:ee}=x(),{mutateAsync:j}=me(),te=ye(),{settings:N,config:P,siteData:R}=W(),[re,se]=I(N,[`icon`,`default_email_address`]),[le,fe]=(0,Y.useState)(`generalSettings`),{localSettings:pe}=xe(),[ge]=I(pe,[`title`]),Se=r(),{data:{newsletters:K}={}}=he(),Ee=[`all`,`paid`].includes(M(N,`comments_enabled`)||``),De=we(e,P,se),[Oe,X]=(0,Y.useState)(K||[]),Ae=Oe.filter(e=>e.status===`active`);(0,Y.useEffect)(()=>{X(K||[])},[K]);let je=[{value:`serif`,label:`Elegant serif`,className:`font-serif`},{value:`sans_serif`,label:`Clean sans-serif`}],Q={sans_serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`medium`,label:`Medium`,className:`font-medium`},{value:`semibold`,label:`Semi-bold`,className:`font-semibold`},{value:`bold`,label:`Bold`,className:`font-bold`}]},serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`bold`,label:`Bold`,className:`font-bold`}],map:{medium:`normal`,semibold:`bold`}}},$=()=>e.background_color===`light`?!1:q(e.background_color).hex().toLowerCase()===`#ffffff`,Me=async()=>{if(e.status===`active`)b.show(_e,{title:`Archive newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,J.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,J.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await j({...e,status:`archived`}),t?.remove(),i.success(`Newsletter archived`)}catch(e){Se(e)}}});else{try{await te?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof be){b.show(ve,{prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>ee({route:`/pro`,isExternal:!0})});return}else throw e}b.show(_e,{title:`Reactivate newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[`Reactivating `,(0,J.jsx)(`strong`,{children:e.name}),` will immediately make it visible to members and re-enable it as an option when publishing new posts.`]}),okLabel:`Reactivate`,onOk:async t=>{await j({...e,status:`active`}),t?.remove(),i.success(`Newsletter reactivated`)}})}},Ne=()=>{if(!ne(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,placeholder:De||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]});if(F(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:se,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]})},Pe=Q[e.title_font_category||`sans_serif`].options,Fe=[{id:`generalSettings`,title:`General`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{"data-invalid":!!o.name||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,J.jsx)(H,{"aria-invalid":!!o.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>s(`name`)}),o.name&&(0,J.jsx)(w,{children:o.name})]}),(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-description`,children:`Description`}),(0,J.jsx)(A,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Email info`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,J.jsx)(H,{id:`newsletter-sender-name`,maxLength:191,placeholder:ge,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Ne(),(0,J.jsx)(ke,{clearError:s,errors:o,newsletter:e,updateNewsletter:n,validate:a})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,J.jsx)(S,{children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,J.jsx)(m,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,J.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,J.jsx)(L,{className:`text-destructive hover:text-destructive`,disabled:Ae.length===1,type:`button`,variant:`ghost`,onClick:Me,children:`Archive newsletter`}):(0,J.jsx)(L,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:Me,children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(Ce,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:Se}),(0,J.jsxs)(l,{gap:`md`,children:[re&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,J.jsx)(m,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,J.jsx)(m,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,J.jsx)(m,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Title section`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,J.jsx)(m,{checked:!!e.show_post_title_section,id:`newsletter-show-post-title`,onCheckedChange:e=>n({show_post_title_section:e})})]}),e.show_post_title_section&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,J.jsx)(m,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,J.jsx)(m,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Footer`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(l,{gap:`lg`,children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,J.jsx)(m,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),Ee&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,J.jsx)(m,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,J.jsx)(m,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,J.jsx)(m,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,J.jsx)(m,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,J.jsx)(Te,{hint:`Any extra information or legal text`,nodes:`MINIMAL_NODES`,placeholder:` `,title:`Email footer`,value:e.footer_content||``,onChange:e=>n({footer_content:e})})]})]}),(0,J.jsx)(V,{className:`mt-8`}),(0,J.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(ie,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,J.jsx)(S,{className:`gap-8`,children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,J.jsx)(D,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,J.jsx)(m,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Global`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{hex:`#ffffff`,value:`light`,title:`White`}],title:`Background color`,value:e.background_color||`light`,onChange:e=>n({background_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading font`}),(0,J.jsxs)(y,{value:e.title_font_category,onValueChange:t=>{let r=e.title_font_weight,i=r;return Q[t].options.find(e=>e.value===r)||(i=Q[t].map?.[r]||`bold`),n({title_font_category:t,title_font_weight:i})},children:[(0,J.jsx)(_,{"aria-label":`Heading font`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading weight`}),(0,J.jsxs)(y,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Q[t].map,i=r&&r[n]||n;return Pe.find(e=>e.value===i)||Pe[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,J.jsx)(_,{"aria-label":`Heading weight`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:Pe.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Body font`}),(0,J.jsxs)(y,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,J.jsx)(_,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`transparent`,title:`Transparent`,hex:`#00000000`}],title:`Header background color`,value:e.header_background_color||`transparent`,onChange:e=>n({header_background_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Title alignment`}),(0,J.jsx)(Z,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,J.jsx)(de,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,J.jsx)(ce,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Body`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button style`}),(0,J.jsx)(Z,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,J.jsx)(U,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button corners`}),(0,J.jsx)(Z,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,J.jsx)(ue,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Link style`}),(0,J.jsx)(Z,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,J.jsx)(z,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,J.jsx)(B,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,J.jsx)(oe,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Image corners`}),(0,J.jsx)(Z,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,J.jsx)(`div`,{className:`flex flex-col`,children:(0,J.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,J.jsxs)(p,{value:le,variant:`underline`,onValueChange:e=>{fe(e)},children:[(0,J.jsx)(f,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Fe.map(e=>(0,J.jsx)(u,{value:e.id,children:e.title},e.id))}),Fe.map(e=>(0,J.jsx)(d,{value:e.id,children:e.contents},e.id))]})})})},je=({newsletter:e,onlyOne:t})=>{let{config:n}=W(),{mutateAsync:o}=me(),{updateRoute:s}=x(),c=Se(`automations`)?`emails`:`newsletters`,{formState:l,saveState:u,updateForm:d,setFormState:f,handleSave:p,validate:m,errors:h,clearError:g,okProps:_}=a({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await o(l),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,J.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&i.info(t)},onSaveError:r(),onValidate:()=>{let e={};return l.name||(e.name=`A name is required for your newsletter`),l.sender_email&&!X.default.isEmail(l.sender_email)?e.sender_email=`Enter a valid email address`:l.sender_email&&F(n)&&l.sender_email.split(`@`)[1]!==pe(n)&&(e.sender_email=`Email address must end with @${pe(n)}`),l.sender_reply_to&&!X.default.isEmail(l.sender_reply_to)&&![`newsletter`,`support`].includes(l.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),v=e=>{d(t=>({...t,...e}))};(0,Y.useEffect)(()=>{f(()=>e)},[f,e]);let y=(0,J.jsx)(Oe,{newsletter:l}),b=(0,J.jsx)(Ae,{clearError:g,errors:h,newsletter:l,onlyOne:t,updateNewsletter:v,validate:m});return(0,J.jsx)(Ee,{buttonsDisabled:_.disabled,cancelLabel:`Close`,dirty:u===`unsaved`,okLabel:_.label||`Save`,okVariant:_.variant,preview:y,previewBgColor:`grey`,previewToolbar:!1,sidebar:b,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>s(c),onOk:async()=>{await p({fakeWhenUnchanged:!0})}})},Q=()=>{let{newsletterId:e}=o(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=he(),i=t?.find(({id:t})=>t===e);return(0,Y.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,J.jsx)(je,{newsletter:i,onlyOne:t.length===1}):null};export{Q as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./hooks-D6EE7BIt.js";import{n as i}from"./dist-Ndy-PuGN.js";import{t as a}from"./use-form-vRjI0Kwk.js";import{m as o}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{x as s}from"./dist-Cb5RSHSg.js";import{t as c}from"./inline-Cw-gigDW.js";import{t as l}from"./stack-CIfOAAVf.js";import{i as u,n as d,r as f,t as p}from"./tabs-BaWRfg8j.js";import{t as m}from"./switch-CE2NuMn-.js";import{i as h,n as g,o as _,s as v,t as y}from"./select-CkXqNJDJ.js";import{s as b,t as x}from"./use-settings-navigation-BmROPrls.js";import{a as S,c as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./field-B3OPenbP.js";import{t as A}from"./textarea-d9qEkMOP.js";import{n as ee,t as j}from"./toggle-group-CVl-Xigr.js";import{r as te}from"./components-CwL6a6As-B0E0-NBJ.js";import{Dn as M,Ir as N,Lr as P,Ls as F,On as I,Pr as L,Qi as R,Rs as ne,Ui as z,Wi as B,Xn as V,Zi as re,bo as ie,ca as ae,cr as H,hs as oe,ma as se,na as ce,qa as le,qo as ue,sa as U,ta as de,zr as fe,zs as pe}from"./index-DUXM0NlS.js";import{i as me,r as he}from"./newsletters-Du0lzskS.js";import{t as ge}from"./validator-Cr0sMKuW.js";import{n as _e}from"./confirmation-modal-CYD7x3UQ.js";import{t as ve}from"./limit-modal-COmLevuY.js";import{n as ye,t as be}from"./use-limiter-Dwg8ivgQ.js";import{n as W}from"./global-data-provider-RzW6Bnlf.js";import{t as xe}from"./use-setting-group-Cmp_sy-d.js";import{t as Se}from"./use-feature-flag-BmJoc5WN.js";import{t as G}from"./color-picker-field-8NoSnhNI.js";import{i as Ce,r as we,t as K}from"./newsletter-emails-B-OLfrvr.js";import{t as Te}from"./html-field-CVZ2sMxw.js";import{t as q}from"./color-utils-Dzeeuj1F.js";import{t as Ee}from"./preview-modal-DctYx20m.js";``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href,``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href,``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href,``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href;var J=n(),De=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:c,showExcerpt:l,titleAlignment:u,titleFontCategory:d,titleFontWeight:f,bodyFontCategory:p,authorPlaceholder:m,showCommentCta:h,showFeatureImage:g,showFeedback:_,showShareButton:v,showLatestPosts:y,showSubscriptionDetails:b,siteTitle:x,footerContent:S,showBadge:C,backgroundColor:w,headerBackgroundColor:T,accentColor:E,textColor:D,secondaryTextColor:O,headerTextColor:k,secondaryHeaderTextColor:A,postTitleColor:ee,sectionTitleColor:j,dividerColor:M,buttonColor:N,buttonTextColor:P,linkColor:F,buttonCorners:I,buttonStyle:L,imageCorners:z,linkStyle:B,dividerStyle:V})=>{let ie=i||a,{config:ae}=W(),H=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),oe=new Date().getFullYear(),ce=S?S.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,ue;ue=ne(ae)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`From: `}),(0,J.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`Reply-to: `}),n||t]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:e}),(0,J.jsxs)(`span`,{children:[` `,t]})]}),(0,J.jsxs)(`p`,{className:`leading-normal`,children:[(0,J.jsx)(`span`,{className:`font-semibold text-grey-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let U=`mb-5 text-pretty leading-[1.7] text-black`;return U=d===`serif`&&p===`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):d!==`serif`&&p===`serif`?s(U,`mb-8 text-[1.7rem] leading-tight tracking-tight`):d===`serif`&&p!==`serif`?s(U,`mb-8 font-serif text-[2.0rem] leading-tight`):s(U,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(U=s(U,`text-center`)),(0,J.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,J.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`mx-auto my-0 flex max-h-full w-full max-w-[700px] flex-col overflow-hidden rounded-[4px] text-black shadow-sm`,children:[(0,J.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-grey-200 bg-white px-6 text-grey-700`,children:ue}),(0,J.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:w},children:[(0,J.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:T},children:[r&&(0,J.jsx)(`div`,{children:(0,J.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),ie&&(0,J.jsxs)(`div`,{className:`py-3`,children:[i&&(0,J.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,J.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-grey-900 uppercase`,style:{color:k},children:a}),o&&(0,J.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-grey-700`,style:{color:A},children:o})]}),c&&(0,J.jsxs)(`div`,{className:s(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,J.jsx)(`h2`,{className:s(`text-4xl leading-supertight font-bold text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:ee},children:`Your email newsletter`}),l&&(0,J.jsx)(`p`,{className:U,style:{color:k},children:`A subtitle to highlight key points and engage your readers.`}),(0,J.jsxs)(`div`,{className:s(`flex w-full justify-between text-center text-md leading-none text-grey-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,J.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:A},children:[`By `,m,(0,J.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:H})]}),(0,J.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:A},children:(0,J.jsx)(`span`,{children:`View in browser`})})]})]}),g&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:s(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,c?``:`pt-6`),children:(0,J.jsx)(`img`,{alt:`Feature`,className:s(`min-h-full min-w-full shrink-0`,z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,J.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-grey-700`,style:{color:A},children:`Feature image caption`})]})]}),(0,J.jsxs)(`div`,{className:s(`px-[7rem]`,T!==`transparent`&&`pt-10`),children:[(0,J.jsxs)(`div`,{className:s(`max-w-[600px] border-b border-grey-200 pb-[52px] leading-[27.2px] text-black`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`,p===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,g||c?``:`pt-8`),style:{borderColor:M},children:[(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`This is what your content will look like when you send one of your posts as an email newsletter to your subscribers.`}),(0,J.jsx)(`p`,{className:`mb-6`,style:{color:D},children:`Over there on the right you'll see some settings that allow you to customize the look and feel of this template – from colors and typography to layout and buttons – to make it perfectly suited to your brand.`}),(0,J.jsx)(`p`,{className:`mb-[52px]`,style:{color:D},children:`Email templates are exceptionally finnicky to make, but we've spent a long time optimising this one to make it work beautifully across devices, email clients and content types. So, you can trust that every email you send with Ghost will look great and work well. Just like the rest of your site.`}),(0,J.jsx)(`hr`,{className:s(`my-[52px] border-[#e0e7eb]`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:M}}),(0,J.jsx)(`h3`,{className:s(`mb-[13px] text-[2.6rem] leading-supertight`,d===`serif`&&`font-serif`,d===`sans_serif`&&`font-sans`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Need inspiration?`}),(0,J.jsxs)(`p`,{className:`mb-[27px]`,style:{color:D},children:[`We've put together a `,(0,J.jsx)(`a`,{className:s(B===`underline`&&`underline`,B===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:F||E},target:`_blank`,children:`quick guide`}),` that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,J.jsx)(`a`,{className:s(`inline-block border px-[18px] py-2 font-sans text-[15px]`,I===`rounded`&&`rounded-[6px]`,I===`pill`&&`rounded-full`,I===`square`&&`rounded-none`,L===`outline`?`bg-transparent`:`border-transparent text-white`,B===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:L===`outline`?{borderColor:N||E,color:N||E}:{backgroundColor:N||E,color:P},target:`_blank`,children:`Learn more`})]}),(_||h||v)&&(0,J.jsx)(`div`,{className:s(`grid gap-5 border-b border-grey-200 px-6 py-5`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:(0,J.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(re,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`More like this`})]}),(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(R,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Less like this`})]})]}),h&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(le,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Comment`})]}),v&&(0,J.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,J.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:M,color:D},children:(0,J.jsx)(se,{className:`size-5`})}),(0,J.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Share`})]})]})}),y&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-6`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h3`,{className:`mt-2 mb-4 pb-1 text-[1.2rem] font-semibold tracking-wide text-black uppercase`,style:{color:D},children:`Keep reading`}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`The three latest posts published on your site`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Posts sent as an email only will never be shown here.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`Displayed at the bottom of each newsletter`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Giving your readers one more place to discover your stories.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,J.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:s(`mt-0.5 text-[1.9rem] text-black`,d===`serif`&&`font-serif`,f===`normal`&&`font-normal`,f===`medium`&&`font-medium`,f===`semibold`&&`font-semibold`,f===`bold`&&`font-bold`),style:{color:j},children:`To keep your work front and center`}),(0,J.jsx)(`p`,{className:`m-0 text-base text-grey-700`,style:{color:O},children:`Making sure that your audience stays engaged.`})]}),(0,J.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,J.jsx)(`img`,{alt:`Latest post`,className:s(z===`square`&&`rounded-none`,z===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),b&&(0,J.jsxs)(`div`,{className:s(`border-b border-grey-200 py-8`,V===`dashed`&&`border-dashed`,V===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:M},children:[(0,J.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:D},children:`Subscription details`}),(0,J.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:D},children:[`You are receiving this because you are a paid subscriber to `,x,`. Your subscription will renew on 17 Jul 2024.`]}),(0,J.jsxs)(`div`,{className:`flex`,children:[(0,J.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,J.jsx)(`p`,{style:{color:D},children:`Name: Jamie Larson`}),(0,J.jsx)(`p`,{style:{color:D},children:`Email: jamie@example.com`}),(0,J.jsx)(`p`,{style:{color:D},children:`Member since: 17 July 2023`})]}),(0,J.jsx)(`span`,{className:s(`w-full self-end text-right text-base whitespace-nowrap`,B===`underline`&&`underline`,B===`bold`&&`font-bold`),style:{color:F||E},children:`Manage subscription`})]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,J.jsx)(`div`,{dangerouslySetInnerHTML:{__html:ce||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-grey-700 [&_a]:underline`,style:{color:O}}),(0,J.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-grey-700`,children:[(0,J.jsxs)(`span`,{style:{color:O},children:[x,` © `,oe,` — `]}),(0,J.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:O},children:`Unsubscribe`})]}),C&&(0,J.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,J.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-grey-900`,href:`https://ghost.org`,style:{color:D},children:[(0,J.jsx)(te,{className:`mr-[6px] size-4`}),(0,J.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},Y=e(t(),1),Oe=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=W(),[a,o,s,c,l]=I(n,[`title`,`icon`,`comments_enabled`,`support_email_address`,`default_email_address`]),u=null;e.show_header_title?u=a||null:e.show_header_name&&(u=e.name);let d=e.show_header_title&&e.show_header_name?e.name:void 0,f=e.show_comment_cta&&s!==`off`,p=e.feedback_enabled,m=e.show_share_button,h=()=>{let t=e.background_color;return/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`#ffffff`},g=()=>{let t=e.header_background_color;return!t||t===`transparent`?`transparent`:/#([0-9a-f]{3}){1,2}$/i.test(t)?t:`transparent`},_=()=>{let t=e.button_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===null?q(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return q(n).hex()},y=()=>{let t=e.link_color===void 0?`accent`:e.link_color;return t===`accent`?r.accent_color:/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:q(h()).hex()},b=()=>{let t=e.post_title_color;if(/#([0-9a-f]{3}){1,2}$/i.test(t||``))return t;if(t===`accent`)return r.accent_color;let n=g();return q(n===`transparent`?h():n).hex()},x=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:q(h()).hex()},S=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},C=q(h()).hex(),w=q(h()).alpha(.5).toString(),T=g()===`transparent`?C:q(g()).hex(),E=g()===`transparent`?w:q(g()).alpha(.5).toString(),D={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:x()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:S()||void 0,textColor:C,secondaryTextColor:w,headerTextColor:T,secondaryHeaderTextColor:E};return(0,J.jsx)(De,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:D.backgroundColor||`#ffffff`,bodyFontCategory:e.body_font_category,buttonCorners:e.button_corners||`rounded`,buttonStyle:e.button_style||`fill`,dividerStyle:e.divider_style||`solid`,footerContent:e.footer_content,headerBackgroundColor:D.headerBackgroundColor||`transparent`,headerIcon:e.show_header_icon?o:void 0,headerImage:e.header_image,headerSubtitle:d,headerTitle:u,imageCorners:e.image_corners||`square`,linkStyle:e.link_style||`underline`,senderEmail:we(e,i,l),senderName:e.sender_name||a,senderReplyTo:K(e,i,c,l),showBadge:e.show_badge,showCommentCta:f,showExcerpt:e.show_excerpt,showFeatureImage:e.show_feature_image,showFeedback:p,showLatestPosts:e.show_latest_posts,showPostTitleSection:e.show_post_title_section,showShareButton:m,showSubscriptionDetails:e.show_subscription_details,siteTitle:a,titleAlignment:e.title_alignment,titleFontCategory:e.title_font_category,titleFontWeight:e.title_font_weight||`bold`,...D})},X=e(ge(),1),Z=({label:e,value:t,options:n,onValueChange:r})=>(0,J.jsx)(j,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,J.jsxs)(N,{children:[(0,J.jsx)(fe,{asChild:!0,children:(0,J.jsx)(ee,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,J.jsx)(P,{children:e.label})]},e.value))}),ke=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=W(),[o,s]=I(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,Y.useState)(K(e,a,s,o)||``),u=we(e,a,o),d=(0,Y.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,J.jsxs)(k,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,J.jsx)(H,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=K(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,J.jsx)(w,{children:n.sender_reply_to})]})},Ae=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:a,errors:o,clearError:s})=>{let{updateRoute:ee}=x(),{mutateAsync:j}=me(),te=ye(),{settings:N,config:P,siteData:R}=W(),[re,se]=I(N,[`icon`,`default_email_address`]),[le,fe]=(0,Y.useState)(`generalSettings`),{localSettings:pe}=xe(),[ge]=I(pe,[`title`]),Se=r(),{data:{newsletters:K}={}}=he(),Ee=[`all`,`paid`].includes(M(N,`comments_enabled`)||``),De=we(e,P,se),[Oe,X]=(0,Y.useState)(K||[]),Ae=Oe.filter(e=>e.status===`active`);(0,Y.useEffect)(()=>{X(K||[])},[K]);let je=[{value:`serif`,label:`Elegant serif`,className:`font-serif`},{value:`sans_serif`,label:`Clean sans-serif`}],Q={sans_serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`medium`,label:`Medium`,className:`font-medium`},{value:`semibold`,label:`Semi-bold`,className:`font-semibold`},{value:`bold`,label:`Bold`,className:`font-bold`}]},serif:{options:[{value:`normal`,label:`Regular`,className:`font-normal`},{value:`bold`,label:`Bold`,className:`font-bold`}],map:{medium:`normal`,semibold:`bold`}}},$=()=>e.background_color===`light`?!1:q(e.background_color).hex().toLowerCase()===`#ffffff`,Me=async()=>{if(e.status===`active`)b.show(_e,{title:`Archive newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,J.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,J.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await j({...e,status:`archived`}),t?.remove(),i.success(`Newsletter archived`)}catch(e){Se(e)}}});else{try{await te?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof be){b.show(ve,{prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>ee({route:`/pro`,isExternal:!0})});return}else throw e}b.show(_e,{title:`Reactivate newsletter`,prompt:(0,J.jsxs)(J.Fragment,{children:[`Reactivating `,(0,J.jsx)(`strong`,{children:e.name}),` will immediately make it visible to members and re-enable it as an option when publishing new posts.`]}),okLabel:`Reactivate`,onOk:async t=>{await j({...e,status:`active`}),t?.remove(),i.success(`Newsletter reactivated`)}})}},Ne=()=>{if(!ne(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,placeholder:De||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]});if(F(P))return(0,J.jsxs)(k,{"data-invalid":!!o.sender_email||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,J.jsx)(H,{"aria-invalid":!!o.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:se,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>s(`sender_email`)}),o.sender_email&&(0,J.jsx)(w,{children:o.sender_email})]})},Pe=Q[e.title_font_category||`sans_serif`].options,Fe=[{id:`generalSettings`,title:`General`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{"data-invalid":!!o.name||void 0,children:[(0,J.jsx)(E,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,J.jsx)(H,{"aria-invalid":!!o.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>s(`name`)}),o.name&&(0,J.jsx)(w,{children:o.name})]}),(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-description`,children:`Description`}),(0,J.jsx)(A,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Email info`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,J.jsx)(H,{id:`newsletter-sender-name`,maxLength:191,placeholder:ge,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Ne(),(0,J.jsx)(ke,{clearError:s,errors:o,newsletter:e,updateNewsletter:n,validate:a})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,J.jsx)(S,{children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,J.jsx)(m,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,J.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,J.jsx)(L,{className:`text-destructive hover:text-destructive`,disabled:Ae.length===1,type:`button`,variant:`ghost`,onClick:Me,children:`Archive newsletter`}):(0,J.jsx)(L,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:Me,children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(Ce,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:Se}),(0,J.jsxs)(l,{gap:`md`,children:[re&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,J.jsx)(m,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,J.jsx)(m,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,J.jsx)(m,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Title section`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,J.jsx)(m,{checked:!!e.show_post_title_section,id:`newsletter-show-post-title`,onCheckedChange:e=>n({show_post_title_section:e})})]}),e.show_post_title_section&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,J.jsx)(m,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,J.jsx)(m,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Footer`}),(0,J.jsxs)(S,{children:[(0,J.jsxs)(l,{gap:`lg`,children:[(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,J.jsx)(m,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),Ee&&(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,J.jsx)(m,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,J.jsx)(m,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,J.jsx)(m,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,J.jsx)(m,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,J.jsx)(Te,{hint:`Any extra information or legal text`,nodes:`MINIMAL_NODES`,placeholder:` `,title:`Email footer`,value:e.footer_content||``,onChange:e=>n({footer_content:e})})]})]}),(0,J.jsx)(V,{className:`mt-8`}),(0,J.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,J.jsx)(`span`,{children:(0,J.jsx)(ie,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,J.jsx)(S,{className:`gap-8`,children:(0,J.jsxs)(k,{orientation:`horizontal`,children:[(0,J.jsxs)(T,{children:[(0,J.jsx)(E,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,J.jsx)(D,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,J.jsx)(m,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Global`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{hex:`#ffffff`,value:`light`,title:`White`}],title:`Background color`,value:e.background_color||`light`,onChange:e=>n({background_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading font`}),(0,J.jsxs)(y,{value:e.title_font_category,onValueChange:t=>{let r=e.title_font_weight,i=r;return Q[t].options.find(e=>e.value===r)||(i=Q[t].map?.[r]||`bold`),n({title_font_category:t,title_font_weight:i})},children:[(0,J.jsx)(_,{"aria-label":`Heading font`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Heading weight`}),(0,J.jsxs)(y,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Q[t].map,i=r&&r[n]||n;return Pe.find(e=>e.value===i)||Pe[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,J.jsx)(_,{"aria-label":`Heading weight`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:Pe.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,J.jsxs)(k,{className:`max-w-[200px]`,children:[(0,J.jsx)(E,{className:`sr-only`,children:`Body font`}),(0,J.jsxs)(y,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,J.jsx)(_,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,J.jsx)(v,{})}),(0,J.jsx)(g,{children:je.map(e=>(0,J.jsx)(h,{value:e.value,children:(0,J.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Header`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`transparent`,title:`Transparent`,hex:`#00000000`}],title:`Header background color`,value:e.header_background_color||`transparent`,onChange:e=>n({header_background_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Title alignment`}),(0,J.jsx)(Z,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,J.jsx)(de,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,J.jsx)(ce,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,J.jsxs)(C,{className:`mt-8`,children:[(0,J.jsx)(O,{className:`text-lg! font-semibold`,children:`Body`}),(0,J.jsxs)(S,{children:[(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button style`}),(0,J.jsx)(Z,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,J.jsx)(U,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Button corners`}),(0,J.jsx)(Z,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,J.jsx)(ue,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:R.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Link style`}),(0,J.jsx)(Z,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,J.jsx)(z,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,J.jsx)(B,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,J.jsx)(oe,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,J.jsxs)(c,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,J.jsx)(`div`,{children:`Image corners`}),(0,J.jsx)(Z,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,J.jsx)(ae,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,J.jsx)(U,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,J.jsx)(`div`,{className:`mb-1`,children:(0,J.jsx)(G,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:R.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,J.jsx)(`div`,{className:`flex flex-col`,children:(0,J.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,J.jsxs)(p,{value:le,variant:`underline`,onValueChange:e=>{fe(e)},children:[(0,J.jsx)(f,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Fe.map(e=>(0,J.jsx)(u,{value:e.id,children:e.title},e.id))}),Fe.map(e=>(0,J.jsx)(d,{value:e.id,children:e.contents},e.id))]})})})},je=({newsletter:e,onlyOne:t})=>{let{config:n}=W(),{mutateAsync:o}=me(),{updateRoute:s}=x(),c=Se(`automations`)?`emails`:`newsletters`,{formState:l,saveState:u,updateForm:d,setFormState:f,handleSave:p,validate:m,errors:h,clearError:g,okProps:_}=a({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await o(l),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,J.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&i.info(t)},onSaveError:r(),onValidate:()=>{let e={};return l.name||(e.name=`A name is required for your newsletter`),l.sender_email&&!X.default.isEmail(l.sender_email)?e.sender_email=`Enter a valid email address`:l.sender_email&&F(n)&&l.sender_email.split(`@`)[1]!==pe(n)&&(e.sender_email=`Email address must end with @${pe(n)}`),l.sender_reply_to&&!X.default.isEmail(l.sender_reply_to)&&![`newsletter`,`support`].includes(l.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),v=e=>{d(t=>({...t,...e}))};(0,Y.useEffect)(()=>{f(()=>e)},[f,e]);let y=(0,J.jsx)(Oe,{newsletter:l}),b=(0,J.jsx)(Ae,{clearError:g,errors:h,newsletter:l,onlyOne:t,updateNewsletter:v,validate:m});return(0,J.jsx)(Ee,{buttonsDisabled:_.disabled,cancelLabel:`Close`,dirty:u===`unsaved`,okLabel:_.label||`Save`,okVariant:_.variant,preview:y,previewBgColor:`grey`,previewToolbar:!1,sidebar:b,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>s(c),onOk:async()=>{await p({fakeWhenUnchanged:!0})}})},Q=()=>{let{newsletterId:e}=o(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=he(),i=t?.find(({id:t})=>t===e);return(0,Y.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,J.jsx)(je,{newsletter:i,onlyOne:t.length===1}):null};export{Q as default};
|
package/core/built/admin/assets/{newsletter-emails-Bf8IZLsP.js → newsletter-emails-B-OLfrvr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{f as n}from"./dist-Cb5RSHSg.js";import{o as r,r as i,t as a}from"./field-
|
|
1
|
+
import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{f as n}from"./dist-Cb5RSHSg.js";import{o as r,r as i,t as a}from"./field-B3OPenbP.js";import{Ls as o,Rs as s,Yi as c}from"./index-DUXM0NlS.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./images-Ok8FFJ3A.js";e();var _=t(),v=({inputId:e=`welcome-email-header-image`,onUploadError:t,value:o,onChange:s})=>{let{mutateAsync:v}=f(),y=async e=>{try{s(g(await v({file:e})))}catch(e){if(t){t(e);return}throw e}};return(0,_.jsxs)(a,{"data-testid":`header-image-field`,children:[(0,_.jsx)(r,{htmlFor:e,children:`Header image`}),(0,_.jsx)(m,{className:`aspect-[2/1] w-full`,children:o?(0,_.jsxs)(u,{children:[(0,_.jsx)(h,{alt:`Header`,src:o}),(0,_.jsx)(l,{children:(0,_.jsx)(d,{"aria-label":`Remove header image`,type:`button`,onClick:()=>s(``),children:(0,_.jsx)(c,{})})})]}):(0,_.jsx)(p,{accept:{"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]},inputId:e,onDropAccepted:e=>e[0]&&y(e[0]),children:(0,_.jsx)(`span`,{className:`text-control font-medium`,children:`Upload header image`})})}),(0,_.jsxs)(i,{children:[n(1200),`×`,n(600),` recommended. Use a transparent PNG for best results on any background.`]})]})},y=(e,t,n)=>s(t)&&!o(t)&&n?n:e.sender_email||n||``,b=(e,t,n,r)=>e.sender_reply_to===`newsletter`?s(t)?``:y(e,t,r):e.sender_reply_to===`support`?n||r||``:e.sender_reply_to,x=(e,t,n,r)=>b(e,t,n,r)||(e.sender_reply_to===`newsletter`?y(e,t,r)||n||r||``:n||r||``);export{v as i,x as n,y as r,b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r,g as i,i as a,r as o}from"./stats-D8nZCTy5.js";import{g as s}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as c,t as l}from"./router-provider-DSQfprxH.js";import{f as u,l as d,p as f}from"./dist-Cb5RSHSg.js";import{g as p,n as m,o as h,r as g}from"./chart-BnXyfH11.js";import{a as _,c as v,i as y,l as b,n as x,t as ee,u as te}from"./chart-helpers-CZElTGYL.js";import{n as ne,t as S}from"./sort-button-CdBsm40v.js";import{r as re,t as ie}from"./tabs-Dd6oOKbv.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./select-D9oU1IoM.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-aUHX0hyR.js";import{t as F}from"./empty-indicator-WB1WgT9h.js";import{a as I,c as L,n as R,r as z,s as B,t as V}from"./table-TMCgCQK7.js";import{$a as H,$r as U,Br as ae,Kr as W,Pr as G,Qa as oe,Vs as K,Wr as q,Yr as se,Zr as ce,ai as le,ir as J,p as Y,sr as ue}from"./index-BHy2DZX-.js";import{i as de,n as fe,r as pe,t as me}from"./stats-view-CugFVf0g.js";import{n as X,r as Z,t as he}from"./kpi-tabs-X3DkOYbI.js";import{t as ge}from"./use-analytics-data-B-b4wNSC.js";import{r as _e}from"./newsletters-Du0lzskS.js";var Q=e(t(),1),$=n(),ve=({active:e,payload:t})=>{if(!e||!t?.length)return null;let n=t[0].payload,r=typeof n.send_date==`string`?n.send_date:n.send_date.toISOString().split(`T`)[0];return(0,$.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,d(r)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,$.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:u(n.sent_to)})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_opens),` / `]}),f(n.open_rate)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_clicks),` / `]}),f(n.click_rate)]})]})]})},ye=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:i,initialTab:a=`total-subscribers`})=>{let[o,l]=(0,Q.useState)(a),[d,S]=(0,Q.useState)(!1),{range:C}=Y(),w=c(),[T]=s(),{appSettings:E}=K(),{emailTrackClicks:D,emailTrackOpens:O}=E?.analytics||{},{totalSubscribers:k,avgOpenRate:A,avgClickRate:j}=n,M=(0,Q.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=y(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:u(e.value),label:`Total Subscribers`}))},[e,C]),N=(0,Q.useMemo)(()=>ee(C,e||[]),[e,C]),P=(0,Q.useMemo)(()=>{if(!M||M.length<=1)return{direction:`same`,value:`0%`};let e=M[0]?.value??0,t=M[M.length-1]?.value??0,n=`same`;t>e?n=`up`:t<e&&(n=`down`);let r;if(e===0)r=t===0?`0%`:`+100%`;else{let n=(t-e)/e*100,i=Math.round(n*10)/10;r=`${n>=0?`+`:``}${i}%`}return{direction:n,value:r}},[M]);(0,Q.useEffect)(()=>{l(a)},[a]);let I=e=>{l(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},L={open_rate:{label:`Open rate`}},R=(0,Q.useMemo)(()=>({"total-subscribers":{color:`var(--chart-darkblue)`,datakey:`value`},"avg-open-rate":{color:`var(--chart-blue)`,datakey:`open_rate`},"avg-click-rate":{color:`var(--chart-teal)`,datakey:`click_rate`}}),[]),{barDomain:z,barTicks:B}=(0,Q.useMemo)(()=>{if(!t||t.length===0||o===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=R[o]?.datakey;if(!e)return{barDomain:[0,1],barTicks:[0,1]};let n=t.map(t=>t[e]).filter(e=>typeof e==`number`);if(n.length===0)return{barDomain:[0,1],barTicks:[0,1]};let r=o===`avg-open-rate`?A:j,i=Math.max(Math.max(...n),r),a;return a=i<.01?.01:i<.1?(Math.floor(i*100)+1)/100:(Math.floor(i*10)+1)/10,{barDomain:[0,a],barTicks:[0,a]}},[t,o,R,A,j]);if(r)return(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(J,{})});let V=`grid-cols-3`;(!D||!O)&&(V=`grid-cols-2`),!D&&!O&&(V=`grid-cols-1`);let W=o===`avg-open-rate`&&A>z[0]&&A<z[1]||o===`avg-click-rate`&&j>z[0]&&j<z[1],G=o===`avg-open-rate`?A:j;return(0,$.jsxs)(ie,{defaultValue:a,variant:`kpis`,children:[(0,$.jsxs)(re,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${V}`,children:[(0,$.jsx)(X,{className:`${!O&&!D&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{I(`total-subscribers`)},children:(0,$.jsx)(Z,{color:R[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:P.direction,diffValue:P.value,label:`Total subscribers`,value:u(k)})}),O&&(0,$.jsx)(X,{value:`avg-open-rate`,onClick:()=>{I(`avg-open-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)})}),D&&(0,$.jsx)(X,{value:`avg-click-rate`,onClick:()=>{I(`avg-click-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})})]}),(0,$.jsxs)(se,{children:[(0,$.jsx)(le,{className:`md:hidden`,asChild:!0,children:(0,$.jsxs)(he,{children:[o===`total-subscribers`&&(0,$.jsx)(Z,{color:R[`total-subscribers`].color,label:`Total subscribers`,value:u(k)}),o===`avg-open-rate`&&O&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)}),o===`avg-click-rate`&&D&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})]})}),(0,$.jsxs)(ce,{align:`end`,className:`w-56`,children:[(0,$.jsx)(U,{onClick:()=>I(`total-subscribers`),children:`Total subscribers`}),O&&(0,$.jsx)(U,{onClick:()=>I(`avg-open-rate`),children:`Avg. open rate`}),D&&(0,$.jsx)(U,{onClick:()=>I(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,$.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[o===`total-subscribers`&&(0,$.jsx)(_,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:R[`total-subscribers`].color,data:M,id:`mrr`,range:N}),(o===`avg-open-rate`&&O||o===`avg-click-rate`&&D)&&(0,$.jsx)($.Fragment,{children:i?(0,$.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,$.jsx)(J,{})}):t&&t.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:L,children:(0,$.jsxs)(ne,{className:d?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`,{crossApp:!0})},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:R[o].color,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:R[o].color,stopOpacity:.6})]})}),(0,$.jsx)(te,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(b,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(v,{axisLine:!1,domain:z,tickFormatter:e=>f(e),tickLine:!1,ticks:B,width:ae(B,e=>f(e))}),(0,$.jsx)(g,{content:(0,$.jsx)(ve,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),W&&(0,$.jsx)(h,{label:{value:`${f(G)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:G}),(0,$.jsx)(p,{activeBar:{fillOpacity:1},dataKey:R[o].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,$.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,o===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(C)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})]})]})},be=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=Y(),r=(0,Q.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Q.useEffect)(()=>{if(r.length>0&&!t){let e=r.find(e=>e.sort_order===0);n(e?e.id:r[0].id)}},[r,t,n]),r.length<=1?null:(0,$.jsxs)(k,{value:t||``,onValueChange:e=>{n(e)},children:[(0,$.jsxs)(E,{className:`w-auto`,children:[(0,$.jsx)(oe,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,$.jsx)(O,{placeholder:`Select a newsletter`})]}),(0,$.jsx)(T,{align:`end`,children:(0,$.jsxs)(D,{children:[(0,$.jsx)(C,{children:`Newsletters`}),r.map(e=>(0,$.jsx)(w,{value:e.id,children:e.name},e.id))]})})]})},xe=(e,t,n=!0)=>{let i=e??30,{startDate:a,endDate:o}=(0,Q.useMemo)(()=>W(i),[i]),s=r({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(a),date_to:q(o)};return t&&(e.newsletter_id=t),e},[a,o,t]),enabled:n});return n?s:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:s.refetch}},Se=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:s,endDate:c}=(0,Q.useMemo)(()=>W(i),[i]),l=o({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(s),date_to:q(c),order:a};return n&&(e.newsletter_id=n),e},[s,c,a,n]),enabled:r});return r?l:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:l.refetch}},Ce=(e,t=[],n=!0)=>{let r=a({searchParams:(0,Q.useMemo)(()=>{let n={};return e&&(n.newsletter_id=e),t.length>0&&(n.post_ids=t.join(`,`)),n},[e,t]),enabled:n});return n?r:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:r.refetch}},we=(e,t,n,r=!0)=>{let i=Se(e,t,n,r),a=(0,Q.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=Ce(n,a,r&&a.length>0);return{data:(0,Q.useMemo)(()=>{if(!i.data?.stats)return;let e=i.data.stats,t=o.data?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...i.data,stats:r}},[i.data,o.data]),isLoading:i.isLoading,isClicksLoading:o.isLoading,error:i.error||o.error,isError:i.isError||o.isError,refetch:()=>{i.refetch(),o.refetch()}}},Te=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=c(),{settings:a}=ge(),o=String(a.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{data:s,isLoading:l,isClicksLoading:p}=we(e,r,t||void 0,!!n),{appSettings:m}=K(),{emailTrackClicks:h,emailTrackOpens:g}=m?.analytics||{},_=(0,Q.useMemo)(()=>s?.stats||[],[s]),v=g&&h?5:g||h?4:3,y=(0,Q.useMemo)(()=>(0,$.jsx)($.Fragment,{children:(0,$.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,$.jsx)(z,{className:`font-medium`,colSpan:v,children:(0,$.jsx)(ue,{className:`mt-5`})})})}),[v]),b=(0,Q.useMemo)(()=>_.length>0?(0,$.jsx)($.Fragment,{children:_.map(e=>(0,$.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,$.jsx)(z,{className:`font-medium`,children:(0,$.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,$.jsx)(G,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`,{crossApp:!0})},children:e.post_title}):(0,$.jsx)($.Fragment,{children:e.post_title})})}),(0,$.jsx)(z,{className:`text-sm whitespace-nowrap`,children:d(e.send_date,o)}),(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:u(e.sent_to)}),g&&(0,$.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.open_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_opens)})]}),h&&(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:p?(0,$.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.click_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_clicks)})]})})]},e.post_id))}):(0,$.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,$.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:v,children:(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(e)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})}),[_,p,i,h,g,e]);return l||!s?y:b});Te.displayName=`NewsletterTableRows`;var Ee=Q.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Q.useMemo)(()=>(0,$.jsxs)(A,{children:[(0,$.jsx)(M,{children:`Top newsletters`}),(0,$.jsxs)(N,{children:[` Your best performing newsletters `,x(n)]})]}),[n]),{appSettings:i}=K(),{emailTrackClicks:a,emailTrackOpens:o}=i?.analytics||{};return(0,$.jsx)(B,{children:(0,$.jsxs)(L,{children:[(0,$.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,$.jsx)(I,{className:`w-[65px]`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),o&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),a&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ee.displayName=`NewsletterTableHeader`;var De=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Q.useState)(`open_rate desc`);return(0,$.jsx)(P,{className:`w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,"data-testid":`top-newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsxs)(V,{children:[(0,$.jsx)(Ee,{range:e,setSortBy:i,sortBy:r}),(0,$.jsx)(R,{children:(0,$.jsx)(Te,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});De.displayName=`TopNewslettersTable`;var Oe=()=>{let{range:e,selectedNewsletterId:t}=Y(),[n]=s(),{appSettings:r}=K(),a=n.get(`tab`)||`total-subscribers`,{data:o,isLoading:c}=_e({searchParams:{limit:`50`}}),u=!c&&o&&o.newsletters.length>0&&!!t,{data:d,isLoading:f}=xe(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=we(e,`date asc`,t||void 0,u||!1),g=(0,Q.useMemo)(()=>!o?.newsletters||!t?null:o.newsletters.find(e=>e.id===t)||null,[o,t]),_=(0,Q.useMemo)(()=>{let e=g?.count?.active_members||d?.stats?.[0]?.total||0,t=0,n=0;if(p?.stats&&p.stats.length>0){let e=p.stats,r=e.reduce((e,t)=>e+(t.open_rate||0),0),i=e.reduce((e,t)=>e+(t.click_rate||0),0);t=r/e.length,n=i/e.length}return{totalSubscribers:e,avgOpenRate:t,avgClickRate:n}},[g,d,p]),v=(0,Q.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=W(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Q.useMemo)(()=>p?.stats?p.stats.map(e=>({post_id:e.post_id,post_title:e.post_title,send_date:e.send_date,sent_to:e.sent_to,total_opens:e.total_opens,open_rate:e.open_rate,total_clicks:e.total_clicks||0,click_rate:e.click_rate||0})):[],[p]),b=f||h||m;return r&&!r.newslettersEnabled?(0,$.jsx)(l,{to:`/analytics`}):(0,$.jsxs)(fe,{children:[(0,$.jsx)(pe,{children:(0,$.jsxs)(i,{children:[(0,$.jsx)(be,{newsletters:o?.newsletters}),(0,$.jsx)(de,{})]})}),(0,$.jsx)(me,{isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{"data-testid":`newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsx)(ye,{avgsData:y,initialTab:a,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,$.jsx)(De,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{Oe as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{c as r,g as i,i as a,r as o}from"./stats-B2KW8E2y.js";import{g as s}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{a as c,t as l}from"./router-provider-DSQfprxH.js";import{f as u,l as d,p as f}from"./dist-Cb5RSHSg.js";import{g as p,n as m,o as h,r as g}from"./chart-BnXyfH11.js";import{a as _,c as v,i as y,l as b,n as x,t as ee,u as te}from"./chart-helpers-DGxvWnBT.js";import{n as ne,t as S}from"./sort-button-B-k54ow2.js";import{r as re,t as ie}from"./tabs-BaWRfg8j.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./select-CkXqNJDJ.js";import{a as A,n as j,o as M,r as N,t as P}from"./card-aUHX0hyR.js";import{t as F}from"./empty-indicator-WB1WgT9h.js";import{a as I,c as L,n as R,r as z,s as B,t as V}from"./table-BtLcEi1M.js";import{$a as H,$r as U,Br as ae,Kr as W,Pr as G,Qa as oe,Vs as K,Wr as q,Yr as se,Zr as ce,ai as le,ir as J,p as Y,sr as ue}from"./index-DUXM0NlS.js";import{i as de,n as fe,r as pe,t as me}from"./stats-view-CVzU2-p5.js";import{n as X,r as Z,t as he}from"./kpi-tabs-R6BjsKhd.js";import{t as ge}from"./use-analytics-data-BiWvcf1u.js";import{r as _e}from"./newsletters-Du0lzskS.js";var Q=e(t(),1),$=n(),ve=({active:e,payload:t})=>{if(!e||!t?.length)return null;let n=t[0].payload,r=typeof n.send_date==`string`?n.send_date:n.send_date.toISOString().split(`T`)[0];return(0,$.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,$.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,d(r)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,$.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:u(n.sent_to)})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_opens),` / `]}),f(n.open_rate)]})]}),(0,$.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,$.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,$.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(n.total_clicks),` / `]}),f(n.click_rate)]})]})]})},ye=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:i,initialTab:a=`total-subscribers`})=>{let[o,l]=(0,Q.useState)(a),[d,S]=(0,Q.useState)(!1),{range:C}=Y(),w=c(),[T]=s(),{appSettings:E}=K(),{emailTrackClicks:D,emailTrackOpens:O}=E?.analytics||{},{totalSubscribers:k,avgOpenRate:A,avgClickRate:j}=n,M=(0,Q.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=y(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:u(e.value),label:`Total Subscribers`}))},[e,C]),N=(0,Q.useMemo)(()=>ee(C,e||[]),[e,C]),P=(0,Q.useMemo)(()=>{if(!M||M.length<=1)return{direction:`same`,value:`0%`};let e=M[0]?.value??0,t=M[M.length-1]?.value??0,n=`same`;t>e?n=`up`:t<e&&(n=`down`);let r;if(e===0)r=t===0?`0%`:`+100%`;else{let n=(t-e)/e*100,i=Math.round(n*10)/10;r=`${n>=0?`+`:``}${i}%`}return{direction:n,value:r}},[M]);(0,Q.useEffect)(()=>{l(a)},[a]);let I=e=>{l(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},L={open_rate:{label:`Open rate`}},R=(0,Q.useMemo)(()=>({"total-subscribers":{color:`var(--chart-darkblue)`,datakey:`value`},"avg-open-rate":{color:`var(--chart-blue)`,datakey:`open_rate`},"avg-click-rate":{color:`var(--chart-teal)`,datakey:`click_rate`}}),[]),{barDomain:z,barTicks:B}=(0,Q.useMemo)(()=>{if(!t||t.length===0||o===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=R[o]?.datakey;if(!e)return{barDomain:[0,1],barTicks:[0,1]};let n=t.map(t=>t[e]).filter(e=>typeof e==`number`);if(n.length===0)return{barDomain:[0,1],barTicks:[0,1]};let r=o===`avg-open-rate`?A:j,i=Math.max(Math.max(...n),r),a;return a=i<.01?.01:i<.1?(Math.floor(i*100)+1)/100:(Math.floor(i*10)+1)/10,{barDomain:[0,a],barTicks:[0,a]}},[t,o,R,A,j]);if(r)return(0,$.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,$.jsx)(J,{})});let V=`grid-cols-3`;(!D||!O)&&(V=`grid-cols-2`),!D&&!O&&(V=`grid-cols-1`);let W=o===`avg-open-rate`&&A>z[0]&&A<z[1]||o===`avg-click-rate`&&j>z[0]&&j<z[1],G=o===`avg-open-rate`?A:j;return(0,$.jsxs)(ie,{defaultValue:a,variant:`kpis`,children:[(0,$.jsxs)(re,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${V}`,children:[(0,$.jsx)(X,{className:`${!O&&!D&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{I(`total-subscribers`)},children:(0,$.jsx)(Z,{color:R[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:P.direction,diffValue:P.value,label:`Total subscribers`,value:u(k)})}),O&&(0,$.jsx)(X,{value:`avg-open-rate`,onClick:()=>{I(`avg-open-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)})}),D&&(0,$.jsx)(X,{value:`avg-click-rate`,onClick:()=>{I(`avg-click-rate`)},children:(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})})]}),(0,$.jsxs)(se,{children:[(0,$.jsx)(le,{className:`md:hidden`,asChild:!0,children:(0,$.jsxs)(he,{children:[o===`total-subscribers`&&(0,$.jsx)(Z,{color:R[`total-subscribers`].color,label:`Total subscribers`,value:u(k)}),o===`avg-open-rate`&&O&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-open-rate`].color,label:`Avg. open rate`,value:f(A)}),o===`avg-click-rate`&&D&&(0,$.jsx)(Z,{className:i?`opacity-50`:``,color:R[`avg-click-rate`].color,label:`Avg. click rate`,value:f(j)})]})}),(0,$.jsxs)(ce,{align:`end`,className:`w-56`,children:[(0,$.jsx)(U,{onClick:()=>I(`total-subscribers`),children:`Total subscribers`}),O&&(0,$.jsx)(U,{onClick:()=>I(`avg-open-rate`),children:`Avg. open rate`}),D&&(0,$.jsx)(U,{onClick:()=>I(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,$.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[o===`total-subscribers`&&(0,$.jsx)(_,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:R[`total-subscribers`].color,data:M,id:`mrr`,range:N}),(o===`avg-open-rate`&&O||o===`avg-click-rate`&&D)&&(0,$.jsx)($.Fragment,{children:i?(0,$.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,$.jsx)(J,{})}):t&&t.length>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:L,children:(0,$.jsxs)(ne,{className:d?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`,{crossApp:!0})},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,$.jsx)(`defs`,{children:(0,$.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:R[o].color,stopOpacity:.8}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:R[o].color,stopOpacity:.6})]})}),(0,$.jsx)(te,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,$.jsx)(b,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,$.jsx)(v,{axisLine:!1,domain:z,tickFormatter:e=>f(e),tickLine:!1,ticks:B,width:ae(B,e=>f(e))}),(0,$.jsx)(g,{content:(0,$.jsx)(ve,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),W&&(0,$.jsx)(h,{label:{value:`${f(G)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:G}),(0,$.jsx)(p,{activeBar:{fillOpacity:1},dataKey:R[o].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,$.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,o===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(C)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})]})]})},be=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=Y(),r=(0,Q.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Q.useEffect)(()=>{if(r.length>0&&!t){let e=r.find(e=>e.sort_order===0);n(e?e.id:r[0].id)}},[r,t,n]),r.length<=1?null:(0,$.jsxs)(k,{value:t||``,onValueChange:e=>{n(e)},children:[(0,$.jsxs)(E,{className:`w-auto`,children:[(0,$.jsx)(oe,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,$.jsx)(O,{placeholder:`Select a newsletter`})]}),(0,$.jsx)(T,{align:`end`,children:(0,$.jsxs)(D,{children:[(0,$.jsx)(C,{children:`Newsletters`}),r.map(e=>(0,$.jsx)(w,{value:e.id,children:e.name},e.id))]})})]})},xe=(e,t,n=!0)=>{let i=e??30,{startDate:a,endDate:o}=(0,Q.useMemo)(()=>W(i),[i]),s=r({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(a),date_to:q(o)};return t&&(e.newsletter_id=t),e},[a,o,t]),enabled:n});return n?s:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:s.refetch}},Se=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:s,endDate:c}=(0,Q.useMemo)(()=>W(i),[i]),l=o({searchParams:(0,Q.useMemo)(()=>{let e={date_from:q(s),date_to:q(c),order:a};return n&&(e.newsletter_id=n),e},[s,c,a,n]),enabled:r});return r?l:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:l.refetch}},Ce=(e,t=[],n=!0)=>{let r=a({searchParams:(0,Q.useMemo)(()=>{let n={};return e&&(n.newsletter_id=e),t.length>0&&(n.post_ids=t.join(`,`)),n},[e,t]),enabled:n});return n?r:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:r.refetch}},we=(e,t,n,r=!0)=>{let i=Se(e,t,n,r),a=(0,Q.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=Ce(n,a,r&&a.length>0);return{data:(0,Q.useMemo)(()=>{if(!i.data?.stats)return;let e=i.data.stats,t=o.data?.stats||[],n=new Map;t.forEach(e=>{n.set(e.post_id,e)});let r=e.map(e=>{let t=n.get(e.post_id);return{...e,total_clicks:t?.total_clicks||0,click_rate:t?.click_rate||0}});return{...i.data,stats:r}},[i.data,o.data]),isLoading:i.isLoading,isClicksLoading:o.isLoading,error:i.error||o.error,isError:i.isError||o.isError,refetch:()=>{i.refetch(),o.refetch()}}},Te=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=c(),{settings:a}=ge(),o=String(a.find(e=>e.key===`timezone`)?.value||`Etc/UTC`),{data:s,isLoading:l,isClicksLoading:p}=we(e,r,t||void 0,!!n),{appSettings:m}=K(),{emailTrackClicks:h,emailTrackOpens:g}=m?.analytics||{},_=(0,Q.useMemo)(()=>s?.stats||[],[s]),v=g&&h?5:g||h?4:3,y=(0,Q.useMemo)(()=>(0,$.jsx)($.Fragment,{children:(0,$.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,$.jsx)(z,{className:`font-medium`,colSpan:v,children:(0,$.jsx)(ue,{className:`mt-5`})})})}),[v]),b=(0,Q.useMemo)(()=>_.length>0?(0,$.jsx)($.Fragment,{children:_.map(e=>(0,$.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,$.jsx)(z,{className:`font-medium`,children:(0,$.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,$.jsx)(G,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`,{crossApp:!0})},children:e.post_title}):(0,$.jsx)($.Fragment,{children:e.post_title})})}),(0,$.jsx)(z,{className:`text-sm whitespace-nowrap`,children:d(e.send_date,o)}),(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:u(e.sent_to)}),g&&(0,$.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.open_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_opens)})]}),h&&(0,$.jsx)(z,{className:`text-right font-mono text-sm`,children:p?(0,$.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`group-hover:hidden`,children:f(e.click_rate)}),(0,$.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:u(e.total_clicks)})]})})]},e.post_id))}):(0,$.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,$.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:v,children:(0,$.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${x(e)}`,children:(0,$.jsx)(H,{strokeWidth:1.5})})})}),[_,p,i,h,g,e]);return l||!s?y:b});Te.displayName=`NewsletterTableRows`;var Ee=Q.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Q.useMemo)(()=>(0,$.jsxs)(A,{children:[(0,$.jsx)(M,{children:`Top newsletters`}),(0,$.jsxs)(N,{children:[` Your best performing newsletters `,x(n)]})]}),[n]),{appSettings:i}=K(),{emailTrackClicks:a,emailTrackOpens:o}=i?.analytics||{};return(0,$.jsx)(B,{children:(0,$.jsxs)(L,{children:[(0,$.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,$.jsx)(I,{className:`w-[65px]`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),o&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),a&&(0,$.jsx)(I,{className:`w-[90px] text-right`,children:(0,$.jsx)(S,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ee.displayName=`NewsletterTableHeader`;var De=Q.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Q.useState)(`open_rate desc`);return(0,$.jsx)(P,{className:`w-full max-w-[calc(100vw-64px)] overflow-x-auto sidebar:max-w-[calc(100vw-64px-280px)]`,"data-testid":`top-newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsxs)(V,{children:[(0,$.jsx)(Ee,{range:e,setSortBy:i,sortBy:r}),(0,$.jsx)(R,{children:(0,$.jsx)(Te,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});De.displayName=`TopNewslettersTable`;var Oe=()=>{let{range:e,selectedNewsletterId:t}=Y(),[n]=s(),{appSettings:r}=K(),a=n.get(`tab`)||`total-subscribers`,{data:o,isLoading:c}=_e({searchParams:{limit:`50`}}),u=!c&&o&&o.newsletters.length>0&&!!t,{data:d,isLoading:f}=xe(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=we(e,`date asc`,t||void 0,u||!1),g=(0,Q.useMemo)(()=>!o?.newsletters||!t?null:o.newsletters.find(e=>e.id===t)||null,[o,t]),_=(0,Q.useMemo)(()=>{let e=g?.count?.active_members||d?.stats?.[0]?.total||0,t=0,n=0;if(p?.stats&&p.stats.length>0){let e=p.stats,r=e.reduce((e,t)=>e+(t.open_rate||0),0),i=e.reduce((e,t)=>e+(t.click_rate||0),0);t=r/e.length,n=i/e.length}return{totalSubscribers:e,avgOpenRate:t,avgClickRate:n}},[g,d,p]),v=(0,Q.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=W(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Q.useMemo)(()=>p?.stats?p.stats.map(e=>({post_id:e.post_id,post_title:e.post_title,send_date:e.send_date,sent_to:e.sent_to,total_opens:e.total_opens,open_rate:e.open_rate,total_clicks:e.total_clicks||0,click_rate:e.click_rate||0})):[],[p]),b=f||h||m;return r&&!r.newslettersEnabled?(0,$.jsx)(l,{to:`/analytics`}):(0,$.jsxs)(fe,{children:[(0,$.jsx)(pe,{children:(0,$.jsxs)(i,{children:[(0,$.jsx)(be,{newsletters:o?.newsletters}),(0,$.jsx)(de,{})]})}),(0,$.jsx)(me,{isLoading:!1,loadingComponent:(0,$.jsx)($.Fragment,{}),children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{"data-testid":`newsletters-card`,children:(0,$.jsx)(j,{children:(0,$.jsx)(ye,{avgsData:y,initialTab:a,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,$.jsx)(De,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{Oe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-DSQfprxH.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,Wt as u,Z as d,ar as f,et as p,ft as m,or as h,rt as g,xo as _,z as v}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./chunk-KS7C4IRE-DG9HTHQ3.js";import{s as i}from"./router-provider-DSQfprxH.js";import{$ as a,B as o,Jt as s,Kt as c,R as l,Wt as u,Z as d,ar as f,et as p,ft as m,or as h,rt as g,xo as _,z as v}from"./index-DUXM0NlS.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-CmFe0N6F.js";var C=e(t(),1),w=n(),T=()=>(0,w.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`}),E=()=>{let{postId:e}=r(),{canGoBack:t}=i(),[n,E]=(0,C.useState)(new Set),[D,O]=(0,C.useState)(new Set),[k,A]=(0,C.useState)(new Set),[j,M]=(0,C.useState)(!1),N=(0,C.useRef)(null),P=(0,C.useRef)(null),F=(0,C.useRef)(null),I=(0,C.useRef)(null),L=s(),{threadParents:R,post:z,processedReplies:B,isLoading:V,loadMoreChildren:H,loadMoreChildReplies:U,hasMoreChildren:W,hasMoreChildReplies:G}=S(decodeURIComponent(e??``),{includeAncestors:!0}),K=z?.object,q=K?.replyCount??0,[J,Y]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{P.current&&R.length>0&&!J&&(P.current.scrollIntoView({behavior:`instant`,block:`start`}),Y(!0))},[R,J]),(0,C.useEffect)(()=>{F.current&&F.current.disconnect();let e=document.querySelector(`[data-scrollable-container]`);if(e)return F.current=new IntersectionObserver(async e=>{if(e[0].isIntersecting&&W&&!j){M(!0);try{await H()}catch(e){console.error(`Failed to load more top-level replies:`,e)}finally{M(!1)}}},{root:e,rootMargin:`200px`}),I.current&&F.current.observe(I.current),()=>{F.current&&F.current.disconnect()}},[W,j,H]),V)return(0,w.jsx)(o,{children:(0,w.jsxs)(`div`,{className:`mx-auto flex max-w-[620px] flex-col items-center gap-3 pt-9 lg:px-8`,children:[(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3`,children:[(0,w.jsx)(h,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(h,{className:`w-24`}),(0,w.jsx)(h,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(h,{}),(0,w.jsx)(h,{className:`w-4/5`}),(0,w.jsx)(h,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(h,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(h,{className:`w-52`}),(0,w.jsx)(h,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(l,{children:(0,w.jsx)(_,{})}),(0,w.jsx)(`div`,{children:`Error loading note.`})]})})});function X(){}function Z(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),O(t=>{let n=new Set(t);return n.add(e),n})),n})}async function Q(e,t){if(!k.has(e)){A(t=>new Set(t).add(e));try{U&&await U(t)}catch(e){console.error(`Failed to load more replies for chain:`,e)}finally{A(t=>{let n=new Set(t);return n.delete(e),n})}}}return(0,w.jsx)(o,{children:(0,w.jsx)(`div`,{className:`mx-auto flex h-full max-w-[620px] flex-col`,children:(0,w.jsx)(`div`,{className:`relative flex-1`,children:(0,w.jsx)(`div`,{className:`grow overflow-y-auto`,children:(0,w.jsxs)(`div`,{className:`mx-auto px-8 pt-5 pb-10 max-lg:px-0`,children:[!R.length&&(0,w.jsx)(g,{actor:z.actor,isCurrentUser:z.object.authored,children:(0,w.jsxs)(`div`,{className:`col-[2/3] mx-auto flex w-full cursor-pointer items-center gap-3 ${t?`pt-10 max-md:pt-5`:`pt-5`}`,children:[(0,w.jsx)(`div`,{className:`relative z-10`,children:(0,w.jsx)(m,{author:z.actor,showFollowButton:!z.object.authored&&!z.actor.followedByMe})}),(0,w.jsxs)(`div`,{className:`relative z-10 flex w-full min-w-0 cursor-pointer flex-col overflow-visible text-[1.5rem]`,onClick:e=>{p(z.actor,L,e)},children:[(0,w.jsx)(`div`,{className:`flex w-full`,children:(0,w.jsx)(`span`,{className:`min-w-0 truncate font-semibold whitespace-nowrap hover:underline`,children:z.actor.name})}),(0,w.jsxs)(`div`,{className:`flex w-full`,children:[(0,w.jsx)(`span`,{className:`truncate text-gray-700 after:mx-1 after:font-normal after:text-gray-700 after:content-["·"]`,children:c(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:a(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(d,{actor:e.actor,allowDelete:!1,commentCount:e.object.replyCount??0,last:!1,layout:`reply`,likeCount:e.object.likeCount??0,object:e.object,repostCount:e.object.repostCount??0,type:`Note`,onClick:()=>{L(`/${e.object.type===`Article`?`reader`:`notes`}/${encodeURIComponent(e.object.id)}`)}})),(0,w.jsx)(`div`,{ref:P,className:`${t?`scroll-mt-[12px]`:`scroll-mt-[124px]`}`,children:(0,w.jsxs)(`div`,{className:`${R.length>0&&`min-h-[calc(100vh-52px)]`}`,children:[(0,w.jsx)(d,{actor:z.actor,allowDelete:!1,commentCount:q,last:!0,layout:`modal`,likeCount:K.likeCount??0,object:K,repostCount:K.repostCount,showHeader:R.length>0,showStats:!0,type:`Note`}),(0,w.jsx)(y,{object:K}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{ref:N,children:[B.map((e,t)=>{let r=t===B.length-1,i=e.mainReply.id,a=n.has(i),o=D.has(i),s=k.has(i),c=e.chain.length>0;return(0,w.jsxs)(C.Fragment,{children:[(0,w.jsx)(d,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:u(e.mainReply.id),last:!c,layout:`reply`,likeCount:e.mainReply.object.likeCount??0,object:e.mainReply.object,parentId:K.id,repostCount:e.mainReply.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.mainReply.id)}`)},onDelete:X}),c&&e.chain[0]&&(0,w.jsx)(d,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:u(e.chain[0].id),last:e.chain.length===1,layout:`reply`,likeCount:e.chain[0].object.likeCount??0,object:e.chain[0].object,parentId:K.id,repostCount:e.chain[0].object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(e.chain[0].id)}`)},onDelete:X},e.chain[0].id),c&&a&&e.chain.slice(1).map((n,r)=>{let i=r===e.chain.slice(1).length-1,a=G&&G(t),o=i&&a;return(0,w.jsx)(d,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:u(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(f,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{f as r}from"./dist-Cb5RSHSg.js";import{$ as i,At as a,B as o,Ca as s,Gt as c,Jt as l,L as u,Li as d,Pr as f,Q as p,R as m,_s as h,ar as g,bo as _,dt as v,et as y,ft as b,lt as x,ns as S,nt as C,or as w,rt as T,ut as E,xa as D,xs as O,z as k}from"./index-BHy2DZX-.js";import"./layout-TMj4P-vv.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,c=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(d,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:c}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(_,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:c}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(D,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:c}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(s,{color:a,size:o,strokeWidth:c}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:c}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=l(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&y(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=l();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),y(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(E(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=l(),s=e=>{t(t=>({...t,[e]:!t[e]}))},d=()=>{},{data:_,error:T,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=_?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?s(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&y(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return T&&c(T)?(0,j.jsx)(u,{errorCode:T.code,statusCode:T.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(m,{children:(0,j.jsx)(h,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(w,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(b,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(f,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),s(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(S,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&y(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(v,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(w,{}),(0,j.jsx)(w,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(v,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(E(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.jsx)(`div`,{className:`notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]`,children:p({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(C,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:d})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(g,{size:`md`})})]})]})})};export{B as default};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{f as r}from"./dist-Cb5RSHSg.js";import{$ as i,At as a,B as o,Ca as s,Gt as c,Jt as l,L as u,Li as d,Pr as f,Q as p,R as m,_s as h,ar as g,bo as _,dt as v,et as y,ft as b,lt as x,ns as S,nt as C,or as w,rt as T,ut as E,xa as D,xs as O,z as k}from"./index-DUXM0NlS.js";import"./layout-yR9rlvEw.js";var A=e(t(),1),j=n(),M=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,o=t===`sm`?13:20,c=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,j.jsx)(d,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:o,strokeWidth:c}),i=`bg-blue-600`;break;case`like`:r=(0,j.jsx)(_,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:c}),i=`bg-pink-600`;break;case`reply`:r=(0,j.jsx)(D,{className:`mr-px mb-px`,color:a,size:o,strokeWidth:c}),i=`bg-purple-600`;break;case`repost`:r=(0,j.jsx)(s,{color:a,size:o,strokeWidth:c}),i=`bg-green-500`;break;case`mention`:r=(0,j.jsx)(O,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:o,strokeWidth:c}),i=`bg-orange-500`;break}return(0,j.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},N=A.createContext(void 0),P=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,j.jsx)(N.Provider,{value:{onClick:r,url:i},children:(0,j.jsx)(`div`,{className:`group relative -mx-4 -my-px ${e?`grid`:`flex`} ${t?`items-center`:`items-start`} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-100 ${a}`,role:`button`,onClick:r,children:n})});P.Icon=({size:e=`lg`,type:t})=>(0,j.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,j.jsx)(M,{notificationType:t,size:e})}),P.Avatars=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),P.Content=({children:e})=>(0,j.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var F=()=>(0,j.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function I(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function L(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${I(e.createdAt)}`,o=`_seq${r}`;switch(e.type){case`like`:e.post?.id&&(i=`like_${e.post.id}${a}${o}`);break;case`reply`:i=`reply_${e.id}`;break;case`repost`:e.post?.id&&(i=`repost_${e.post.id}${a}${o}`);break;case`follow`:i=`follow_${a}${o}`;break;case`mention`:i=`mention_${e.id}`;break}t[i]||(t[i]={id:e.id,type:e.type,actors:[],post:e.post,inReplyTo:e.inReplyTo,createdAt:e.createdAt}),t[i].actors.find(t=>t.id===e.actor.id)||t[i].actors.push(e.actor)}),Object.values(t)}var R=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=l(),s=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{actor:t,align:`center`,isCurrentUser:!1,children:(0,j.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&y(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,j.jsxs)(j.Fragment,{children:[s,` followed you`]});case`like`:return(0,j.jsxs)(j.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,j.jsxs)(j.Fragment,{children:[s,` reposted your `,e.post?.type===`article`?`post`:`note`]});case`reply`:if(e.inReplyTo&&typeof e.inReplyTo!=`string`)return s;break;case`mention`:return s}return(0,j.jsx)(j.Fragment,{})},z=({content:e,className:t,stripTags:n=[]})=>{let r=(0,A.useRef)(null),i=l();return(0,A.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),y(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,j.jsx)(`div`,{dangerouslySetInnerHTML:{__html:x(E(e||``,n))},ref:r,className:t})},B=()=>{let[e,t]=A.useState({}),n=l(),s=e=>{t(t=>({...t,[e]:!t[e]}))},d=()=>{},{data:_,error:T,fetchNextPage:D,hasNextPage:O,isFetchingNextPage:N,isLoading:I}=a(`index`),B=_?.pages.flatMap(e=>L(e.notifications))??Array(10).fill({actors:[{}]}),V=(0,A.useRef)(null),H=(0,A.useRef)(null);(0,A.useEffect)(()=>(V.current&&V.current.disconnect(),V.current=new IntersectionObserver(e=>{e[0].isIntersecting&&O&&!N&&D()}),H.current&&V.current.observe(H.current),()=>{V.current&&V.current.disconnect()}),[O,N,D]);let U=(e,t)=>{switch(e.type){case`like`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`reply`:e.post&&e.inReplyTo&&n(`/notes/${encodeURIComponent(e.post.id)}`);break;case`repost`:e.post&&n(`/${e.post.type===`article`?`reader`:`notes`}/${encodeURIComponent(e.post.id)}`);break;case`follow`:e.actors.length>1?s(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&y(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return T&&c(T)?(0,j.jsx)(u,{errorCode:T.code,statusCode:T.statusCode}):(0,j.jsx)(o,{children:(0,j.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[I===!1&&B.length===0&&(0,j.jsxs)(k,{children:[(0,j.jsx)(m,{children:(0,j.jsx)(h,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),B.length>0&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:B.map((t,a)=>(0,j.jsxs)(A.Fragment,{children:[(0,j.jsxs)(P,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>U(t,a),children:[I?(0,j.jsx)(w,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,j.jsx)(P.Icon,{type:t.type}):(0,j.jsxs)(`div`,{className:`relative`,children:[(0,j.jsx)(b,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,j.jsx)(M,{className:`absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black`,notificationType:t.type,size:`sm`})]}),t.actors.length>1&&(0,j.jsx)(P.Avatars,{children:(0,j.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,j.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${a}`]&&t.actors.slice(0,5).map(e=>(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},className:`-ml-2 bg-[#F3F3F3]! outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-100 dark:outline-black group-hover:dark:outline-gray-950`,size:`notification`},e.id)),t.actors.length>5&&!e[t.id||`${t.type}_${a}`]&&(0,j.jsx)(`div`,{className:`absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white`,children:`+${r(t.actors.length-5)}`}),t.actors.length>1&&(0,j.jsxs)(f,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),s(t.id||`${t.type}_${a}`)},children:[(0,j.jsx)(S,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,j.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,j.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${a}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${a}`]&&t.actors.length>1&&(0,j.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,j.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&y(e.handle,n)},children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,j.jsx)(b,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,j.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,j.jsx)(`span`,{className:`ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600`,children:e.handle})]}),t.type===`follow`&&!e.followedByMe&&e.handle&&(0,j.jsx)(v,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,j.jsxs)(P.Content,{children:[(0,j.jsx)(`div`,{children:I?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(w,{}),(0,j.jsx)(w,{className:`w-full max-w-60`})]}):(0,j.jsxs)(`div`,{className:`flex justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:(0,j.jsx)(R,{group:t})}),t.actors.length<2&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,j.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:i(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,j.jsx)(v,{following:!1,handle:t.actors[0].handle,variant:`link`})]})}),(t.type===`reply`&&t.inReplyTo||t.type===`mention`||t.type===`like`&&!t.post?.name&&t.post?.content||t.type===`repost`&&!t.post?.name&&t.post?.content)&&(t.type!==`reply`&&t.type!==`mention`?(0,j.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[t.post?.type===`article`&&t.post?.title&&(0,j.jsxs)(j.Fragment,{children:[t.post.title,` — `]}),(0,j.jsx)(`span`,{dangerouslySetInnerHTML:{__html:x(E(t.post?.content||``))}})]}):(0,j.jsx)(j.Fragment,{children:(0,j.jsxs)(`div`,{className:`mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-950/30 group-hover:dark:bg-black/40`,children:[(0,j.jsx)(z,{className:`ap-note-content text-pretty`,content:t.post?.content||``,stripTags:[`a`]}),t.post&&t.post.attachments&&t.post.attachments.length>0&&(0,j.jsx)(`div`,{className:`notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]`,children:p({...t.post,type:`Note`,attachment:t.post.attachments})})]})})),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,j.jsx)(`div`,{className:`mt-1.5`,children:(0,j.jsx)(C,{actor:{...t.actors[0],icon:{url:t.actors[0].avatarUrl||``},id:t.actors[0].url,preferredUsername:t.actors[0].handle?.replace(/^@([^@]+)@.*$/,`$1`)||`unknown`},buttonClassName:`hover:bg-gray-200`,commentCount:t.post.replyCount||0,layout:`notification`,likeCount:t.post.likeCount||0,object:{...t.post,liked:t.post.likedByMe,reposted:t.post.repostedByMe},repostCount:t.post.repostCount||0,onLikeClick:d})})]})]}),a<B.length-1&&(0,j.jsx)(`div`,{className:`pl-[52px]`,children:(0,j.jsx)(F,{})})]},t.id||`${t.type}_${a}`))}),(0,j.jsx)(`div`,{ref:H,className:`h-1`}),N&&(0,j.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,j.jsx)(g,{size:`md`})})]})]})})};export{B as default};
|