ghost 6.62.0 → 6.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/tryghost-adapter-base-jobs-0.0.0.tgz +0 -0
- package/components/tryghost-adapter-base-scheduling-0.2.3.tgz +0 -0
- package/components/tryghost-adapter-base-sso-0.1.3.tgz +0 -0
- package/components/tryghost-admin-api-schema-0.0.0.tgz +0 -0
- package/components/tryghost-checkout-0.0.0.tgz +0 -0
- package/components/tryghost-i18n-0.0.0.tgz +0 -0
- package/components/tryghost-kg-card-factory-5.2.4.tgz +0 -0
- package/components/tryghost-kg-clean-basic-html-4.3.4.tgz +0 -0
- package/components/tryghost-kg-converters-1.2.5.tgz +0 -0
- package/components/tryghost-kg-default-cards-10.3.5.tgz +0 -0
- package/components/tryghost-kg-default-nodes-2.2.1.tgz +0 -0
- package/components/tryghost-kg-default-transforms-1.3.4.tgz +0 -0
- package/components/tryghost-kg-html-to-lexical-1.4.0.tgz +0 -0
- package/components/tryghost-kg-lexical-html-renderer-1.5.0.tgz +0 -0
- package/components/tryghost-kg-markdown-html-renderer-7.2.4.tgz +0 -0
- package/components/tryghost-kg-utils-1.1.4.tgz +0 -0
- package/components/tryghost-limit-service-0.0.0.tgz +0 -0
- package/components/tryghost-metafield-types-0.0.0.tgz +0 -0
- package/content/themes/source/package.json +2 -2
- package/content/themes/source/partials/post-card.hbs +1 -1
- package/core/boot.js +7 -5
- package/core/built/admin/assets/{about-Dyae_UT6.js → about-C1C3s5-g.js} +1 -1
- package/core/built/admin/assets/accordion-CxGsDKwa.js +1 -0
- package/core/built/admin/assets/{account-migration-CESa0mnX.js → account-migration-CbUhW6gk.js} +1 -1
- package/core/built/admin/assets/activitypub/{account-migration-By69CgCp.js → account-migration-KA6Jjf9L.js} +7 -7
- package/core/built/admin/assets/activitypub/activitypub.js +3 -3
- package/core/built/admin/assets/activitypub/{avatar-DLPL3Abs.js → avatar-DVJF5bxP.js} +2 -2
- package/core/built/admin/assets/activitypub/{avatar-flipboard-C9iDY-QV.js → avatar-flipboard-csQaNeYK.js} +2 -2
- package/core/built/admin/assets/activitypub/{bluesky-sharing-BJcPMrDd.js → bluesky-sharing-C7nTDMvw.js} +9 -9
- package/core/built/admin/assets/activitypub/{content-formatters-3rTHg3mp.js → content-formatters-CLcjaBwV.js} +4 -4
- package/core/built/admin/assets/activitypub/{copy-DIAOQoCZ.js → copy-DcOh8kXw.js} +2 -2
- package/core/built/admin/assets/activitypub/{domain-DUR4xSkV.js → domain-fZ-X8i4-.js} +9 -9
- package/core/built/admin/assets/activitypub/{edit-profile-BqtfzxCp.js → edit-profile-BqMLQV88.js} +6 -6
- package/core/built/admin/assets/activitypub/{explore-BxuJd-J4.js → explore-B4yPoP8E.js} +10 -10
- package/core/built/admin/assets/activitypub/{feed-BM1TcksA.js → feed-BRC_mvAe.js} +9 -9
- package/core/built/admin/assets/activitypub/{field-Dn7HHx2-.js → field-COacNgOt.js} +3 -3
- package/core/built/admin/assets/activitypub/{hash-Bm3WxYN4.js → hash-C7u-irQQ.js} +2 -2
- package/core/built/admin/assets/activitypub/{inbox-CCjkuow2.js → inbox-BW-yvUoN.js} +10 -10
- package/core/built/admin/assets/activitypub/{inbox-d8oJRTf4.js → inbox-CbTTdDQ3.js} +2 -2
- package/core/built/admin/assets/activitypub/{label-1AA_s9Fa.js → label-kPMmYI7l.js} +3 -3
- package/core/built/admin/assets/activitypub/layout-BL4_jtuV.js +1 -0
- package/core/built/admin/assets/activitypub/{moderation-CnmxEB8w.js → moderation-CuidJzc0.js} +10 -10
- package/core/built/admin/assets/activitypub/{note-ZKc_Bnba.js → note-CAMRRSqD.js} +7 -7
- package/core/built/admin/assets/activitypub/{notifications-CB2tJZau.js → notifications-BmNlXGgp.js} +9 -9
- package/core/built/admin/assets/activitypub/{onboarding-BsJ9E5qf.js → onboarding-Bqg7fh_L.js} +2 -2
- package/core/built/admin/assets/activitypub/{onboarding-CSUJJIlh.js → onboarding-Dmun9jr_.js} +2 -2
- package/core/built/admin/assets/activitypub/{preferences-0-JZnUkI.js → preferences--oH19wf9.js} +11 -11
- package/core/built/admin/assets/activitypub/{profile-C35cFIhM.js → profile-DH_tQx2D.js} +14 -14
- package/core/built/admin/assets/activitypub/{reply-DYK5vVqb.js → reply-Cap9PxSH.js} +2 -2
- package/core/built/admin/assets/activitypub/{routes-BD4vscyc.js → routes-DdyY9uFF.js} +30 -30
- package/core/built/admin/assets/activitypub/{separator-BbQqTm-p.js → separator-CAxxu8VV.js} +3 -3
- package/core/built/admin/assets/activitypub/{settings-BsMROdqh.js → settings-B6EEcVkW.js} +6 -6
- package/core/built/admin/assets/activitypub/{site-O0RL9YCN.js → site-BYps63oh.js} +2 -2
- package/core/built/admin/assets/activitypub/{step-1-BMSx7c_X.js → step-1-CKjR2KAm.js} +6 -6
- package/core/built/admin/assets/activitypub/{step-2-DtPQzlTH.js → step-2-B6PKfOUQ.js} +6 -6
- package/core/built/admin/assets/activitypub/{step-3-CLlOZTyt.js → step-3-C-qBbcUo.js} +11 -11
- package/core/built/admin/assets/activitypub/{tabs-Dxk-b9M-.js → tabs-DLhZtVde.js} +6 -6
- package/core/built/admin/assets/activitypub/{topic-filter-5yZH6tId.js → topic-filter-DsUOuu0k.js} +3 -3
- package/core/built/admin/assets/activitypub/{use-activity-pub-queries-CV50qe03.js → use-activity-pub-queries-CX9snsLs.js} +3 -3
- package/core/built/admin/assets/activitypub/{use-navigate-with-base-path-Bmk5h4lW.js → use-navigate-with-base-path-DsJTGDSS.js} +988 -959
- package/core/built/admin/assets/activitypub/{use-reply-chain-data-Cbvzgjzd.js → use-reply-chain-data-AJi9zkzm.js} +5 -5
- package/core/built/admin/assets/activitypub/{users-BjcoP_HC.js → users-inweyKL5.js} +186 -160
- package/core/built/admin/assets/activitypub/{x-DbQZOLiI.js → x-DR8AT3-4.js} +2 -2
- package/core/built/admin/assets/{add-integration-modal-BlF6rs_f.js → add-integration-modal-BT_onDJy.js} +1 -1
- package/core/built/admin/assets/{add-newsletter-modal-CglVQqah.js → add-newsletter-modal-Cx1kQpiY.js} +1 -1
- package/core/built/admin/assets/{add-recommendation-modal-wz7BsuaG.js → add-recommendation-modal-B5nvAhvr.js} +1 -1
- package/core/built/admin/assets/{analytics-C4HE1gBg.js → analytics-DjoJWPI7.js} +1 -1
- package/core/built/admin/assets/{announcement-bar-modal-Ci4zz8jO.js → announcement-bar-modal-Dwd0EGFP.js} +1 -1
- package/core/built/admin/assets/{api-keys-3-0vJC3Y.js → api-keys-BGPzLHzA.js} +1 -1
- package/core/built/admin/assets/{api-keys-Ck-Yteiv.js → api-keys-BoeacM-s.js} +1 -1
- package/core/built/admin/assets/{audience-CtbA54Sn.js → audience-ceV3XVHq.js} +1 -1
- package/core/built/admin/assets/automated-emails-BLesE41L.js +1 -0
- package/core/built/admin/assets/{automations-sAcJ1334.js → automations-BN4u3GR8.js} +1 -1
- package/core/built/admin/assets/automations-C-ZTUwW3.js +1 -0
- package/core/built/admin/assets/{bluesky-sharing-BEtJ_gL_.js → bluesky-sharing-vzh-oPXL.js} +1 -1
- package/core/built/admin/assets/{breadcrumb-zUrZrBtW.js → breadcrumb-CaLk2b7D.js} +1 -1
- package/core/built/admin/assets/{button-eNMKQWXr.js → button-Dvcv1QSR.js} +1 -1
- package/core/built/admin/assets/calendar-Bl9RLcZX.js +1 -0
- package/core/built/admin/assets/{chart-helpers-CfBKt0vT.js → chart-helpers-FHywU0pj.js} +1 -1
- package/core/built/admin/assets/{checkbox-CgOn_tKW.js → checkbox-BtayFtjg.js} +1 -1
- package/core/built/admin/assets/chunk.254.035b85ec456ebbd7336b.js +440 -0
- package/core/built/admin/assets/{chunk.524.a697dee88db67fdf6021.js → chunk.524.e6975095fccdf22d90f8.js} +5 -5
- package/core/built/admin/assets/{chunk.582.5ed5d124cfca9c259b9c.js → chunk.582.98b485f9b2802f540897.js} +6 -6
- package/core/built/admin/assets/{chunk.492.f24d855d7e3f3aad261c.js → chunk.901.4ccc639821020230bcca.js} +9949 -7921
- package/core/built/admin/assets/{code-editor-view-K2wI-I5f.js → code-editor-view-C3ZfoF1X.js} +1 -1
- package/core/built/admin/assets/{code-editor-view-BYNoAoNV.js → code-editor-view-CAyRWy1s.js} +1 -1
- package/core/built/admin/assets/{color-picker-Ddw80xX6.js → color-picker-G4kGR7rp.js} +1 -1
- package/core/built/admin/assets/{color-picker-field-D9nUhvA7.js → color-picker-field-DQFVTNnT.js} +1 -1
- package/core/built/admin/assets/{combobox-w9j8PPQT.js → combobox-BnYzgEB4.js} +1 -1
- package/core/built/admin/assets/{command-BfpHORBv.js → command-C_vyTikI.js} +1 -1
- package/core/built/admin/assets/comments-aBrxfnZf.js +1 -0
- package/core/built/admin/assets/{config-DOMQDZGZ.js → config-kSHvwdTG.js} +1 -1
- package/core/built/admin/assets/{confirmation-context-CBM8G0Vj.js → confirmation-context-DwXX_Y5h.js} +1 -1
- package/core/built/admin/assets/{content-api-modal-TXRz3U7S.js → content-api-modal-D2G0nJP6.js} +1 -1
- package/core/built/admin/assets/{context-menu-_QMdd3kp.js → context-menu-DOVB6yaz.js} +1 -1
- package/core/built/admin/assets/{copy-field-6N01S07E.js → copy-field-DCJwh9qf.js} +1 -1
- package/core/built/admin/assets/{create-ghost-browse-value-source-qIBymvvf.js → create-ghost-browse-value-source-5C53jJaX.js} +1 -1
- package/core/built/admin/assets/custom-field-type-option-BAuW0F-E.js +1 -0
- package/core/built/admin/assets/{custom-integration-modal-DmNquxUV.js → custom-integration-modal-AbJGVyKc.js} +1 -1
- package/core/built/admin/assets/{date-range-select-uvz_DtPh.js → date-range-select-BY3K-ukj.js} +1 -1
- package/core/built/admin/assets/design-and-theme-modal-BvEy4_pC.js +2 -0
- package/core/built/admin/assets/{dirty-confirm-dialog-BZ1iytEd.js → dirty-confirm-dialog-DVPuGz3U.js} +1 -1
- package/core/built/admin/assets/{disabled-sources-indicator-DMRrxsiJ.js → disabled-sources-indicator-Cy7Zp4c8.js} +1 -1
- package/core/built/admin/assets/{domain-BNYrt0aD.js → domain-Dl61QGuk.js} +1 -1
- package/core/built/admin/assets/{dropzone-D7nFdAe5.js → dropzone-Dtz5Rmjt.js} +4 -4
- package/core/built/admin/assets/edit-profile-DNJSMDwm.js +1 -0
- package/core/built/admin/assets/editor-DbAen9zf.js +8 -0
- package/core/built/admin/assets/editor-screen-BFWThIai.js +26 -0
- package/core/built/admin/assets/email-sending-status-context-CWDOD1FN.js +1 -0
- package/core/built/admin/assets/email-sending-status-provider-DCPkDICt.js +1 -0
- package/core/built/admin/assets/emails-vFMk4yYl.js +1 -0
- package/core/built/admin/assets/{embed-signup-form-modal-Ds6mPEi5.js → embed-signup-form-modal-DGqsORxS.js} +1 -1
- package/core/built/admin/assets/{explore-UY10Egsp.js → explore-nnRr1Fja.js} +1 -1
- package/core/built/admin/assets/feature-flag-overrides-context-DQjdJFAk.js +1 -0
- package/core/built/admin/assets/{feature-image-placeholder-D1iF_8bc.js → feature-image-placeholder-BrIHmPs8.js} +1 -1
- package/core/built/admin/assets/{feed-81C8mJWR.js → feed-BNUcNu-W.js} +1 -1
- package/core/built/admin/assets/feedback-DJ4Zb9rZ.js +1 -0
- package/core/built/admin/assets/{field-Dihp5p18.js → field-C93_Mg6j.js} +1 -1
- package/core/built/admin/assets/filter-sources-CGJb4C5r.js +1 -0
- package/core/built/admin/assets/{filters-DirqNXjH.js → filters--kKP-EC8.js} +1 -1
- package/core/built/admin/assets/filters-DxA_a4FP.js +1 -0
- package/core/built/admin/assets/{first-promoter-modal-CT6MxYZb.js → first-promoter-modal-BYDtrz2S.js} +1 -1
- package/core/built/admin/assets/focus-koenig-editor-on-bottom-click-BbSnGOtK.js +1 -0
- package/core/built/admin/assets/{ghost-8eabfc1ece81b03cf7b90780d31487e8.css → ghost-8fd5bb799356bbefb254210ba7e1236d.css} +1 -1
- package/core/built/admin/assets/{ghost-c2848508292937415f20f5a830eea59e.js → ghost-b4e8a403baba61905cd7560e30b9732d.js} +43 -27
- package/core/built/admin/assets/{ghost-dark-a7bebe2c561f55369dcf29f4c820f7ff.css → ghost-dark-cac0cb2d5bb78e9bd14d8d1c2768ed45.css} +1 -1
- package/core/built/admin/assets/{gift-link-modal-CQVAye17.js → gift-link-modal-B7u5bD4e.js} +1 -1
- package/core/built/admin/assets/{gift-links-DLDS7ljO.js → gift-links-CfLSnst2.js} +1 -1
- package/core/built/admin/assets/growth-Cd1uO9d2.js +1 -0
- package/core/built/admin/assets/growth-aG32xfdE.js +3 -0
- package/core/built/admin/assets/{history-modal-CFd1Hvx6.js → history-modal-Df8lW8h-.js} +1 -1
- package/core/built/admin/assets/hooks-Cy_-oZ4o.js +2 -0
- package/core/built/admin/assets/{html-field-CJBCLTvv.js → html-field-DA4eU7eq.js} +1 -1
- package/core/built/admin/assets/{images-scfkWZiK.js → images-KXmyO3Ss.js} +1 -1
- package/core/built/admin/assets/{inbox-Mcp4DXZN.js → inbox-gJHG7_xd.js} +6 -6
- package/core/built/admin/assets/index-BHHXtR5C.css +2 -0
- package/core/built/admin/assets/index-CgMCwsxN.js +4 -0
- package/core/built/admin/assets/index.es-CY6-yuw9.js +1 -0
- package/core/built/admin/assets/{input-group-CMhe2DvY.js → input-group-BE8rM2y1.js} +1 -1
- package/core/built/admin/assets/{integrations-Bjbu86Z0.js → integrations-B4kuRBFY.js} +1 -1
- package/core/built/admin/assets/{invite-user-modal-DfheMXs0.js → invite-user-modal-B4CuNcx4.js} +1 -1
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.js +2 -2
- package/core/built/admin/assets/koenig-lexical/koenig-lexical.umd.js +2 -2
- package/core/built/admin/assets/{koenig-lexical-DBSqAuiI.js → koenig-lexical-CGXb0F8o.js} +2 -2
- package/core/built/admin/assets/koenig-loader-BeM5rFPX.js +2 -0
- package/core/built/admin/assets/{kpi-card-DBRMfGOW.js → kpi-card-B21aToe8.js} +1 -1
- package/core/built/admin/assets/{kpi-card-DFafD1qq.js → kpi-card-pz6Wv4Ae.js} +1 -1
- package/core/built/admin/assets/{kpi-helpers-Cv8i8hns.js → kpi-helpers-Dq5jelmP.js} +1 -1
- package/core/built/admin/assets/{kpi-tabs-BJItvLYm.js → kpi-tabs-DEZHpKUt.js} +1 -1
- package/core/built/admin/assets/{label-BnSCvffu.js → label-OLCzze8N.js} +1 -1
- package/core/built/admin/assets/label-picker-BigOvMPV.js +1 -0
- package/core/built/admin/assets/{labels-CH3Kn8RV.js → labels-Dr0SgUQD.js} +1 -1
- package/core/built/admin/assets/layout-DUTL8SH5.js +1 -0
- package/core/built/admin/assets/lib-7QPTI0FS.js +1 -0
- package/core/built/admin/assets/link-helpers-BRAg9SCj.js +1 -0
- package/core/built/admin/assets/links-BDHPTlyj.js +1 -0
- package/core/built/admin/assets/{member-custom-fields-DDQV6QeG.js → member-custom-fields-TRTHCAz9.js} +1 -1
- package/core/built/admin/assets/member-detail-b6dRwc3C.js +1 -0
- package/core/built/admin/assets/members-Czt5lJSc.js +4 -0
- package/core/built/admin/assets/{moderation-AgCIEso4.js → moderation-ZWefD9uH.js} +1 -1
- package/core/built/admin/assets/{multi-select-combobox-BcITkUVr.js → multi-select-combobox-CT13MTo-.js} +1 -1
- package/core/built/admin/assets/navigation-modal-C8FEhBK5.js +1 -0
- package/core/built/admin/assets/newsletter-5VYW4RyJ.js +1 -0
- package/core/built/admin/assets/newsletter-detail-modal-ChjC0ZqH.js +1 -0
- package/core/built/admin/assets/{newsletter-emails-DKzwafuh.js → newsletter-emails-DZH6I-PY.js} +1 -1
- package/core/built/admin/assets/{newsletters-BRBb_uQC.js → newsletters-DOC9KBcX.js} +1 -1
- package/core/built/admin/assets/newsletters-Rq1M3GD-.js +1 -0
- package/core/built/admin/assets/{note-DyGHtS9a.js → note-DIV-Pojr.js} +1 -1
- package/core/built/admin/assets/{notifications-ZgWniKna.js → notifications-s20-H49V.js} +1 -1
- package/core/built/admin/assets/{offers-9J1CSiLy.js → offers--e2nGvkW.js} +1 -1
- package/core/built/admin/assets/{offers-container-modal-B-E8TIWr.js → offers-container-modal-BmG5M5Tv.js} +1 -1
- package/core/built/admin/assets/onboarding-CUuy9unR.js +1 -0
- package/core/built/admin/assets/{onboarding-CzIsre-d.js → onboarding-pXyct0Jm.js} +1 -1
- package/core/built/admin/assets/{onboarding-route-CaavZulg.js → onboarding-route-CK4pcXoR.js} +1 -1
- package/core/built/admin/assets/overview-CaPsciMs.js +1 -0
- package/core/built/admin/assets/overview-a8GfcsKX.js +1 -0
- package/core/built/admin/assets/{page-header-De0VzKBi.js → page-header-DM_KyoFI.js} +1 -1
- package/core/built/admin/assets/{pagemenu-B5KKCpbA.js → pagemenu-vgZVUVKR.js} +1 -1
- package/core/built/admin/assets/pages-CjDY2CBI.js +1 -0
- package/core/built/admin/assets/pages-route-BzKZYdV5.js +1 -0
- package/core/built/admin/assets/{pintura-modal-BZ2J9w3n.js → pintura-modal-DExCF1ii.js} +1 -1
- package/core/built/admin/assets/{portal-frame-B6Hr9wHc.js → portal-frame-Cqanidq4.js} +1 -1
- package/core/built/admin/assets/portal-modal-oinBgA27.js +1 -0
- package/core/built/admin/assets/post-analytics-C5oJ1dWV.js +1 -0
- package/core/built/admin/assets/post-analytics-header-OATo3X_r.js +1 -0
- package/core/built/admin/assets/post-analytics-provider-tOpIVGT5.js +1 -0
- package/core/built/admin/assets/post-helpers-C88JBa4D.js +1 -0
- package/core/built/admin/assets/post-share-modal-DvhC1XgV.js +1 -0
- package/core/built/admin/assets/post-utils-DKF4mfuo.js +1 -0
- package/core/built/admin/assets/posts-list-screen-o4ZjbgS3.js +2 -0
- package/core/built/admin/assets/posts-pCPrhQeR.js +1 -0
- package/core/built/admin/assets/posts-route-9F--xdIb.js +1 -0
- package/core/built/admin/assets/{preferences-C5YJLp74.js → preferences--vNubsqD.js} +2 -2
- package/core/built/admin/assets/{preview-modal-BfeFqi5y.js → preview-modal-YYbzlYdO.js} +1 -1
- package/core/built/admin/assets/profile-BllKV3dR.js +1 -0
- package/core/built/admin/assets/radio-group-DL8GI8rt.js +1 -0
- package/core/built/admin/assets/{referrers-CnhCMWCs.js → referrers-D8oHPmDB.js} +1 -1
- package/core/built/admin/assets/router-provider-BSvTXgZY.js +1 -0
- package/core/built/admin/assets/schemas-BoYdB6YU.js +64 -0
- package/core/built/admin/assets/{select-cb0t_TAJ.js → select-v5YbA3Mw.js} +1 -1
- package/core/built/admin/assets/settings-PEsZupw1.js +4 -0
- package/core/built/admin/assets/{settings-breadcrumbs-DLzbRRSt.js → settings-breadcrumbs-NwPnCTC7.js} +1 -1
- package/core/built/admin/assets/{settings-DZqxR0Da.js → settings-u_s1CRkr.js} +1 -1
- package/core/built/admin/assets/{share-modal-D2-Bz1_I.js → share-modal-SskCmVGL.js} +1 -1
- package/core/built/admin/assets/{slack-modal-DYDTUria.js → slack-modal-XxSJiYgo.js} +1 -1
- package/core/built/admin/assets/{sort-button-VVeQjjbu.js → sort-button-Cx1KtINE.js} +1 -1
- package/core/built/admin/assets/{source-icon-Ck5_5Kgq.js → source-icon-Bdp9Im_5.js} +1 -1
- package/core/built/admin/assets/stats-D9PDLS3x.js +1 -0
- package/core/built/admin/assets/stats-view-W2g6Jsd-.js +1 -0
- package/core/built/admin/assets/{step-1-CsaBjeN4.js → step-1-BQYzvBzr.js} +1 -1
- package/core/built/admin/assets/{step-2-D2vnxOOM.js → step-2-xES32xJV.js} +1 -1
- package/core/built/admin/assets/{step-3-wBoLdGEb.js → step-3-DA_XK5kW.js} +2 -2
- package/core/built/admin/assets/{stripe-button-CDgLz0S0.js → stripe-button-CVsLHelt.js} +1 -1
- package/core/built/admin/assets/{stripe-connect-modal-CSjMJetP.js → stripe-connect-modal-ClmLOMGS.js} +1 -1
- package/core/built/admin/assets/style-Wd9nQubI.css +1 -0
- package/core/built/admin/assets/{table-Do6iQ83Q.js → table-BenqVupI.js} +1 -1
- package/core/built/admin/assets/{tabs-D2yWLMp_.js → tabs-eBBlxPp8.js} +1 -1
- package/core/built/admin/assets/tag-detail-Ce8Se2qd.js +2 -0
- package/core/built/admin/assets/tag-picker-C3UR-uJ-.js +1 -0
- package/core/built/admin/assets/tags-B-kJxCs7.js +1 -0
- package/core/built/admin/assets/{tags-zTFiKRpb.js → tags-ChfdwJyS.js} +1 -1
- package/core/built/admin/assets/{testimonials-modal-CtnZBJKl.js → testimonials-modal-9Q6fT06V.js} +1 -1
- package/core/built/admin/assets/tier-detail-modal-CDyYdqK7.js +1 -0
- package/core/built/admin/assets/tiers-BCpIOGQr.js +1 -0
- package/core/built/admin/assets/{toggle-group-ByUJsxwD.js → toggle-group-CviIkyok.js} +1 -1
- package/core/built/admin/assets/{topic-filter-BgC3g5_v.js → topic-filter-I2jCBGxm.js} +1 -1
- package/core/built/admin/assets/{transistor-modal-Drr0SNfo.js → transistor-modal-p53u3W8y.js} +1 -1
- package/core/built/admin/assets/{trend-badge-6ye93YAW.js → trend-badge-CideVzQd.js} +1 -1
- package/core/built/admin/assets/{unsplash-modal-p6AoQoWp.js → unsplash-modal-DY8UcKcE.js} +1 -1
- package/core/built/admin/assets/{use-analytics-data-CWCMAESo.js → use-analytics-data-DAIGcr2f.js} +1 -1
- package/core/built/admin/assets/{use-check-theme-limit-error-Cw3WQHy8.js → use-check-theme-limit-error-DRUjK4YM.js} +1 -1
- package/core/built/admin/assets/use-filter-params-JkZhIS8L.js +1 -0
- package/core/built/admin/assets/{use-filterable-api-CzXcpUh8.js → use-filterable-api-BVEVMrhZ.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-DCVG3s9w.js → use-growth-stats-937CUj6j.js} +1 -1
- package/core/built/admin/assets/use-host-limits-D0Dv3tKA.js +1 -0
- package/core/built/admin/assets/{use-limiter-D2WRRx0H.js → use-limiter-CohWfzvK.js} +1 -1
- package/core/built/admin/assets/{use-navigate-with-base-path-BHPA228f.js → use-navigate-with-base-path-BkxcPj5l.js} +1 -1
- package/core/built/admin/assets/use-pintura-config-xgytjU35.js +1 -0
- package/core/built/admin/assets/{use-pintura-editor-BfN1UwzH.js → use-pintura-editor-CaV1mbfO.js} +1 -1
- package/core/built/admin/assets/{use-post-referrers-Czg47m8s.js → use-post-referrers-BCQI7fDg.js} +1 -1
- package/core/built/admin/assets/{use-reply-chain-data-ns0caK8k.js → use-reply-chain-data-CYRhoaxY.js} +1 -1
- package/core/built/admin/assets/{use-router-history-entry-uldn7zJO.js → use-router-history-entry-NOKcd--l.js} +1 -1
- package/core/built/admin/assets/{use-setting-group-DpcuCUDg.js → use-setting-group-bLKMwoBT.js} +1 -1
- package/core/built/admin/assets/{use-settings-navigation-CZjGrhsp.js → use-settings-navigation-B-qrriKD.js} +1 -1
- package/core/built/admin/assets/{use-simple-pagination-DzJWobPR.js → use-simple-pagination-CNPd6Rf6.js} +1 -1
- package/core/built/admin/assets/use-staff-users-pRIMIyiW.js +1 -0
- package/core/built/admin/assets/{use-tinybird-query-CSnGXzZh.js → use-tinybird-query-CmdbCS9X.js} +1 -1
- package/core/built/admin/assets/{use-tinybird-token-DTOKRR7e.js → use-tinybird-token-KLne235s.js} +1 -1
- package/core/built/admin/assets/{use-unsaved-changes-guard-CBzs-KPi.js → use-unsaved-changes-guard-7-ug0JdH.js} +1 -1
- package/core/built/admin/assets/use-upgrade-route-Dm_qqKr0.js +1 -0
- package/core/built/admin/assets/{use-url-input-DFr8lCbS.js → use-url-input-fvp-TpPx.js} +1 -1
- package/core/built/admin/assets/user-detail-modal-D3KlGYv-.js +1 -0
- package/core/built/admin/assets/{users-Cg-OeGzC.js → users-DVNWrqg9.js} +1 -1
- package/core/built/admin/assets/{vendor-5753232c7d6ffb3c44e1eb0a02133953.js → vendor-2dd263291938d407802568d3357ec69e.js} +19 -17
- package/core/built/admin/assets/{virtual-list-BW-padMe.js → virtual-list-CZ3RK2Yf.js} +1 -1
- package/core/built/admin/assets/{web-C1v33ehA.js → web-ClEJsCAj.js} +2 -2
- package/core/built/admin/assets/web-X9rdnrtq.js +1 -0
- package/core/built/admin/assets/{zapier-modal-BBFfI6Ml.js → zapier-modal-DfVhV17j.js} +1 -1
- package/core/built/admin/index.html +19 -18
- package/core/server/adapters/jobs/InMemoryJobsBackend.js +74 -29
- package/core/server/api/endpoints/authentication.js +1 -2
- package/core/server/api/endpoints/authors-public.js +15 -5
- package/core/server/api/endpoints/emails.js +13 -0
- package/core/server/api/endpoints/index.js +8 -0
- package/core/server/api/endpoints/member-metafields-members.js +23 -0
- package/core/server/api/endpoints/member-metafields.js +33 -20
- package/core/server/api/endpoints/members-account.js +42 -0
- package/core/server/api/endpoints/newsletters-public.js +10 -1
- package/core/server/api/endpoints/pages-public.js +15 -5
- package/core/server/api/endpoints/posts-public.js +15 -5
- package/core/server/api/endpoints/tags-public.js +22 -3
- package/core/server/api/endpoints/tiers-checkout-config.js +2 -2
- package/core/server/api/endpoints/tiers-public.js +38 -1
- package/core/server/api/endpoints/users.js +2 -2
- package/core/server/api/endpoints/utils/api-filter-utils.js +170 -3
- package/core/server/api/endpoints/utils/public-cache-keys.js +3 -0
- package/core/server/api/endpoints/utils/serializers/input/authors.js +2 -0
- package/core/server/api/endpoints/utils/serializers/input/members.js +16 -2
- package/core/server/api/endpoints/utils/serializers/input/pages.js +2 -0
- package/core/server/api/endpoints/utils/serializers/input/posts.js +2 -0
- package/core/server/api/endpoints/utils/serializers/input/tags.js +2 -0
- package/core/server/api/endpoints/utils/serializers/output/emails.js +7 -0
- package/core/server/api/endpoints/utils/serializers/output/index.js +4 -0
- package/core/server/api/endpoints/utils/serializers/output/member-metafields.js +3 -3
- package/core/server/api/endpoints/utils/serializers/output/members-account.js +19 -0
- package/core/server/api/endpoints/utils/serializers/output/members-csv-transform.js +1 -1
- package/core/server/api/endpoints/utils/serializers/output/tiers.js +10 -2
- package/core/server/api/endpoints/utils/serializers/output/users.js +0 -10
- package/core/server/data/exporter/table-lists.js +3 -3
- package/core/server/data/migrations/versions/6.53/2026-07-15-20-22-53-add-members-custom-field-values.js +1 -1
- package/core/server/data/migrations/versions/6.57/2026-08-04-18-00-00-store-custom-field-values-as-leaf-rows.js +10 -1
- package/core/server/data/migrations/versions/6.63/2026-09-03-10-07-03-rename-custom-field-tables-to-metafields.js +169 -0
- package/core/server/data/migrations/versions/6.63/2026-09-03-11-03-31-remove-member-custom-field-read-permissions.js +30 -0
- package/core/server/data/schema/fixtures/fixtures.json +0 -11
- package/core/server/data/schema/lib/default-index-name.js +8 -11
- package/core/server/data/schema/schema.js +18 -18
- package/core/server/data/seeders/README.md +48 -0
- package/core/server/data/tinybird/pipes/mv_hits.pipe +86 -50
- package/core/server/lib/db-types/count.js +16 -0
- package/core/server/lib/validate-password.js +81 -120
- package/core/server/models/action.js +4 -4
- package/core/server/models/base/plugins/filtered-collection.js +16 -0
- package/core/server/models/member.js +6 -6
- package/core/server/models/user.js +1 -1
- package/core/server/services/automations/automations-api.js +1 -1
- package/core/server/services/automations/database-automations-repository.js +11 -4
- package/core/server/services/email-service/CONTEXT.md +37 -0
- package/core/server/services/email-service/README.md +42 -0
- package/core/server/services/email-service/batch-sending-service.js +2 -0
- package/core/server/services/email-service/email-controller.js +18 -2
- package/core/server/services/email-service/email-service-wrapper.js +3 -0
- package/core/server/services/email-service/sending-status-schema.js +21 -0
- package/core/server/services/email-service/sending-status-serializers.js +33 -0
- package/core/server/services/email-service/sending-status-service.js +47 -0
- package/core/server/services/email-service/sending-status.js +111 -0
- package/core/server/services/email-suppression-list/email-suppression-list.js +0 -33
- package/core/server/services/email-suppression-list/mailgun-email-suppression-list.js +6 -7
- package/core/server/services/gifts/README.md +2 -2
- package/core/server/services/gifts/constants.js +1 -1
- package/core/server/services/gifts/gift-service.js +19 -57
- package/core/server/services/gifts/index.js +0 -2
- package/core/server/services/jobs-service/index.js +8 -0
- package/core/server/services/jobs-service/jobs-service.js +52 -3
- package/core/server/services/jobs-service/register-job-handlers.js +13 -2
- package/core/server/services/members/account-service.js +98 -0
- package/core/server/services/members/api.js +4 -4
- package/core/server/services/members/import-export/export/exporter.js +20 -20
- package/core/server/services/members/import-export/import/completion-email.js +6 -6
- package/core/server/services/members/import-export/import/importer.js +13 -13
- package/core/server/services/members/import-export/index.js +7 -7
- package/core/server/services/members/members-api/members-api.js +26 -6
- package/core/server/services/members/members-api/repositories/member-repository.js +4 -4
- package/core/server/services/members/members-api/services/member-bread-service.js +45 -39
- package/core/server/services/members/members-ssr.js +18 -0
- package/core/server/services/members/middleware.js +95 -81
- package/core/server/services/members/service.js +70 -42
- package/core/server/services/members/utils.js +9 -0
- package/core/server/services/members-metafields/access.js +28 -0
- package/core/server/services/{members-custom-fields → members-metafields}/actions.js +5 -5
- package/core/server/services/members-metafields/bindings-service.js +147 -0
- package/core/server/services/{members-custom-fields → members-metafields}/codec.js +4 -4
- package/core/server/services/{members-custom-fields → members-metafields}/config.js +1 -1
- package/core/server/services/{members-custom-fields → members-metafields}/definitions-service.js +17 -23
- package/core/server/services/{members-custom-fields → members-metafields}/filter.js +9 -9
- package/core/server/services/{members-custom-fields → members-metafields}/index.js +16 -7
- package/core/server/services/{members-custom-fields → members-metafields}/key.js +1 -1
- package/core/server/services/{members-custom-fields → members-metafields}/models.js +4 -4
- package/core/server/services/members-metafields/namespaces.js +34 -0
- package/core/server/services/{members-custom-fields → members-metafields}/queries.js +1 -1
- package/core/server/services/{members-custom-fields → members-metafields}/schema.js +16 -12
- package/core/server/services/{members-custom-fields → members-metafields}/serializers.js +6 -6
- package/core/server/services/{members-custom-fields → members-metafields}/values-service.js +32 -22
- package/core/server/services/mentions/mention-sending-service.js +26 -9
- package/core/server/services/mentions/send-webmentions-job.js +18 -0
- package/core/server/services/mentions/service.js +1 -31
- package/core/server/services/stripe/services/webhook/checkout-session-event-service.js +2 -2
- package/core/server/services/stripe/stripe-service.js +4 -4
- package/core/server/services/tier-checkout-config/codec.js +2 -2
- package/core/server/services/tier-checkout-config/index.js +2 -1
- package/core/server/services/tier-checkout-config/models.js +2 -2
- package/core/server/services/tier-checkout-config/queries.js +8 -8
- package/core/server/services/tier-checkout-config/serializers.js +57 -0
- package/core/server/services/tier-checkout-config/service.js +1 -1
- package/core/server/services/tiers/service.js +3 -3
- package/core/server/services/url/router-filter.js +8 -10
- package/core/server/services/users.js +1 -19
- package/core/server/web/api/endpoints/admin/routes.js +1 -0
- package/core/server/web/members/account/index.js +2 -0
- package/core/server/web/members/account/routes.js +46 -0
- package/core/server/web/members/app.js +4 -18
- package/core/shared/config/defaults.json +1 -1
- package/core/shared/labs.js +4 -2
- package/package.json +22 -22
- package/pnpm-lock.yaml +513 -571
- package/pnpm-workspace.yaml +12 -12
- package/components/tryghost-custom-field-types-0.0.0.tgz +0 -0
- package/core/built/admin/assets/activitypub/layout-2-0bw6HN.js +0 -1
- package/core/built/admin/assets/automated-emails-D5VVMND9.js +0 -1
- package/core/built/admin/assets/automations-CzKt5fb8.js +0 -1
- package/core/built/admin/assets/chunk.598.7e056fabb47ce7dbd73f.js +0 -366
- package/core/built/admin/assets/comments-BLmCmyCs.js +0 -1
- package/core/built/admin/assets/custom-field-type-option-BddFlJFa.js +0 -1
- package/core/built/admin/assets/design-and-theme-modal-BSmo12Op.js +0 -2
- package/core/built/admin/assets/edit-profile-C5Asm4LA.js +0 -1
- package/core/built/admin/assets/editor-REokrzci.js +0 -8
- package/core/built/admin/assets/filter-sources-BO9xUPj7.js +0 -1
- package/core/built/admin/assets/filters-CRUWecfY.js +0 -1
- package/core/built/admin/assets/growth-BWIu-6xj.js +0 -3
- package/core/built/admin/assets/growth-DU29oxeA.js +0 -1
- package/core/built/admin/assets/hooks-CuEZV2-q.js +0 -2
- package/core/built/admin/assets/index-6MkPdCtr.js +0 -4
- package/core/built/admin/assets/index-Bn7QhcZu.css +0 -2
- package/core/built/admin/assets/index.es-CNnuNH0d.js +0 -1
- package/core/built/admin/assets/koenig-loader-aFQNlJlD.js +0 -2
- package/core/built/admin/assets/label-picker-KVoo91sh.js +0 -1
- package/core/built/admin/assets/layout-Bjv2Ll-5.js +0 -1
- package/core/built/admin/assets/link-helpers-MVDdnFCY.js +0 -1
- package/core/built/admin/assets/member-detail-CdJF6Agw.js +0 -1
- package/core/built/admin/assets/members-DjQbq9Z2.js +0 -4
- package/core/built/admin/assets/navigation-modal-BkT7b1M2.js +0 -1
- package/core/built/admin/assets/newsletter-BMMAuvgq.js +0 -1
- package/core/built/admin/assets/newsletter-detail-modal-0SCJ7Zpm.js +0 -1
- package/core/built/admin/assets/newsletters-DhNigJUh.js +0 -1
- package/core/built/admin/assets/onboarding-qg8Akovm.js +0 -1
- package/core/built/admin/assets/overview-BW8GLeYi.js +0 -1
- package/core/built/admin/assets/overview-BkXZNzaZ.js +0 -1
- package/core/built/admin/assets/pages-jgaFm69d.js +0 -1
- package/core/built/admin/assets/pages-route-CIUAQxtY.js +0 -1
- package/core/built/admin/assets/portal-modal-D4ceei3t.js +0 -1
- package/core/built/admin/assets/post-analytics-header-BYCsT0GP.js +0 -1
- package/core/built/admin/assets/post-analytics-ot7f6pih.js +0 -1
- package/core/built/admin/assets/post-analytics-provider-Bo1gmYaP.js +0 -1
- package/core/built/admin/assets/post-helpers-C5OQMBoi.js +0 -1
- package/core/built/admin/assets/post-share-modal-C-PaYZ_e.js +0 -1
- package/core/built/admin/assets/posts-DuGazgTb.js +0 -1
- package/core/built/admin/assets/posts-list-screen-CBGGgjjj.js +0 -2
- package/core/built/admin/assets/posts-route-D6xmS7Vf.js +0 -1
- package/core/built/admin/assets/profile-B8mx2yAu.js +0 -1
- package/core/built/admin/assets/radio-group-DczlLKOn.js +0 -1
- package/core/built/admin/assets/router-provider-B0gZyiGJ.js +0 -1
- package/core/built/admin/assets/schemas-DppqmpeJ.js +0 -64
- package/core/built/admin/assets/settings-DvfTNdHQ.js +0 -4
- package/core/built/admin/assets/stats-Rjmk5owg.js +0 -1
- package/core/built/admin/assets/stats-view-BGGmkmgv.js +0 -1
- package/core/built/admin/assets/tag-detail-BhXlOsCa.js +0 -2
- package/core/built/admin/assets/tags-ldukRApe.js +0 -1
- package/core/built/admin/assets/tier-detail-modal-BOs8e_G8.js +0 -1
- package/core/built/admin/assets/tiers-Nd_z4BZY.js +0 -1
- package/core/built/admin/assets/use-filter-params-BIni9taJ.js +0 -1
- package/core/built/admin/assets/use-host-limits-DZtR08oa.js +0 -1
- package/core/built/admin/assets/use-pintura-config-h-J0Lvta.js +0 -1
- package/core/built/admin/assets/use-staff-users-Csipb-O0.js +0 -1
- package/core/built/admin/assets/use-upgrade-route-DhRSo7at.js +0 -1
- package/core/built/admin/assets/user-detail-modal-B_iUClI6.js +0 -1
- package/core/built/admin/assets/web-C4BKzn2T.js +0 -1
- package/core/server/services/email-suppression-list/in-memory-email-suppression-list.js +0 -39
- package/core/server/services/members-custom-fields/bindings-service.js +0 -120
- /package/core/built/admin/assets/{chunk.492.f24d855d7e3f3aad261c.js.LICENSE.txt → chunk.901.4ccc639821020230bcca.js.LICENSE.txt} +0 -0
- /package/core/server/services/{members-custom-fields → members-metafields}/storage.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{g as r,p as i}from"./hooks-Cy_-oZ4o.js";import{n as a}from"./dist-Ndy-PuGN.js";import{t as o}from"./use-form-vRjI0Kwk.js";import{a as s,i as c,r as l}from"./config-kSHvwdTG.js";import{h as u}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{w as d}from"./dist-B3keLvjj.js";import{t as f}from"./inline-BWSs_VzR.js";import{t as p}from"./stack-B2eszIiq.js";import{i as m,o as h,r as g}from"./shade-app-CcS3f8MZ-vwURazk8.js";import{A as _,Gn as v,N as y,P as b,S as ee,U as x,W as S,Z as C,_r as w,hn as te,k as T,t as ne,x as re,zt as ie}from"./button-Dvcv1QSR.js";import{i as E,n as D,r as O,t as ae}from"./tabs-eBBlxPp8.js";import{t as k}from"./switch-CI4gLWqb.js";import{i as oe,n as A,o as j,s as M,t as se}from"./select-v5YbA3Mw.js";import{t as ce}from"./use-settings-navigation-B-qrriKD.js";import{a as N,c as P,i as F,n as I,o as L,r as le,s as R,t as z}from"./field-C93_Mg6j.js";import{t as ue}from"./textarea-DJ1Q5V39.js";import{n as B,t as V}from"./toggle-group-CviIkyok.js";import{r as de}from"./components-CwL6a6As-B0E0-NBJ.js";import{t as H}from"./use-limiter-CohWfzvK.js";import{i as fe,r as pe}from"./newsletters-Rq1M3GD-.js";import{mi as U,pi as me,qn as he,rr as W,t as ge}from"./index-CgMCwsxN.js";import{t as _e}from"./validator-Cr0sMKuW.js";import{n as ve}from"./confirmation-context-DwXX_Y5h.js";import{n as G}from"./global-data-context-gAMDH9u1.js";import{t as ye}from"./use-upgrade-route-Dm_qqKr0.js";import{t as be}from"./use-setting-group-bLKMwoBT.js";import{t as K}from"./color-picker-field-DQFVTNnT.js";import{i as xe,r as Se,t as q}from"./newsletter-emails-DZH6I-PY.js";import{t as Ce}from"./html-field-DA4eU7eq.js";import{t as J}from"./color-utils-Dzeeuj1F.js";import{t as we}from"./preview-modal-YYbzlYdO.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 Y=n(),Te=({senderName:e,senderEmail:t,senderReplyTo:n,headerImage:r,headerIcon:i,headerTitle:a,headerSubtitle:o,showPostTitleSection:s,showExcerpt:l,titleAlignment:u,titleFontCategory:f,titleFontWeight:p,bodyFontCategory:m,authorPlaceholder:h,showCommentCta:g,showFeatureImage:v,showFeedback:y,showShareButton:b,showLatestPosts:ee,showSubscriptionDetails:x,siteTitle:S,footerContent:w,showBadge:te,backgroundColor:ne,headerBackgroundColor:re,accentColor:E,textColor:D,secondaryTextColor:O,headerTextColor:ae,secondaryHeaderTextColor:k,postTitleColor:oe,sectionTitleColor:A,dividerColor:j,buttonColor:M,buttonTextColor:se,linkColor:ce,buttonCorners:N,buttonStyle:P,imageCorners:F,linkStyle:I,dividerStyle:L})=>{let le=i||a,{config:R}=G(),z=new Date().toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`numeric`}),ue=new Date().getFullYear(),B=w?w.replace(/<a/g,`<a target="_blank" rel="noopener noreferrer"`):``,V;V=c(R)?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`leading-normal`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-gray-900`,children:`From: `}),(0,Y.jsxs)(`span`,{children:[e,` (`,t,`)`]})]}),(0,Y.jsxs)(`p`,{className:`leading-normal`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-gray-900`,children:`Reply-to: `}),n||t]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`leading-normal`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-gray-900`,children:e}),(0,Y.jsxs)(`span`,{children:[` `,t]})]}),(0,Y.jsxs)(`p`,{className:`leading-normal`,children:[(0,Y.jsx)(`span`,{className:`font-semibold text-gray-900`,children:`To:`}),` Jamie Larson jamie@example.com`]})]});let H=`mb-5 text-pretty leading-[1.7] text-black`;return H=f===`serif`&&m===`serif`?d(H,`mb-8 font-serif text-[2.0rem] leading-tight`):f!==`serif`&&m===`serif`?d(H,`mb-8 text-[1.7rem] leading-tight tracking-tight`):f===`serif`&&m!==`serif`?d(H,`mb-8 font-serif text-[2.0rem] leading-tight`):d(H,`mb-8 text-[1.9rem] leading-tight tracking-tight`),u===`center`&&(H=d(H,`text-center`)),(0,Y.jsx)(`div`,{className:`relative flex grow flex-col`,children:(0,Y.jsx)(`div`,{className:`absolute inset-0 m-5 flex items-center justify-center`,children:(0,Y.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,Y.jsx)(`div`,{className:`flex-column flex min-h-[77px] justify-center gap-1 rounded-t-sm border-b border-gray-200 bg-white px-6 text-gray-700`,children:V}),(0,Y.jsxs)(`div`,{className:`overflow-y-auto`,style:{backgroundColor:ne},children:[(0,Y.jsxs)(`div`,{className:`px-[7rem]`,style:{backgroundColor:re},children:[r&&(0,Y.jsx)(`div`,{children:(0,Y.jsx)(`img`,{alt:``,className:`mb-4 block pt-6`,src:r})}),le&&(0,Y.jsxs)(`div`,{className:`py-3`,children:[i&&(0,Y.jsx)(`img`,{alt:``,className:`mx-auto mb-2 size-10`,role:`presentation`,src:i}),a&&(0,Y.jsx)(`h4`,{className:`mb-1 text-center text-[1.6rem] leading-tight font-bold tracking-tight text-gray-900 uppercase`,style:{color:ae},children:a}),o&&(0,Y.jsx)(`h5`,{className:`mb-1 text-center text-[1.3rem] font-normal text-gray-700`,style:{color:k},children:o})]}),s&&(0,Y.jsxs)(`div`,{className:d(`flex flex-col py-8`,u===`center`?`items-center`:`items-start`),children:[(0,Y.jsx)(`h2`,{className:d(`text-4xl leading-supertight font-bold text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`,u===`center`?`text-center`:`text-left`,l?`mb-2`:`mb-8`),style:{color:oe},children:`Your email newsletter`}),l&&(0,Y.jsx)(`p`,{className:H,style:{color:ae},children:`A subtitle to highlight key points and engage your readers.`}),(0,Y.jsxs)(`div`,{className:d(`flex w-full justify-between text-center text-md leading-none text-gray-700`,u===`center`?`flex-col gap-1`:`flex-row`),children:[(0,Y.jsxs)(`p`,{className:`pb-1 text-[1.3rem]`,style:{color:k},children:[`By `,h,(0,Y.jsx)(`span`,{className:`before:pr-1 before:pl-0.5 before:content-['•']`,children:z})]}),(0,Y.jsx)(`p`,{className:`pb-1 text-[1.3rem] underline`,style:{color:k},children:(0,Y.jsx)(`span`,{children:`View in browser`})})]})]}),v&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:d(`h-[unset] w-full max-w-[600px] bg-cover bg-no-repeat`,s?``:`pt-6`),children:(0,Y.jsx)(`img`,{alt:`Feature`,className:d(`min-h-full min-w-full shrink-0`,F===`square`&&`rounded-none`,F===`rounded`&&`rounded-md`),src:``+new URL(`user-cover-yM4cP_Mo.jpg`,import.meta.url).href})}),(0,Y.jsx)(`div`,{className:`mt-1 w-full max-w-[600px] pb-8 text-center text-[1.3rem] text-gray-700`,style:{color:k},children:`Feature image caption`})]})]}),(0,Y.jsxs)(`div`,{className:d(`px-[7rem]`,re!==`transparent`&&`pt-10`),children:[(0,Y.jsxs)(`div`,{className:d(`max-w-[600px] border-b border-gray-200 pb-[52px] leading-[27.2px] text-black`,L===`dashed`&&`border-dashed`,L===`dotted`&&`border-b-2 border-dotted`,m===`serif`?`font-serif text-[1.8rem]`:`text-[1.7rem] tracking-tight`,v||s?``:`pt-8`),style:{borderColor:j},children:[(0,Y.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,Y.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,Y.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,Y.jsx)(`hr`,{className:d(`my-[52px] border-[#e0e7eb]`,L===`dashed`&&`border-dashed`,L===`dotted`&&`border-t-0 border-b-2 border-dotted`),style:{borderColor:j}}),(0,Y.jsx)(`h3`,{className:d(`mb-[13px] text-[2.6rem] leading-supertight`,f===`serif`&&`font-serif`,f===`sans_serif`&&`font-sans`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:A},children:`Need inspiration?`}),(0,Y.jsxs)(`p`,{className:`mb-[27px]`,style:{color:D},children:[`We've put together a`,` `,(0,Y.jsx)(`a`,{className:d(I===`underline`&&`underline`,I===`bold`&&`font-bold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:{color:ce||E},target:`_blank`,children:`quick guide`}),` `,`that walks through all of the available settings, along with a few examples of what's possible.`]}),(0,Y.jsx)(`a`,{className:d(`inline-block border px-[18px] py-2 font-sans text-[15px]`,N===`rounded`&&`rounded-[6px]`,N===`pill`&&`rounded-full`,N===`square`&&`rounded-none`,P===`outline`?`bg-transparent`:`border-transparent text-white`,I===`bold`?`font-bold`:`font-semibold`),href:`https://ghost.org/help/email-design/`,rel:`noopener noreferrer`,style:P===`outline`?{borderColor:M||E,color:M||E}:{backgroundColor:M||E,color:se},target:`_blank`,children:`Learn more`})]}),(y||g||b)&&(0,Y.jsx)(`div`,{className:d(`grid gap-5 border-b border-gray-200 px-6 py-5`,L===`dashed`&&`border-dashed`,L===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:j},children:(0,Y.jsxs)(`div`,{className:`grid auto-cols-fr grid-flow-col gap-4`,children:[y&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:j,color:D},children:(0,Y.jsx)(T,{className:`size-5`})}),(0,Y.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`More like this`})]}),(0,Y.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:j,color:D},children:(0,Y.jsx)(_,{className:`size-5`})}),(0,Y.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Less like this`})]})]}),g&&(0,Y.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:j,color:D},children:(0,Y.jsx)(ie,{className:`size-5`})}),(0,Y.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Comment`})]}),b&&(0,Y.jsxs)(`div`,{className:`pointer-events-none flex min-w-[120px] cursor-default flex-col items-center gap-[11px] text-center`,children:[(0,Y.jsx)(`span`,{className:`inline-flex size-[54px] items-center justify-center rounded-full border`,style:{borderColor:j,color:D},children:(0,Y.jsx)(C,{className:`size-5`})}),(0,Y.jsx)(`span`,{className:`font-sans text-[1.3rem] leading-[1.4] font-medium`,style:{color:D},children:`Share`})]})]})}),ee&&(0,Y.jsxs)(`div`,{className:d(`border-b border-gray-200 py-6`,L===`dashed`&&`border-dashed`,L===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:j},children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:A},children:`The three latest posts published on your site`}),(0,Y.jsx)(`p`,{className:`m-0 text-base text-gray-700`,style:{color:O},children:`Posts sent as an email only will never be shown here.`})]}),(0,Y.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Y.jsx)(`img`,{alt:`Latest post`,className:d(F===`square`&&`rounded-none`,F===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-1-D7-ilqhR.jpg`,import.meta.url).href})})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:A},children:`Displayed at the bottom of each newsletter`}),(0,Y.jsx)(`p`,{className:`m-0 text-base text-gray-700`,style:{color:O},children:`Giving your readers one more place to discover your stories.`})]}),(0,Y.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Y.jsx)(`img`,{alt:`Latest post`,className:d(F===`square`&&`rounded-none`,F===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-2-BPfbGB8B.jpg`,import.meta.url).href})})]}),(0,Y.jsxs)(`div`,{className:`flex justify-between gap-4 py-2`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:d(`mt-0.5 text-[1.9rem] text-black`,f===`serif`&&`font-serif`,p===`normal`&&`font-normal`,p===`medium`&&`font-medium`,p===`semibold`&&`font-semibold`,p===`bold`&&`font-bold`),style:{color:A},children:`To keep your work front and center`}),(0,Y.jsx)(`p`,{className:`m-0 text-base text-gray-700`,style:{color:O},children:`Making sure that your audience stays engaged.`})]}),(0,Y.jsx)(`div`,{className:`aspect-square h-auto w-full max-w-[100px] bg-cover bg-no-repeat`,children:(0,Y.jsx)(`img`,{alt:`Latest post`,className:d(F===`square`&&`rounded-none`,F===`rounded`&&`rounded-md`),src:``+new URL(`latest-posts-3-D72O3dn8.jpg`,import.meta.url).href})})]})]}),x&&(0,Y.jsxs)(`div`,{className:d(`border-b border-gray-200 py-8`,L===`dashed`&&`border-dashed`,L===`dotted`&&`border-b-2 border-dotted`),style:{borderColor:j},children:[(0,Y.jsx)(`h4`,{className:`mb-3 text-[1.2rem] tracking-wide text-black uppercase`,style:{color:D},children:`Subscription details`}),(0,Y.jsxs)(`p`,{className:`m-0 mb-4 text-base`,style:{color:D},children:[`You are receiving this because you are a paid subscriber to `,S,`. Your subscription will renew on 17 Jul 2024.`]}),(0,Y.jsxs)(`div`,{className:`flex`,children:[(0,Y.jsxs)(`div`,{className:`shrink-0 text-base`,children:[(0,Y.jsx)(`p`,{style:{color:D},children:`Name: Jamie Larson`}),(0,Y.jsx)(`p`,{style:{color:D},children:`Email: jamie@example.com`}),(0,Y.jsx)(`p`,{style:{color:D},children:`Member since: 17 July 2023`})]}),(0,Y.jsx)(`span`,{className:d(`w-full self-end text-right text-base whitespace-nowrap`,I===`underline`&&`underline`,I===`bold`&&`font-bold`),style:{color:ce||E},children:`Manage subscription`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col items-center pt-10`,children:[(0,Y.jsx)(`div`,{dangerouslySetInnerHTML:{__html:B||``},className:`text px-8 py-3 text-center text-[1.3rem] leading-base break-words text-gray-700 [&_a]:underline`,style:{color:O}}),(0,Y.jsxs)(`div`,{className:`px-8 pt-3 pb-14 text-center text-[1.3rem] text-gray-700`,children:[(0,Y.jsxs)(`span`,{style:{color:O},children:[S,` © `,ue,` —`,` `]}),(0,Y.jsx)(`span`,{className:`pointer-events-none cursor-auto underline`,style:{color:O},children:`Unsubscribe`})]}),te&&(0,Y.jsx)(`div`,{className:`flex flex-col items-center pt-[10px] pb-[40px]`,children:(0,Y.jsxs)(`a`,{className:`pointer-events-none inline-flex cursor-auto items-center px-2 py-1 text-[1.25rem] font-semibold tracking-tight text-gray-900`,href:`https://ghost.org`,style:{color:D},children:[(0,Y.jsx)(de,{className:`mr-[6px] size-4`}),(0,Y.jsx)(`span`,{children:`Powered by Ghost`})]})})]})]})]})]})})})},X=e(t(),1),Ee=({newsletter:e})=>{let{currentUser:t,settings:n,siteData:r,config:i}=G(),[a,o,s,c,l]=U(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?J(h()).hex():r.accent_color},v=()=>{let t=e.button_style,n=_();if(n&&t===`fill`)return J(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:J(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 J(n===`transparent`?h():n).hex()},ee=()=>{let t=e.section_title_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:J(h()).hex()},x=()=>{let t=e.divider_color;return/#([0-9a-f]{3}){1,2}$/i.test(t||``)?t:t===`accent`?r.accent_color:`#e0e7eb`},S=J(h()).hex(),C=J(h()).alpha(.5).toString(),w=g()===`transparent`?S:J(g()).hex(),te=g()===`transparent`?C:J(g()).alpha(.5).toString(),T={backgroundColor:h(),headerBackgroundColor:g(),postTitleColor:b()||void 0,sectionTitleColor:ee()||void 0,buttonColor:_()||void 0,buttonTextColor:v()||void 0,linkColor:y()||void 0,dividerColor:x()||void 0,textColor:S,secondaryTextColor:C,headerTextColor:w,secondaryHeaderTextColor:te};return(0,Y.jsx)(Te,{accentColor:r.accent_color,authorPlaceholder:t.name||t.email,backgroundColor:T.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:T.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:Se(e,i,l),senderName:e.sender_name||a,senderReplyTo:q(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`,...T})},De=e(_e(),1),Z=({label:e,value:t,options:n,onValueChange:r})=>(0,Y.jsx)(V,{"aria-label":e,type:`single`,value:t,onValueChange:e=>e&&r(e),children:n.map(e=>(0,Y.jsxs)(g,{children:[(0,Y.jsx)(h,{asChild:!0,children:(0,Y.jsx)(B,{"aria-label":e.label,disabled:e.disabled,value:e.value,children:e.icon})}),(0,Y.jsx)(m,{children:e.label})]},e.value))}),Oe=({newsletter:e,updateNewsletter:t,errors:n,clearError:r})=>{let{settings:i,config:a}=G(),[o,s]=U(i,[`default_email_address`,`support_email_address`]),[c,l]=(0,X.useState)(q(e,a,s,o)||``),u=Se(e,a,o),d=(0,X.useCallback)(e=>{l(e.target.value),t({sender_reply_to:e.target.value||`newsletter`})},[t,l]);return(0,Y.jsxs)(z,{"data-invalid":!!n.sender_reply_to||void 0,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-reply-to`,children:`Reply-to email`}),(0,Y.jsx)(W,{"aria-invalid":!!n.sender_reply_to||void 0,id:`newsletter-reply-to`,maxLength:191,placeholder:u||``,value:c,onBlur:()=>{let t=q(e,a,s,o)||``;l(t)},onChange:d,onKeyDown:()=>r(`sender_reply_to`)}),n.sender_reply_to&&(0,Y.jsx)(F,{children:n.sender_reply_to})]})},ke=({newsletter:e,onlyOne:t,updateNewsletter:n,validate:o,errors:s,clearError:u})=>{let{updateRoute:d}=ce(),m=ye(),{mutateAsync:h}=fe(),g=H(),{settings:_,config:C,siteData:T}=G(),[ie,B]=U(_,[`icon`,`default_email_address`]),[V,de]=(0,X.useState)(`generalSettings`),{localSettings:ge}=be(),[_e]=U(ge,[`title`]),q=i(),{confirm:we,showLimit:Te}=ve(),{data:{newsletters:Ee}={}}=pe(),De=[`all`,`paid`].includes(me(_,`comments_enabled`)||``),ke=Se(e,C,B),[Ae,je]=(0,X.useState)(Ee||[]),Me=Ae.filter(e=>e.status===`active`);(0,X.useEffect)(()=>{je(Ee||[])},[Ee]);let Ne=[{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:J(e.background_color).hex().toLowerCase()===`#ffffff`,Pe=async()=>{if(e.status===`active`)we({title:`Archive newsletter`,prompt:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`mb-6`,children:[`Your newsletter `,(0,Y.jsx)(`strong`,{children:e.name}),` will no longer be visible to members or available as an option when publishing new posts.`]}),(0,Y.jsx)(`div`,{children:`Existing posts previously sent as this newsletter will remain unchanged.`})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async t=>{try{await h({...e,status:`archived`}),t?.remove(),a.success(`Newsletter archived`)}catch(e){q(e)}}});else{try{await g?.errorIfWouldGoOverLimit(`newsletters`)}catch(e){if(e instanceof r){Te({prompt:e.message||`Your current plan doesn't support more newsletters.`,onOk:()=>d({route:m,isExternal:!0})});return}else throw e}we({title:`Reactivate newsletter`,prompt:(0,Y.jsxs)(Y.Fragment,{children:[`Reactivating `,(0,Y.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 h({...e,status:`active`}),t?.remove(),a.success(`Newsletter reactivated`)}})}},Fe=()=>{if(!c(C))return(0,Y.jsxs)(z,{"data-invalid":!!s.sender_email||void 0,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Y.jsx)(W,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,placeholder:ke||``,value:e.sender_email||``,onChange:e=>n({sender_email:e.target.value}),onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Y.jsx)(F,{children:s.sender_email})]});if(l(C))return(0,Y.jsxs)(z,{"data-invalid":!!s.sender_email||void 0,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-sender-email`,children:`Sender email address`}),(0,Y.jsx)(W,{"aria-invalid":!!s.sender_email||void 0,id:`newsletter-sender-email`,maxLength:191,placeholder:B,value:e.sender_email||``,onChange:e=>{n({sender_email:e.target.value})},onKeyDown:()=>u(`sender_email`)}),s.sender_email&&(0,Y.jsx)(F,{children:s.sender_email})]})},Ie=Q[e.title_font_category||`sans_serif`].options,Le=[{id:`generalSettings`,title:`General`,contents:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Name and description`}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{"data-invalid":!!s.name||void 0,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-detail-name`,children:`Name`}),(0,Y.jsx)(W,{"aria-invalid":!!s.name||void 0,id:`newsletter-detail-name`,maxLength:191,placeholder:`Weekly Roundup`,value:e.name||``,onChange:e=>n({name:e.target.value}),onKeyDown:()=>u(`name`)}),s.name&&(0,Y.jsx)(F,{children:s.name})]}),(0,Y.jsxs)(z,{children:[(0,Y.jsx)(L,{htmlFor:`newsletter-description`,children:`Description`}),(0,Y.jsx)(ue,{id:`newsletter-description`,maxLength:2e3,rows:2,value:e.description||``,onChange:e=>n({description:e.target.value})})]})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Email info`}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{children:[(0,Y.jsx)(L,{htmlFor:`newsletter-sender-name`,children:`Sender name`}),(0,Y.jsx)(W,{id:`newsletter-sender-name`,maxLength:191,placeholder:_e,value:e.sender_name||``,onChange:e=>n({sender_name:e.target.value})})]}),Fe(),(0,Y.jsx)(Oe,{clearError:u,errors:s,newsletter:e,updateNewsletter:n,validate:o})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Member settings`}),(0,Y.jsx)(N,{children:(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-subscribe-on-signup`,children:`Subscribe new members on signup`}),(0,Y.jsx)(k,{checked:!!e.subscribe_on_signup,id:`newsletter-subscribe-on-signup`,onCheckedChange:e=>n({subscribe_on_signup:e})})]})})]}),(0,Y.jsx)(`div`,{className:`mt-10 mb-5`,children:e.status===`active`?!t&&(0,Y.jsx)(ne,{className:`text-destructive hover:text-destructive`,disabled:Me.length===1,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Archive newsletter`}):(0,Y.jsx)(ne,{className:`text-green hover:text-green`,type:`button`,variant:`ghost`,onClick:()=>void Pe(),children:`Reactivate newsletter`})})]})},{id:`content`,title:`Content`,contents:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Header`}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(xe,{inputId:`newsletter-header-image`,value:e.header_image||``,onChange:e=>n({header_image:e||null}),onUploadError:q}),(0,Y.jsxs)(p,{gap:`md`,children:[ie&&(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-header-icon`,children:`Publication icon`}),(0,Y.jsx)(k,{checked:!!e.show_header_icon,id:`newsletter-show-header-icon`,onCheckedChange:e=>n({show_header_icon:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-header-title`,children:`Publication title`}),(0,Y.jsx)(k,{checked:!!e.show_header_title,id:`newsletter-show-header-title`,onCheckedChange:e=>n({show_header_title:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-header-name`,children:`Newsletter name`}),(0,Y.jsx)(k,{checked:!!e.show_header_name,id:`newsletter-show-header-name`,onCheckedChange:e=>n({show_header_name:e})})]})]})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Title section`}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-post-title`,children:`Post title`}),(0,Y.jsx)(k,{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,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-excerpt`,children:`Post excerpt`}),(0,Y.jsx)(k,{checked:!!e.show_excerpt,id:`newsletter-show-excerpt`,onCheckedChange:e=>n({show_excerpt:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-feature-image`,children:`Feature image`}),(0,Y.jsx)(k,{checked:!!e.show_feature_image,id:`newsletter-show-feature-image`,onCheckedChange:e=>n({show_feature_image:e})})]})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Footer`}),(0,Y.jsxs)(N,{children:[(0,Y.jsxs)(p,{gap:`lg`,children:[(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-feedback-enabled`,children:`Ask your readers for feedback`}),(0,Y.jsx)(k,{checked:!!e.feedback_enabled,id:`newsletter-feedback-enabled`,onCheckedChange:e=>n({feedback_enabled:e})})]}),De&&(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-comment-cta`,children:`Add a link to your comments`}),(0,Y.jsx)(k,{checked:!!e.show_comment_cta,id:`newsletter-show-comment-cta`,onCheckedChange:e=>n({show_comment_cta:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-share-button`,children:`Show share button`}),(0,Y.jsx)(k,{checked:!!e.show_share_button,id:`newsletter-show-share-button`,onCheckedChange:e=>n({show_share_button:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-latest-posts`,children:`Share your latest posts`}),(0,Y.jsx)(k,{checked:!!e.show_latest_posts,id:`newsletter-show-latest-posts`,onCheckedChange:e=>n({show_latest_posts:e})})]}),(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-subscription-details`,children:`Show subscription details`}),(0,Y.jsx)(k,{checked:!!e.show_subscription_details,id:`newsletter-show-subscription-details`,onCheckedChange:e=>n({show_subscription_details:e})})]})]}),(0,Y.jsx)(Ce,{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,Y.jsx)(he,{className:`mt-8`}),(0,Y.jsxs)(`div`,{className:`my-5 flex w-full items-start`,children:[(0,Y.jsx)(`span`,{children:(0,Y.jsx)(te,{className:`mt-[-1px] mr-2 size-5 text-red`})}),(0,Y.jsx)(N,{className:`gap-8`,children:(0,Y.jsxs)(z,{orientation:`horizontal`,children:[(0,Y.jsxs)(I,{children:[(0,Y.jsx)(L,{htmlFor:`newsletter-show-badge`,children:`Promote independent publishing`}),(0,Y.jsx)(le,{children:`Show you're a part of the indie publishing movement with a small badge in the footer`})]}),(0,Y.jsx)(k,{checked:!!e.show_badge,id:`newsletter-show-badge`,onCheckedChange:e=>n({show_badge:e})})]})})]})]})},{id:`design`,title:`Design`,contents:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Global`}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{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,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:`Heading font`}),(0,Y.jsxs)(z,{className:`max-w-[200px]`,children:[(0,Y.jsx)(L,{className:`sr-only`,children:`Heading font`}),(0,Y.jsxs)(se,{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,Y.jsx)(j,{"aria-label":`Heading font`,children:(0,Y.jsx)(M,{})}),(0,Y.jsx)(A,{children:Ne.map(e=>(0,Y.jsx)(oe,{value:e.value,children:(0,Y.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:`Heading weight`}),(0,Y.jsxs)(z,{className:`max-w-[200px]`,children:[(0,Y.jsx)(L,{className:`sr-only`,children:`Heading weight`}),(0,Y.jsxs)(se,{value:(()=>{let t=e.title_font_category||`sans_serif`,n=e.title_font_weight,r=Q[t].map,i=r&&r[n]||n;return Ie.find(e=>e.value===i)||Ie[0]})().value,onValueChange:e=>n({title_font_weight:e}),children:[(0,Y.jsx)(j,{"aria-label":`Heading weight`,children:(0,Y.jsx)(M,{})}),(0,Y.jsx)(A,{children:Ie.map(e=>(0,Y.jsx)(oe,{value:e.value,children:(0,Y.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{className:`shrink-0`,children:`Body font`}),(0,Y.jsxs)(z,{className:`max-w-[200px]`,children:[(0,Y.jsx)(L,{className:`sr-only`,children:`Body font`}),(0,Y.jsxs)(se,{value:e.body_font_category,onValueChange:e=>n({body_font_category:e}),children:[(0,Y.jsx)(j,{"aria-label":`Body font`,"data-testid":`body-font-select`,children:(0,Y.jsx)(M,{})}),(0,Y.jsx)(A,{children:Ne.map(e=>(0,Y.jsx)(oe,{value:e.value,children:(0,Y.jsx)(`span`,{className:e.className,children:e.label})},e.value))})]})]})]})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Header`}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{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,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Post title color`,value:e.post_title_color,onChange:e=>n({post_title_color:e})})}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{children:`Title alignment`}),(0,Y.jsx)(Z,{label:`Title alignment`,options:[{value:`left`,label:`Left`,icon:(0,Y.jsx)(y,{className:`size-3.5!`}),disabled:!e.show_post_title_section},{value:`center`,label:`Center`,icon:(0,Y.jsx)(b,{className:`size-3.5!`}),disabled:!e.show_post_title_section}],value:e.title_alignment,onValueChange:e=>n({title_alignment:e})})]})]})]}),(0,Y.jsxs)(P,{className:`mt-8`,children:[(0,Y.jsx)(R,{className:`text-lg! font-semibold`,children:`Body`}),(0,Y.jsxs)(N,{children:[(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{direction:`rtl`,eyedropper:!0,swatches:[{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Section title color`,value:e.section_title_color,onChange:e=>n({section_title_color:e})})}),(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Button color`,value:e.button_color,onChange:e=>n({button_color:e})})}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{children:`Button style`}),(0,Y.jsx)(Z,{label:`Button style`,options:[{value:`fill`,label:`Fill`,icon:(0,Y.jsx)(x,{className:`size-3.5!`,fill:`currentColor`})},{value:`outline`,label:`Outline`,icon:(0,Y.jsx)(x,{className:`size-3.5!`})}],value:e.button_style||`fill`,onValueChange:e=>n({button_style:e})})]}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{children:`Button corners`}),(0,Y.jsx)(Z,{label:`Button corners`,options:[{value:`square`,label:`Squared`,icon:(0,Y.jsx)(S,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Y.jsx)(x,{className:`size-3.5!`})},{value:`pill`,label:`Pill`,icon:(0,Y.jsx)(v,{className:`size-3.5!`})}],value:e.button_corners||`rounded`,onValueChange:e=>n({button_corners:e})})]}),(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{direction:`rtl`,eyedropper:!0,swatches:[{value:`accent`,title:`Accent`,hex:T.accent_color},{value:null,title:`Auto`,hex:$()?`#ffffff`:`#000000`}],title:`Link color`,value:e.link_color,onChange:e=>n({link_color:e})})}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{children:`Link style`}),(0,Y.jsx)(Z,{label:`Link style`,options:[{value:`underline`,label:`Underline`,icon:(0,Y.jsx)(re,{className:`size-3.5!`})},{value:`regular`,label:`Regular`,icon:(0,Y.jsx)(ee,{className:`size-3.5!`})},{value:`bold`,label:`Bold`,icon:(0,Y.jsx)(w,{className:`size-3.5!`})}],value:e.link_style||`underline`,onValueChange:e=>n({link_style:e})})]}),(0,Y.jsxs)(f,{className:`w-full`,gap:`sm`,justify:`between`,children:[(0,Y.jsx)(`div`,{children:`Image corners`}),(0,Y.jsx)(Z,{label:`Image corners`,options:[{value:`square`,label:`Squared`,icon:(0,Y.jsx)(S,{className:`size-3.5!`})},{value:`rounded`,label:`Rounded`,icon:(0,Y.jsx)(x,{className:`size-3.5!`})}],value:e.image_corners||`square`,onValueChange:e=>n({image_corners:e})})]}),(0,Y.jsx)(`div`,{className:`mb-1`,children:(0,Y.jsx)(K,{direction:`rtl`,eyedropper:!0,swatches:[{value:`light`,title:`Light`,hex:`#e0e7eb`},{value:`accent`,title:`Accent`,hex:T.accent_color}],title:`Divider color`,value:e.divider_color||`light`,onChange:e=>n({divider_color:e})})})]})]})]})}];return(0,Y.jsx)(`div`,{className:`flex flex-col`,children:(0,Y.jsx)(`div`,{className:`px-7 pt-0 pb-7`,children:(0,Y.jsxs)(ae,{value:V,variant:`underline`,onValueChange:e=>{de(e)},children:[(0,Y.jsx)(O,{className:`sticky top-0 z-50 bg-surface-elevated-2`,children:Le.map(e=>(0,Y.jsx)(E,{value:e.id,children:e.title},e.id))}),Le.map(e=>(0,Y.jsx)(D,{value:e.id,children:e.contents},e.id))]})})})},Ae=({newsletter:e,onlyOne:t})=>{let{config:n}=G(),{mutateAsync:r}=fe(),{updateRoute:c}=ce(),u=ge(`automations`)?`emails`:`newsletters`,{formState:d,saveState:f,updateForm:p,setFormState:m,handleSave:h,validate:g,errors:_,clearError:v,okProps:y}=o({initialState:e,savingDelay:500,onSave:async()=>{let{meta:{sent_email_verification:[e]=[]}={}}=await r(d),t;(e&&e===`sender_email`||e&&e===`sender_reply_to`)&&(t=(0,Y.jsx)(`div`,{children:`We‘ve sent a confirmation email to the new address.`})),t&&a.info(t)},onSaveError:i(),onValidate:()=>{let e={};return d.name||(e.name=`A name is required for your newsletter`),d.sender_email&&!De.default.isEmail(d.sender_email)?e.sender_email=`Enter a valid email address`:d.sender_email&&l(n)&&d.sender_email.split(`@`)[1]!==s(n)&&(e.sender_email=`Email address must end with @${s(n)}`),d.sender_reply_to&&!De.default.isEmail(d.sender_reply_to)&&![`newsletter`,`support`].includes(d.sender_reply_to)&&(e.sender_reply_to=`Enter a valid email address`),e}}),b=e=>{p(t=>({...t,...e}))};(0,X.useEffect)(()=>{m(()=>e)},[m,e]);let ee=(0,Y.jsx)(Ee,{newsletter:d}),x=(0,Y.jsx)(ke,{clearError:v,errors:_,newsletter:d,onlyOne:t,updateNewsletter:b,validate:g});return(0,Y.jsx)(we,{buttonsDisabled:y.disabled,cancelLabel:`Close`,dirty:f===`unsaved`,okLabel:y.label||`Save`,okVariant:y.variant,preview:ee,previewBgColor:`grey`,previewToolbar:!1,sidebar:x,sidebarPadding:!1,testId:`newsletter-modal`,title:`Newsletter`,onClose:()=>c(u),onOk:async()=>{await h({fakeWhenUnchanged:!0})}})},je=()=>{let{newsletterId:e}=u(),{data:{newsletters:t,isEnd:n}={},fetchNextPage:r}=pe(),i=t?.find(({id:t})=>t===e);return(0,X.useEffect)(()=>{!i&&!n&&r()},[r,n,i]),i?(0,Y.jsx)(Ae,{newsletter:i,onlyOne:t.length===1}):null};export{je as default};
|
package/core/built/admin/assets/{newsletter-emails-DKzwafuh.js → newsletter-emails-DZH6I-PY.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{i as n,r}from"./config-
|
|
1
|
+
import"./rolldown-runtime-DAXXjFlN.js";import{t as e}from"./react-Bb3IsNbi.js";import{t}from"./jsx-runtime-DX3WBWVO.js";import{i as n,r}from"./config-kSHvwdTG.js";import{m as i}from"./dist-B3keLvjj.js";import{D as a}from"./button-Dvcv1QSR.js";import{o,r as s,t as c}from"./field-C93_Mg6j.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-KXmyO3Ss.js";e();var _=t(),v=({inputId:e=`welcome-email-header-image`,onUploadError:t,value:n,onChange:r})=>{let{mutateAsync:v}=f(),y=async e=>{try{r(g(await v({file:e})))}catch(e){if(t){t(e);return}throw e}};return(0,_.jsxs)(c,{"data-testid":`header-image-field`,children:[(0,_.jsx)(o,{htmlFor:e,children:`Header image`}),(0,_.jsx)(m,{className:`aspect-[2/1] w-full`,children:n?(0,_.jsxs)(u,{children:[(0,_.jsx)(h,{alt:`Header`,src:n}),(0,_.jsx)(l,{children:(0,_.jsx)(d,{"aria-label":`Remove header image`,type:`button`,onClick:()=>r(``),children:(0,_.jsx)(a,{})})})]}):(0,_.jsx)(p,{accept:{"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]},inputId:e,onDropAccepted:e=>e[0]&&void y(e[0]),children:(0,_.jsx)(`span`,{className:`text-control font-medium`,children:`Upload header image`})})}),(0,_.jsxs)(s,{children:[i(1200),`×`,i(600),` recommended. Use a transparent PNG for best results on any background.`]})]})},y=(e,t,i)=>n(t)&&!r(t)&&i?i:e.sender_email||i||``,b=(e,t,r,i)=>e.sender_reply_to===`newsletter`?n(t)?``:y(e,t,i):e.sender_reply_to===`support`?r||i||``: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{i as r}from"./pagemenu-B5KKCpbA.js";import{_ as i}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{a,t as o}from"./router-provider-B0gZyiGJ.js";import{c as s,h as c,m as l,u}from"./dist-B3keLvjj.js";import{Ut as d,Wt as f,t as p}from"./button-eNMKQWXr.js";import{g as m,n as h,o as g,r as _}from"./chart-BrhA41Zi.js";import{a as v,i as y,o as b,r as ee}from"./trend-badge-6ye93YAW.js";import{n as te,t as x}from"./sort-button-VVeQjjbu.js";import{r as ne,t as re}from"./tabs-D2yWLMp_.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./select-cb0t_TAJ.js";import{n as k}from"./skeleton-Ce9GgUpf.js";import{a as A,n as j,o as M,r as N,t as P}from"./card--VNbfgo3.js";import{t as F}from"./empty-indicator-D9QdpuNX.js";import{a as I,c as L,n as R,r as z,s as B,t as ie}from"./table-Do6iQ83Q.js";import{r as V}from"./newsletters-DhNigJUh.js";import{Cr as ae,J as H,Tr as U,Zn as oe,ci as W,jr as se,si as G,ui as ce,xr as le}from"./index-6MkPdCtr.js";import{i as ue,n as de,r as fe,t as pe}from"./stats-view-BGGmkmgv.js";import{i as me,r as he,u as ge}from"./stats-Rjmk5owg.js";import{a as K,c as _e,i as q,n as J,r as ve}from"./chart-helpers-CfBKt0vT.js";import{n as Y,r as X,t as ye}from"./kpi-tabs-BJItvLYm.js";import{t as be}from"./use-analytics-data-CWCMAESo.js";import{t as xe}from"./get-site-timezone-HgL0jI_F.js";var Z=e(t(),1),Q=n(),Se=({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,Q.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,Q.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,u(r)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,Q.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:l(n.sent_to)})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(n.total_opens),` / `]}),c(n.open_rate)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(n.total_clicks),` / `]}),c(n.click_rate)]})]})]})},Ce=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:o,initialTab:u=`total-subscribers`})=>{let[d,p]=(0,Z.useState)(u),[x,S]=(0,Z.useState)(!1),{range:C}=H(),w=a(),[T]=i(),E=G(),D=W(),{totalSubscribers:O,avgOpenRate:k,avgClickRate:A}=n,j=(0,Z.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=_e(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:l(e.value),label:`Total Subscribers`}))},[e,C]),M=(0,Z.useMemo)(()=>ve(C,e||[]),[e,C]),N=(0,Z.useMemo)(()=>{if(!j||j.length<=1)return{direction:`same`,value:`0%`};let e=j[0]?.value??0,t=j[j.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}},[j]);(0,Z.useEffect)(()=>{p(u)},[u]);let P=e=>{p(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},I={open_rate:{label:`Open rate`}},L=(0,Z.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:R,barTicks:z}=(0,Z.useMemo)(()=>{if(!t||t.length===0||d===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=L[d]?.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=d===`avg-open-rate`?k:A,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,d,L,k,A]);if(r)return(0,Q.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,Q.jsx)(oe,{})});let B=`grid-cols-3`;(!E||!D)&&(B=`grid-cols-2`),!E&&!D&&(B=`grid-cols-1`);let ie=d===`avg-open-rate`&&k>R[0]&&k<R[1]||d===`avg-click-rate`&&A>R[0]&&A<R[1],V=d===`avg-open-rate`?k:A;return(0,Q.jsxs)(re,{defaultValue:u,variant:`kpis`,children:[(0,Q.jsxs)(ne,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${B}`,children:[(0,Q.jsx)(Y,{className:`${!D&&!E&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{P(`total-subscribers`)},children:(0,Q.jsx)(X,{color:L[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:N.direction,diffValue:N.value,label:`Total subscribers`,value:l(O)})}),D&&(0,Q.jsx)(Y,{value:`avg-open-rate`,onClick:()=>{P(`avg-open-rate`)},children:(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-open-rate`].color,label:`Avg. open rate`,value:c(k)})}),E&&(0,Q.jsx)(Y,{value:`avg-click-rate`,onClick:()=>{P(`avg-click-rate`)},children:(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-click-rate`].color,label:`Avg. click rate`,value:c(A)})})]}),(0,Q.jsxs)(le,{children:[(0,Q.jsx)(se,{className:`md:hidden`,asChild:!0,children:(0,Q.jsxs)(ye,{children:[d===`total-subscribers`&&(0,Q.jsx)(X,{color:L[`total-subscribers`].color,label:`Total subscribers`,value:l(O)}),d===`avg-open-rate`&&D&&(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-open-rate`].color,label:`Avg. open rate`,value:c(k)}),d===`avg-click-rate`&&E&&(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-click-rate`].color,label:`Avg. click rate`,value:c(A)})]})}),(0,Q.jsxs)(ae,{align:`end`,className:`w-56`,children:[(0,Q.jsx)(U,{onClick:()=>P(`total-subscribers`),children:`Total subscribers`}),D&&(0,Q.jsx)(U,{onClick:()=>P(`avg-open-rate`),children:`Avg. open rate`}),E&&(0,Q.jsx)(U,{onClick:()=>P(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,Q.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[d===`total-subscribers`&&(0,Q.jsx)(ee,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:L[`total-subscribers`].color,data:j,id:`mrr`,range:M}),(d===`avg-open-rate`&&D||d===`avg-click-rate`&&E)&&(0,Q.jsx)(Q.Fragment,{children:o?(0,Q.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,Q.jsx)(oe,{})}):t&&t.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:I,children:(0,Q.jsxs)(te,{className:x?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`)},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:L[d].color,stopOpacity:.8}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:L[d].color,stopOpacity:.6})]})}),(0,Q.jsx)(b,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,Q.jsx)(v,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,Q.jsx)(y,{axisLine:!1,domain:R,tickFormatter:e=>c(e),tickLine:!1,ticks:z,width:s(z,e=>c(e))}),(0,Q.jsx)(_,{content:(0,Q.jsx)(Se,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),ie&&(0,Q.jsx)(g,{label:{value:`${c(V)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:V}),(0,Q.jsx)(m,{activeBar:{fillOpacity:1},dataKey:L[d].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,Q.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,d===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,Q.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${q(C)}`,children:(0,Q.jsx)(f,{strokeWidth:1.5})})})]})]})},we=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=H(),r=(0,Z.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Z.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,Q.jsxs)(O,{value:t||``,onValueChange:e=>{n(e)},children:[(0,Q.jsxs)(T,{className:`w-auto`,children:[(0,Q.jsx)(d,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,Q.jsx)(D,{placeholder:`Select a newsletter`})]}),(0,Q.jsx)(w,{align:`end`,children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(S,{children:`Newsletters`}),r.map(e=>(0,Q.jsx)(C,{value:e.id,children:e.name},e.id))]})})]})},Te=(e,t,n=!0)=>{let r=e??30,{startDate:i,endDate:a}=(0,Z.useMemo)(()=>K(r),[r]),o=ge({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(i),date_to:J(a)};return t&&(e.newsletter_id=t),e},[i,a,t]),enabled:n});return n?o:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:o.refetch}},Ee=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:o,endDate:s}=(0,Z.useMemo)(()=>K(i),[i]),c=he({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(o),date_to:J(s),order:a};return n&&(e.newsletter_id=n),e},[o,s,a,n]),enabled:r});return r?c:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:c.refetch}},De=(e,t=[],n=!0)=>{let r=me({searchParams:(0,Z.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}},Oe=(e,t,n,r=!0)=>{let i=Ee(e,t,n,r),a=(0,Z.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=De(n,a,r&&a.length>0);return{data:(0,Z.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()}}},ke=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=a(),{settings:o}=be(),s=xe(o),{data:d,isLoading:m,isClicksLoading:h}=Oe(e,r,t||void 0,!!n),g=G(),_=W(),v=(0,Z.useMemo)(()=>d?.stats||[],[d]),y=_&&g?5:_||g?4:3,b=(0,Z.useMemo)(()=>(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,Q.jsx)(z,{className:`font-medium`,colSpan:y,children:(0,Q.jsx)(k,{className:`mt-5`})})})}),[y]),ee=(0,Z.useMemo)(()=>v.length>0?(0,Q.jsx)(Q.Fragment,{children:v.map(e=>(0,Q.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,Q.jsx)(z,{className:`font-medium`,children:(0,Q.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,Q.jsx)(p,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`)},children:e.post_title}):(0,Q.jsx)(Q.Fragment,{children:e.post_title})})}),(0,Q.jsx)(z,{className:`text-sm whitespace-nowrap`,children:u(e.send_date,s)}),(0,Q.jsx)(z,{className:`text-right font-mono text-sm`,children:l(e.sent_to)}),_&&(0,Q.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:c(e.open_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:l(e.total_opens)})]}),g&&(0,Q.jsx)(z,{className:`text-right font-mono text-sm`,children:h?(0,Q.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:c(e.click_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:l(e.total_clicks)})]})})]},e.post_id))}):(0,Q.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,Q.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:y,children:(0,Q.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${q(e)}`,children:(0,Q.jsx)(f,{strokeWidth:1.5})})})}),[v,h,i,g,_,e,s]);return m||!d?b:ee});ke.displayName=`NewsletterTableRows`;var Ae=Z.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Z.useMemo)(()=>(0,Q.jsxs)(A,{children:[(0,Q.jsx)(M,{children:`Top newsletters`}),(0,Q.jsxs)(N,{children:[` Your best performing newsletters `,q(n)]})]}),[n]),i=G(),a=W();return(0,Q.jsx)(B,{children:(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,Q.jsx)(I,{className:`w-[65px]`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),a&&(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),i&&(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ae.displayName=`NewsletterTableHeader`;var $=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Z.useState)(`open_rate desc`);return(0,Q.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,Q.jsx)(j,{children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(Ae,{range:e,setSortBy:i,sortBy:r}),(0,Q.jsx)(R,{children:(0,Q.jsx)(ke,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});$.displayName=`TopNewslettersTable`;var je=()=>{let{range:e,selectedNewsletterId:t}=H(),[n]=i(),a=ce(),s=n.get(`tab`)||`total-subscribers`,{data:c,isLoading:l}=V({searchParams:{limit:`50`}}),u=!l&&c&&c.newsletters.length>0&&!!t,{data:d,isLoading:f}=Te(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=Oe(e,`date asc`,t||void 0,u||!1),g=(0,Z.useMemo)(()=>!c?.newsletters||!t?null:c.newsletters.find(e=>e.id===t)||null,[c,t]),_=(0,Z.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,Z.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=K(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Z.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 a===!1?(0,Q.jsx)(o,{to:`/analytics`}):(0,Q.jsxs)(de,{children:[(0,Q.jsx)(fe,{children:(0,Q.jsxs)(r,{children:[(0,Q.jsx)(we,{newsletters:c?.newsletters}),(0,Q.jsx)(ue,{})]})}),(0,Q.jsx)(pe,{isLoading:!1,loadingComponent:(0,Q.jsx)(Q.Fragment,{}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{"data-testid":`newsletters-card`,children:(0,Q.jsx)(j,{children:(0,Q.jsx)(Ce,{avgsData:y,initialTab:s,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,Q.jsx)($,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{je 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"./pagemenu-vgZVUVKR.js";import{_ as i}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{a,t as o}from"./router-provider-BSvTXgZY.js";import{c as s,h as c,m as l,u}from"./dist-B3keLvjj.js";import{Gt as d,Wt as f,t as p}from"./button-Dvcv1QSR.js";import{g as m,n as h,o as g,r as _}from"./chart-BrhA41Zi.js";import{a as v,i as y,o as b,r as ee}from"./trend-badge-CideVzQd.js";import{n as te,t as x}from"./sort-button-Cx1KtINE.js";import{r as ne,t as re}from"./tabs-eBBlxPp8.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./select-v5YbA3Mw.js";import{n as k}from"./skeleton-Ce9GgUpf.js";import{a as A,n as j,o as M,r as N,t as P}from"./card--VNbfgo3.js";import{t as F}from"./empty-indicator-D9QdpuNX.js";import{a as I,c as L,n as R,r as z,s as B,t as ie}from"./table-BenqVupI.js";import{r as V}from"./newsletters-Rq1M3GD-.js";import{Ci as ae,Dr as oe,Fr as se,Tr as ce,X as H,bi as U,kr as W,tr as le,xi as G}from"./index-CgMCwsxN.js";import{i as ue,n as de,r as fe,t as pe}from"./stats-view-W2g6Jsd-.js";import{a as me,f as he,o as ge}from"./stats-D9PDLS3x.js";import{a as K,c as _e,i as q,n as J,r as ve}from"./chart-helpers-FHywU0pj.js";import{n as Y,r as X,t as ye}from"./kpi-tabs-DEZHpKUt.js";import{t as be}from"./use-analytics-data-DAIGcr2f.js";import{t as xe}from"./get-site-timezone-HgL0jI_F.js";var Z=e(t(),1),Q=n(),Se=({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,Q.jsxs)(`div`,{className:`max-w-[240px] min-w-[220px] rounded-lg border bg-background px-3 py-2 shadow-lg`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex w-full flex-col border-b pb-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm leading-tight font-semibold`,children:n.post_title}),(0,Q.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`Sent on `,u(r)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Sent`}),(0,Q.jsx)(`div`,{className:`ml-2 w-full text-right font-mono`,children:l(n.sent_to)})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Opens`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(n.total_opens),` / `]}),c(n.open_rate)]})]}),(0,Q.jsxs)(`div`,{className:`mb-1 flex w-full justify-between`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Clicks`}),(0,Q.jsxs)(`div`,{className:`ml-2 w-full text-right font-mono`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(n.total_clicks),` / `]}),c(n.click_rate)]})]})]})},Ce=({subscribersData:e,avgsData:t,totals:n,isLoading:r,isAvgsLoading:o,initialTab:u=`total-subscribers`})=>{let[f,p]=(0,Z.useState)(u),[x,S]=(0,Z.useState)(!1),{range:C}=H(),w=a(),[T]=i(),E=U(),D=G(),{totalSubscribers:O,avgOpenRate:k,avgClickRate:A}=n,j=(0,Z.useMemo)(()=>{if(!e||e.length===0)return[];let t=[];return t=_e(e,C,`value`,`exact`),t.map(e=>({...e,formattedValue:l(e.value),label:`Total Subscribers`}))},[e,C]),M=(0,Z.useMemo)(()=>ve(C,e||[]),[e,C]),N=(0,Z.useMemo)(()=>{if(!j||j.length<=1)return{direction:`same`,value:`0%`};let e=j[0]?.value??0,t=j[j.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}},[j]);(0,Z.useEffect)(()=>{p(u)},[u]);let P=e=>{p(e);let t=new URLSearchParams(T);t.set(`tab`,e),w(`?${t.toString()}`,{replace:!0})},I={open_rate:{label:`Open rate`}},L=(0,Z.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:R,barTicks:z}=(0,Z.useMemo)(()=>{if(!t||t.length===0||f===`total-subscribers`)return{barDomain:[0,1],barTicks:[0,1]};let e=L[f]?.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=f===`avg-open-rate`?k:A,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,f,L,k,A]);if(r)return(0,Q.jsx)(`div`,{className:`-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center`,children:(0,Q.jsx)(le,{})});let B=`grid-cols-3`;(!E||!D)&&(B=`grid-cols-2`),!E&&!D&&(B=`grid-cols-1`);let ie=f===`avg-open-rate`&&k>R[0]&&k<R[1]||f===`avg-click-rate`&&A>R[0]&&A<R[1],V=f===`avg-open-rate`?k:A;return(0,Q.jsxs)(re,{defaultValue:u,variant:`kpis`,children:[(0,Q.jsxs)(ne,{className:`-mx-6 hidden grid-cols-3 md:visible! md:grid! ${B}`,children:[(0,Q.jsx)(Y,{className:`${!D&&!E&&`cursor-auto after:hidden`}`,value:`total-subscribers`,onClick:()=>{P(`total-subscribers`)},children:(0,Q.jsx)(X,{color:L[`total-subscribers`].color,"data-testid":`total-subscribers-value`,diffDirection:N.direction,diffValue:N.value,label:`Total subscribers`,value:l(O)})}),D&&(0,Q.jsx)(Y,{value:`avg-open-rate`,onClick:()=>{P(`avg-open-rate`)},children:(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-open-rate`].color,label:`Avg. open rate`,value:c(k)})}),E&&(0,Q.jsx)(Y,{value:`avg-click-rate`,onClick:()=>{P(`avg-click-rate`)},children:(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-click-rate`].color,label:`Avg. click rate`,value:c(A)})})]}),(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(se,{className:`md:hidden`,asChild:!0,children:(0,Q.jsxs)(ye,{children:[f===`total-subscribers`&&(0,Q.jsx)(X,{color:L[`total-subscribers`].color,label:`Total subscribers`,value:l(O)}),f===`avg-open-rate`&&D&&(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-open-rate`].color,label:`Avg. open rate`,value:c(k)}),f===`avg-click-rate`&&E&&(0,Q.jsx)(X,{className:o?`opacity-50`:``,color:L[`avg-click-rate`].color,label:`Avg. click rate`,value:c(A)})]})}),(0,Q.jsxs)(oe,{align:`end`,className:`w-56`,children:[(0,Q.jsx)(W,{onClick:()=>P(`total-subscribers`),children:`Total subscribers`}),D&&(0,Q.jsx)(W,{onClick:()=>P(`avg-open-rate`),children:`Avg. open rate`}),E&&(0,Q.jsx)(W,{onClick:()=>P(`avg-click-rate`),children:`Avg. click rate`})]})]}),(0,Q.jsxs)(`div`,{className:`my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500`,children:[f===`total-subscribers`&&(0,Q.jsx)(ee,{className:`-mb-3 h-[16vw] max-h-[320px] min-h-[180px] w-full`,color:L[`total-subscribers`].color,data:j,id:`mrr`,range:M}),(f===`avg-open-rate`&&D||f===`avg-click-rate`&&E)&&(0,Q.jsx)(Q.Fragment,{children:o?(0,Q.jsx)(`div`,{className:`h-[320px] w-full items-center justify-center`,children:(0,Q.jsx)(le,{})}):t&&t.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(h,{className:`aspect-auto h-[200px] w-full md:h-[220px] xl:h-[320px]`,config:I,children:(0,Q.jsxs)(te,{className:x?`cursor-pointer!`:``,data:t,margin:{top:20},onClick:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;t&&w(`/posts/analytics/${t}`)},onMouseLeave:()=>S(!1),onMouseMove:e=>{let t=(e.activePayload?.[0])?.payload?.post_id;S(!!t)},children:[(0,Q.jsx)(`defs`,{children:(0,Q.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,x2:`0`,y1:`0`,y2:`1`,children:[(0,Q.jsx)(`stop`,{offset:`0%`,stopColor:L[f].color,stopOpacity:.8}),(0,Q.jsx)(`stop`,{offset:`100%`,stopColor:L[f].color,stopOpacity:.6})]})}),(0,Q.jsx)(b,{horizontal:!0,stroke:`var(--border)`,vertical:!1}),(0,Q.jsx)(v,{axisLine:{stroke:`var(--border)`,strokeWidth:1},dataKey:`post_id`,interval:0,stroke:`var(--border)`,tickFormatter:()=>``,tickLine:!1,tickMargin:10}),(0,Q.jsx)(y,{axisLine:!1,domain:R,tickFormatter:e=>c(e),tickLine:!1,ticks:z,width:s(z,e=>c(e))}),(0,Q.jsx)(_,{content:(0,Q.jsx)(Se,{}),cursor:!1,isAnimationActive:!1,position:{y:10}}),ie&&(0,Q.jsx)(g,{label:{value:`${c(V)}`,position:`left`,offset:8,fill:`var(--muted-foreground)`},opacity:.5,stroke:`var(--muted-foreground)`,strokeDasharray:`4 4`,y:V}),(0,Q.jsx)(m,{activeBar:{fillOpacity:1},dataKey:L[f].datakey,fill:`url(#barGradient)`,fillOpacity:.6,isAnimationActive:!1,maxBarSize:32,minPointSize:3,radius:4})]})}),(0,Q.jsxs)(`div`,{className:`-mt-4 text-center text-sm text-muted-foreground`,children:[`Newsletters `,f===`avg-open-rate`?`opens`:`clicks`,` in this period`]})]}):(0,Q.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${q(C)}`,children:(0,Q.jsx)(d,{strokeWidth:1.5})})})]})]})},we=({newsletters:e})=>{let{selectedNewsletterId:t,setSelectedNewsletterId:n}=H(),r=(0,Z.useMemo)(()=>e?.filter(e=>e.status===`active`)||[],[e]);return(0,Z.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,Q.jsxs)(O,{value:t||``,onValueChange:e=>{n(e)},children:[(0,Q.jsxs)(T,{className:`w-auto`,children:[(0,Q.jsx)(f,{className:`mr-2`,size:16,strokeWidth:1.5}),(0,Q.jsx)(D,{placeholder:`Select a newsletter`})]}),(0,Q.jsx)(w,{align:`end`,children:(0,Q.jsxs)(E,{children:[(0,Q.jsx)(S,{children:`Newsletters`}),r.map(e=>(0,Q.jsx)(C,{value:e.id,children:e.name},e.id))]})})]})},Te=(e,t,n=!0)=>{let r=e??30,{startDate:i,endDate:a}=(0,Z.useMemo)(()=>K(r),[r]),o=he({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(i),date_to:J(a)};return t&&(e.newsletter_id=t),e},[i,a,t]),enabled:n});return n?o:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:o.refetch}},Ee=(e,t,n,r=!0)=>{let i=e??30,a=t??`date desc`,{startDate:o,endDate:s}=(0,Z.useMemo)(()=>K(i),[i]),c=me({searchParams:(0,Z.useMemo)(()=>{let e={date_from:J(o),date_to:J(s),order:a};return n&&(e.newsletter_id=n),e},[o,s,a,n]),enabled:r});return r?c:{data:void 0,isLoading:!1,error:null,isError:!1,refetch:c.refetch}},De=(e,t=[],n=!0)=>{let r=ge({searchParams:(0,Z.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}},Oe=(e,t,n,r=!0)=>{let i=Ee(e,t,n,r),a=(0,Z.useMemo)(()=>i.data?.stats?i.data.stats.map(e=>e.post_id):[],[i.data]),o=De(n,a,r&&a.length>0);return{data:(0,Z.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()}}},ke=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})=>{let i=a(),{settings:o}=be(),s=xe(o),{data:f,isLoading:m,isClicksLoading:h}=Oe(e,r,t||void 0,!!n),g=U(),_=G(),v=(0,Z.useMemo)(()=>f?.stats||[],[f]),y=_&&g?5:_||g?4:3,b=(0,Z.useMemo)(()=>(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(L,{className:`last:border-none [&>td]:py-2.5`,children:(0,Q.jsx)(z,{className:`font-medium`,colSpan:y,children:(0,Q.jsx)(k,{className:`mt-5`})})})}),[y]),ee=(0,Z.useMemo)(()=>v.length>0?(0,Q.jsx)(Q.Fragment,{children:v.map(e=>(0,Q.jsxs)(L,{className:`last:border-none [&>td]:py-2.5`,children:[(0,Q.jsx)(z,{className:`font-medium`,children:(0,Q.jsx)(`div`,{className:`group/link inline-flex items-center gap-2`,children:e.post_id?(0,Q.jsx)(p,{className:`h-auto p-0 text-left whitespace-normal hover:underline!`,title:`View post analytics`,variant:`link`,onClick:()=>{i(`/posts/analytics/${e.post_id}/`)},children:e.post_title}):(0,Q.jsx)(Q.Fragment,{children:e.post_title})})}),(0,Q.jsx)(z,{className:`text-sm whitespace-nowrap`,children:u(e.send_date,s)}),(0,Q.jsx)(z,{className:`text-right font-mono text-sm`,children:l(e.sent_to)}),_&&(0,Q.jsxs)(z,{className:`text-right font-mono text-sm`,children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:c(e.open_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:l(e.total_opens)})]}),g&&(0,Q.jsx)(z,{className:`text-right font-mono text-sm`,children:h?(0,Q.jsx)(`span`,{className:`inline-block h-4 w-8 animate-pulse rounded bg-gray-200`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`group-hover:hidden`,children:c(e.click_rate)}),(0,Q.jsx)(`span`,{className:`hidden group-hover:visible! group-hover:block!`,children:l(e.total_clicks)})]})})]},e.post_id))}):(0,Q.jsx)(L,{className:`border-none hover:bg-transparent`,children:(0,Q.jsx)(z,{className:`text-center group-hover:bg-transparent!`,colSpan:y,children:(0,Q.jsx)(F,{className:`size-full py-20`,title:`No newsletters ${q(e)}`,children:(0,Q.jsx)(d,{strokeWidth:1.5})})})}),[v,h,i,g,_,e,s]);return m||!f?b:ee});ke.displayName=`NewsletterTableRows`;var Ae=Z.memo(({sortBy:e,setSortBy:t,range:n})=>{let r=(0,Z.useMemo)(()=>(0,Q.jsxs)(A,{children:[(0,Q.jsx)(M,{children:`Top newsletters`}),(0,Q.jsxs)(N,{children:[` Your best performing newsletters `,q(n)]})]}),[n]),i=U(),a=G();return(0,Q.jsx)(B,{children:(0,Q.jsxs)(L,{children:[(0,Q.jsx)(I,{className:`min-w-[320px]`,variant:`cardhead`,children:r}),(0,Q.jsx)(I,{className:`w-[65px]`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`date desc`,children:`Date`})}),(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`sent_to desc`,children:`Sent`})}),a&&(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`open_rate desc`,children:`Opens`})}),i&&(0,Q.jsx)(I,{className:`w-[90px] text-right`,children:(0,Q.jsx)(x,{activeSortBy:e,setSortBy:t,sortBy:`click_rate desc`,children:`Clicks`})})]})})});Ae.displayName=`NewsletterTableHeader`;var $=Z.memo(({range:e,selectedNewsletterId:t,shouldFetchStats:n})=>{let[r,i]=(0,Z.useState)(`open_rate desc`);return(0,Q.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,Q.jsx)(j,{children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(Ae,{range:e,setSortBy:i,sortBy:r}),(0,Q.jsx)(R,{children:(0,Q.jsx)(ke,{range:e,selectedNewsletterId:t,shouldFetchStats:n,sortBy:r})})]})})})});$.displayName=`TopNewslettersTable`;var je=()=>{let{range:e,selectedNewsletterId:t}=H(),[n]=i(),a=ae(),s=n.get(`tab`)||`total-subscribers`,{data:c,isLoading:l}=V({searchParams:{limit:`50`}}),u=!l&&c&&c.newsletters.length>0&&!!t,{data:d,isLoading:f}=Te(e,t||void 0,u||!1),{data:p,isLoading:m,isClicksLoading:h}=Oe(e,`date asc`,t||void 0,u||!1),g=(0,Z.useMemo)(()=>!c?.newsletters||!t?null:c.newsletters.find(e=>e.id===t)||null,[c,t]),_=(0,Z.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,Z.useMemo)(()=>{if(!d?.stats?.[0]?.values||d.stats[0].values.length===0){let{startDate:t,endDate:n}=K(e),r=[],i=t.clone().toDate(),a=n.toDate();for(;i<=a;)r.push({date:i.toISOString().split(`T`)[0],value:0}),i.setDate(i.getDate()+1);return r}let t=d.stats[0].values;if(t.length===1){let n=t[0],r=new Date,i=e,a=new Date(r.getTime()-i*24*60*60*1e3);return[{...n,date:a.toISOString().split(`T`)[0]},{...n,date:r.toISOString().split(`T`)[0]}]}return t},[d,e]),y=(0,Z.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 a===!1?(0,Q.jsx)(o,{to:`/analytics`}):(0,Q.jsxs)(de,{children:[(0,Q.jsx)(fe,{children:(0,Q.jsxs)(r,{children:[(0,Q.jsx)(we,{newsletters:c?.newsletters}),(0,Q.jsx)(ue,{})]})}),(0,Q.jsx)(pe,{isLoading:!1,loadingComponent:(0,Q.jsx)(Q.Fragment,{}),children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(P,{"data-testid":`newsletters-card`,children:(0,Q.jsx)(j,{children:(0,Q.jsx)(Ce,{avgsData:y,initialTab:s,isAvgsLoading:!1,isLoading:b,subscribersData:v,totals:_})})}),(0,Q.jsx)($,{range:e,selectedNewsletterId:t,shouldFetchStats:!!u})]})})]})};export{je as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./hooks-Cy_-oZ4o.js";import{n,r}from"./update-queries-C4CnvJaW.js";import{c as i,d as a,g as o,i as s,m as c,r as l,u}from"./schemas-BoYdB6YU.js";var d=a({id:c(),uuid:c(),name:c(),description:c().nullable(),feedback_enabled:s(),slug:c(),sender_name:c().nullable(),sender_email:c().nullable(),sender_reply_to:c(),status:c(),visibility:c(),subscribe_on_signup:s(),sort_order:u(),header_image:c().nullable(),show_header_icon:s(),show_header_title:s(),title_font_category:c(),title_font_weight:c(),title_alignment:c(),show_excerpt:s(),show_feature_image:s(),body_font_category:c(),footer_content:c().nullable(),show_badge:s(),show_header_name:s(),show_post_title_section:s(),show_comment_cta:s(),show_share_button:s(),show_subscription_details:s(),show_latest_posts:s(),background_color:c(),header_background_color:c(),button_color:c().nullable(),link_color:c().nullable(),post_title_color:c().nullable(),section_title_color:c().nullable(),divider_color:c().nullable(),button_corners:c().nullable(),button_style:c().nullable(),image_corners:c().nullable(),link_style:c().nullable(),divider_style:c().nullish(),created_at:c(),updated_at:c().nullable(),count:a({posts:u().optional(),active_members:u().optional()}).optional()}),f=a({meta:a({capabilities:a({dislikes:s().optional()}).optional(),pagination:a({page:u(),limit:o([u(),i(`all`)]),pages:u(),total:u(),next:u().nullable(),prev:u().nullable()})}).optional(),newsletters:l(d)}),p=`NewslettersResponseType`,m=p,h=t({dataType:p,path:`/newsletters/`,parseResponse:e=>f.parse(e),defaultSearchParams:{include:`count.active_members,count.posts`,limit:`50`},defaultNextPageParams:(e,t)=>{let n=e.meta?.pagination.next;if(n)return{...t,page:n.toString()}},returnData:e=>{let{pages:t}=e,n=t.flatMap(e=>e.newsletters),r=t[t.length-1].meta;return{newsletters:n,meta:r,isEnd:r?r.pagination.pages===r.pagination.page:!0}}}),g=e({method:`POST`,path:()=>`/newsletters/`,body:({opt_in_existing:e,...t})=>({newsletters:[t]}),searchParams:e=>({opt_in_existing:e.opt_in_existing.toString(),include:`count.active_members,count.posts`}),updateQueries:{dataType:p,emberUpdateType:`createOrUpdate`,update:n(`newsletters`)}}),_=e({method:`PUT`,path:e=>`/newsletters/${e.id}/`,body:e=>({newsletters:[e]}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:p,emberUpdateType:`createOrUpdate`,update:r(`newsletters`)}}),v=e({method:`PUT`,path:()=>`/newsletters/verifications/`,body:({token:e})=>({token:e}),defaultSearchParams:{include:`count.active_members,count.posts`},updateQueries:{dataType:p,emberUpdateType:`createOrUpdate`,update:r(`newsletters`)}});export{v as a,_ as i,g as n,h as r,m 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{h as r}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{s as i}from"./router-provider-
|
|
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{h as r}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{s as i}from"./router-provider-BSvTXgZY.js";import{gn as a}from"./button-Dvcv1QSR.js";import{t as o}from"./skeleton-Ce9GgUpf.js";import{t as s}from"./use-navigate-with-base-path-BkxcPj5l.js";import{Ft as c,It as l,Yt as u,_t as d,gt as f,jn as p,kn as m,kt as h,nr as g,vt as _,zt as v}from"./index-CgMCwsxN.js";import{i as y,n as b,r as x,t as S}from"./use-reply-chain-data-CYRhoaxY.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)(_,{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)(o,{className:`size-10 rounded-full`}),(0,w.jsxs)(`div`,{className:`grow pt-1`,children:[(0,w.jsx)(o,{className:`w-24`}),(0,w.jsx)(o,{className:`w-3/5`})]})]}),(0,w.jsxs)(`div`,{className:`mb-7 w-full`,children:[(0,w.jsx)(o,{}),(0,w.jsx)(o,{className:`w-4/5`}),(0,w.jsx)(o,{})]}),(0,w.jsx)(T,{}),(0,w.jsxs)(`div`,{className:`flex w-full items-center gap-3 py-3`,children:[(0,w.jsx)(o,{className:`block size-full`,containerClassName:`size-10 rounded-full overflow-hidden`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(o,{className:`w-52`}),(0,w.jsx)(o,{className:`w-28`})]})]}),(0,w.jsx)(T,{})]})});if(!z)return(0,w.jsx)(_,{children:(0,w.jsx)(`div`,{className:`mx-auto mt-4 flex w-full max-w-[620px] flex-col items-center`,children:(0,w.jsxs)(d,{children:[(0,w.jsx)(f,{children:(0,w.jsx)(a,{})}),(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)(_,{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)(v,{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)(u,{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=>{l(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:p(z.actor)}),(0,w.jsx)(`span`,{className:`text-gray-700`,children:c(K,!K.authored)})]})]})]})}),R.map(e=>e.object.type===`Tombstone`?(0,w.jsx)(x,{last:!1}):(0,w.jsx)(h,{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)(h,{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)(h,{actor:e.mainReply.actor,allowDelete:e.mainReply.object.authored,commentCount:e.mainReply.object.replyCount??0,isChainParent:c,isPending:m(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)(h,{actor:e.chain[0].actor,allowDelete:e.chain[0].object.authored,commentCount:e.chain[0].object.replyCount??0,isChainContinuation:!0,isPending:m(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)(h,{actor:n.actor,allowDelete:n.object.authored,commentCount:n.object.replyCount??0,isChainContinuation:!0,isPending:m(n.id),last:i&&!o,layout:`reply`,likeCount:n.object.likeCount??0,object:n.object,parentId:K.id,repostCount:n.object.repostCount??0,type:`Note`,onClick:()=>{L(`/notes/${encodeURIComponent(n.id)}`)},onDelete:X},n.id)}),c&&e.chain.length>1&&!a&&(0,w.jsx)(b,{variant:`expand`,onClick:()=>Z(i)}),c&&a&&o&&G&&G(t)&&(0,w.jsx)(b,{loading:s,variant:`loadMore`,onClick:()=>Q(i,t)}),!r&&(0,w.jsx)(T,{})]},e.mainReply.id)}),j&&(0,w.jsx)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:(0,w.jsx)(g,{size:`md`})})]}),W&&(0,w.jsx)(`div`,{ref:I,className:`h-1`})]})})]})})})})})};export{E as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{t}from"./react-Bb3IsNbi.js";import{t as n}from"./jsx-runtime-DX3WBWVO.js";import{m as r}from"./dist-B3keLvjj.js";import{$n as i,_r as a,ct as o,h as s,mn as c,ot as l,t as u,xr as d}from"./button-eNMKQWXr.js";import{t as f}from"./skeleton-Ce9GgUpf.js";import{t as p}from"./use-navigate-with-base-path-BHPA228f.js";import{At as m,En as h,Ft as g,Gt as _,Ht as v,It as y,Mt as b,Nt as x,Ot as S,Qn as C,Tt as w,Ut as T,Wt as E,ft as D,ht as O,jt as k,ln as A,mt as j,pt as M}from"./index-6MkPdCtr.js";import"./layout-Bjv2Ll-5.js";var N=e(t(),1),P=n(),F=({notificationType:e,size:t=`lg`,className:n})=>{let r,i=``,a=`white`,u=t===`sm`?13:20,f=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,P.jsx)(s,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:a,size:u,strokeWidth:f}),i=`bg-blue-600`;break;case`like`:r=(0,P.jsx)(c,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:a,strokeWidth:f}),i=`bg-pink-600`;break;case`reply`:r=(0,P.jsx)(l,{className:`mr-px mb-px`,color:a,size:u,strokeWidth:f}),i=`bg-purple-600`;break;case`repost`:r=(0,P.jsx)(o,{color:a,size:u,strokeWidth:f}),i=`bg-green-500`;break;case`mention`:r=(0,P.jsx)(d,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:a,size:u,strokeWidth:f}),i=`bg-orange-500`;break}return(0,P.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${i} ${n&&n}`,children:r})},I=N.createContext(void 0),L=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,P.jsx)(I.Provider,{value:{onClick:r,url:i},children:(0,P.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})});L.Icon=({size:e=`lg`,type:t})=>(0,P.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,P.jsx)(F,{notificationType:t,size:e})}),L.Avatars=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),L.Content=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var R=()=>(0,P.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function z(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function B(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${z(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 V=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=p(),s=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(y,{actor:t,align:`center`,isCurrentUser:!1,children:(0,P.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&x(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,P.jsxs)(P.Fragment,{children:[s,` followed you`]});case`like`:return(0,P.jsxs)(P.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,P.jsxs)(P.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,P.jsx)(P.Fragment,{})},H=({content:e,className:t,stripTags:n=[]})=>{let r=(0,N.useRef)(null),i=p();return(0,N.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(),x(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,P.jsx)(`div`,{dangerouslySetInnerHTML:{__html:v(T(e||``,n))},ref:r,className:t})},U=({post:e,variant:t})=>{let n=e?.attachments??[],r=n.length>0,{contentWarning:i,shouldHideContentWarning:a,shouldHideSensitiveMedia:o,revealSensitiveMedia:s,revealContentWarning:c}=k({contentWarning:e?.contentWarning,sensitive:e?.sensitive,hasMedia:r,resetKey:e?.id});return e?a&&i?t===`inline`?(0,P.jsxs)(`button`,{className:`mt-0.5 block max-w-full truncate text-left text-sm text-gray-700 hover:text-black dark:text-gray-600 dark:hover:text-white`,type:`button`,onClick:c,children:[(0,P.jsx)(`span`,{className:`font-semibold`,children:`Content warning:`}),` `,i,` `,(0,P.jsx)(`span`,{className:`font-semibold`,children:`Show`})]}):(0,P.jsx)(w,{className:`mt-2.5`,label:i,size:`compact`,onReveal:c}):t===`inline`?(0,P.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[e.type===`article`&&e.title&&(0,P.jsxs)(P.Fragment,{children:[e.title,` — `]}),(0,P.jsx)(`span`,{dangerouslySetInnerHTML:{__html:v(T(e.content||``))}})]}):(0,P.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,P.jsx)(H,{className:`ap-note-content text-pretty`,content:e.content||``,stripTags:[`a`]}),r&&(0,P.jsxs)(`div`,{className:`relative mt-2.5 aspect-square w-[calc(20%-6.4px)] min-w-[96px] overflow-hidden rounded-md [&_img]:absolute [&_img]:inset-0 [&_img]:mt-0 [&_img]:size-full [&_img]:max-h-none [&_img]:max-w-none [&_img]:object-cover [&>.attachment-gallery]:absolute [&>.attachment-gallery]:inset-0 [&>.attachment-gallery]:mt-0 [&>.attachment-gallery]:grid [&>.attachment-gallery]:size-full`,children:[m({type:`Note`,attachment:n}),o&&(0,P.jsx)(S,{showLabel:!1,size:`compact`,isLayered:!0,onReveal:s})]})]}):null},W=()=>{let[e,t]=N.useState({}),n=p(),o=e=>{t(t=>({...t,[e]:!t[e]}))},s=()=>{},{data:c,error:l,fetchNextPage:d,hasNextPage:m,isFetchingNextPage:v,isLoading:y}=A(`index`),S=c?.pages.flatMap(e=>B(e.notifications))??Array(10).fill({actors:[{}]}),w=(0,N.useRef)(null),T=(0,N.useRef)(null);(0,N.useEffect)(()=>(w.current&&w.current.disconnect(),w.current=new IntersectionObserver(e=>{e[0].isIntersecting&&m&&!v&&d()}),T.current&&w.current.observe(T.current),()=>{w.current&&w.current.disconnect()}),[m,v,d]);let k=(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?o(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&x(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return l&&h(l)?(0,P.jsx)(D,{errorCode:l.code,statusCode:l.statusCode}):(0,P.jsx)(O,{children:(0,P.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[y===!1&&S.length===0&&(0,P.jsxs)(j,{children:[(0,P.jsx)(M,{children:(0,P.jsx)(a,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),S.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:S.map((t,a)=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsxs)(L,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>k(t,a),children:[y?(0,P.jsx)(f,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,P.jsx)(L.Icon,{type:t.type}):(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(_,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,P.jsx)(F,{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,P.jsx)(L.Avatars,{children:(0,P.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,P.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,P.jsx)(_,{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,P.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,P.jsxs)(u,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${a}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),o(t.id||`${t.type}_${a}`)},children:[(0,P.jsx)(i,{className:`${e[t.id||`${t.type}_${a}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${a}`]?`Hide`:(0,P.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,P.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,P.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,P.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&x(e.handle,n)},children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,P.jsx)(_,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,P.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,P.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,P.jsx)(E,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,P.jsxs)(L.Content,{children:[(0,P.jsx)(`div`,{children:y?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(f,{}),(0,P.jsx)(f,{className:`w-full max-w-60`})]}):(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:(0,P.jsx)(V,{group:t})}),t.actors.length<2&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,P.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:b(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,P.jsx)(E,{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)&&(0,P.jsx)(U,{post:t.post,variant:t.type!==`reply`&&t.type!==`mention`?`inline`:`quoted`}),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,P.jsx)(`div`,{className:`mt-1.5`,children:(0,P.jsx)(g,{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:s})})]})]}),a<S.length-1&&(0,P.jsx)(`div`,{className:`pl-[52px]`,children:(0,P.jsx)(R,{})})]},t.id||`${t.type}_${a}`))}),(0,P.jsx)(`div`,{ref:T,className:`h-1`}),v&&(0,P.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,P.jsx)(C,{size:`md`})})]})]})})};export{W 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"./dist-B3keLvjj.js";import{Cr as i,ct as a,h as o,hn as s,ot as c,t as l,tr as u,yr as d}from"./button-Dvcv1QSR.js";import{t as f}from"./skeleton-Ce9GgUpf.js";import{t as p}from"./use-navigate-with-base-path-BkxcPj5l.js";import{An as m,Ft as h,Gt as g,It as _,Jt as v,Kt as y,Nt as b,Ot as x,Pt as S,Rt as C,Yt as w,_t as T,gt as E,ht as D,jt as O,nr as k,pn as A,vt as j,zt as M}from"./index-CgMCwsxN.js";import"./layout-DUTL8SH5.js";var N=e(t(),1),P=n(),F=({notificationType:e,size:t=`lg`,className:n})=>{let r,l=``,u=`white`,d=t===`sm`?13:20,f=t===`sm`?2:1.5;switch(e){case`follow`:r=(0,P.jsx)(o,{className:`-mt-0.5 -mr-0.5 ${t===`sm`&&`size-[11px]`}`,color:u,size:d,strokeWidth:f}),l=`bg-blue-600`;break;case`like`:r=(0,P.jsx)(s,{className:`${t===`sm`?`size-[11px]`:`mt-px size-5`}`,color:u,strokeWidth:f}),l=`bg-pink-600`;break;case`reply`:r=(0,P.jsx)(c,{className:`mr-px mb-px`,color:u,size:d,strokeWidth:f}),l=`bg-purple-600`;break;case`repost`:r=(0,P.jsx)(a,{color:u,size:d,strokeWidth:f}),l=`bg-green-500`;break;case`mention`:r=(0,P.jsx)(i,{className:`${t===`sm`?`size-[12px]`:`size-5`}`,color:u,size:d,strokeWidth:f}),l=`bg-orange-500`;break}return(0,P.jsx)(`div`,{className:`flex ${t===`sm`?`size-5`:`size-9`} items-center justify-center rounded-full ${l} ${n&&n}`,children:r})},I=N.createContext(void 0),L=({isGrouped:e,centerAlign:t,children:n,onClick:r,url:i,className:a})=>(0,P.jsx)(I.Provider,{value:{onClick:r,url:i},children:(0,P.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})});L.Icon=({size:e=`lg`,type:t})=>(0,P.jsx)(`div`,{className:`col-start-1 row-start-1`,children:(0,P.jsx)(F,{notificationType:t,size:e})}),L.Avatars=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-1 flex gap-2`,children:e}),L.Content=({children:e})=>(0,P.jsx)(`div`,{className:`col-start-2 row-start-2 -mt-0.5 grow overflow-hidden`,children:e});var R=()=>(0,P.jsx)(`div`,{className:`h-px w-full bg-gray-200 dark:bg-gray-950`});function z(e){let t=1440*60*1e3,n=new Date(e).getTime();return(Math.floor(n/t)*t).toString()}function B(e){let t={},n=null,r=0;return e.forEach(e=>{e.type!==n&&(r+=1,n=e.type);let i=``,a=`_${z(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 V=({group:e})=>{let[t,...n]=e.actors,i=n.length>0,a=n.length,o=p(),s=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(M,{actor:t,align:`center`,isCurrentUser:!1,children:(0,P.jsx)(`span`,{className:`cursor-pointer font-semibold hover:underline text-black dark:text-white`,onClick:e=>{e?.stopPropagation(),t.handle&&_(t.handle,o)},children:t.name})}),i&&` and ${r(a)} ${a>1?`others`:`other`}`]});switch(e.type){case`follow`:return(0,P.jsxs)(P.Fragment,{children:[s,` followed you`]});case`like`:return(0,P.jsxs)(P.Fragment,{children:[s,` liked your `,e.post?.type===`article`?`post`:`note`]});case`repost`:return(0,P.jsxs)(P.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,P.jsx)(P.Fragment,{})},H=({content:e,className:t,stripTags:n=[]})=>{let r=(0,N.useRef)(null),i=p();return(0,N.useEffect)(()=>{let e=r.current;if(!e)return;let t=e=>{let t=e.target.closest(`a[data-profile]`);if(t){let n=t.getAttribute(`data-profile`)?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(n||``)&&n&&(e.preventDefault(),e.stopPropagation(),_(n,i))}};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}},[i,e]),(0,P.jsx)(`div`,{dangerouslySetInnerHTML:{__html:g(y(e||``,n))},ref:r,className:t})},U=({post:e,variant:t})=>{let n=e?.attachments??[],r=n.length>0,{contentWarning:i,shouldHideContentWarning:a,shouldHideSensitiveMedia:o,revealSensitiveMedia:s,revealContentWarning:c}=S({contentWarning:e?.contentWarning,sensitive:e?.sensitive,hasMedia:r,resetKey:e?.id});return e?a&&i?t===`inline`?(0,P.jsxs)(`button`,{className:`mt-0.5 block max-w-full truncate text-left text-sm text-gray-700 hover:text-black dark:text-gray-600 dark:hover:text-white`,type:`button`,onClick:c,children:[(0,P.jsx)(`span`,{className:`font-semibold`,children:`Content warning:`}),` `,i,` `,(0,P.jsx)(`span`,{className:`font-semibold`,children:`Show`})]}):(0,P.jsx)(x,{className:`mt-2.5`,label:i,size:`compact`,onReveal:c}):t===`inline`?(0,P.jsxs)(`div`,{className:`ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600`,children:[e.type===`article`&&e.title&&(0,P.jsxs)(P.Fragment,{children:[e.title,` — `]}),(0,P.jsx)(`span`,{dangerouslySetInnerHTML:{__html:g(y(e.content||``))}})]}):(0,P.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,P.jsx)(H,{className:`ap-note-content text-pretty`,content:e.content||``,stripTags:[`a`]}),r&&(0,P.jsxs)(`div`,{className:`relative mt-2.5 aspect-square w-[calc(20%-6.4px)] min-w-[96px] overflow-hidden rounded-md [&_img]:absolute [&_img]:inset-0 [&_img]:mt-0 [&_img]:size-full [&_img]:max-h-none [&_img]:max-w-none [&_img]:object-cover [&>.attachment-gallery]:absolute [&>.attachment-gallery]:inset-0 [&>.attachment-gallery]:mt-0 [&>.attachment-gallery]:grid [&>.attachment-gallery]:size-full`,children:[b({type:`Note`,attachment:n}),o&&(0,P.jsx)(O,{showLabel:!1,size:`compact`,isLayered:!0,onReveal:s})]})]}):null},W=()=>{let[e,t]=N.useState({}),n=p(),i=e=>{t(t=>({...t,[e]:!t[e]}))},a=()=>{},{data:o,error:s,fetchNextPage:c,hasNextPage:g,isFetchingNextPage:y,isLoading:b}=A(`index`),x=o?.pages.flatMap(e=>B(e.notifications))??Array(10).fill({actors:[{}]}),S=(0,N.useRef)(null),O=(0,N.useRef)(null);(0,N.useEffect)(()=>(S.current&&S.current.disconnect(),S.current=new IntersectionObserver(e=>{e[0].isIntersecting&&g&&!y&&c()}),O.current&&S.current.observe(O.current),()=>{S.current&&S.current.disconnect()}),[g,y,c]);let M=(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?i(e.id||`${e.type}_${t}`):e.actors[0]?.handle&&_(e.actors[0].handle,n);break;case`mention`:e.post&&n(`/notes/${encodeURIComponent(e.post.id)}`);break}};return s&&m(s)?(0,P.jsx)(D,{errorCode:s.code,statusCode:s.statusCode}):(0,P.jsx)(j,{children:(0,P.jsxs)(`div`,{className:`z-0 flex w-full flex-col items-center`,children:[b===!1&&x.length===0&&(0,P.jsxs)(T,{children:[(0,P.jsx)(E,{children:(0,P.jsx)(d,{})}),`Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here.`]}),x.length>0&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`my-8 flex w-full max-w-[620px] flex-col max-md:mt-5`,children:x.map((t,o)=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsxs)(L,{centerAlign:t.actors.length<2&&t.type===`follow`,className:`hover:bg-gray-100 dark:hover:bg-gray-950`,isGrouped:t.actors.length>1,onClick:()=>M(t,o),children:[b?(0,P.jsx)(f,{className:`rounded-full`,containerClassName:`flex h-10 w-10`}):t.actors.length>1?(0,P.jsx)(L.Icon,{type:t.type}):(0,P.jsxs)(`div`,{className:`relative`,children:[(0,P.jsx)(w,{author:{icon:{url:t.actors[0].avatarUrl||``},name:t.actors[0].name,handle:t.actors[0].handle},size:`notification`},t.actors[0].id),(0,P.jsx)(F,{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,P.jsx)(L.Avatars,{children:(0,P.jsxs)(`div`,{className:`flex w-full flex-col`,children:[(0,P.jsxs)(`div`,{className:`relative flex w-fit items-center pl-2`,children:[!e[t.id||`${t.type}_${o}`]&&t.actors.slice(0,5).map(e=>(0,P.jsx)(w,{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}_${o}`]&&(0,P.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,P.jsxs)(l,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${e[t.id||`${t.type}_${o}`]?`ml-[-20px]`:`ml-0 w-[28px]`}`,variant:`ghost`,onClick:e=>{e?.stopPropagation(),i(t.id||`${t.type}_${o}`)},children:[(0,P.jsx)(u,{className:`${e[t.id||`${t.type}_${o}`]?`rotate-180`:``}`,size:20,strokeWidth:1.5}),e[t.id||`${t.type}_${o}`]?`Hide`:(0,P.jsx)(`span`,{className:`sr-only`,children:`Show all`})]})]}),(0,P.jsx)(`div`,{className:`overflow-hidden transition-all duration-300 ease-in-out ${e[t.id||`${t.type}_${o}`]?`mb-2 max-h-[1384px] opacity-100`:`max-h-0 opacity-0`}`,children:e[t.id||`${t.type}_${o}`]&&t.actors.length>1&&(0,P.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t.actors.map(e=>(0,P.jsxs)(`div`,{className:`group/item break-anywhere flex items-center justify-between gap-4`,onClick:t=>{t?.stopPropagation(),e.handle&&_(e.handle,n)},children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center`,children:[(0,P.jsx)(w,{author:{icon:{url:e.avatarUrl||``},name:e.name,handle:e.handle},size:`xs`}),(0,P.jsx)(`span`,{className:`ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white`,children:e.name}),(0,P.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,P.jsx)(v,{following:!1,handle:e.handle,variant:`link`})]},e.id))})})]})}),(0,P.jsxs)(L.Content,{children:[(0,P.jsx)(`div`,{children:b?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(f,{}),(0,P.jsx)(f,{className:`w-full max-w-60`})]}):(0,P.jsxs)(`div`,{className:`flex justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsx)(`span`,{className:`truncate`,children:(0,P.jsx)(V,{group:t})}),t.actors.length<2&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`mt-px text-[8px] text-gray-700 dark:text-gray-600`,children:`•`}),(0,P.jsx)(`span`,{className:`mt-0.5 text-sm text-gray-700 dark:text-gray-600`,children:h(t,!1)})]})]}),t.actors.length===1&&(t.type===`follow`||t.type===`reply`||t.type===`mention`)&&!t.actors[0].followedByMe&&t.actors[0].handle&&(0,P.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)&&(0,P.jsx)(U,{post:t.post,variant:t.type!==`reply`&&t.type!==`mention`?`inline`:`quoted`}),(t.type===`reply`&&t.post||t.type===`mention`)&&(0,P.jsx)(`div`,{className:`mt-1.5`,children:(0,P.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:a})})]})]}),o<x.length-1&&(0,P.jsx)(`div`,{className:`pl-[52px]`,children:(0,P.jsx)(R,{})})]},t.id||`${t.type}_${o}`))}),(0,P.jsx)(`div`,{ref:O,className:`h-1`}),y&&(0,P.jsx)(`div`,{className:`-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center`,children:(0,P.jsx)(k,{size:`md`})})]})]})})};export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e}from"./framework-provider-DqI25epG.js";import{i as t,n,r}from"./hooks-
|
|
1
|
+
import{s as e}from"./framework-provider-DqI25epG.js";import{i as t,n,r}from"./hooks-Cy_-oZ4o.js";import{n as i,r as a}from"./update-queries-C4CnvJaW.js";var o=`OffersResponseType`,s=()=>{let t=e();return()=>t.invalidateQueries({queryKey:[o]})},c=r({dataType:o,path:`/offers/`,defaultSearchParams:{}}),l=t({dataType:o,path:e=>`/offers/${e}/`}),u=n({method:`PUT`,path:e=>`/offers/${e.id}/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:a(`offers`)}}),d=n({method:`POST`,path:()=>`/offers/`,body:e=>({offers:[e]}),updateQueries:{dataType:o,emberUpdateType:`createOrUpdate`,update:i(`offers`)}});export{s as a,u as i,c as n,l as r,d 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{_ as r,f as i,p as a}from"./hooks-CuEZV2-q.js";import{n as o}from"./dist-Ndy-PuGN.js";import{t as s}from"./use-form-vRjI0Kwk.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers-9J1CSiLy.js";import{i as p,r as m}from"./currency-Dy4Tc2R2.js";import{m as h}from"./dist-B3keLvjj.js";import{t as g}from"./inline-BWSs_VzR.js";import{t as _}from"./stack-B2eszIiq.js";import{Or as v,Sr as y,br as b,en as x,t as S}from"./button-eNMKQWXr.js";import{t as C}from"./switch-CI4gLWqb.js";import{i as w,n as T,o as E,s as D,t as O}from"./select-cb0t_TAJ.js";import{o as k,t as A}from"./use-settings-navigation-CZjGrhsp.js";import{a as j,i as M,n as N,o as P,r as F,t as I}from"./field-Dihp5p18.js";import{a as L,i as R,n as z,r as B,t as V}from"./input-group-CMhe2DvY.js";import{n as H,t as ee}from"./radio-group-DczlLKOn.js";import{a as U,c as W,n as G,r as K,s as te,t as q}from"./table-Do6iQ83Q.js";import{t as J}from"./textarea-DJ1Q5V39.js";import{$n as Y,Cr as ne,Dr as re,Er as ie,Kn as X,Or as ae,Sr as oe,Tr as se,jr as ce,kr as le,ut as ue,xr as de}from"./index-6MkPdCtr.js";import{a as fe,r as pe}from"./tiers-Nd_z4BZY.js";import{n as me}from"./confirmation-context-CBM8G0Vj.js";import{n as Z}from"./global-data-context-gAMDH9u1.js";import{t as he}from"./brand-icon-CrIGOA3Z.js";import{o as ge,r as _e}from"./zapier-modal-BBFfI6Ml.js";import{t as ve}from"./preview-modal-BfeFqi5y.js";import{t as ye}from"./portal-frame-B6Hr9wHc.js";import{t as be}from"./settings-breadcrumbs-DLzbRRSt.js";var xe=(e,t)=>{let{disableBackground:n=!1,name:r,code:i,displayTitle:a=``,displayDescription:o=``,type:s,cadence:c,amount:l=0,duration:u,durationInMonths:d,currency:f=`usd`,status:p,tierId:m,redemptionType:h=`signup`}=e;t=t.replace(/\/$/,``);let g=new URLSearchParams;return g.append(`disableBackground`,`false`),g.append(`name`,encodeURIComponent(r)),g.append(`code`,encodeURIComponent(i)),g.append(`display_title`,encodeURIComponent(a)),g.append(`display_description`,encodeURIComponent(o)),g.append(`type`,encodeURIComponent(s)),g.append(`cadence`,encodeURIComponent(c)),g.append(`amount`,encodeURIComponent(l)),g.append(`duration`,encodeURIComponent(u)),g.append(`duration_in_months`,encodeURIComponent(d)),g.append(`currency`,encodeURIComponent(f)),g.append(`status`,encodeURIComponent(p)),g.append(`tier_id`,encodeURIComponent(m)),g.append(`redemption_type`,encodeURIComponent(h)),n&&g.append(`disableBackground`,`true`),g.append(`admin_toolbar`,`0`),`${t}/?v=modal-portal-offer#/portal/preview/offer?${g.toString()}`},Se=e=>{let t=[];return e.forEach(e=>{t.push({label:`${e.name} - Monthly`,value:`${e.id}-month-${e.currency}`}),t.push({label:`${e.name} - Yearly`,value:`${e.id}-year-${e.currency}`})}),t},Q=e(t(),1),$=n();function Ce(e){return e.toString().toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^\w-]+/g,``).replace(/--+/g,`-`)}var we=191,Te=e=>{let{fixedAmount:t=0,percentAmount:n=0,trialAmount:r=0,amount:i=0}=e;switch(e.type){case`fixed`:return t*100;case`percent`:return n;case`trial`:return r;default:return i}},Ee=({tierOptions:e,handleTierChange:t,selectedTier:n,typeOptions:r,durationOptions:i,handleTypeChange:a,handleDurationChange:o,overrides:s,handleAmountTypeChange:c,handleNameInput:l,handleTextAreaInput:u,handleDisplayTitleInput:d,handleDurationInMonthsInput:f,handleAmountInput:p,handleCodeInput:m,clearError:g,errors:_,testId:v,handleTrialAmountInput:y,amountOptions:b})=>{let x=s.cadence===`year`,C=x?i.filter(e=>e.value!==`repeating`):i,[k,A]=(0,Q.useState)(0),B=k>40?`text-red`:`text-green`,{siteData:U}=Z(),[W,G]=(0,Q.useState)(!1),K=ue(U),te=`${K}${s.code.value}`,q=async()=>{await navigator.clipboard.writeText(te),G(!0),setTimeout(()=>G(!1),2e3)};return(0,$.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,$.jsxs)(j,{className:`mb-10 gap-8`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{"data-invalid":!!_.name||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-name`,children:`Offer name`}),(0,$.jsx)(Y,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),A(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,$.jsx)(M,{children:_.name}):(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,$.jsxs)(`strong`,{children:[(0,$.jsx)(`span`,{className:B,children:h(k)}),` /`,` `,h(40)]})]})})]}),(0,$.jsxs)(I,{"data-invalid":!!_.displayTitle||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-display-title`,children:`Display title`}),(0,$.jsx)(Y,{"aria-invalid":!!_.displayTitle||void 0,id:`offer-display-title`,maxLength:we,placeholder:`Black Friday Special`,value:s.displayTitle.value,onChange:e=>{d(e)},onKeyDown:()=>g(`displayTitle`)}),_.displayTitle&&(0,$.jsx)(M,{children:_.displayTitle})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`offer-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`offer-display-description`,maxLength:we,placeholder:`Take advantage of this limited-time offer.`,value:s.displayDescription,onChange:e=>{u(e)}})]})]})]}),(0,$.jsxs)(`section`,{className:`mt-4`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(ee,{"aria-label":`Offer type`,className:`rounded-md border border-border-default p-4`,value:s.type===`trial`?`trial`:`percent`,onValueChange:a,children:r.map(e=>{let t=`offer-type-${e.value}`;return(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsx)(H,{id:t,value:e.value}),(0,$.jsxs)(N,{children:[(0,$.jsx)(P,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,$.jsx)(F,{children:e.description})]})]},e.value)})}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Tier — Cadence`}),(0,$.jsxs)(O,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,$.jsx)(E,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:e.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-amount`,children:`Amount off`}),(0,$.jsxs)(V,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(R,{id:`offer-amount`,type:`number`,value:s.type===`fixed`?s.fixedAmount===0?``:s.fixedAmount?.toString():s.percentAmount===0?``:s.percentAmount?.toString(),onChange:e=>{p(e)},onKeyDown:()=>g(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsxs)(O,{value:s.type===`percent`?b[0].value:b[1].value,onValueChange:c,children:[(0,$.jsx)(E,{"aria-label":`Amount type`,className:`h-7 w-20 border-0 bg-transparent px-2 shadow-none focus-visible:ring-0`,"data-testid":`amount-type-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{align:`end`,children:b.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,$.jsx)(M,{children:_.amount})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Duration`}),(0,$.jsxs)(O,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,$.jsx)(E,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:C.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!x&&(0,$.jsx)(`div`,{className:`-mt-4`,children:(0,$.jsxs)(I,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,$.jsxs)(V,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!_.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:s.durationInMonths===0?``:String(s.durationInMonths),onChange:e=>{f(e)},onKeyDown:()=>g(`durationInMonths`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,$.jsx)(M,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,$.jsxs)(I,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,$.jsx)(Y,{"aria-invalid":!!_.amount||void 0,id:`trial-duration`,type:`number`,value:s.trialAmount?.toString(),onChange:e=>{y(e)},onKeyDown:()=>g(`amount`)}),_.amount&&(0,$.jsx)(M,{children:_.amount})]}),(0,$.jsxs)(I,{"data-invalid":!!_.code||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-code`,children:`Offer code`}),(0,$.jsx)(Y,{"aria-invalid":!!_.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:s.code.value,onChange:e=>{m(e)},onKeyDown:()=>g(`code`)}),_.code?(0,$.jsx)(M,{children:_.code}):s.code.value!==``&&(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[K,(0,$.jsx)(`span`,{className:`font-bold`,children:s.code.value})]}),(0,$.jsx)(S,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void q(),children:W?`Copied`:`Copy`})]})})]})]})]})]})})},De=e=>{let[t,n,r]=e.split(`-`);if(!t||!n||!r)throw Error(`Invalid input format. Expected format is: id-period-currency`);return{id:t,period:n,currency:r}},Oe=()=>{let{siteData:e}=Z(),t=[{title:`Discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free trial`,description:`Give free access for a limited time`,value:`trial`}],n=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],[i,a]=(0,Q.useState)(``),{updateRoute:c}=A(),{data:{tiers:l}={}}=fe(),d=pe(l||[]),p=Se(d),{mutateAsync:m}=f(),[h,g]=(0,Q.useState)({tier:p[0]||{},dataset:{id:p[0]?.value?De(p[0]?.value).id:``,period:p[0]?.value?De(p[0]?.value).period:``,currency:p[0]?.value?De(p[0]?.value).currency:``}}),{data:{offers:_=[]}={}}=u(),{formState:v,updateForm:y,handleSave:b,saveState:x,okProps:S,validate:C,errors:w,clearError:T}=s({initialState:{disableBackground:!1,name:``,code:{isDirty:!1,value:``},displayTitle:{isDirty:!1,value:``},displayDescription:``,type:`percent`,cadence:h?.dataset?.period||``,amount:0,duration:`once`,durationInMonths:1,currency:h?.dataset?.currency||`USD`,status:`active`,tierId:h?.dataset?.id||``,trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{let e=v.type===`trial`?`trial`:v.duration,t={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:Te(v)||0,duration:e,...e===`repeating`?{duration_in_months:v.durationInMonths}:{},currency:v.currency,status:v.status,redemption_type:`signup`,tier:{id:v.tierId},type:v.type,currency_restriction:!1},n=await m(t);n&&n.offers&&n.offers.length>0&&c(`offers/success/${n.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{let e={};return!v.name&&v.name.length===0&&(e.name=`Name is required`),!v.code.value&&v.code.value.length===0&&(e.code=`Code is required`),!v.displayTitle.value&&v.displayTitle.value.length===0&&(e.displayTitle=`Display title is required`),v.type===`percent`&&v.percentAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`percent`&&(v.percentAmount<1||v.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),(v.type===`fixed`&&v.fixedAmount===0||v.type===`fixed`&&v.fixedAmount<1)&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount<1&&(e.amount=`Free trial must be at least 1 day.`),v.type!==`trial`&&v.duration===`repeating`&&(!Number.isInteger(v.durationInMonths)||v.durationInMonths<1)&&(e.durationInMonths=`Enter a whole number of months (1 or more).`),e},savingDelay:500}),E=[{value:`percent`,label:`%`},{value:`fixed`,label:v.currency}],D=e=>{let t=De(e.value),n=t.period===`year`;g({tier:e,dataset:t}),y(e=>({...e,cadence:t.period,currency:t.currency,tierId:t.id,duration:n&&e.duration===`repeating`?`once`:e.duration})),n&&T(`durationInMonths`)},O=e=>{e===`trial`&&(T(`amount`),T(`durationInMonths`)),y(t=>({...t,type:e}))},k=e=>{y(t=>({...t,type:e===`percent`?`percent`:`fixed`}))},j=e=>{let t=e.target;v.type===`fixed`?y(e=>({...e,fixedAmount:Number(t.value)})):v.type===`percent`?y(e=>({...e,percentAmount:Number(t.value)})):y(e=>({...e,amount:Number(t.value)}))},M=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},N=e=>{let t=e.target.value;y(e=>{let n={...e};return n.name=t,e.code.isDirty||(T(`code`),n.code={...e.code,value:Ce(t)}),e.displayTitle.isDirty||(T(`displayTitle`),n.displayTitle={...e.displayTitle,value:t}),n})},P=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},F=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},I=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},L=e=>{y(t=>({...t,duration:e}))},R=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},z=()=>{_.length>0?c(`offers/edit`):c(`offers`)},B=(0,Q.useMemo)(()=>({name:v.name||``,code:v.code.value||``,displayTitle:v.displayTitle.value||``,displayDescription:v.displayDescription||``,type:v.type||`percent`,cadence:v.cadence||`month`,amount:Te(v)||0,duration:v.type===`trial`?`trial`:v.duration||`once`,durationInMonths:v.durationInMonths||0,currency:v.currency||`USD`,status:v.status||`active`,tierId:v.tierId||d[0]?.id,redemptionType:`signup`}),[v,d]);(0,Q.useEffect)(()=>{let t=xe(B,e.url);a(t)},[v,e.url,v.type,B]);let V=(0,$.jsx)(Ee,{amountOptions:E,clearError:T,durationOptions:n,errors:w,handleAmountInput:j,handleAmountTypeChange:k,handleCodeInput:R,handleDisplayTitleInput:P,handleDurationChange:L,handleDurationInMonthsInput:M,handleNameInput:N,handleTextAreaInput:F,handleTierChange:D,handleTrialAmountInput:I,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),H=(0,$.jsx)(ye,{href:i||``,portalParent:`offers`});return(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:x===`unsaved`,height:`full`,okLabel:`Publish`,okVariant:S.variant,preview:H,previewToolbar:!1,sidebar:V,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:z,onClose:()=>{c(`offers`)},onOk:async()=>{if(C(),!Object.values(w).every(e=>!e)){o.dismiss(),o.info(`Can't save offer`,{description:`Make sure you filled all required fields`});return}try{if(await b({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:t||`Please try again later`})}}})},ke=e=>new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`}),Ae=e=>{let t=`${i().adminRoot}#/members`,n=`offer_redemptions:[${e.join(`,`)}]`;return`${t}?filter=${encodeURIComponent(n)}`},je=e=>Ae([e]),Me=({amount:e,duration:t})=>e===100&&t===`repeating`,Ne=(e,t)=>`Retention ${e} (${t})`,Pe=({amount:e,duration:t,durationInMonths:n})=>Me({amount:e,duration:t})?`${n} ${n===1?`month`:`months`} free`:t===`once`?`${e}% off once`:t===`repeating`?`${e}% off for ${n} mo`:`${e}% off forever`,Fe=(e,t)=>{let n=t.trim(),r=Pe(e),i=Ne(r,n);if(i.length<=40)return i;let a=i.length-40,o=Math.max(3,n.length-a);return Ne(r,n.slice(0,o))},Ie=e=>e===`month`?`monthly`:`yearly`,Le=e=>e===`once`?`First payment`:e===`repeating`?`Repeating`:`Forever`,Re=(e,t,n,r,i)=>{let a=``,o=n===`month`?i?.monthly_price??0:i?.yearly_price??0,s=o,c=e=>parseFloat(e.toFixed(2)),l=e=>h(c(m(e)),{maximumFractionDigits:2}),u=p(r)+l(o);switch(e){case`percent`:a=`${h(t)}% off`,s=o-o*t/100;break;case`fixed`:a=`${l(t)} ${r} off`,s=o-t;break;case`trial`:a=`${h(t)} days free`,u=``;break;default:break}s<0&&(s=0);let d=p(r)+l(s);return{discountOffer:a,originalPriceWithCurrency:u,updatedPriceWithCurrency:d}};function ze(e){return new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`})}var Be=({clearError:e,errors:t,offer:n,updateOffer:r})=>{let{siteData:i}=Z(),[s,c]=(0,Q.useState)(!1),u=a(),{confirm:d}=me(),{mutateAsync:f}=l(),[p,m]=(0,Q.useState)(n?.name.length||0),g=p>40?`text-red`:`text-green`,{updateRoute:_}=A();(0,Q.useEffect)(()=>{n?.name&&m(n?.name.length)},[n?.name]);let v=ue(i),y=`${v}${n?.code}`,b=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},x=()=>{n?.status===`active`?d({title:`Archive offer`,prompt:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`New members will no longer be able to subscribe using this offer.`}),(0,$.jsxs)(`p`,{children:[`All members that previously redeemed `,(0,$.jsx)(`strong`,{children:n?.name}),` will remain unchanged.`]})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async e=>{try{await f({...n,status:`archived`}),e?.remove(),o.success(`Offer archived`),_(`offers/edit`)}catch(e){u(e)}}}):d({title:`Reactivate offer`,prompt:(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`p`,{children:[`Reactivating `,(0,$.jsx)(`strong`,{children:n?.name}),` will allow new members to subscribe using this offer. Existing members will remain unchanged.`]})}),okLabel:`Reactivate`,onOk:async e=>{try{await f({...n,status:`active`}),e?.remove(),o.success(`Offer reactivated`),_(`offers/edit`)}catch(e){u(e)}}})};return(0,$.jsxs)(`div`,{className:`flex grow flex-col pt-2`,children:[(0,$.jsxs)(j,{className:`mb-10 grow gap-8`,children:[(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-md border border-gray-300 p-4 pb-3.5 dark:border-gray-800`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Created on`}),(0,$.jsx)(`span`,{children:ze(n?.created_at?n.created_at:``)})]}),(0,$.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Performance`}),(0,$.jsxs)(`span`,{children:[h(n?.redemption_count||0),` `,n?.redemption_count===1?`redemption`:`redemptions`]})]}),n?.redemption_count>0&&n?.last_redeemed?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Last redemption`}),(0,$.jsx)(`span`,{children:ze(n?.last_redeemed)})]}):null]}),n?.redemption_count>0?(0,$.jsx)(`a`,{className:`font-semibold text-green`,href:je(n?.id),children:`See members →`}):null]})]})}),(0,$.jsxs)(`section`,{className:`mt-2`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{"data-invalid":!!t.name||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-name`,children:`Offer name`}),(0,$.jsx)(Y,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),r({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,$.jsx)(M,{children:t.name}):(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,$.jsxs)(`strong`,{children:[(0,$.jsx)(`span`,{className:g,children:h(p)}),` /`,` `,h(40)]})]})})]}),(0,$.jsxs)(I,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-code`,children:`Offer code`}),(0,$.jsxs)(V,{"data-invalid":!!t.code||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>r({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(B,{onClick:()=>void b(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,$.jsx)(M,{children:t.code}):n?.code!==``&&(0,$.jsxs)(F,{className:`truncate`,children:[v,(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,$.jsxs)(I,{"data-invalid":!!t.displayTitle||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-display-title`,children:`Display title`}),(0,$.jsx)(Y,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>r({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,$.jsx)(M,{children:t.displayTitle})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`offer-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`offer-display-description`,placeholder:`Take advantage of this limited-time offer.`,value:n?.display_description??``,onChange:e=>r({display_description:e.target.value})})]})]})]})]}),(0,$.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,$.jsx)(S,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:x,children:`Archive offer`}):(0,$.jsx)(S,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:x,children:`Reactivate offer`})})]})},Ve=({id:e})=>{let{siteData:t}=Z(),{updateRoute:n}=A(),i=a(),{mutateAsync:c}=l(),[u,f]=(0,Q.useState)(``),{data:{offers:p=[]}={}}=d(e||``),{formState:m,saveState:h,updateForm:g,setFormState:_,handleSave:v,validate:y,errors:b,clearError:x,okProps:S}=s({initialState:p[0],savingDelay:500,onSave:async()=>{await c(m)},onSaveError:i,onValidate:()=>{let e={};return m?.name||(e.name=`Name is required`),m?.display_title||(e.displayTitle=`Display title is required`),m?.code||(e.code=`Please enter a code`),e}});(0,Q.useEffect)(()=>{_(()=>p[0])},[_,p]);let C=(0,$.jsx)(Be,{clearError:x,errors:b,offer:m,updateOffer:e=>{g(t=>({...t,...e}))},validate:y});(0,Q.useEffect)(()=>{let e=xe({name:m?.name||``,code:m?.code||``,displayTitle:m?.display_title||``,displayDescription:m?.display_description||``,type:m?.type||``,cadence:m?.cadence||``,amount:m?.amount,duration:m?.duration||``,durationInMonths:m?.duration_in_months||0,currency:m?.currency||``,status:m?.status||``,tierId:m?.tier?.id||``,redemptionType:`signup`},t.url);f(e)},[m,t]);let w=(0,$.jsx)(ye,{href:u||``,portalParent:`offers`}),T=()=>{n(`offers/edit`)};return p?(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:h===`unsaved`,height:`full`,okLabel:S.label||`Save`,okVariant:S.variant,preview:w,previewToolbarBreadcrumbs:(0,$.jsx)(be,{current:m?.name||`Offer`,label:`Offers`,onBack:T}),sidebar:C,size:`lg`,testId:`offer-update-modal`,title:`Offer`,width:1140,onCancel:T,onClose:()=>{n(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:`Please try again later`})}}}):null},He=[{title:`Percentage discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free month(s)`,description:`Give free access for a limited time`,value:`free_months`}],Ue=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],We=191,Ge=99,Ke=`Enter a whole number of months between 1 and ${Ge}.`,qe=e=>Math.max(1,Number.isFinite(e)?Math.trunc(e):0),Je=({type:e,percentAmount:t,freeMonths:n,lastPercentAmount:r,lastFreeMonths:i})=>e===`free_months`?n>0?n:i:t>0?t:r,Ye=(e=`monthly`)=>({enabled:!1,displayTitle:``,displayDescription:``,type:e===`yearly`?`percent`:`free_months`,percentAmount:20,duration:`once`,durationInMonths:1,freeMonths:1}),Xe=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,Ze=(e,t=`monthly`)=>{let n=Ye(t);if(!e)return n;let r=Xe(e),i=e.type===`percent`&&!r,a=e.duration===`repeating`&&e.duration_in_months?e.duration_in_months:n.durationInMonths;return{enabled:e.status===`active`,displayTitle:e.display_title||``,displayDescription:e.display_description||``,type:r?`free_months`:`percent`,percentAmount:i?e.amount:n.percentAmount,duration:i?e.duration:n.duration,durationInMonths:a,freeMonths:r&&e.duration_in_months||n.freeMonths}},Qe=({formState:e,lastPercentAmount:t,lastFreeMonths:n})=>{let r=Je({type:e.type,percentAmount:e.percentAmount,freeMonths:e.freeMonths,lastPercentAmount:t,lastFreeMonths:n});if(e.type===`free_months`)return{type:`percent`,amount:100,duration:`repeating`,durationInMonths:qe(r)};let i=e.duration;return{type:`percent`,amount:r,duration:i,durationInMonths:i===`repeating`?qe(e.durationInMonths):0}},$e=e=>{if(!e)return null;let t=e.duration_in_months??0;return{type:`percent`,amount:e.amount,duration:e.duration,durationInMonths:t}},et=e=>e?`${e.type}:${e.amount}:${e.duration}:${e.durationInMonths}`:``,tt=e=>Number.isInteger(e)&&e>0&&e<=Ge,nt=(e,t)=>e.displayTitle!==t.displayTitle||e.displayDescription!==t.displayDescription||e.type!==t.type||e.percentAmount!==t.percentAmount||e.duration!==t.duration||e.durationInMonths!==t.durationInMonths||e.freeMonths!==t.freeMonths,rt=({formState:e,updateForm:t,clearError:n,errors:r,cadence:i,lastRedeemed:a,membersFilterUrl:o,redemptions:s})=>{let c=i===`yearly`?Ue.filter(e=>e.value!==`repeating`):Ue;return(0,$.jsx)(`div`,{className:`flex grow flex-col pt-2`,children:(0,$.jsxs)(j,{className:`mb-10 grow gap-8`,children:[(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5 rounded-md border border-gray-300 p-4 pb-3.5 dark:border-gray-800`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Performance`}),(0,$.jsxs)(`span`,{children:[h(s),` `,s===1?`redemption`:`redemptions`]})]}),s>0&&a?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Last redemption`}),(0,$.jsx)(`span`,{children:ke(a)})]}):null]}),s>0&&o?(0,$.jsx)(`a`,{className:`font-semibold text-green`,href:o,children:`See members →`}):null]})})})}),(0,$.jsx)(`section`,{className:`mt-2`,children:(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsxs)(N,{children:[(0,$.jsxs)(P,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,$.jsx)(F,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,$.jsx)(C,{checked:e.enabled,id:`${i}-retention-enabled`,onCheckedChange:e=>t(t=>({...t,enabled:e}))})]})}),e.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`mt-2`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`retention-display-title`,children:`Display title`}),(0,$.jsx)(Y,{id:`retention-display-title`,maxLength:We,placeholder:`Before you go`,value:e.displayTitle,onChange:e=>{t(t=>({...t,displayTitle:e.target.value}))}})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`retention-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`retention-display-description`,maxLength:We,placeholder:`We'd hate to see you leave. How about a special offer to stay?`,value:e.displayDescription,onChange:e=>{t(t=>({...t,displayDescription:e.target.value}))}})]})]})]}),(0,$.jsxs)(`section`,{className:`mt-4`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i===`monthly`&&(0,$.jsx)(ee,{"aria-label":`${i} retention offer type`,className:`rounded-md border border-border-default p-4`,value:e.type,onValueChange:e=>{n(`amount`),n(`durationInMonths`),t(t=>({...t,type:e}))},children:He.map(e=>{let t=`${i}-retention-type-${e.value}`;return(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsx)(H,{id:t,value:e.value}),(0,$.jsxs)(N,{children:[(0,$.jsx)(P,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,$.jsx)(F,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`retention-amount`,children:`Amount off`}),(0,$.jsxs)(V,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.amount||void 0,id:`retention-amount`,type:`number`,value:e.percentAmount===0?``:String(e.percentAmount),onChange:e=>{let n=Number(e.target.value),r=Number.isNaN(n)?0:n;t(e=>({...e,percentAmount:r}))},onKeyDown:()=>n(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:`%`})})]}),r.amount&&(0,$.jsx)(M,{children:r.amount})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Duration`}),(0,$.jsxs)(O,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,$.jsx)(E,{"aria-label":`Duration`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:c.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,$.jsx)(`div`,{className:`-mt-4`,children:(0,$.jsxs)(I,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,$.jsxs)(V,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:e.durationInMonths===0?``:String(e.durationInMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`durationInMonths`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,$.jsx)(M,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,$.jsxs)(I,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`retention-free-months`,children:`Free months`}),(0,$.jsxs)(V,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.amount||void 0,id:`retention-free-months`,type:`number`,value:e.freeMonths===0?``:String(e.freeMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,freeMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,$.jsx)(M,{children:r.amount})]})]})]})]})]})})},it=({cadence:e})=>{let{updateRoute:t}=A(),{siteData:n}=Z(),{data:{tiers:i=[]}={}}=fe(),{data:{offers:a=[]}={},isFetched:d,isFetching:p}=u(),{mutateAsync:m}=f(),{mutateAsync:h}=l(),g=c(),[_,v]=(0,Q.useState)(``),y=e===`monthly`?`Monthly retention`:`Yearly retention`,b=e===`monthly`?`month`:`year`,x=pe(i||[]),S=(0,Q.useMemo)(()=>a.filter(e=>e.redemption_type===`retention`&&e.cadence===b).sort((e,t)=>{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n}),[a,b]),C=(0,Q.useMemo)(()=>S.find(e=>e.status===`active`)||null,[S]),w=S[0]||null,T=C||w,E=(0,Q.useMemo)(()=>S.reduce((e,t)=>e+(t.redemption_count||0),0),[S]),D=(0,Q.useMemo)(()=>S.map(e=>e.id),[S]),O=(0,Q.useMemo)(()=>S.map(e=>e.last_redeemed).filter(e=>!!e).sort((e,t)=>new Date(t).getTime()-new Date(e).getTime())[0]||null,[S]),k=(0,Q.useMemo)(()=>E===0||D.length===0?null:Ae(D),[D,E]),[j,M]=(0,Q.useState)(20),[N,P]=(0,Q.useState)(1),[F,I]=(0,Q.useState)(null),{formState:L,setFormState:R,updateForm:z,handleSave:B,saveState:V,okProps:H,errors:ee,clearError:U}=s({initialState:Ye(e),savingDelay:500,onSave:async()=>{let t=!1,n=Qe({formState:L,lastPercentAmount:j,lastFreeMonths:N}),r=et($e(T))!==et(n),i=L.enabled?`active`:`archived`,a=L.displayTitle||``,o=L.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Ye(e),l=!L.enabled&&!T&&nt(L,c),u=async e=>{let r=crypto.getRandomValues(new Uint32Array(1))[0].toString(16).padStart(8,`0`),i=Fe(n,r);await m({name:i,code:r,display_title:a,display_description:o,cadence:b,amount:n.amount,duration:n.duration,duration_in_months:n.duration===`repeating`?n.durationInMonths:null,currency:null,status:e,redemption_type:`retention`,tier:null,type:n.type,currency_restriction:!1}),t=!0},d=async()=>{t&&await g()};if(!(!T&&!L.enabled&&!l)){if(r){!L.enabled&&C&&(await h({...C,status:`archived`}),t=!0),await u(i),await d();return}if(T){let e=T.status!==i;(s||e)&&(await h({...T,display_title:a,display_description:o,status:i}),t=!0),await d();return}(L.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message||t),o.dismiss(),o.error(`Failed to save offer`,{description:t})},onValidate:()=>{let e={};return L.enabled?(L.type===`percent`&&((L.percentAmount<1||L.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),L.duration===`repeating`&&!tt(L.durationInMonths)&&(e.durationInMonths=Ke)),L.type===`free_months`&&(tt(L.freeMonths)||(e.amount=Ke)),e):e}}),W=`${e}:${T?.id||`none`}`;(0,Q.useEffect)(()=>{!d||p||V===`unsaved`||F===W||(R(()=>Ze(T,e)),I(W))},[e,W,T,d,F,p,V,R]),(0,Q.useEffect)(()=>{L.percentAmount>0&&M(L.percentAmount)},[L.percentAmount]),(0,Q.useEffect)(()=>{L.freeMonths>0&&P(L.freeMonths)},[L.freeMonths]);let G=()=>{t(`offers/edit`)},K=(0,$.jsx)(rt,{cadence:e,clearError:U,errors:ee,formState:L,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:z}),te=async()=>{try{await B({force:!0})&&G()}catch{}},q=(0,Q.useMemo)(()=>{let t=Qe({formState:L,lastPercentAmount:j,lastFreeMonths:N}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:L.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:L.displayTitle||``,displayDescription:L.displayDescription||``,type:t.type,cadence:b,amount:t.amount,duration:t.duration,durationInMonths:t.durationInMonths,currency:``,status:`active`,tierId:n?.id||``,redemptionType:`retention`}},[x,e,L,N,j,b]);(0,Q.useEffect)(()=>{if(!n.url){v(``);return}let e=xe(q,n.url);v(e)},[q,n.url]);let J=(0,$.jsx)(ye,{href:_||``,portalParent:`offers`});return(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:V===`unsaved`,height:`full`,okLabel:H.label||`Save`,okVariant:H.variant,preview:J,previewToolbarBreadcrumbs:(0,$.jsx)(be,{current:y,label:`Offers`,onBack:G}),sidebar:K,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:G,onClose:()=>t(`offers`),onOk:te})},at=({id:e})=>{let{updateRoute:t}=A(),{data:{offers:n=[]}={}}=d(e||``),[r,i]=(0,Q.useState)(),[a,o]=(0,Q.useState)(``),{siteData:s}=Z();(0,Q.useEffect)(()=>{if(n.length>0){let e=n[0],t=`${ue(s)}${e?.code}`;o(t),i(e)}},[n,s]);let[c,l]=(0,Q.useState)(!1),u=()=>{let e=``;switch(r?.type){case`percent`:e=r?.amount+`% discount`;break;case`fixed`:e=h(m(r?.amount),{maximumFractionDigits:2})+` `+r?.currency+` discount`;break;case`trial`:e=r?.amount+` days free trial`;break;default:break}return`${encodeURIComponent(r?.name||``)} — Check out ${encodeURIComponent(e)} on:`},f=async()=>{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)};return(0,$.jsx)(k,{animate:!1,backDropClick:!1,footer:!1,height:`full`,size:`lg`,testId:`offer-success-modal`,topRightContent:`close`,width:1140,onClose:()=>{t(`offers`)},children:(0,$.jsxs)(`div`,{className:`-mt-6 flex h-full flex-col items-center justify-center text-center`,children:[(0,$.jsx)(be,{className:`absolute top-5 left-6`,current:r?.name||``,label:`Offers`,onBack:()=>t(`offers/edit`)}),(0,$.jsx)(b,{className:`-mt-4 size-10 text-gray-700`}),(0,$.jsx)(`h1`,{className:`mt-6 text-4xl`,children:`Your new offer is live!`}),(0,$.jsx)(`p`,{className:`mt-3 max-w-[510px] text-[1.6rem]`,children:`You can share the link anywhere. In your newsletter, social media, a podcast, or in-person. It all just works.`}),(0,$.jsxs)(`div`,{className:`mt-8 flex w-full max-w-md flex-col gap-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2`,children:[(0,$.jsx)(Y,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,$.jsx)(S,{className:`w-full`,type:`button`,onClick:()=>void f(),children:c?`Copied!`:`Copy link`})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-4 text-sm font-medium before:h-px before:grow before:bg-gray-300 before:content-[""] after:h-px after:grow after:bg-gray-300 after:content-[""] dark:before:bg-gray-800 dark:after:bg-gray-800`,children:`OR`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(S,{"aria-label":`Share on X`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(a)}&text=${u()}`,`_blank`)},children:(0,$.jsx)(he,{className:`size-3.5!`,name:`twitter-x`})}),(0,$.jsx)(S,{"aria-label":`Share on Facebook`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(a)}`,`_blank`)},children:(0,$.jsx)(he,{className:`size-3.5!`,name:`facebook`})}),(0,$.jsx)(S,{"aria-label":`Share on LinkedIn`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(a)}&title=${u()}`,`_blank`)},children:(0,$.jsx)(he,{className:`size-3.5!`,name:`linkedin`})})]})]})]})})},ot=(e,t)=>e.find(e=>e.redemption_type===`retention`&&e.cadence===t&&e.status===`active`)||null,st=(e,t)=>e.reduce((e,n)=>n.redemption_type!==`retention`||n.cadence!==t?e:e+(n.redemption_count||0),0),ct=(e,t)=>e.filter(e=>e.redemption_type===`retention`&&e.cadence===t).map(e=>e.id),lt=(e,t)=>{let n=e.filter(e=>e.redemption_type===`retention`&&e.cadence===t&&e.created_at).map(e=>new Date(e.created_at).getTime()).filter(e=>!Number.isNaN(e));return n.length===0?null:new Date(Math.max(...n)).toISOString()},ut=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,dt=e=>{if(!e)return null;if(ut(e)){let t=e.duration_in_months||0,n=t===1?`month`:`months`;return`${h(t)} ${n} free`}return e.type===`percent`?`${h(e.amount)}% OFF`:null},ft=e=>{if(!e)return null;if(ut(e))return``;if(e.duration===`once`)return`First payment`;if(e.duration===`repeating`&&e.duration_in_months){let t=e.duration_in_months===1?`month`:`months`;return`For ${h(e.duration_in_months)} ${t}`}return e.duration===`forever`?`Forever`:null},pt=e=>{let t=ot(e,`month`),n=ot(e,`year`),r=ct(e,`month`),i=ct(e,`year`),a=st(e,`month`),o=st(e,`year`);return[{id:`monthly`,name:`Monthly retention`,description:`Applied to monthly plans`,terms:dt(t),termsDetail:ft(t),redemptionOfferIds:r,redemptions:a,status:t?`active`:`inactive`,createdAt:lt(e,`month`)},{id:`yearly`,name:`Yearly retention`,description:`Applied to annual plans`,terms:dt(n),termsDetail:ft(n),redemptionOfferIds:i,redemptions:o,status:n?`active`:`inactive`,createdAt:lt(e,`year`)}]},mt=({showArchived:e,setShowArchived:t,sortOption:n,sortDirection:r,onSortChange:i,onDirectionChange:a})=>(0,$.jsxs)(de,{children:[(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(S,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,$.jsx)(x,{size:16,strokeWidth:1.5})})}),(0,$.jsxs)(ne,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,$.jsx)(ie,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,$.jsxs)(re,{value:n,onValueChange:i,children:[(0,$.jsx)(ae,{value:`date-added`,children:`Date added`}),(0,$.jsx)(ae,{value:`name`,children:`Name`}),(0,$.jsx)(ae,{value:`redemptions`,children:`Redemptions`})]}),(0,$.jsxs)(se,{onSelect:a,children:[r===`asc`?(0,$.jsx)(y,{className:`size-3`}):(0,$.jsx)(v,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,$.jsx)(le,{}),(0,$.jsx)(oe,{checked:e,onCheckedChange:e=>t(!!e),children:`Show archived`})]})]}),ht=({offer:e,onClick:t})=>{let n=e.redemptions>0&&e.redemptionOfferIds.length>0?Ae(e.redemptionOfferIds):void 0;return(0,$.jsxs)(W,{"data-testid":`retention-offer-item`,children:[(0,$.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.terms?(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:e.terms}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.termsDetail})]}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:n?(0,$.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,"data-testid":`retention-redemptions-link-${e.id}`,href:n,children:h(e.redemptions)}):(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,"data-testid":`retention-redemptions-link-${e.id}`,type:`button`,onClick:t,children:h(e.redemptions)})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.status===`active`?(0,$.jsx)(X,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,$.jsx)(X,{className:`rounded-full uppercase`,variant:`secondary`,children:`Inactive`})})})]})},gt=({archived:e,offer:t,tier:n,onClick:r})=>{let{discountOffer:i,originalPriceWithCurrency:a,updatedPriceWithCurrency:o}=Re(t.type,t.amount,t.cadence,t.currency||`USD`,n);return(0,$.jsxs)(W,{className:e?`opacity-60`:void 0,"data-testid":`offer-item`,children:[(0,$.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:t.name}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.name,` `,Ie(t.cadence)]})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:i}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t.type===`trial`?`Trial period`:Le(t.duration)})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsxs)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:o}),` `,t.type===`trial`?null:(0,$.jsx)(`span`,{className:`relative text-sm text-muted-foreground before:absolute before:-inset-x-0.5 before:top-1/2 before:rotate-[-20deg] before:border-t before:content-[""]`,children:a})]})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:t.redemption_count>0&&t.id?(0,$.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,href:je(t.id),children:h(t.redemption_count)}):(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:h(t.redemption_count)})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:e?(0,$.jsx)(X,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,$.jsx)(X,{className:`rounded-full uppercase`,variant:`success`,children:`Active`})})})]})},_t=e=>e.offer.name,vt=e=>e.kind===`retention`?e.offer.redemptions:e.offer.redemption_count,yt=e=>e.kind===`retention`?e.offer.createdAt:e.offer.created_at||null,bt=(e,t,n)=>{let r=n===`desc`?-1:1;return[...e].sort((e,n)=>{let i;switch(t){case`name`:i=_t(e).localeCompare(_t(n));break;case`redemptions`:i=vt(e)-vt(n);break;default:{let t=yt(e),r=yt(n);if(!t&&!r)i=0;else if(!t)return 1;else if(r)i=new Date(t).getTime()-new Date(r).getTime();else return-1;break}}return(i||_t(e).localeCompare(_t(n)))*r})},xt=()=>{let{updateRoute:e}=A(),{data:{offers:t=[]}={}}=u(),{data:{tiers:n}={}}=fe(),r=t.filter(e=>e.redemption_type===`signup`),i=pt(t),{sortingState:a,setSortingState:s}=ge(),c=a?.find(e=>e.type===`offers`),{offersShowArchived:l,setOffersShowArchived:d}=_e(),f=c?.option||`date-added`,p=c?.direction||`desc`,m=t=>{t&&e(`offers/edit/${t}`)},h=t=>{e(`offers/edit/retention/${t}`)},v=pe(n||[]),y=r.filter(e=>{let t=n?.find(t=>t.id===e?.tier?.id),r=e.status===`active`&&t&&t.active===!0,i=e.status===`archived`||t&&t.active===!1;return!!(r||l&&i)}),b=bt([...i.map(e=>({kind:`retention`,offer:e})),...y.map(e=>({kind:`signup`,offer:e}))],f,p),x=e=>{s?.([{type:`offers`,option:e,direction:p}])},C=()=>{s?.([{type:`offers`,option:f,direction:p===`asc`?`desc`:`asc`}])},w=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,$.jsx)(k,{animate:!1,backDropClick:!1,cancelLabel:``,footer:!1,height:`full`,size:`lg`,testId:`offers-modal`,title:`Offers`,topRightContent:(0,$.jsxs)(g,{gap:`md`,children:[(0,$.jsx)(S,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,$.jsx)(S,{type:`button`,onClick:()=>{v.length===0?o.info(`You must have an active tier to create an offer.`):e(`offers/new`)},children:`New offer`})]}),width:1140,onClose:()=>{e(`offers`)},children:(0,$.jsx)(_,{className:`h-full pt-8`,children:(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(q,{className:`m-0 min-w-[900px]`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-[25%]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[220px]`})]}),(0,$.jsx)(te,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(U,{className:`sticky left-0 z-10 h-auto bg-background p-0 pb-2.5 pl-5 uppercase`,children:`Name`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Terms`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Price`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Redemptions`}),(0,$.jsx)(U,{className:`h-auto p-0 px-5 pb-2.5 uppercase`,children:(0,$.jsxs)(g,{align:`center`,justify:`between`,children:[`Status`,(0,$.jsx)(mt,{setShowArchived:d,showArchived:l,sortDirection:p,sortOption:f,onDirectionChange:C,onSortChange:x})]})})]})}),(0,$.jsx)(G,{"data-testid":`offers-table-body`,children:b.map(e=>{if(e.kind===`retention`)return(0,$.jsx)(ht,{offer:e.offer,onClick:()=>h(e.offer.id)},`retention-${e.offer.id}`);let t=e.offer,r=n?.find(e=>e.id===t?.tier?.id);if(!r)return null;let i=w(t);return(0,$.jsx)(gt,{archived:i,offer:t,tier:r,onClick:()=>m(t.id)},`signup-${t.id}`)})})]})})})})},St=`offers/edit/retention/`,Ct=e=>{let t=e.slice(22).replace(/\/+$/,``);return t===`monthly`||t===`yearly`?t:null},wt=({route:e})=>{if(e===`offers/new`)return(0,$.jsx)(Oe,{});if(e===`offers/edit/retention`||e.startsWith(St)){let t=e.startsWith(St)?Ct(e):null;return t?(0,$.jsx)(it,{cadence:t}):(0,$.jsx)(xt,{})}else if(e.startsWith(`offers/edit/`)&&e.length>12){let t=e.split(`/`).pop();return(0,$.jsx)(Ve,{id:t||``})}else if(e.startsWith(`offers/success/`)&&e.length>15){let t=e.split(`/`).pop();return(0,$.jsx)(at,{id:t||``})}else if(e===`offers/edit`||e===`offers/edit/`)return(0,$.jsx)(xt,{})},Tt=()=>{let{route:e}=A();return(0,$.jsx)(wt,{route:e})};export{Tt 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{_ as r,f as i,p as a}from"./hooks-Cy_-oZ4o.js";import{n as o}from"./dist-Ndy-PuGN.js";import{t as s}from"./use-form-vRjI0Kwk.js";import{a as c,i as l,n as u,r as d,t as f}from"./offers--e2nGvkW.js";import{i as p,r as m}from"./currency-Dy4Tc2R2.js";import{m as h}from"./dist-B3keLvjj.js";import{t as g}from"./inline-BWSs_VzR.js";import{t as _}from"./stack-B2eszIiq.js";import{Ar as v,Sr as y,t as b,tn as x,wr as S}from"./button-Dvcv1QSR.js";import{t as C}from"./switch-CI4gLWqb.js";import{i as w,n as T,o as E,s as D,t as O}from"./select-v5YbA3Mw.js";import{o as k,t as A}from"./use-settings-navigation-B-qrriKD.js";import{a as j,i as M,n as N,o as P,r as F,t as I}from"./field-C93_Mg6j.js";import{a as L,i as R,n as z,r as B,t as V}from"./input-group-BE8rM2y1.js";import{n as H,t as ee}from"./radio-group-DL8GI8rt.js";import{a as U,c as W,n as G,r as K,s as te,t as q}from"./table-BenqVupI.js";import{t as J}from"./textarea-DJ1Q5V39.js";import{Ar as ne,Dr as re,Er as ie,Fr as ae,Mr as oe,Nr as se,Tr as ce,Xn as Y,jr as le,kr as ue,pt as de,rr as X}from"./index-CgMCwsxN.js";import{a as fe,r as pe}from"./tiers-BCpIOGQr.js";import{t as me}from"./brand-icon-CrIGOA3Z.js";import{n as he}from"./confirmation-context-DwXX_Y5h.js";import{n as Z}from"./global-data-context-gAMDH9u1.js";import{o as ge,r as _e}from"./zapier-modal-DfVhV17j.js";import{t as ve}from"./preview-modal-YYbzlYdO.js";import{t as ye}from"./portal-frame-Cqanidq4.js";import{t as be}from"./settings-breadcrumbs-NwPnCTC7.js";var xe=(e,t)=>{let{disableBackground:n=!1,name:r,code:i,displayTitle:a=``,displayDescription:o=``,type:s,cadence:c,amount:l=0,duration:u,durationInMonths:d,currency:f=`usd`,status:p,tierId:m,redemptionType:h=`signup`}=e;t=t.replace(/\/$/,``);let g=new URLSearchParams;return g.append(`disableBackground`,`false`),g.append(`name`,encodeURIComponent(r)),g.append(`code`,encodeURIComponent(i)),g.append(`display_title`,encodeURIComponent(a)),g.append(`display_description`,encodeURIComponent(o)),g.append(`type`,encodeURIComponent(s)),g.append(`cadence`,encodeURIComponent(c)),g.append(`amount`,encodeURIComponent(l)),g.append(`duration`,encodeURIComponent(u)),g.append(`duration_in_months`,encodeURIComponent(d)),g.append(`currency`,encodeURIComponent(f)),g.append(`status`,encodeURIComponent(p)),g.append(`tier_id`,encodeURIComponent(m)),g.append(`redemption_type`,encodeURIComponent(h)),n&&g.append(`disableBackground`,`true`),g.append(`admin_toolbar`,`0`),`${t}/?v=modal-portal-offer#/portal/preview/offer?${g.toString()}`},Se=e=>{let t=[];return e.forEach(e=>{t.push({label:`${e.name} - Monthly`,value:`${e.id}-month-${e.currency}`}),t.push({label:`${e.name} - Yearly`,value:`${e.id}-year-${e.currency}`})}),t},Q=e(t(),1),$=n();function Ce(e){return e.toString().toLowerCase().trim().replace(/\s+/g,`-`).replace(/[^\w-]+/g,``).replace(/--+/g,`-`)}var we=191,Te=e=>{let{fixedAmount:t=0,percentAmount:n=0,trialAmount:r=0,amount:i=0}=e;switch(e.type){case`fixed`:return t*100;case`percent`:return n;case`trial`:return r;default:return i}},Ee=({tierOptions:e,handleTierChange:t,selectedTier:n,typeOptions:r,durationOptions:i,handleTypeChange:a,handleDurationChange:o,overrides:s,handleAmountTypeChange:c,handleNameInput:l,handleTextAreaInput:u,handleDisplayTitleInput:d,handleDurationInMonthsInput:f,handleAmountInput:p,handleCodeInput:m,clearError:g,errors:_,testId:v,handleTrialAmountInput:y,amountOptions:x})=>{let S=s.cadence===`year`,C=S?i.filter(e=>e.value!==`repeating`):i,[k,A]=(0,Q.useState)(0),B=k>40?`text-red`:`text-green`,{siteData:U}=Z(),[W,G]=(0,Q.useState)(!1),K=de(U),te=`${K}${s.code.value}`,q=async()=>{await navigator.clipboard.writeText(te),G(!0),setTimeout(()=>G(!1),2e3)};return(0,$.jsx)(`div`,{className:`pt-7`,"data-testid":v,children:(0,$.jsxs)(j,{className:`mb-10 gap-8`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{"data-invalid":!!_.name||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-name`,children:`Offer name`}),(0,$.jsx)(X,{"aria-invalid":!!_.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,onChange:e=>{l(e),A(e.target.value.length)},onKeyDown:()=>g(`name`)}),_.name?(0,$.jsx)(M,{children:_.name}):(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,$.jsxs)(`strong`,{children:[(0,$.jsx)(`span`,{className:B,children:h(k)}),` /`,` `,h(40)]})]})})]}),(0,$.jsxs)(I,{"data-invalid":!!_.displayTitle||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-display-title`,children:`Display title`}),(0,$.jsx)(X,{"aria-invalid":!!_.displayTitle||void 0,id:`offer-display-title`,maxLength:we,placeholder:`Black Friday Special`,value:s.displayTitle.value,onChange:e=>{d(e)},onKeyDown:()=>g(`displayTitle`)}),_.displayTitle&&(0,$.jsx)(M,{children:_.displayTitle})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`offer-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`offer-display-description`,maxLength:we,placeholder:`Take advantage of this limited-time offer.`,value:s.displayDescription,onChange:e=>{u(e)}})]})]})]}),(0,$.jsxs)(`section`,{className:`mt-4`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsx)(ee,{"aria-label":`Offer type`,className:`rounded-md border border-border-default p-4`,value:s.type===`trial`?`trial`:`percent`,onValueChange:a,children:r.map(e=>{let t=`offer-type-${e.value}`;return(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsx)(H,{id:t,value:e.value}),(0,$.jsxs)(N,{children:[(0,$.jsx)(P,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,$.jsx)(F,{children:e.description})]})]},e.value)})}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Tier — Cadence`}),(0,$.jsxs)(O,{value:n.value,onValueChange:n=>{let r=e.find(e=>e.value===n);r&&t(r)},children:[(0,$.jsx)(E,{"aria-label":`Tier — Cadence`,"data-testid":`tier-cadence-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:e.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),s.type!==`trial`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-amount`,children:`Amount off`}),(0,$.jsxs)(V,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(R,{id:`offer-amount`,type:`number`,value:s.type===`fixed`?s.fixedAmount===0?``:s.fixedAmount?.toString():s.percentAmount===0?``:s.percentAmount?.toString(),onChange:e=>{p(e)},onKeyDown:()=>g(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsxs)(O,{value:s.type===`percent`?x[0].value:x[1].value,onValueChange:c,children:[(0,$.jsx)(E,{"aria-label":`Amount type`,className:`h-7 w-20 border-0 bg-transparent px-2 shadow-none focus-visible:ring-0`,"data-testid":`amount-type-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{align:`end`,children:x.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})})]}),_.amount&&(0,$.jsx)(M,{children:_.amount})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Duration`}),(0,$.jsxs)(O,{value:s.duration,onValueChange:e=>{g(`durationInMonths`),o(e)},children:[(0,$.jsx)(E,{"aria-label":`Duration`,"data-testid":`duration-select-offers`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:C.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),s.duration===`repeating`&&!S&&(0,$.jsx)(`div`,{className:`-mt-4`,children:(0,$.jsxs)(I,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,$.jsxs)(V,{"data-invalid":!!_.durationInMonths||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!_.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:s.durationInMonths===0?``:String(s.durationInMonths),onChange:e=>{f(e)},onKeyDown:()=>g(`durationInMonths`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:s.durationInMonths===1?`month`:`months`})})]}),_.durationInMonths&&(0,$.jsx)(M,{children:_.durationInMonths})]})})]}),s.type===`trial`&&(0,$.jsxs)(I,{"data-invalid":!!_.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`trial-duration`,children:`Trial duration`}),(0,$.jsx)(X,{"aria-invalid":!!_.amount||void 0,id:`trial-duration`,type:`number`,value:s.trialAmount?.toString(),onChange:e=>{y(e)},onKeyDown:()=>g(`amount`)}),_.amount&&(0,$.jsx)(M,{children:_.amount})]}),(0,$.jsxs)(I,{"data-invalid":!!_.code||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-code`,children:`Offer code`}),(0,$.jsx)(X,{"aria-invalid":!!_.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:s.code.value,onChange:e=>{m(e)},onKeyDown:()=>g(`code`)}),_.code?(0,$.jsx)(M,{children:_.code}):s.code.value!==``&&(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[K,(0,$.jsx)(`span`,{className:`font-bold`,children:s.code.value})]}),(0,$.jsx)(b,{className:`h-auto p-0 text-sm text-green hover:text-green`,size:`sm`,type:`button`,variant:`link`,onClick:()=>void q(),children:W?`Copied`:`Copy`})]})})]})]})]})]})})},De=e=>{let[t,n,r]=e.split(`-`);if(!t||!n||!r)throw Error(`Invalid input format. Expected format is: id-period-currency`);return{id:t,period:n,currency:r}},Oe=()=>{let{siteData:e}=Z(),t=[{title:`Discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free trial`,description:`Give free access for a limited time`,value:`trial`}],n=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],[i,a]=(0,Q.useState)(``),{updateRoute:c}=A(),{data:{tiers:l}={}}=fe(),d=pe(l||[]),p=Se(d),{mutateAsync:m}=f(),[h,g]=(0,Q.useState)({tier:p[0]||{},dataset:{id:p[0]?.value?De(p[0]?.value).id:``,period:p[0]?.value?De(p[0]?.value).period:``,currency:p[0]?.value?De(p[0]?.value).currency:``}}),{data:{offers:_=[]}={}}=u(),{formState:v,updateForm:y,handleSave:b,saveState:x,okProps:S,validate:C,errors:w,clearError:T}=s({initialState:{disableBackground:!1,name:``,code:{isDirty:!1,value:``},displayTitle:{isDirty:!1,value:``},displayDescription:``,type:`percent`,cadence:h?.dataset?.period||``,amount:0,duration:`once`,durationInMonths:1,currency:h?.dataset?.currency||`USD`,status:`active`,tierId:h?.dataset?.id||``,trialAmount:7,fixedAmount:0,percentAmount:0},onSave:async()=>{let e=v.type===`trial`?`trial`:v.duration,t={name:v.name,code:v.code.value,display_title:v.displayTitle.value,display_description:v.displayDescription,cadence:v.cadence,amount:Te(v)||0,duration:e,...e===`repeating`?{duration_in_months:v.durationInMonths}:{},currency:v.currency,status:v.status,redemption_type:`signup`,tier:{id:v.tierId},type:v.type,currency_restriction:!1},n=await m(t);n&&n.offers&&n.offers.length>0&&c(`offers/success/${n.offers[0].id}`)},onSaveError:()=>{},onValidate:()=>{let e={};return!v.name&&v.name.length===0&&(e.name=`Name is required`),!v.code.value&&v.code.value.length===0&&(e.code=`Code is required`),!v.displayTitle.value&&v.displayTitle.value.length===0&&(e.displayTitle=`Display title is required`),v.type===`percent`&&v.percentAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`percent`&&(v.percentAmount<1||v.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),(v.type===`fixed`&&v.fixedAmount===0||v.type===`fixed`&&v.fixedAmount<1)&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount===0&&(e.amount=`Enter an amount greater than 0.`),v.type===`trial`&&v.trialAmount<1&&(e.amount=`Free trial must be at least 1 day.`),v.type!==`trial`&&v.duration===`repeating`&&(!Number.isInteger(v.durationInMonths)||v.durationInMonths<1)&&(e.durationInMonths=`Enter a whole number of months (1 or more).`),e},savingDelay:500}),E=[{value:`percent`,label:`%`},{value:`fixed`,label:v.currency}],D=e=>{let t=De(e.value),n=t.period===`year`;g({tier:e,dataset:t}),y(e=>({...e,cadence:t.period,currency:t.currency,tierId:t.id,duration:n&&e.duration===`repeating`?`once`:e.duration})),n&&T(`durationInMonths`)},O=e=>{e===`trial`&&(T(`amount`),T(`durationInMonths`)),y(t=>({...t,type:e}))},k=e=>{y(t=>({...t,type:e===`percent`?`percent`:`fixed`}))},j=e=>{let t=e.target;v.type===`fixed`?y(e=>({...e,fixedAmount:Number(t.value)})):v.type===`percent`?y(e=>({...e,percentAmount:Number(t.value)})):y(e=>({...e,amount:Number(t.value)}))},M=e=>{let t=e.target,n=Number(t.value);y(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},N=e=>{let t=e.target.value;y(e=>{let n={...e};return n.name=t,e.code.isDirty||(T(`code`),n.code={...e.code,value:Ce(t)}),e.displayTitle.isDirty||(T(`displayTitle`),n.displayTitle={...e.displayTitle,value:t}),n})},P=e=>{let t=e.target;y(e=>({...e,displayTitle:{...e.displayTitle,isDirty:!0,value:t.value}}))},F=e=>{let t=e.target;y(e=>({...e,displayDescription:t.value}))},I=e=>{let t=e.target;y(e=>({...e,trialAmount:Number(t.value)}))},L=e=>{y(t=>({...t,duration:e}))},R=e=>{let t=e.target;y(e=>({...e,code:{...e.code,isDirty:!0,value:t.value}}))},z=()=>{_.length>0?c(`offers/edit`):c(`offers`)},B=(0,Q.useMemo)(()=>({name:v.name||``,code:v.code.value||``,displayTitle:v.displayTitle.value||``,displayDescription:v.displayDescription||``,type:v.type||`percent`,cadence:v.cadence||`month`,amount:Te(v)||0,duration:v.type===`trial`?`trial`:v.duration||`once`,durationInMonths:v.durationInMonths||0,currency:v.currency||`USD`,status:v.status||`active`,tierId:v.tierId||d[0]?.id,redemptionType:`signup`}),[v,d]);(0,Q.useEffect)(()=>{let t=xe(B,e.url);a(t)},[v,e.url,v.type,B]);let V=(0,$.jsx)(Ee,{amountOptions:E,clearError:T,durationOptions:n,errors:w,handleAmountInput:j,handleAmountTypeChange:k,handleCodeInput:R,handleDisplayTitleInput:P,handleDurationChange:L,handleDurationInMonthsInput:M,handleNameInput:N,handleTextAreaInput:F,handleTierChange:D,handleTrialAmountInput:I,handleTypeChange:O,overrides:v,selectedTier:h.tier,testId:`add-offer-sidebar`,tierOptions:p,typeOptions:t,validate:C}),H=(0,$.jsx)(ye,{href:i||``,portalParent:`offers`});return(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:x===`unsaved`,height:`full`,okLabel:`Publish`,okVariant:S.variant,preview:H,previewToolbar:!1,sidebar:V,size:`lg`,testId:`add-offer-modal`,title:`Offer`,width:1140,onCancel:z,onClose:()=>{c(`offers`)},onOk:async()=>{if(C(),!Object.values(w).every(e=>!e)){o.dismiss(),o.info(`Can't save offer`,{description:`Make sure you filled all required fields`});return}try{if(await b({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:t||`Please try again later`})}}})},ke=e=>new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`}),Ae=e=>{let t=`${i().adminRoot}#/members`,n=`offer_redemptions:[${e.join(`,`)}]`;return`${t}?filter=${encodeURIComponent(n)}`},je=e=>Ae([e]),Me=({amount:e,duration:t})=>e===100&&t===`repeating`,Ne=(e,t)=>`Retention ${e} (${t})`,Pe=({amount:e,duration:t,durationInMonths:n})=>Me({amount:e,duration:t})?`${n} ${n===1?`month`:`months`} free`:t===`once`?`${e}% off once`:t===`repeating`?`${e}% off for ${n} mo`:`${e}% off forever`,Fe=(e,t)=>{let n=t.trim(),r=Pe(e),i=Ne(r,n);if(i.length<=40)return i;let a=i.length-40,o=Math.max(3,n.length-a);return Ne(r,n.slice(0,o))},Ie=e=>e===`month`?`monthly`:`yearly`,Le=e=>e===`once`?`First payment`:e===`repeating`?`Repeating`:`Forever`,Re=(e,t,n,r,i)=>{let a=``,o=n===`month`?i?.monthly_price??0:i?.yearly_price??0,s=o,c=e=>parseFloat(e.toFixed(2)),l=e=>h(c(m(e)),{maximumFractionDigits:2}),u=p(r)+l(o);switch(e){case`percent`:a=`${h(t)}% off`,s=o-o*t/100;break;case`fixed`:a=`${l(t)} ${r} off`,s=o-t;break;case`trial`:a=`${h(t)} days free`,u=``;break;default:break}s<0&&(s=0);let d=p(r)+l(s);return{discountOffer:a,originalPriceWithCurrency:u,updatedPriceWithCurrency:d}};function ze(e){return new Date(e).toLocaleDateString(`default`,{year:`numeric`,month:`short`,day:`2-digit`})}var Be=({clearError:e,errors:t,offer:n,updateOffer:r})=>{let{siteData:i}=Z(),[s,c]=(0,Q.useState)(!1),u=a(),{confirm:d}=he(),{mutateAsync:f}=l(),[p,m]=(0,Q.useState)(n?.name.length||0),g=p>40?`text-red`:`text-green`,{updateRoute:_}=A();(0,Q.useEffect)(()=>{n?.name&&m(n?.name.length)},[n?.name]);let v=de(i),y=`${v}${n?.code}`,x=async()=>{await navigator.clipboard.writeText(y),c(!0),setTimeout(()=>c(!1),2e3)},S=()=>{n?.status===`active`?d({title:`Archive offer`,prompt:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`New members will no longer be able to subscribe using this offer.`}),(0,$.jsxs)(`p`,{children:[`All members that previously redeemed `,(0,$.jsx)(`strong`,{children:n?.name}),` will remain unchanged.`]})]}),okLabel:`Archive`,okVariant:`destructive`,onOk:async e=>{try{await f({...n,status:`archived`}),e?.remove(),o.success(`Offer archived`),_(`offers/edit`)}catch(e){u(e)}}}):d({title:`Reactivate offer`,prompt:(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`p`,{children:[`Reactivating `,(0,$.jsx)(`strong`,{children:n?.name}),` will allow new members to subscribe using this offer. Existing members will remain unchanged.`]})}),okLabel:`Reactivate`,onOk:async e=>{try{await f({...n,status:`active`}),e?.remove(),o.success(`Offer reactivated`),_(`offers/edit`)}catch(e){u(e)}}})};return(0,$.jsxs)(`div`,{className:`flex grow flex-col pt-2`,children:[(0,$.jsxs)(j,{className:`mb-10 grow gap-8`,children:[(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5 rounded-md border border-gray-300 p-4 pb-3.5 dark:border-gray-800`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Created on`}),(0,$.jsx)(`span`,{children:ze(n?.created_at?n.created_at:``)})]}),(0,$.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Performance`}),(0,$.jsxs)(`span`,{children:[h(n?.redemption_count||0),` `,n?.redemption_count===1?`redemption`:`redemptions`]})]}),n?.redemption_count>0&&n?.last_redeemed?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Last redemption`}),(0,$.jsx)(`span`,{children:ze(n?.last_redeemed)})]}):null]}),n?.redemption_count>0?(0,$.jsx)(`a`,{className:`font-semibold text-green`,href:je(n?.id),children:`See members →`}):null]})]})}),(0,$.jsxs)(`section`,{className:`mt-2`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{"data-invalid":!!t.name||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-name`,children:`Offer name`}),(0,$.jsx)(X,{"aria-invalid":!!t.name||void 0,id:`offer-name`,maxLength:40,placeholder:`Black Friday`,value:n?.name??``,onChange:e=>{m(e.target.value.length),r({name:e.target.value})},onKeyDown:()=>e(`name`)}),t.name?(0,$.jsx)(M,{children:t.name}):(0,$.jsx)(F,{children:(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{children:`Visible to members on Stripe Checkout page`}),(0,$.jsxs)(`strong`,{children:[(0,$.jsx)(`span`,{className:g,children:h(p)}),` /`,` `,h(40)]})]})})]}),(0,$.jsxs)(I,{className:`group`,"data-invalid":!!t.code||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-code`,children:`Offer code`}),(0,$.jsxs)(V,{"data-invalid":!!t.code||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!t.code||void 0,id:`offer-code`,placeholder:`black-friday`,value:n?.code??``,onChange:e=>r({code:e.target.value}),onKeyDown:()=>e(`code`)}),n?.code!==``&&(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(B,{onClick:()=>void x(),children:s?`Copied!`:`Copy link`})})]}),t.code?(0,$.jsx)(M,{children:t.code}):n?.code!==``&&(0,$.jsxs)(F,{className:`truncate`,children:[v,(0,$.jsx)(`span`,{className:`font-bold text-foreground`,children:n?.code})]})]}),(0,$.jsxs)(I,{"data-invalid":!!t.displayTitle||void 0,children:[(0,$.jsx)(P,{htmlFor:`offer-display-title`,children:`Display title`}),(0,$.jsx)(X,{"aria-invalid":!!t.displayTitle||void 0,id:`offer-display-title`,placeholder:`Black Friday Special`,value:n?.display_title??``,onChange:e=>r({display_title:e.target.value}),onKeyDown:()=>e(`displayTitle`)}),t.displayTitle&&(0,$.jsx)(M,{children:t.displayTitle})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`offer-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`offer-display-description`,placeholder:`Take advantage of this limited-time offer.`,value:n?.display_description??``,onChange:e=>r({display_description:e.target.value})})]})]})]})]}),(0,$.jsx)(`div`,{className:`mb-2`,children:n?.status===`active`?(0,$.jsx)(b,{className:`h-auto p-0 text-destructive hover:text-destructive`,type:`button`,variant:`link`,onClick:S,children:`Archive offer`}):(0,$.jsx)(b,{className:`h-auto p-0 text-green hover:text-green`,type:`button`,variant:`link`,onClick:S,children:`Reactivate offer`})})]})},Ve=({id:e})=>{let{siteData:t}=Z(),{updateRoute:n}=A(),i=a(),{mutateAsync:c}=l(),[u,f]=(0,Q.useState)(``),{data:{offers:p=[]}={}}=d(e||``),{formState:m,saveState:h,updateForm:g,setFormState:_,handleSave:v,validate:y,errors:b,clearError:x,okProps:S}=s({initialState:p[0],savingDelay:500,onSave:async()=>{await c(m)},onSaveError:i,onValidate:()=>{let e={};return m?.name||(e.name=`Name is required`),m?.display_title||(e.displayTitle=`Display title is required`),m?.code||(e.code=`Please enter a code`),e}});(0,Q.useEffect)(()=>{_(()=>p[0])},[_,p]);let C=(0,$.jsx)(Be,{clearError:x,errors:b,offer:m,updateOffer:e=>{g(t=>({...t,...e}))},validate:y});(0,Q.useEffect)(()=>{let e=xe({name:m?.name||``,code:m?.code||``,displayTitle:m?.display_title||``,displayDescription:m?.display_description||``,type:m?.type||``,cadence:m?.cadence||``,amount:m?.amount,duration:m?.duration||``,durationInMonths:m?.duration_in_months||0,currency:m?.currency||``,status:m?.status||``,tierId:m?.tier?.id||``,redemptionType:`signup`},t.url);f(e)},[m,t]);let w=(0,$.jsx)(ye,{href:u||``,portalParent:`offers`}),T=()=>{n(`offers/edit`)};return p?(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:h===`unsaved`,height:`full`,okLabel:S.label||`Save`,okVariant:S.variant,preview:w,previewToolbarBreadcrumbs:(0,$.jsx)(be,{current:m?.name||`Offer`,label:`Offers`,onBack:T}),sidebar:C,size:`lg`,testId:`offer-update-modal`,title:`Offer`,width:1140,onCancel:T,onClose:()=>{n(`offers`)},onOk:async()=>{try{if(await v({force:!0}))return}catch(e){let t;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message),o.dismiss(),t&&o.error(`Can't save offer`,{description:`Please try again later`})}}}):null},He=[{title:`Percentage discount`,description:`Offer a special reduced price`,value:`percent`},{title:`Free month(s)`,description:`Give free access for a limited time`,value:`free_months`}],Ue=[{value:`once`,label:`First-payment`},{value:`repeating`,label:`Multiple-months`},{value:`forever`,label:`Forever`}],We=191,Ge=99,Ke=`Enter a whole number of months between 1 and ${Ge}.`,qe=e=>Math.max(1,Number.isFinite(e)?Math.trunc(e):0),Je=({type:e,percentAmount:t,freeMonths:n,lastPercentAmount:r,lastFreeMonths:i})=>e===`free_months`?n>0?n:i:t>0?t:r,Ye=(e=`monthly`)=>({enabled:!1,displayTitle:``,displayDescription:``,type:e===`yearly`?`percent`:`free_months`,percentAmount:20,duration:`once`,durationInMonths:1,freeMonths:1}),Xe=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,Ze=(e,t=`monthly`)=>{let n=Ye(t);if(!e)return n;let r=Xe(e),i=e.type===`percent`&&!r,a=e.duration===`repeating`&&e.duration_in_months?e.duration_in_months:n.durationInMonths;return{enabled:e.status===`active`,displayTitle:e.display_title||``,displayDescription:e.display_description||``,type:r?`free_months`:`percent`,percentAmount:i?e.amount:n.percentAmount,duration:i?e.duration:n.duration,durationInMonths:a,freeMonths:r&&e.duration_in_months||n.freeMonths}},Qe=({formState:e,lastPercentAmount:t,lastFreeMonths:n})=>{let r=Je({type:e.type,percentAmount:e.percentAmount,freeMonths:e.freeMonths,lastPercentAmount:t,lastFreeMonths:n});if(e.type===`free_months`)return{type:`percent`,amount:100,duration:`repeating`,durationInMonths:qe(r)};let i=e.duration;return{type:`percent`,amount:r,duration:i,durationInMonths:i===`repeating`?qe(e.durationInMonths):0}},$e=e=>{if(!e)return null;let t=e.duration_in_months??0;return{type:`percent`,amount:e.amount,duration:e.duration,durationInMonths:t}},et=e=>e?`${e.type}:${e.amount}:${e.duration}:${e.durationInMonths}`:``,tt=e=>Number.isInteger(e)&&e>0&&e<=Ge,nt=(e,t)=>e.displayTitle!==t.displayTitle||e.displayDescription!==t.displayDescription||e.type!==t.type||e.percentAmount!==t.percentAmount||e.duration!==t.duration||e.durationInMonths!==t.durationInMonths||e.freeMonths!==t.freeMonths,rt=({formState:e,updateForm:t,clearError:n,errors:r,cadence:i,lastRedeemed:a,membersFilterUrl:o,redemptions:s})=>{let c=i===`yearly`?Ue.filter(e=>e.value!==`repeating`):Ue;return(0,$.jsx)(`div`,{className:`flex grow flex-col pt-2`,children:(0,$.jsxs)(j,{className:`mb-10 grow gap-8`,children:[(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`flex flex-col gap-5 rounded-md border border-gray-300 p-4 pb-3.5 dark:border-gray-800`,children:(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Performance`}),(0,$.jsxs)(`span`,{children:[h(s),` `,s===1?`redemption`:`redemptions`]})]}),s>0&&a?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm leading-none font-semibold text-gray-700`,children:`Last redemption`}),(0,$.jsx)(`span`,{children:ke(a)})]}):null]}),s>0&&o?(0,$.jsx)(`a`,{className:`font-semibold text-green`,href:o,children:`See members →`}):null]})})})}),(0,$.jsx)(`section`,{className:`mt-2`,children:(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsxs)(N,{children:[(0,$.jsxs)(P,{htmlFor:`${i}-retention-enabled`,children:[`Enable `,i,` retention`]}),(0,$.jsx)(F,{children:i===`monthly`?`Applied to monthly plans`:`Applied to annual plans`})]}),(0,$.jsx)(C,{checked:e.enabled,id:`${i}-retention-enabled`,onCheckedChange:e=>t(t=>({...t,enabled:e}))})]})}),e.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`section`,{className:`mt-2`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`General`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`retention-display-title`,children:`Display title`}),(0,$.jsx)(X,{id:`retention-display-title`,maxLength:We,placeholder:`Before you go`,value:e.displayTitle,onChange:e=>{t(t=>({...t,displayTitle:e.target.value}))}})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{htmlFor:`retention-display-description`,children:`Display description`}),(0,$.jsx)(J,{id:`retention-display-description`,maxLength:We,placeholder:`We'd hate to see you leave. How about a special offer to stay?`,value:e.displayDescription,onChange:e=>{t(t=>({...t,displayDescription:e.target.value}))}})]})]})]}),(0,$.jsxs)(`section`,{className:`mt-4`,children:[(0,$.jsx)(`h2`,{className:`mb-4 text-lg`,children:`Details`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[i===`monthly`&&(0,$.jsx)(ee,{"aria-label":`${i} retention offer type`,className:`rounded-md border border-border-default p-4`,value:e.type,onValueChange:e=>{n(`amount`),n(`durationInMonths`),t(t=>({...t,type:e}))},children:He.map(e=>{let t=`${i}-retention-type-${e.value}`;return(0,$.jsxs)(I,{orientation:`horizontal`,children:[(0,$.jsx)(H,{id:t,value:e.value}),(0,$.jsxs)(N,{children:[(0,$.jsx)(P,{className:`cursor-pointer`,htmlFor:t,children:e.title}),(0,$.jsx)(F,{children:e.description})]})]},e.value)})}),e.type===`percent`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(I,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`retention-amount`,children:`Amount off`}),(0,$.jsxs)(V,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.amount||void 0,id:`retention-amount`,type:`number`,value:e.percentAmount===0?``:String(e.percentAmount),onChange:e=>{let n=Number(e.target.value),r=Number.isNaN(n)?0:n;t(e=>({...e,percentAmount:r}))},onKeyDown:()=>n(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:`%`})})]}),r.amount&&(0,$.jsx)(M,{children:r.amount})]}),(0,$.jsxs)(I,{children:[(0,$.jsx)(P,{children:`Duration`}),(0,$.jsxs)(O,{value:e.duration,onValueChange:e=>{n(`durationInMonths`),t(t=>({...t,duration:e}))},children:[(0,$.jsx)(E,{"aria-label":`Duration`,children:(0,$.jsx)(D,{})}),(0,$.jsx)(T,{children:c.map(e=>(0,$.jsx)(w,{value:e.value,children:e.label},e.value))})]})]}),e.duration===`repeating`&&(0,$.jsx)(`div`,{className:`-mt-4`,children:(0,$.jsxs)(I,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,$.jsxs)(V,{"data-invalid":!!r.durationInMonths||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.durationInMonths||void 0,"data-testid":`duration-months-input`,type:`number`,value:e.durationInMonths===0?``:String(e.durationInMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,durationInMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`durationInMonths`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:e.durationInMonths===1?`month`:`months`})})]}),r.durationInMonths&&(0,$.jsx)(M,{children:r.durationInMonths})]})})]}),e.type===`free_months`&&(0,$.jsxs)(I,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(P,{htmlFor:`retention-free-months`,children:`Free months`}),(0,$.jsxs)(V,{"data-invalid":!!r.amount||void 0,children:[(0,$.jsx)(R,{"aria-invalid":!!r.amount||void 0,id:`retention-free-months`,type:`number`,value:e.freeMonths===0?``:String(e.freeMonths),onChange:e=>{let n=Number(e.target.value);t(e=>({...e,freeMonths:Number.isNaN(n)?0:n}))},onKeyDown:()=>n(`amount`)}),(0,$.jsx)(z,{align:`inline-end`,children:(0,$.jsx)(L,{children:e.freeMonths===1?`month`:`months`})})]}),r.amount&&(0,$.jsx)(M,{children:r.amount})]})]})]})]})]})})},it=({cadence:e})=>{let{updateRoute:t}=A(),{siteData:n}=Z(),{data:{tiers:i=[]}={}}=fe(),{data:{offers:a=[]}={},isFetched:d,isFetching:p}=u(),{mutateAsync:m}=f(),{mutateAsync:h}=l(),g=c(),[_,v]=(0,Q.useState)(``),y=e===`monthly`?`Monthly retention`:`Yearly retention`,b=e===`monthly`?`month`:`year`,x=pe(i||[]),S=(0,Q.useMemo)(()=>a.filter(e=>e.redemption_type===`retention`&&e.cadence===b).sort((e,t)=>{let n=e.created_at?new Date(e.created_at).getTime():0;return(t.created_at?new Date(t.created_at).getTime():0)-n}),[a,b]),C=(0,Q.useMemo)(()=>S.find(e=>e.status===`active`)||null,[S]),w=S[0]||null,T=C||w,E=(0,Q.useMemo)(()=>S.reduce((e,t)=>e+(t.redemption_count||0),0),[S]),D=(0,Q.useMemo)(()=>S.map(e=>e.id),[S]),O=(0,Q.useMemo)(()=>S.map(e=>e.last_redeemed).filter(e=>!!e).sort((e,t)=>new Date(t).getTime()-new Date(e).getTime())[0]||null,[S]),k=(0,Q.useMemo)(()=>E===0||D.length===0?null:Ae(D),[D,E]),[j,M]=(0,Q.useState)(20),[N,P]=(0,Q.useState)(1),[F,I]=(0,Q.useState)(null),{formState:L,setFormState:R,updateForm:z,handleSave:B,saveState:V,okProps:H,errors:ee,clearError:U}=s({initialState:Ye(e),savingDelay:500,onSave:async()=>{let t=!1,n=Qe({formState:L,lastPercentAmount:j,lastFreeMonths:N}),r=et($e(T))!==et(n),i=L.enabled?`active`:`archived`,a=L.displayTitle||``,o=L.displayDescription||``,s=T?a!==(T.display_title||``)||o!==(T.display_description||``):a!==``||o!==``,c=Ye(e),l=!L.enabled&&!T&&nt(L,c),u=async e=>{let r=crypto.getRandomValues(new Uint32Array(1))[0].toString(16).padStart(8,`0`),i=Fe(n,r);await m({name:i,code:r,display_title:a,display_description:o,cadence:b,amount:n.amount,duration:n.duration,duration_in_months:n.duration===`repeating`?n.durationInMonths:null,currency:null,status:e,redemption_type:`retention`,tier:null,type:n.type,currency_restriction:!1}),t=!0},d=async()=>{t&&await g()};if(!(!T&&!L.enabled&&!l)){if(r){!L.enabled&&C&&(await h({...C,status:`archived`}),t=!0),await u(i),await d();return}if(T){let e=T.status!==i;(s||e)&&(await h({...T,display_title:a,display_description:o,status:i}),t=!0),await d();return}(L.enabled||l)&&await u(i),await d()}},onSaveError:e=>{let t=`Please try again later`;e instanceof r&&e.data&&e.data.errors[0]&&(t=e.data.errors[0].context||e.data.errors[0].message||t),o.dismiss(),o.error(`Failed to save offer`,{description:t})},onValidate:()=>{let e={};return L.enabled?(L.type===`percent`&&((L.percentAmount<1||L.percentAmount>100)&&(e.amount=`Enter an amount between 1 and 100%.`),L.duration===`repeating`&&!tt(L.durationInMonths)&&(e.durationInMonths=Ke)),L.type===`free_months`&&(tt(L.freeMonths)||(e.amount=Ke)),e):e}}),W=`${e}:${T?.id||`none`}`;(0,Q.useEffect)(()=>{!d||p||V===`unsaved`||F===W||(R(()=>Ze(T,e)),I(W))},[e,W,T,d,F,p,V,R]),(0,Q.useEffect)(()=>{L.percentAmount>0&&M(L.percentAmount)},[L.percentAmount]),(0,Q.useEffect)(()=>{L.freeMonths>0&&P(L.freeMonths)},[L.freeMonths]);let G=()=>{t(`offers/edit`)},K=(0,$.jsx)(rt,{cadence:e,clearError:U,errors:ee,formState:L,lastRedeemed:O,membersFilterUrl:k,redemptions:E,updateForm:z}),te=async()=>{try{await B({force:!0})&&G()}catch{}},q=(0,Q.useMemo)(()=>{let t=Qe({formState:L,lastPercentAmount:j,lastFreeMonths:N}),n=x.find(e=>b===`month`?e.monthly_price:e.yearly_price);return{enabled:L.enabled,name:`${e} retention`,code:`${e}-retention`,displayTitle:L.displayTitle||``,displayDescription:L.displayDescription||``,type:t.type,cadence:b,amount:t.amount,duration:t.duration,durationInMonths:t.durationInMonths,currency:``,status:`active`,tierId:n?.id||``,redemptionType:`retention`}},[x,e,L,N,j,b]);(0,Q.useEffect)(()=>{if(!n.url){v(``);return}let e=xe(q,n.url);v(e)},[q,n.url]);let J=(0,$.jsx)(ye,{href:_||``,portalParent:`offers`});return(0,$.jsx)(ve,{backDropClick:!1,cancelLabel:`Cancel`,dirty:V===`unsaved`,height:`full`,okLabel:H.label||`Save`,okVariant:H.variant,preview:J,previewToolbarBreadcrumbs:(0,$.jsx)(be,{current:y,label:`Offers`,onBack:G}),sidebar:K,size:`lg`,testId:`retention-offer-modal`,title:`Offer`,width:1140,onCancel:G,onClose:()=>t(`offers`),onOk:te})},at=({id:e})=>{let{updateRoute:t}=A(),{data:{offers:n=[]}={}}=d(e||``),[r,i]=(0,Q.useState)(),[a,o]=(0,Q.useState)(``),{siteData:s}=Z();(0,Q.useEffect)(()=>{if(n.length>0){let e=n[0],t=`${de(s)}${e?.code}`;o(t),i(e)}},[n,s]);let[c,l]=(0,Q.useState)(!1),u=()=>{let e=``;switch(r?.type){case`percent`:e=r?.amount+`% discount`;break;case`fixed`:e=h(m(r?.amount),{maximumFractionDigits:2})+` `+r?.currency+` discount`;break;case`trial`:e=r?.amount+` days free trial`;break;default:break}return`${encodeURIComponent(r?.name||``)} — Check out ${encodeURIComponent(e)} on:`},f=async()=>{await navigator.clipboard.writeText(a),l(!0),setTimeout(()=>l(!1),2e3)};return(0,$.jsx)(k,{animate:!1,backDropClick:!1,footer:!1,height:`full`,size:`lg`,testId:`offer-success-modal`,topRightContent:`close`,width:1140,onClose:()=>{t(`offers`)},children:(0,$.jsxs)(`div`,{className:`-mt-6 flex h-full flex-col items-center justify-center text-center`,children:[(0,$.jsx)(be,{className:`absolute top-5 left-6`,current:r?.name||``,label:`Offers`,onBack:()=>t(`offers/edit`)}),(0,$.jsx)(y,{className:`-mt-4 size-10 text-gray-700`}),(0,$.jsx)(`h1`,{className:`mt-6 text-4xl`,children:`Your new offer is live!`}),(0,$.jsx)(`p`,{className:`mt-3 max-w-[510px] text-[1.6rem]`,children:`You can share the link anywhere. In your newsletter, social media, a podcast, or in-person. It all just works.`}),(0,$.jsxs)(`div`,{className:`mt-8 flex w-full max-w-md flex-col gap-8`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col-reverse gap-2`,children:[(0,$.jsx)(X,{name:`offer-url`,type:`url`,value:a,disabled:!0}),(0,$.jsx)(b,{className:`w-full`,type:`button`,onClick:()=>void f(),children:c?`Copied!`:`Copy link`})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-4 text-sm font-medium before:h-px before:grow before:bg-gray-300 before:content-[""] after:h-px after:grow after:bg-gray-300 after:content-[""] dark:before:bg-gray-800 dark:after:bg-gray-800`,children:`OR`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(b,{"aria-label":`Share on X`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://twitter.com/intent/tweet?url=${encodeURI(a)}&text=${u()}`,`_blank`)},children:(0,$.jsx)(me,{className:`size-3.5!`,name:`twitter-x`})}),(0,$.jsx)(b,{"aria-label":`Share on Facebook`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(a)}`,`_blank`)},children:(0,$.jsx)(me,{className:`size-3.5!`,name:`facebook`})}),(0,$.jsx)(b,{"aria-label":`Share on LinkedIn`,className:`h-8 flex-1`,size:`sm`,type:`button`,variant:`outline`,onClick:()=>{window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(a)}&title=${u()}`,`_blank`)},children:(0,$.jsx)(me,{className:`size-3.5!`,name:`linkedin`})})]})]})]})})},ot=(e,t)=>e.find(e=>e.redemption_type===`retention`&&e.cadence===t&&e.status===`active`)||null,st=(e,t)=>e.reduce((e,n)=>n.redemption_type!==`retention`||n.cadence!==t?e:e+(n.redemption_count||0),0),ct=(e,t)=>e.filter(e=>e.redemption_type===`retention`&&e.cadence===t).map(e=>e.id),lt=(e,t)=>{let n=e.filter(e=>e.redemption_type===`retention`&&e.cadence===t&&e.created_at).map(e=>new Date(e.created_at).getTime()).filter(e=>!Number.isNaN(e));return n.length===0?null:new Date(Math.max(...n)).toISOString()},ut=e=>e.type===`percent`&&e.amount===100&&e.duration===`repeating`,dt=e=>{if(!e)return null;if(ut(e)){let t=e.duration_in_months||0,n=t===1?`month`:`months`;return`${h(t)} ${n} free`}return e.type===`percent`?`${h(e.amount)}% OFF`:null},ft=e=>{if(!e)return null;if(ut(e))return``;if(e.duration===`once`)return`First payment`;if(e.duration===`repeating`&&e.duration_in_months){let t=e.duration_in_months===1?`month`:`months`;return`For ${h(e.duration_in_months)} ${t}`}return e.duration===`forever`?`Forever`:null},pt=e=>{let t=ot(e,`month`),n=ot(e,`year`),r=ct(e,`month`),i=ct(e,`year`),a=st(e,`month`),o=st(e,`year`);return[{id:`monthly`,name:`Monthly retention`,description:`Applied to monthly plans`,terms:dt(t),termsDetail:ft(t),redemptionOfferIds:r,redemptions:a,status:t?`active`:`inactive`,createdAt:lt(e,`month`)},{id:`yearly`,name:`Yearly retention`,description:`Applied to annual plans`,terms:dt(n),termsDetail:ft(n),redemptionOfferIds:i,redemptions:o,status:n?`active`:`inactive`,createdAt:lt(e,`year`)}]},mt=({showArchived:e,setShowArchived:t,sortOption:n,sortDirection:r,onSortChange:i,onDirectionChange:a})=>(0,$.jsxs)(ce,{children:[(0,$.jsx)(ae,{asChild:!0,children:(0,$.jsx)(b,{"aria-label":`Filter options`,className:`text-muted-foreground hover:text-foreground`,size:`icon`,type:`button`,variant:`ghost`,children:(0,$.jsx)(x,{size:16,strokeWidth:1.5})})}),(0,$.jsxs)(re,{align:`end`,className:`z-[9999] min-w-[200px] normal-case`,children:[(0,$.jsx)(ne,{className:`text-xs tracking-wide text-muted-foreground uppercase`,children:`Sort by`}),(0,$.jsxs)(le,{value:n,onValueChange:i,children:[(0,$.jsx)(oe,{value:`date-added`,children:`Date added`}),(0,$.jsx)(oe,{value:`name`,children:`Name`}),(0,$.jsx)(oe,{value:`redemptions`,children:`Redemptions`})]}),(0,$.jsxs)(ue,{onSelect:a,children:[r===`asc`?(0,$.jsx)(S,{className:`size-3`}):(0,$.jsx)(v,{className:`size-3`}),r===`asc`?`Ascending`:`Descending`]}),(0,$.jsx)(se,{}),(0,$.jsx)(ie,{checked:e,onCheckedChange:e=>t(!!e),children:`Show archived`})]})]}),ht=({offer:e,onClick:t})=>{let n=e.redemptions>0&&e.redemptionOfferIds.length>0?Ae(e.redemptionOfferIds):void 0;return(0,$.jsxs)(W,{"data-testid":`retention-offer-item`,children:[(0,$.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:e.name}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.terms?(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:e.terms}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.termsDetail})]}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`–`})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:n?(0,$.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,"data-testid":`retention-redemptions-link-${e.id}`,href:n,children:h(e.redemptions)}):(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,"data-testid":`retention-redemptions-link-${e.id}`,type:`button`,onClick:t,children:h(e.redemptions)})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:t,children:e.status===`active`?(0,$.jsx)(Y,{className:`rounded-full uppercase`,variant:`success`,children:`Active`}):(0,$.jsx)(Y,{className:`rounded-full uppercase`,variant:`secondary`,children:`Inactive`})})})]})},gt=({archived:e,offer:t,tier:n,onClick:r})=>{let{discountOffer:i,originalPriceWithCurrency:a,updatedPriceWithCurrency:o}=Re(t.type,t.amount,t.cadence,t.currency||`USD`,n);return(0,$.jsxs)(W,{className:e?`opacity-60`:void 0,"data-testid":`offer-item`,children:[(0,$.jsx)(K,{className:`sticky left-0 z-10 bg-background p-0`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`font-semibold`,children:t.name}),(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[n.name,` `,Ie(t.cadence)]})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:(0,$.jsxs)(_,{gap:`none`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium uppercase`,children:i}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:t.type===`trial`?`Trial period`:Le(t.duration)})]})})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsxs)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:o}),` `,t.type===`trial`?null:(0,$.jsx)(`span`,{className:`relative text-sm text-muted-foreground before:absolute before:-inset-x-0.5 before:top-1/2 before:rotate-[-20deg] before:border-t before:content-[""]`,children:a})]})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:t.redemption_count>0&&t.id?(0,$.jsx)(`a`,{className:`block cursor-pointer p-5 hover:underline`,href:je(t.id),children:h(t.redemption_count)}):(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:h(t.redemption_count)})}),(0,$.jsx)(K,{className:`p-0 whitespace-nowrap`,children:(0,$.jsx)(`button`,{className:`block w-full cursor-pointer p-5 text-left`,type:`button`,onClick:r,children:e?(0,$.jsx)(Y,{className:`rounded-full uppercase`,variant:`secondary`,children:`Archived`}):(0,$.jsx)(Y,{className:`rounded-full uppercase`,variant:`success`,children:`Active`})})})]})},_t=e=>e.offer.name,vt=e=>e.kind===`retention`?e.offer.redemptions:e.offer.redemption_count,yt=e=>e.kind===`retention`?e.offer.createdAt:e.offer.created_at||null,bt=(e,t,n)=>{let r=n===`desc`?-1:1;return[...e].sort((e,n)=>{let i;switch(t){case`name`:i=_t(e).localeCompare(_t(n));break;case`redemptions`:i=vt(e)-vt(n);break;default:{let t=yt(e),r=yt(n);if(!t&&!r)i=0;else if(!t)return 1;else if(r)i=new Date(t).getTime()-new Date(r).getTime();else return-1;break}}return(i||_t(e).localeCompare(_t(n)))*r})},xt=()=>{let{updateRoute:e}=A(),{data:{offers:t=[]}={}}=u(),{data:{tiers:n}={}}=fe(),r=t.filter(e=>e.redemption_type===`signup`),i=pt(t),{sortingState:a,setSortingState:s}=ge(),c=a?.find(e=>e.type===`offers`),{offersShowArchived:l,setOffersShowArchived:d}=_e(),f=c?.option||`date-added`,p=c?.direction||`desc`,m=t=>{t&&e(`offers/edit/${t}`)},h=t=>{e(`offers/edit/retention/${t}`)},v=pe(n||[]),y=r.filter(e=>{let t=n?.find(t=>t.id===e?.tier?.id),r=e.status===`active`&&t&&t.active===!0,i=e.status===`archived`||t&&t.active===!1;return!!(r||l&&i)}),x=bt([...i.map(e=>({kind:`retention`,offer:e})),...y.map(e=>({kind:`signup`,offer:e}))],f,p),S=e=>{s?.([{type:`offers`,option:e,direction:p}])},C=()=>{s?.([{type:`offers`,option:f,direction:p===`asc`?`desc`:`asc`}])},w=e=>{let t=n?.find(t=>t.id===e?.tier?.id);return e.status===`archived`||t?.active===!1};return(0,$.jsx)(k,{animate:!1,backDropClick:!1,cancelLabel:``,footer:!1,height:`full`,size:`lg`,testId:`offers-modal`,title:`Offers`,topRightContent:(0,$.jsxs)(g,{gap:`md`,children:[(0,$.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>{e(`offers`)},children:`Close`}),(0,$.jsx)(b,{type:`button`,onClick:()=>{v.length===0?o.info(`You must have an active tier to create an offer.`):e(`offers/new`)},children:`New offer`})]}),width:1140,onClose:()=>{e(`offers`)},children:(0,$.jsx)(_,{className:`h-full pt-8`,children:(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(q,{className:`m-0 min-w-[900px]`,children:[(0,$.jsxs)(`colgroup`,{children:[(0,$.jsx)(`col`,{className:`w-[25%]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[200px]`}),(0,$.jsx)(`col`,{className:`w-[220px]`})]}),(0,$.jsx)(te,{children:(0,$.jsxs)(W,{children:[(0,$.jsx)(U,{className:`sticky left-0 z-10 h-auto bg-background p-0 pb-2.5 pl-5 uppercase`,children:`Name`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Terms`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Price`}),(0,$.jsx)(U,{className:`h-auto p-0 pb-2.5 pl-5 uppercase`,children:`Redemptions`}),(0,$.jsx)(U,{className:`h-auto p-0 px-5 pb-2.5 uppercase`,children:(0,$.jsxs)(g,{align:`center`,justify:`between`,children:[`Status`,(0,$.jsx)(mt,{setShowArchived:d,showArchived:l,sortDirection:p,sortOption:f,onDirectionChange:C,onSortChange:S})]})})]})}),(0,$.jsx)(G,{"data-testid":`offers-table-body`,children:x.map(e=>{if(e.kind===`retention`)return(0,$.jsx)(ht,{offer:e.offer,onClick:()=>h(e.offer.id)},`retention-${e.offer.id}`);let t=e.offer,r=n?.find(e=>e.id===t?.tier?.id);if(!r)return null;let i=w(t);return(0,$.jsx)(gt,{archived:i,offer:t,tier:r,onClick:()=>m(t.id)},`signup-${t.id}`)})})]})})})})},St=`offers/edit/retention/`,Ct=e=>{let t=e.slice(22).replace(/\/+$/,``);return t===`monthly`||t===`yearly`?t:null},wt=({route:e})=>{if(e===`offers/new`)return(0,$.jsx)(Oe,{});if(e===`offers/edit/retention`||e.startsWith(St)){let t=e.startsWith(St)?Ct(e):null;return t?(0,$.jsx)(it,{cadence:t}):(0,$.jsx)(xt,{})}else if(e.startsWith(`offers/edit/`)&&e.length>12){let t=e.split(`/`).pop();return(0,$.jsx)(Ve,{id:t||``})}else if(e.startsWith(`offers/success/`)&&e.length>15){let t=e.split(`/`).pop();return(0,$.jsx)(at,{id:t||``})}else if(e===`offers/edit`||e===`offers/edit/`)return(0,$.jsx)(xt,{})},Tt=()=>{let{route:e}=A();return(0,$.jsx)(wt,{route:e})};export{Tt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-DAXXjFlN.js";import{n as t,t as n}from"./onboarding-pXyct0Jm.js";var r=e({default:()=>n,useOnboardingStatus:()=>t});export{r 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{o as r}from"./hooks-
|
|
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{o as r}from"./hooks-Cy_-oZ4o.js";import{i}from"./chunk-KS7C4IRE-DCsL4i4D.js";import{m as a}from"./users-DVNWrqg9.js";var o=e(t(),1);function s(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}function c(e,t){let n=s(e);return JSON.stringify({...n,...t})}var l=n(),u=()=>{let{data:e}=r(),{mutateAsync:t}=a(),n=o.useMemo(()=>e?.accessibility&&s(e.accessibility).apOnboarding||{},[e?.accessibility]),i=o.useCallback(async n=>{if(!e)return;let r=s(e.accessibility),i=c(e.accessibility,{apOnboarding:{...r.apOnboarding,...n}});await t({...e,accessibility:i})},[e,t]);return{isOnboarded:!!n.welcomeStepsFinished,isExplainerClosed:!!n.exploreExplainerClosed,setOnboarded:e=>i({welcomeStepsFinished:e}),setExplainerClosed:e=>i({exploreExplainerClosed:e})}},d=()=>(0,l.jsx)(`div`,{className:`h-full pt-14`,children:(0,l.jsx)(i,{})});export{u as n,d as t};
|