ghost 6.24.0 → 6.25.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-i18n-6.24.0.tgz → tryghost-i18n-6.25.0.tgz} +0 -0
- package/components/tryghost-parse-email-address-6.25.0.tgz +0 -0
- package/core/boot.js +3 -1
- package/core/built/admin/assets/{PolarAngleAxis-7TlIQL3R.js → PolarAngleAxis-BNo3yZOE.js} +1 -1
- package/core/built/admin/assets/{_baseAssignValue-DJsCJz6y.js → _baseAssignValue-DwWJd_kU.js} +1 -1
- package/core/built/admin/assets/{a-large-small-BnBpzYwl.js → a-large-small-DzN0AB7t.js} +1 -1
- package/core/built/admin/assets/{at-sign-DC4NtDDM.js → at-sign-vqoOA4VZ.js} +1 -1
- package/core/built/admin/assets/{audience-CC5U4UxI.js → audience-CFjVlFTu.js} +1 -1
- package/core/built/admin/assets/{avatar-flipboard-_GQfQXQc.js → avatar-flipboard-DuTJ0ty5.js} +1 -1
- package/core/built/admin/assets/{bluesky-sharing-BKyzPl9y.js → bluesky-sharing-C1WkXrRJ.js} +1 -1
- package/core/built/admin/assets/{chart-BCQFlmhJ.js → chart-Bs2L1q8g.js} +1 -1
- package/core/built/admin/assets/{chunk.423.dae9a3bbe7845c3a3cfc.js → chunk.434.de8a15730373eccfeefe.js} +13 -101
- package/core/built/admin/assets/{chunk.524.b5e454aa74df4428420c.js → chunk.524.ed5714f505e821e549f3.js} +5 -5
- package/core/built/admin/assets/{chunk.582.20635869be68725e6d5c.js → chunk.582.639cecaca9e77bd7dd4f.js} +7 -7
- package/core/built/admin/assets/{chunk.123.1255d9e815f933dfdc57.js → chunk.603.5cb992da88800a9388f3.js} +8 -6
- package/core/built/admin/assets/{code-editor-view-BXnjo7qe.js → code-editor-view-DIH4grxv.js} +1 -1
- package/core/built/admin/assets/comments-gAnA10dK.js +1 -0
- package/core/built/admin/assets/{content-helpers-CQXipRWa.js → content-helpers-Cr_DHEOl.js} +1 -1
- package/core/built/admin/assets/{copy-B-MxRWPu.js → copy-w3c9zkaZ.js} +1 -1
- package/core/built/admin/assets/{data-list-B2sqn7IE.js → data-list-D-K_XfF3.js} +1 -1
- package/core/built/admin/assets/{deleted-feed-item-DQi676Dy.js → deleted-feed-item-DK47iaMV.js} +1 -1
- package/core/built/admin/assets/{dropzone-GgOCfK2j.js → dropzone-BHWXAN0m.js} +3 -3
- package/core/built/admin/assets/{edit-profile-COx5FmF9.js → edit-profile-DCyHhZgx.js} +1 -1
- package/core/built/admin/assets/{empty-indicator-Bf4Dqk72.js → empty-indicator-DjmACVr2.js} +1 -1
- package/core/built/admin/assets/{en-BkI47Ou-.js → en-Cl0b7CNW.js} +1 -1
- package/core/built/admin/assets/{feed-Dzc-8jwd.js → feed-C5AauoXf.js} +1 -1
- package/core/built/admin/assets/filters-DzSJ1ez3.js +1 -0
- package/core/built/admin/assets/{gh-chart-Ch6dYUac.js → gh-chart-xjwu2HZo.js} +1 -1
- package/core/built/admin/assets/{ghost-69e448feab2cb78aba64f7177fa4d6f0.js → ghost-78b4a517ac907213ab47708eef33bc6f.js} +423 -542
- package/core/built/admin/assets/{growth-BIBJdcm6.js → growth-DDyypj0q.js} +1 -1
- package/core/built/admin/assets/{hash-BGd7HEsT.js → hash-Bowe71Lt.js} +1 -1
- package/core/built/admin/assets/{inbox-CFzKvW3h.js → inbox-DS4qMjUb.js} +1 -1
- package/core/built/admin/assets/{index-DDJAHYHQ.js → index-4xuWCs9h.js} +1 -1
- package/core/built/admin/assets/{index-DIO8ceib.js → index-6Ag8SK_E.js} +1 -1
- package/core/built/admin/assets/{index-Dy8dCc8t.js → index-A6WmqYr6.js} +4 -4
- package/core/built/admin/assets/index-B8XuCPIT.js +1 -0
- package/core/built/admin/assets/{index-S2DGJkmz.js → index-BCvRITTU.js} +2 -2
- package/core/built/admin/assets/{index-BZyG96u1.js → index-B_XhekWb.js} +1 -1
- package/core/built/admin/assets/{index-D0gRP4Gp.js → index-C8ssgmjI.js} +1 -1
- package/core/built/admin/assets/{index-DM98UB_U.js → index-CFY2MOp4.js} +1 -1
- package/core/built/admin/assets/{index-CvX5YYEz.js → index-CVvW6Q-y.js} +1 -1
- package/core/built/admin/assets/{index-DpZazR71.js → index-CZK1A375.js} +1 -1
- package/core/built/admin/assets/{index-BYXKsmpv.js → index-CfpTfwls.js} +1 -1
- package/core/built/admin/assets/index-Chp0ODAU.css +1 -0
- package/core/built/admin/assets/{index-7NTHsKgE.js → index-DX6vaEVx.js} +1 -1
- package/core/built/admin/assets/{index-CsHjDdYB.js → index-DqlHFtZD.js} +1 -1
- package/core/built/admin/assets/{index-ZuWSQ3L6.js → index-JMWMnGGt.js} +93 -93
- package/core/built/admin/assets/{index-_WMp37yL.js → index-N61Xkr32.js} +1 -1
- package/core/built/admin/assets/{index-n5opb8tL.js → index-SDMWxO5r.js} +1 -1
- package/core/built/admin/assets/{koenig-lexical-8qAZ5o1x.js → koenig-lexical-DL3I-AcK.js} +1 -1
- package/core/built/admin/assets/{kpis-Cv75oSPY.js → kpis-Bm-hIEkf.js} +1 -1
- package/core/built/admin/assets/{label-CofMdj8x.js → label-DBwnwMrX.js} +1 -1
- package/core/built/admin/assets/{links-MSlYSad1.js → links-CnjcW0lg.js} +1 -1
- package/core/built/admin/assets/{loader-circle-CF5G2g_Z.js → loader-circle-CGDGFypO.js} +1 -1
- package/core/built/admin/assets/{lucide-react-DZiAu6PQ.js → lucide-react-BfVLf4Hw.js} +1 -1
- package/core/built/admin/assets/{main-layout-DEVUkqt_.js → main-layout-C_UH037j.js} +1 -1
- package/core/built/admin/assets/{member-route-mLKS-PsA.js → member-route-CKuE9uDU.js} +1 -1
- package/core/built/admin/assets/members-CzztojNk.js +15 -0
- package/core/built/admin/assets/{message-square-text-DESy3kSk.js → message-square-text-BDJyLbG2.js} +1 -1
- package/core/built/admin/assets/{minus-DVNwSjD6.js → minus-BM0xhFIQ.js} +1 -1
- package/core/built/admin/assets/{modals-FYjLOMaQ.js → modals-B6ZySU0x.js} +13 -13
- package/core/built/admin/assets/{moderation-u4WS46a-.js → moderation-CQMIGpv1.js} +1 -1
- package/core/built/admin/assets/{newsletter-Cj0UCg4J.js → newsletter-Dexg7vU8.js} +1 -1
- package/core/built/admin/assets/{newsletters-_UvhdBE3.js → newsletters-CT4k07rm.js} +1 -1
- package/core/built/admin/assets/{note-CRnFryTp.js → note-CiemurXq.js} +1 -1
- package/core/built/admin/assets/{overview-Cr0dGxEU.js → overview-9TwqfzGq.js} +1 -1
- package/core/built/admin/assets/{pagemenu-BqoDENpI.js → pagemenu-Dq744OgH.js} +1 -1
- package/core/built/admin/assets/{post-analytics-DIr_rDtL.js → post-analytics-CcRhLDKA.js} +1 -1
- package/core/built/admin/assets/{post-analytics-context-WA--pwK5.js → post-analytics-context-COgn3d86.js} +1 -1
- package/core/built/admin/assets/{post-analytics-header-D97SoEaV.js → post-analytics-header-DtBp2QSX.js} +1 -1
- package/core/built/admin/assets/{post-share-modal-DBxR7WCX.js → post-share-modal-BlOEKX3-.js} +1 -1
- package/core/built/admin/assets/posts/comments-C4rwkXWy.mjs +1473 -0
- package/core/built/admin/assets/posts/{dialog-67vvNv8e.mjs → dialog-Chkt119L.mjs} +3 -3
- package/core/built/admin/assets/posts/{dropdown-menu-BKZfsAPJ.mjs → dropdown-menu-CvSs_ay2.mjs} +5 -5
- package/core/built/admin/assets/posts/{empty-indicator-DTmBQa_3.mjs → empty-indicator-GyeO28CG.mjs} +2 -2
- package/core/built/admin/assets/posts/filters-BD3A2GlB.mjs +2831 -0
- package/core/built/admin/assets/posts/{get-site-timezone-D75cHSJ1.mjs → get-site-timezone-Baeue4hE.mjs} +2 -2
- package/core/built/admin/assets/posts/{growth-BqJWjpAp.mjs → growth-kmVbKjBt.mjs} +14 -14
- package/core/built/admin/assets/posts/{heading-DXxLDQ96.mjs → heading-DV_WQJh4.mjs} +2 -2
- package/core/built/admin/assets/posts/{hooks-pVotzebr.mjs → hooks-DQhsid0U.mjs} +2 -2
- package/core/built/admin/assets/posts/{index-By5yPnMZ.mjs → index-Bl1ReYmV.mjs} +10 -10
- package/core/built/admin/assets/posts/{index-DZ1HzbGS.mjs → index-CVum5OE6.mjs} +3 -3
- package/core/built/admin/assets/posts/{input-DdXe2Fjm.mjs → input-C7qFEkmt.mjs} +2 -2
- package/core/built/admin/assets/posts/{kpis-1MXZeSC9.mjs → kpis-DteuJY-D.mjs} +10 -10
- package/core/built/admin/assets/posts/{links-DGzzdzsH.mjs → links-eoZr0T0x.mjs} +4 -4
- package/core/built/admin/assets/posts/{loading-indicator-CSj2spwS.mjs → loading-indicator-Dj1SCL40.mjs} +3 -3
- package/core/built/admin/assets/posts/{main-layout-CGs25JVH.mjs → main-layout-Ct-TA0TH.mjs} +2 -2
- package/core/built/admin/assets/posts/{members-BRcED5fL.mjs → members-BY9oPKo4.mjs} +3814 -3378
- package/core/built/admin/assets/posts/{newsletter-D706LlgM.mjs → newsletter-BR1tln6E.mjs} +15 -15
- package/core/built/admin/assets/posts/{overview-5dG5ypjx.mjs → overview-j1ANMAQ2.mjs} +16 -16
- package/core/built/admin/assets/posts/{post-analytics-wvNuOa4c.mjs → post-analytics-DnG-Rolr.mjs} +6 -6
- package/core/built/admin/assets/posts/{post-analytics-context-BqnFe05q.mjs → post-analytics-context-hiKFF4yE.mjs} +5 -5
- package/core/built/admin/assets/posts/{post-analytics-header-Dsi5l6hb.mjs → post-analytics-header-OqAJ8SUL.mjs} +11 -11
- package/core/built/admin/assets/posts/{post-share-modal-DWe35McY.mjs → post-share-modal-BWfujDu2.mjs} +4 -4
- package/core/built/admin/assets/posts/posts-CS9tqSJC.mjs +37 -0
- package/core/built/admin/assets/posts/posts.js +1 -1
- package/core/built/admin/assets/posts/{reply-B4vwBMwj.mjs → reply-CX_EQh9X.mjs} +2 -2
- package/core/built/admin/assets/posts/{search-DQuB1WMm.mjs → search-BqzdnPQb.mjs} +2 -2
- package/core/built/admin/assets/posts/{select-BMPHyOdQ.mjs → select-CD5WLIrZ.mjs} +8 -8
- package/core/built/admin/assets/posts/{separator-DgZ2VF9r.mjs → separator-DFPLsWCc.mjs} +3 -3
- package/core/built/admin/assets/posts/{settings-D-wnf7Qg.mjs → settings-lnEt3Kb-.mjs} +2 -2
- package/core/built/admin/assets/posts/{sheet-SOdCzxUt.mjs → sheet-CkLfUqdH.mjs} +3 -3
- package/core/built/admin/assets/posts/{skeleton-Du7JXZ_1.mjs → skeleton-BZCi-IYy.mjs} +3 -3
- package/core/built/admin/assets/posts/{source-icon-DcBtKbCl.mjs → source-icon-C0k2hDC_.mjs} +3 -3
- package/core/built/admin/assets/posts/{stats-CeLav-Hu.mjs → stats-AHbSTqzG.mjs} +4 -4
- package/core/built/admin/assets/posts/{table-DlaJMBps.mjs → table-DMrf6wp5.mjs} +2 -2
- package/core/built/admin/assets/posts/{tabs-BQQbtw2g.mjs → tabs-BH8GNJCe.mjs} +14 -14
- package/core/built/admin/assets/posts/tags-C5VV8Gd0.mjs +398 -0
- package/core/built/admin/assets/posts/{tags-CLyaNf39.mjs → tags-DucujdYI.mjs} +2 -2
- package/core/built/admin/assets/posts/use-scroll-restoration-C7A3TpAz.mjs +517 -0
- package/core/built/admin/assets/posts/{use-infinite-virtual-scroll-B_NwiBXK.mjs → virtual-list-window-BIGoc0th.mjs} +322 -244
- package/core/built/admin/assets/posts/{web-TEVKbXSI.mjs → web-DczNailO.mjs} +18 -18
- package/core/built/admin/assets/posts-Dr3u9yOp.js +1 -0
- package/core/built/admin/assets/{referrers-J4vexZCf.js → referrers-6As_USul.js} +1 -1
- package/core/built/admin/assets/{repeat-BxOK9zhN.js → repeat-D-Ki-Cg5.js} +1 -1
- package/core/built/admin/assets/{reply-BoTN-eE0.js → reply-C4V0xZ2U.js} +1 -1
- package/core/built/admin/assets/{select-Bd1zcqox.js → select-Dt579MbD.js} +1 -1
- package/core/built/admin/assets/{settings-D72z6T_a.js → settings-BMsoTszq.js} +1 -1
- package/core/built/admin/assets/{settings-BGbGoa4s.js → settings-Ck1Hqs1x.js} +19 -19
- package/core/built/admin/assets/{sort-button-BOLTpImz.js → sort-button-Bn325H3y.js} +1 -1
- package/core/built/admin/assets/{source-icon-BqEM5MvU.js → source-icon-CNqsYZeA.js} +1 -1
- package/core/built/admin/assets/{sprout-Bf-wc2Vo.js → sprout-C9DbfYGe.js} +1 -1
- package/core/built/admin/assets/{square-Cj_bJ0HZ.js → square-CWrI0H4v.js} +1 -1
- package/core/built/admin/assets/stats/{audience-BiHYBUzT.mjs → audience-DBW5Xu1c.mjs} +3 -3
- package/core/built/admin/assets/stats/{content-helpers-CIXZiyCm.mjs → content-helpers-BR6DcWwH.mjs} +4 -4
- package/core/built/admin/assets/stats/{index-DBB8Oih1.mjs → index-BuS4r1cs.mjs} +5 -5
- package/core/built/admin/assets/stats/{index-CkKk-p14.mjs → index-CFvGHbAV.mjs} +8 -8
- package/core/built/admin/assets/stats/{index-9zQR4gr0.mjs → index-DKS4mzS-.mjs} +3621 -3512
- package/core/built/admin/assets/stats/{index-DMSmQLxG.mjs → index-TeAxlGlY.mjs} +5 -5
- package/core/built/admin/assets/stats/{index-DErXBfDM.mjs → index-ZjicrvMA.mjs} +5 -5
- package/core/built/admin/assets/stats/{sort-button-BqY7GFaO.mjs → sort-button-DbwzvVKL.mjs} +3 -3
- package/core/built/admin/assets/stats/{stats-BeJgKX2G.mjs → stats-BatzfgdA.mjs} +4 -4
- package/core/built/admin/assets/stats/stats.js +1 -1
- package/core/built/admin/assets/stats/{tabs-CPz357mW.mjs → tabs-B32ptD5t.mjs} +3 -3
- package/core/built/admin/assets/stats/{use-growth-stats-WMYXBQE3.mjs → use-growth-stats-DmTT2gKd.mjs} +3 -3
- package/core/built/admin/assets/{stats-DWpHtRym.js → stats-G4Ge9ETb.js} +1 -1
- package/core/built/admin/assets/stats-view-Bx3oDAIW.js +1 -0
- package/core/built/admin/assets/{step-1-Bjya9Gt0.js → step-1-y3anLU0g.js} +1 -1
- package/core/built/admin/assets/{step-2-CJ6I8JNc.js → step-2-Dr1lGnHU.js} +1 -1
- package/core/built/admin/assets/{step-3-3fs6Y2Kj.js → step-3-C_d2hvMs.js} +2 -2
- package/core/built/admin/assets/{table-B4zlzEDP.js → table-CbN_vbUx.js} +1 -1
- package/core/built/admin/assets/{tabs-mR5oJGm5.js → tabs-DFJzY5np.js} +1 -1
- package/core/built/admin/assets/tags-D5g9tXZU.js +1 -0
- package/core/built/admin/assets/{tags-CsgMtkFL.js → tags-Ddg8oG2Y.js} +1 -1
- package/core/built/admin/assets/{textarea-CQjEvapR.js → textarea-DikWsYMt.js} +1 -1
- package/core/built/admin/assets/{tiers-CQE0v797.js → tiers-B7qV_8mO.js} +1 -1
- package/core/built/admin/assets/{toggle-group-CR-Z-bJL.js → toggle-group-tXaaTD7P.js} +1 -1
- package/core/built/admin/assets/{topic-filter-_NyD55eH.js → topic-filter-bQtscKE6.js} +1 -1
- package/core/built/admin/assets/{trash-BFSLkv0z.js → trash--VS50LgS.js} +1 -1
- package/core/built/admin/assets/{upload-BTxT4v2z.js → upload-Dz-DI9rQ.js} +1 -1
- package/core/built/admin/assets/{use-growth-stats-BGymNu5O.js → use-growth-stats-DNVioFUq.js} +1 -1
- package/core/built/admin/assets/use-scroll-restoration-CxWEiCuS.js +1 -0
- package/core/built/admin/assets/{use-simple-pagination-Cq7Afp_c.js → use-simple-pagination-BA6xsVQO.js} +1 -1
- package/core/built/admin/assets/{user-plus-DMl69yKl.js → user-plus-B0tpOnLM.js} +1 -1
- package/core/built/admin/assets/{user-round-check-CVuZXUPz.js → user-round-check-caJYm0bB.js} +1 -1
- package/core/built/admin/assets/virtual-list-window-JdKgHS9L.js +4 -0
- package/core/built/admin/assets/{wallet-cards-zHR_y6Sp.js → wallet-cards-DBM65lA_.js} +1 -1
- package/core/built/admin/assets/{web-CmFHgeQw.js → web-CSXixG1S.js} +1 -1
- package/core/built/admin/index.html +7 -7
- package/core/frontend/helpers/ghost_head.js +1 -4
- package/core/server/data/migrations/versions/6.25/2026-03-26-15-47-00-insert-default-email-design-settings-row.js +42 -0
- package/core/server/data/migrations/versions/6.25/2026-03-30-20-22-25-add-email-design-setting-permissions.js +44 -0
- package/core/server/data/migrations/versions/6.25/2026-03-30-22-16-43-add-email-design-setting-id-to-automated-emails.js +8 -0
- package/core/server/data/migrations/versions/6.25/2026-03-31-13-12-10-backfill-automated-emails-email-design-setting-id.js +45 -0
- package/core/server/data/migrations/versions/6.25/2026-03-31-20-31-19-drop-nullable-on-automated-emails-email-design-setting-id.js +3 -0
- package/core/server/data/schema/fixtures/fixtures.json +35 -0
- package/core/server/data/schema/schema.js +1 -0
- package/core/server/data/seeders/importers/comment-reports-importer.js +1 -3
- package/core/server/data/seeders/importers/comments-importer.js +3 -2
- package/core/server/data/seeders/importers/email-batches-importer.js +3 -3
- package/core/server/data/seeders/importers/email-recipients-importer.js +6 -6
- package/core/server/data/seeders/importers/emails-importer.js +4 -3
- package/core/server/data/seeders/importers/members-click-events-importer.js +1 -1
- package/core/server/data/seeders/importers/members-created-events-importer.js +2 -1
- package/core/server/data/seeders/importers/members-feedback-importer.js +3 -4
- package/core/server/data/seeders/importers/members-login-events-importer.js +3 -2
- package/core/server/data/seeders/importers/members-status-events-importer.js +1 -2
- package/core/server/data/seeders/importers/members-stripe-customers-importer.js +2 -1
- package/core/server/data/seeders/importers/members-stripe-customers-subscriptions-importer.js +4 -2
- package/core/server/data/seeders/importers/members-subscribe-events-importer.js +1 -2
- package/core/server/data/seeders/importers/members-subscription-created-events-importer.js +3 -1
- package/core/server/data/seeders/importers/offer-redemptions-importer.js +3 -3
- package/core/server/data/seeders/utils/database-date.js +26 -1
- package/core/server/models/automated-email.js +27 -0
- package/core/server/models/email-design-setting.js +27 -0
- package/core/server/services/stripe/service.js +1 -2
- package/core/server/services/webhooks/webhook-trigger.js +1 -1
- package/package.json +10 -28
- package/tsconfig.tsbuildinfo +1 -1
- package/yarn.lock +423 -107
- package/components/tryghost-parse-email-address-6.24.0.tgz +0 -0
- package/core/built/admin/assets/comments-CteqV7ZN.js +0 -1
- package/core/built/admin/assets/filters-DXXaCya7.js +0 -1
- package/core/built/admin/assets/index-QB-va_sk.css +0 -1
- package/core/built/admin/assets/index-nBUk6L1X.js +0 -1
- package/core/built/admin/assets/members-DcElgZ2t.js +0 -15
- package/core/built/admin/assets/posts/comments-Bswx2dzs.mjs +0 -1551
- package/core/built/admin/assets/posts/filters-Ds_ZaYIU.mjs +0 -2722
- package/core/built/admin/assets/posts/posts-DI5YQFp4.mjs +0 -17
- package/core/built/admin/assets/posts/tags-CjwolIiT.mjs +0 -395
- package/core/built/admin/assets/posts/use-scroll-restoration-YSR5jwQl.mjs +0 -232
- package/core/built/admin/assets/posts-CJHEP4C-.js +0 -1
- package/core/built/admin/assets/stats-view-CcyaLPwj.js +0 -1
- package/core/built/admin/assets/tags-DEFC6GpD.js +0 -1
- package/core/built/admin/assets/use-infinite-virtual-scroll-CNqGwgHd.js +0 -4
- package/core/built/admin/assets/use-scroll-restoration-BWtb0NrS.js +0 -1
- /package/core/built/admin/assets/{chunk.423.dae9a3bbe7845c3a3cfc.js.LICENSE.txt → chunk.434.de8a15730373eccfeefe.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,bB as A,t as u,b as g,bC as E,r as j,bx as T,by as z,L as S,E as M,c as P,bD as U,S as w,A as $,B,bp as L,m as C,h as v,d as W,n as _,bE as D,bF as H,e as O,P as q}from"./index-JMWMnGGt.js";import{A as V}from"./at-sign-vqoOA4VZ.js";import{R as G,U as K}from"./user-round-check-caJYm0bB.js";import{R as Q}from"./reply-C4V0xZ2U.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",c=l==="sm"?13:20,o=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mt-0.5 -mr-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:c,strokeWidth:o}),s="bg-blue-600";break;case"like":r=t.jsx(A,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:o}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mr-px mb-px",color:n,size:c,strokeWidth:o}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:c,strokeWidth:o}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:c,strokeWidth:o}),s="bg-orange-500";break}return t.jsx("div",{className:`flex ${l==="sm"?"size-5":"size-9"} items-center justify-center rounded-full ${s} ${i&&i}`,children:r})},Z=u.createContext(void 0),h=({isGrouped:a,centerAlign:l,children:i,onClick:r,url:s,className:n})=>t.jsx(Z.Provider,{value:{onClick:r,url:s},children:t.jsx("div",{className:`group relative -mx-4 -my-px ${a?"grid":"flex"} ${l?"items-center":"items-start"} break-anywhere cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left hover:bg-gray-75 ${n}`,role:"button",onClick:r,children:i})}),J=({size:a="lg",type:l})=>t.jsx("div",{className:"col-start-1 row-start-1",children:t.jsx(I,{notificationType:l,size:a})}),X=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-1 flex gap-2",children:a}),Y=({children:a})=>t.jsx("div",{className:"col-start-2 row-start-2 -mt-0.5 grow overflow-hidden",children:a});h.Icon=J;h.Avatars=X;h.Content=Y;const ee=()=>t.jsx("div",{className:"h-px w-full bg-gray-150 dark:bg-gray-950"});function te(a){const r=new Date(a).getTime();return(Math.floor(r/864e5)*864e5).toString()}function se(a){const l={};let i=null,r=0;return a.forEach(s=>{s.type!==i&&(r+=1,i=s.type);let n="";const c=`_${te(s.createdAt)}`,o=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${c}${o}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${c}${o}`);break;case"follow":n=`follow_${c}${o}`;break;case"mention":n=`mention_${s.id}`;break}l[n]||(l[n]={id:s.id,type:s.type,actors:[],post:s.post,inReplyTo:s.inReplyTo,createdAt:s.createdAt}),l[n].actors.find(f=>f.id===s.actor.id)||l[n].actors.push(s.actor)}),Object.values(l)}const ae=({group:a})=>{const[l,...i]=a.actors,r=i.length>0,s="cursor-pointer font-semibold hover:underline text-black dark:text-white",n=g(),c=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:o=>{o?.stopPropagation(),v(l.handle,n)},children:l.name})}),r&&` and ${i.length} ${i.length>1?"others":"other"}`]});switch(a.type){case"follow":return t.jsxs(t.Fragment,{children:[c," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[c," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[c," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return c;break;case"mention":return c}return t.jsx(t.Fragment,{})},ne=({content:a,className:l,stripTags:i=[]})=>{const r=j.useRef(null),s=g();return j.useEffect(()=>{const n=r.current;if(!n)return;const c=o=>{const y=o.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(o.preventDefault(),o.stopPropagation(),v(x,s))}};return n.addEventListener("click",c),()=>{n.removeEventListener("click",c)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},ce=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:c,error:o,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=E("index"),k=c?.pages.flatMap(e=>se(e.notifications))??Array(10).fill({actors:[{}]}),p=j.useRef(null),N=j.useRef(null);j.useEffect(()=>(p.current&&p.current.disconnect(),p.current=new IntersectionObserver(e=>{e[0].isIntersecting&&y&&!x&&f()}),N.current&&p.current.observe(N.current),()=>{p.current&&p.current.disconnect()}),[y,x,f]);const R=(e,d)=>{switch(e.type){case"like":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"reply":e.post&&e.inReplyTo&&i(`/notes/${encodeURIComponent(e.post.id)}`);break;case"repost":e.post&&i(`/${e.post.type==="article"?"reader":"notes"}/${encodeURIComponent(e.post.id)}`);break;case"follow":e.actors.length>1?r(e.id||`${e.type}_${d}`):v(e.actors[0].handle,i);break;case"mention":e.post&&i(`/notes/${encodeURIComponent(e.post.id)}`);break}};return o&&T(o)?t.jsx(z,{errorCode:o.code,statusCode:o.statusCode}):t.jsx(S,{children:t.jsxs("div",{className:"z-0 flex w-full flex-col items-center",children:[b===!1&&k.length===0&&t.jsxs(M,{children:[t.jsx(P,{children:t.jsx(U,{})}),"Quiet for now, but not for long! When someone likes, boosts, or replies to you, you'll find it here."]}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-8 flex w-full max-w-[620px] flex-col max-md:mt-5",children:k.map((e,d)=>t.jsxs(u.Fragment,{children:[t.jsxs(h,{centerAlign:e.actors.length<2&&e.type==="follow",className:"hover:bg-gray-75 dark:hover:bg-gray-950",isGrouped:e.actors.length>1,onClick:()=>R(e,d),children:[b?t.jsx(w,{className:"rounded-full",containerClassName:"flex h-10 w-10"}):e.actors.length>1?t.jsx(h.Icon,{type:e.type}):t.jsxs("div",{className:"relative",children:[t.jsx($,{author:{icon:{url:e.actors[0].avatarUrl||""},name:e.actors[0].name,handle:e.actors[0].handle},size:"notification"},e.actors[0].id),t.jsx(I,{className:"absolute -right-1 -bottom-1 z-10 border-2 border-white dark:border-black",notificationType:e.type,size:"sm"})]}),e.actors.length>1&&t.jsx(h.Avatars,{children:t.jsxs("div",{className:"flex w-full flex-col",children:[t.jsxs("div",{className:"relative flex items-center pl-2",children:[!a[e.id||`${e.type}_${d}`]&&e.actors.slice(0,n).map(m=>t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},className:"-ml-2 bg-[#F3F3F3]! outline outline-2 outline-white group-hover:bg-[#EDEEF0]! group-hover:outline-gray-75 dark:outline-black group-hover:dark:outline-gray-950",size:"notification"},m.id)),e.actors.length>n&&!a[e.id||`${e.type}_${d}`]&&t.jsx("div",{className:"absolute right-[28px] z-10 flex size-9 items-center justify-center rounded-full bg-black/50 text-base font-semibold tracking-tightest text-white",children:`+${e.actors.length-n}`}),e.actors.length>1&&t.jsxs(B,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${a[e.id||`${e.type}_${d}`]?"ml-[-20px]":"ml-0 w-[28px]"}`,variant:"ghost",onClick:m=>{m?.stopPropagation(),r(e.id||`${e.type}_${d}`)},children:[t.jsx(L,{className:`${a[e.id||`${e.type}_${d}`]?"rotate-180":""}`,size:20,strokeWidth:1.5}),a[e.id||`${e.type}_${d}`]?"Hide":t.jsx("span",{className:"sr-only",children:"Show all"})]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${a[e.id||`${e.type}_${d}`]?"mb-2 max-h-[1384px] opacity-100":"max-h-0 opacity-0"}`,children:a[e.id||`${e.type}_${d}`]&&e.actors.length>1&&t.jsx("div",{className:"flex flex-col gap-2 pt-2",children:e.actors.map(m=>t.jsxs("div",{className:"group/item break-anywhere flex items-center justify-between gap-4",onClick:F=>{F?.stopPropagation(),v(m.handle,i)},children:[t.jsxs("div",{className:"flex min-w-0 items-center",children:[t.jsx($,{author:{icon:{url:m.avatarUrl||""},name:m.name,handle:m.handle},size:"xs"}),t.jsx("span",{className:"ml-2 line-clamp-1 text-base font-semibold group-hover/item:underline dark:text-white",children:m.name}),t.jsx("span",{className:"ml-1 line-clamp-1 text-base text-gray-700 dark:text-gray-600",children:m.handle})]}),e.type==="follow"&&!m.followedByMe&&t.jsx(C,{following:!1,handle:m.handle,variant:"link"})]},m.id))})})]})}),t.jsxs(h.Content,{children:[t.jsx("div",{children:b?t.jsxs(t.Fragment,{children:[t.jsx(w,{}),t.jsx(w,{className:"w-full max-w-60"})]}):t.jsxs("div",{className:"flex justify-between",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate",children:t.jsx(ae,{group:e})}),e.actors.length<2&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mt-px text-[8px] text-gray-700 dark:text-gray-600",children:"•"}),t.jsx("span",{className:"mt-0.5 text-sm text-gray-700 dark:text-gray-600",children:W(e,!1)})]})]}),e.actors.length===1&&(e.type==="follow"||e.type==="reply"||e.type==="mention")&&!e.actors[0].followedByMe&&t.jsx(C,{following:!1,handle:e.actors[0].handle,variant:"link"})]})}),(e.type==="reply"&&e.inReplyTo||e.type==="mention"||e.type==="like"&&!e.post?.name&&e.post?.content||e.type==="repost"&&!e.post?.name&&e.post?.content)&&(e.type!=="reply"&&e.type!=="mention"?t.jsxs("div",{className:"ap-note-content mt-0.5 line-clamp-1 text-sm text-pretty text-gray-700 dark:text-gray-600",children:[e.post?.type==="article"&&e.post?.title&&t.jsxs(t.Fragment,{children:[e.post.title," — "]}),t.jsx("span",{dangerouslySetInnerHTML:{__html:_(e.post?.content||"")}})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"mt-2.5 rounded-md bg-gray-100 px-5 py-[14px] group-hover:bg-gray-200 dark:bg-gray-925/30 group-hover:dark:bg-black/40",children:[t.jsx(ne,{className:"ap-note-content text-pretty",content:e.post?.content||"",stripTags:["a"]}),e.post&&e.post.attachments&&e.post.attachments.length>0&&t.jsx("div",{className:"notification-attachments mb-1 [&_.attachment-gallery]:flex [&_.attachment-gallery]:flex-wrap [&_img]:aspect-square [&_img]:max-w-[calc(20%-6.4px)]",children:D({...e.post,type:"Note",attachment:e.post.attachments})})]})})),(e.type==="reply"&&e.post||e.type==="mention")&&t.jsx("div",{className:"mt-1.5",children:t.jsx(H,{actor:{...e.actors[0],icon:{url:e.actors[0].avatarUrl||""},id:e.actors[0].url,preferredUsername:e.actors[0].handle?.replace(/^@([^@]+)@.*$/,"$1")||"unknown"},buttonClassName:"hover:bg-gray-200",commentCount:e.post.replyCount||0,layout:"notification",likeCount:e.post.likeCount||0,object:{...e.post,liked:e.post.likedByMe,reposted:e.post.repostedByMe},repostCount:e.post.repostCount||0,onLikeClick:s})})]})]}),d<k.length-1&&t.jsx("div",{className:"pl-[52px]",children:t.jsx(ee,{})})]},e.id||`${e.type}_${d}`))}),t.jsx("div",{ref:N,className:"h-1"}),x&&t.jsx("div",{className:"-mt-4 mb-8 flex flex-col items-center justify-center gap-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{ce as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{t as I,aD as ye,r as O,aX as De,j as e,B as Ce,b$ as Te,c0 as je,bW as Ke,am as T,cD as Z,aY as st,cE as V,b5 as nt,aU as it,b7 as ot,b9 as de,c$ as z,aZ as lt,ai as re,bY as ct,aj as H,S as Ge,cC as dt,bO as mt,bP as ut,bQ as pt,bR as ft,bS as ht,bT as xt,ak as B,bc as Pe}from"./index-ZuWSQ3L6.js";import{s as oe,g as W,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-CcyaLPwj.js";import{E as ce}from"./empty-indicator-Bf4Dqk72.js";import{A as St,a as At}from"./wallet-cards-zHR_y6Sp.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-Ch6dYUac.js";import{T as $e,a as Ve,K as me,d as Y,e as Tt,b as ue}from"./tabs-mR5oJGm5.js";import{a as _t,c as kt}from"./audience-CC5U4UxI.js";import{S as te,B as Ot}from"./sort-button-BOLTpImz.js";import{S as Pt,C as Q,g as Mt,b as Rt}from"./content-helpers-CQXipRWa.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as U}from"./table-B4zlzEDP.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-DWpHtRym.js";import{u as Gt}from"./referrers-J4vexZCf.js";import{C as be,a as _e,b as ke,h as Oe,c as ge,j as $t}from"./pagemenu-BqoDENpI.js";import{h as ne,F as Vt,T as Yt,b as fe,r as Ae,H as ae,L as ie,o as X,c as zt,S as Ut,A as Wt,I as Ht,i as Me,d as qt,J,u as Ue,e as Qt,K as Xt,G as Zt,m as he,l as Jt,n as ea,M as ta,N as pe,O as Re,g as aa,s as ra,C as We,a as He,v as sa,B as Ee}from"./chart-BCQFlmhJ.js";import{S as qe,a as Qe,b as Xe,c as Ze,f as we}from"./select-Bd1zcqox.js";import{u as na}from"./tiers-CQE0v797.js";import{P as ia,a as oa}from"./PolarAngleAxis-7TlIQL3R.js";import{k as la,l as ca,i as da}from"./lucide-react-DZiAu6PQ.js";import{u as ma}from"./use-growth-stats-BGymNu5O.js";import"./loader-circle-CF5G2g_Z.js";import"./user-plus-DMl69yKl.js";import"./sprout-Bf-wc2Vo.js";import"./_baseAssignValue-DJsCJz6y.js";import"./index-DIO8ceib.js";import"./a-large-small-BnBpzYwl.js";import"./upload-BTxT4v2z.js";import"./at-sign-DC4NtDDM.js";import"./copy-B-MxRWPu.js";import"./message-square-text-DESy3kSk.js";import"./hash-BGd7HEsT.js";import"./inbox-CFzKvW3h.js";import"./minus-DVNwSjD6.js";import"./tags-CsgMtkFL.js";import"./square-Cj_bJ0HZ.js";import"./user-round-check-CVuZXUPz.js";import"./repeat-BxOK9zhN.js";import"./reply-BoTN-eE0.js";import"./trash-BFSLkv0z.js";var xe;function se(r){"@babel/helpers - typeof";return se=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},se(r)}function ee(){return ee=Object.assign?Object.assign.bind():function(r){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},ee.apply(this,arguments)}function Be(r,a){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);a&&(t=t.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,t)}return n}function R(r){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function ua(r,a){if(!(r instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(r,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,et(t.key),t)}}function pa(r,a,n){return a&&Ie(r.prototype,a),n&&Ie(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function fa(r,a,n){return a=ve(a),ha(r,Je()?Reflect.construct(a,n||[],ve(r).constructor):a.apply(r,n))}function ha(r,a){if(a&&(se(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(r)}function xa(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Je(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Je=function(){return!!r})()}function ve(r){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(r)}function ba(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(a&&a.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),a&&Ne(r,a)}function Ne(r,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},Ne(r,a)}function L(r,a,n){return a=et(a),a in r?Object.defineProperty(r,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[a]=n,r}function et(r){var a=ga(r,"string");return se(a)=="symbol"?a:a+""}function ga(r,a){if(se(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,a);if(se(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var G=(function(r){function a(n){var t;return ua(this,a),t=fa(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Xt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var s=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(s)&&s()}),L(t,"handleAnimationStart",function(){var s=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(s)&&s()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,r),pa(a,[{key:"isActiveIndex",value:function(t){var s=this.props.activeIndex;return Array.isArray(s)?s.indexOf(t)!==-1:t===s}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,h=l.labelLine,g=l.dataKey,c=l.valueKey,o=fe(this.props,!1),j=fe(i,!1),A=fe(h,!1),x=i&&i.offsetRadius||20,w=t.map(function(u,b){var N=(u.startAngle+u.endAngle)/2,p=Ae(u.cx,u.cy,u.outerRadius+x,N),f=R(R(R(R({},o),u),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,u.cx)},p),m=R(R(R(R({},o),u),{},{fill:"none",stroke:u.fill},A),{},{index:b,points:[Ae(u.cx,u.cy,u.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(u.startAngle,"-").concat(u.endAngle,"-").concat(u.midAngle,"-").concat(b)},h&&a.renderLabelLineItem(h,m,"line"),a.renderLabelItem(i,f,X(u,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var s=this,l=this.props,i=l.activeShape,h=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=s.isActiveIndex(o),A=g&&s.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:h?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!s.sectorRefs.includes(b)&&s.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},zt(s.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,s=this.props,l=s.sectors,i=s.isAnimationActive,h=s.animationBegin,g=s.animationDuration,c=s.animationEasing,o=s.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:h,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var u=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(f,m){var v=A&&A[m],C=m>0?Ht(f,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,f.endAngle-f.startAngle),d=R(R({},f),{},{startAngle:p+C,endAngle:p+S(u)+C});b.push(d),p=d.endAngle}else{var k=f.endAngle,y=f.startAngle,D=Me(0,k-y),P=D(u),M=R(R({},f),{},{startAngle:p+C,endAngle:p+P+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var s=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[i].focus(),s.setState({sectorToFocus:i});break}case"ArrowRight":{var h=--s.state.sectorToFocus<0?s.sectorRefs.length-1:s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[h].focus(),s.setState({sectorToFocus:h});break}case"Escape":{s.sectorRefs[s.state.sectorToFocus].blur(),s.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,s=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&s&&s.length&&(!i||!qt(i,s))?this.renderSectorsWithAnimation():this.renderSectorsStatically(s)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,s=this.props,l=s.hide,i=s.sectors,h=s.className,g=s.label,c=s.cx,o=s.cy,j=s.innerRadius,A=s.outerRadius,x=s.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!J(c)||!J(o)||!J(j)||!J(A))return null;var u=ye("recharts-pie",h);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:u,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),Ue.renderCallByParent(this.props,null,!1),(!x||w)&&Qt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,s){return s.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==s.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:s.curSectors,isAnimationFinished:!0}:t.sectors!==s.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,s){return t>s?"start":t<s?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,s,l){if(I.isValidElement(t))return I.cloneElement(t,s);if(ne(t))return t(s);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Vt,ee({},s,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,s,l){if(I.isValidElement(t))return I.cloneElement(t,s);var i=l;if(ne(t)&&(i=t(s),I.isValidElement(i)))return i;var h=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(Yt,ee({},s,{alignmentBaseline:"middle",className:h}),i)}}])})(O.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Zt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(r,a){var n=he(a-r),t=Math.min(Math.abs(a-r),360);return n*t});L(G,"getRealPieData",function(r){var a=r.data,n=r.children,t=fe(r,!1),s=Jt(n,ea);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),s&&s[i]&&s[i].props)}):s&&s.length?s.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(r,a){var n=a.top,t=a.left,s=a.width,l=a.height,i=ta(s,l),h=t+pe(r.cx,s,s/2),g=n+pe(r.cy,l,l/2),c=pe(r.innerRadius,i,0),o=pe(r.outerRadius,i,i*.8),j=r.maxRadius||Math.sqrt(s*s+l*l)/2;return{cx:h,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(r){var a=r.item,n=r.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,s=xe.getRealPieData(t);if(!s||!s.length)return null;var l=t.cornerRadius,i=t.startAngle,h=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),u=xe.parseDeltaAngle(i,h),b=Math.abs(u),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
1
|
+
import{t as I,aD as ye,r as O,aS as De,j as e,B as Ce,bX as Te,bY as je,bR as Ke,am as T,cD as Q,aT as st,cE as $,b0 as nt,aP as it,b2 as ot,b4 as de,d0 as z,aU as lt,ai as re,bU as ct,aj as W,S as Ge,cC as dt,bJ as mt,bK as ut,bL as pt,bM as ft,bN as ht,bO as xt,ak as B,b7 as Pe}from"./index-JMWMnGGt.js";import{s as oe,g as H,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-Bx3oDAIW.js";import{E as ce}from"./empty-indicator-DjmACVr2.js";import{A as St,a as At}from"./wallet-cards-DBM65lA_.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-xjwu2HZo.js";import{T as Ve,a as $e,K as me,d as Y,e as Tt,b as ue}from"./tabs-DFJzY5np.js";import{a as _t,c as kt}from"./audience-CFjVlFTu.js";import{S as te,B as Ot}from"./sort-button-Bn325H3y.js";import{S as Pt,C as X,g as Mt,b as Rt}from"./content-helpers-Cr_DHEOl.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as U}from"./table-CbN_vbUx.js";import{g as Se}from"./currency-fEUUCkj0.js";import{g as Bt}from"./source-utils-B1S3ZHA2.js";import{a as It,b as Ft,u as Lt,k as Kt}from"./stats-G4Ge9ETb.js";import{u as Gt}from"./referrers-6As_USul.js";import{C as be,a as _e,b as ke,h as Oe,c as ge,j as Vt}from"./pagemenu-Dq744OgH.js";import{h as ne,F as $t,T as Yt,b as fe,r as Ae,H as ae,L as ie,o as J,c as zt,S as Ut,A as Ht,I as Wt,i as Me,d as qt,J as Z,u as Ue,e as Xt,K as Jt,G as Qt,m as he,l as Zt,n as ea,M as ta,N as pe,O as Re,g as aa,s as ra,C as He,a as We,v as sa,B as Ee}from"./chart-Bs2L1q8g.js";import{S as qe,a as Xe,b as Je,c as Qe,f as we}from"./select-Dt579MbD.js";import{u as na}from"./tiers-B7qV_8mO.js";import{P as ia,a as oa}from"./PolarAngleAxis-BNo3yZOE.js";import{k as la,l as ca,i as da}from"./lucide-react-BfVLf4Hw.js";import{u as ma}from"./use-growth-stats-DNVioFUq.js";import"./loader-circle-CGDGFypO.js";import"./user-plus-B0tpOnLM.js";import"./sprout-C9DbfYGe.js";import"./_baseAssignValue-DwWJd_kU.js";import"./index-6Ag8SK_E.js";import"./a-large-small-DzN0AB7t.js";import"./upload-Dz-DI9rQ.js";import"./at-sign-vqoOA4VZ.js";import"./copy-w3c9zkaZ.js";import"./message-square-text-BDJyLbG2.js";import"./hash-Bowe71Lt.js";import"./inbox-DS4qMjUb.js";import"./minus-BM0xhFIQ.js";import"./tags-Ddg8oG2Y.js";import"./square-CWrI0H4v.js";import"./user-round-check-caJYm0bB.js";import"./repeat-D-Ki-Cg5.js";import"./reply-C4V0xZ2U.js";import"./trash--VS50LgS.js";var xe;function se(r){"@babel/helpers - typeof";return se=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},se(r)}function ee(){return ee=Object.assign?Object.assign.bind():function(r){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=n[t])}return r},ee.apply(this,arguments)}function Be(r,a){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);a&&(t=t.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),n.push.apply(n,t)}return n}function R(r){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?Be(Object(n),!0).forEach(function(t){L(r,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(n,t))})}return r}function ua(r,a){if(!(r instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(r,a){for(var n=0;n<a.length;n++){var t=a[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,et(t.key),t)}}function pa(r,a,n){return a&&Ie(r.prototype,a),n&&Ie(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r}function fa(r,a,n){return a=ve(a),ha(r,Ze()?Reflect.construct(a,n||[],ve(r).constructor):a.apply(r,n))}function ha(r,a){if(a&&(se(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(r)}function xa(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Ze(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!r})()}function ve(r){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(r)}function ba(r,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(a&&a.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),a&&Ne(r,a)}function Ne(r,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},Ne(r,a)}function L(r,a,n){return a=et(a),a in r?Object.defineProperty(r,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[a]=n,r}function et(r){var a=ga(r,"string");return se(a)=="symbol"?a:a+""}function ga(r,a){if(se(r)!="object"||!r)return r;var n=r[Symbol.toPrimitive];if(n!==void 0){var t=n.call(r,a);if(se(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}var G=(function(r){function a(n){var t;return ua(this,a),t=fa(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var s=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(s)&&s()}),L(t,"handleAnimationStart",function(){var s=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(s)&&s()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,r),pa(a,[{key:"isActiveIndex",value:function(t){var s=this.props.activeIndex;return Array.isArray(s)?s.indexOf(t)!==-1:t===s}},{key:"hasActiveIndex",value:function(){var t=this.props.activeIndex;return Array.isArray(t)?t.length!==0:t||t===0}},{key:"renderLabels",value:function(t){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,h=l.labelLine,g=l.dataKey,c=l.valueKey,o=fe(this.props,!1),j=fe(i,!1),A=fe(h,!1),x=i&&i.offsetRadius||20,w=t.map(function(u,b){var N=(u.startAngle+u.endAngle)/2,p=Ae(u.cx,u.cy,u.outerRadius+x,N),f=R(R(R(R({},o),u),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,u.cx)},p),m=R(R(R(R({},o),u),{},{fill:"none",stroke:u.fill},A),{},{index:b,points:[Ae(u.cx,u.cy,u.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(u.startAngle,"-").concat(u.endAngle,"-").concat(u.midAngle,"-").concat(b)},h&&a.renderLabelLineItem(h,m,"line"),a.renderLabelItem(i,f,J(u,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var s=this,l=this.props,i=l.activeShape,h=l.blendStroke,g=l.inactiveShape;return t.map(function(c,o){if(c?.startAngle===0&&c?.endAngle===0&&t.length!==1)return null;var j=s.isActiveIndex(o),A=g&&s.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:h?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!s.sectorRefs.includes(b)&&s.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},zt(s.props,c,o),{key:"sector-".concat(c?.startAngle,"-").concat(c?.endAngle,"-").concat(c.midAngle,"-").concat(o)}),I.createElement(Ut,ee({option:x,isActive:j,shapeType:"sector"},w)))})}},{key:"renderSectorsWithAnimation",value:function(){var t=this,s=this.props,l=s.sectors,i=s.isAnimationActive,h=s.animationBegin,g=s.animationDuration,c=s.animationEasing,o=s.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Ht,{begin:h,duration:g,isActive:i,easing:c,from:{t:0},to:{t:1},key:"pie-".concat(o,"-").concat(x),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(w){var u=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(f,m){var v=A&&A[m],C=m>0?Wt(f,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,f.endAngle-f.startAngle),d=R(R({},f),{},{startAngle:p+C,endAngle:p+S(u)+C});b.push(d),p=d.endAngle}else{var k=f.endAngle,y=f.startAngle,D=Me(0,k-y),P=D(u),M=R(R({},f),{},{startAngle:p+C,endAngle:p+P+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var s=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[i].focus(),s.setState({sectorToFocus:i});break}case"ArrowRight":{var h=--s.state.sectorToFocus<0?s.sectorRefs.length-1:s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[h].focus(),s.setState({sectorToFocus:h});break}case"Escape":{s.sectorRefs[s.state.sectorToFocus].blur(),s.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,s=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&s&&s.length&&(!i||!qt(i,s))?this.renderSectorsWithAnimation():this.renderSectorsStatically(s)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,s=this.props,l=s.hide,i=s.sectors,h=s.className,g=s.label,c=s.cx,o=s.cy,j=s.innerRadius,A=s.outerRadius,x=s.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var u=ye("recharts-pie",h);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:u,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),Ue.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,s){return s.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==s.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:s.curSectors,isAnimationFinished:!0}:t.sectors!==s.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,s){return t>s?"start":t<s?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,s,l){if(I.isValidElement(t))return I.cloneElement(t,s);if(ne(t))return t(s);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement($t,ee({},s,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,s,l){if(I.isValidElement(t))return I.cloneElement(t,s);var i=l;if(ne(t)&&(i=t(s),I.isValidElement(i)))return i;var h=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(Yt,ee({},s,{alignmentBaseline:"middle",className:h}),i)}}])})(O.PureComponent);xe=G;L(G,"displayName","Pie");L(G,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Qt.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});L(G,"parseDeltaAngle",function(r,a){var n=he(a-r),t=Math.min(Math.abs(a-r),360);return n*t});L(G,"getRealPieData",function(r){var a=r.data,n=r.children,t=fe(r,!1),s=Zt(n,ea);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),s&&s[i]&&s[i].props)}):s&&s.length?s.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(r,a){var n=a.top,t=a.left,s=a.width,l=a.height,i=ta(s,l),h=t+pe(r.cx,s,s/2),g=n+pe(r.cy,l,l/2),c=pe(r.innerRadius,i,0),o=pe(r.outerRadius,i,i*.8),j=r.maxRadius||Math.sqrt(s*s+l*l)/2;return{cx:h,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(r){var a=r.item,n=r.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,s=xe.getRealPieData(t);if(!s||!s.length)return null;var l=t.cornerRadius,i=t.startAngle,h=t.endAngle,g=t.paddingAngle,c=t.dataKey,o=t.nameKey,j=t.valueKey,A=t.tooltipType,x=Math.abs(t.minAngle),w=xe.parseCoordinateOfPie(t,n),u=xe.parseDeltaAngle(i,h),b=Math.abs(u),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
2
2
|
the props "valueKey" will be deprecated in 1.1.0`),N="value"):ae(c)&&(Re(!1,`Use "dataKey" to specify the value of pie,
|
|
3
|
-
the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=s.filter(function(d){return X(d,N,0)!==0}).length,f=(b>=360?p:p-1)*g,m=b-p*x-f,v=s.reduce(function(d,k){var y=X(k,N,0);return d+(J(y)?y:0)},0),C;if(v>0){var S;C=s.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),P=(J(y)?y:0)/v,M;k?M=S.endAngle+he(u)*g*(y!==0?1:0):M=i;var _=M+he(u)*((y!==0?x:0)+P*m),E=(M+_)/2,$=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],rt=Ae(w.cx,w.cy,$,E);return S=R(R(R({percent:P,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:$,tooltipPosition:rt},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:he(u)*g}),S})}return R(R({},w),{},{sectors:C,data:s})});var va=aa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:r})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:r,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=r=>r==="total-members"||r==="free-members"||r==="paid-members"||r==="mrr",ya=({active:r,payload:a,range:n,color:t,showBreakdown:s})=>{if(!r||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:h,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"var(--chart-purple)"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:h})]})]})]})]})},Sa=({chartData:r,totals:a,initialTab:n,currencySymbol:t,isLoading:s,onTabChange:l})=>{const i=ja(n)?n:"total-members",[h,g]=O.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();O.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:u,paidMembers:b,mrr:N,percentChanges:p,directions:f}=a,m=O.useMemo(()=>{if(!r||r.length===0)return[];let S=[],d="value";switch(h){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(r,c,d,"exact");let k=[];switch(h){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:Z(y.mrr),formattedValue:`${t}${T(Z(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[h,r,c,t]),v={"total-members":{color:"var(--chart-darkblue)"},"free-members":{color:"var(--chart-blue)"},"paid-members":{color:"var(--chart-purple)"},mrr:{color:"var(--chart-teal)"}};return s?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(st,{})}):e.jsxs($e,{defaultValue:i,variant:"kpis",children:[e.jsxs(Ve,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:visible! lg:grid!":"grid grid-cols-4"}`,children:[e.jsx(me,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"var(--chart-darkblue)",diffDirection:c===V.allTime.value?"hidden":f.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(me,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"var(--chart-blue)",diffDirection:c===V.allTime.value?"hidden":f.free,diffValue:p.free,label:"Free members",value:T(u)})}),e.jsx(me,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"var(--chart-purple)",diffDirection:c===V.allTime.value?"hidden":f.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(me,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"var(--chart-teal)",diffDirection:c===V.allTime.value?"hidden":f.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(Z(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[h==="total-members"&&e.jsx(Y,{color:"var(--chart-darkblue)",diffDirection:c===V.allTime.value?"hidden":f.total,diffValue:p.total,label:"Total members",value:T(w)}),h==="free-members"&&e.jsx(Y,{color:"var(--chart-blue)",diffDirection:c===V.allTime.value?"hidden":f.free,diffValue:p.free,label:"Free members",value:T(u)}),h==="paid-members"&&e.jsx(Y,{color:"var(--chart-purple)",diffDirection:c===V.allTime.value?"hidden":f.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),h==="mrr"&&e.jsx(Y,{color:"var(--chart-teal)",diffDirection:c===V.allTime.value?"hidden":f.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(Z(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[h].color,data:m,dataFormatter:h==="mrr"?S=>`${t}${T(S)}`:T,id:h,range:c,tooltipContent:h==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(r,a="signups desc",n=50)=>{const{startDate:t,endDate:s,timezone:l}=re(r),i={date_from:H(t),date_to:H(s),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:r,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const s=n?r.slice(0,n):r,{appSettings:l}=je();return e.jsx(le,{children:s.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(Z(i.mrr))]})]})]},i.source))})},wa=({range:r,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:s})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:h}=je(),[g,c]=O.useState("free_members desc"),o=t||g,j=s||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(r,A,a),u=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,u),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,u]),f="Top sources",m=`Where did your growth come from ${W(r)}`;return h?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:h?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${W(r)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:bg-transparent!",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:bg-transparent!",colSpan:4,children:e.jsxs(mt,{children:[e.jsx(ut,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ft,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ht,{children:f}),e.jsx(xt,{children:m})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(U,{children:"Source"}),e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),h?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:h?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:r,payload:a})=>{if(r&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:r,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:H(re(a).startDate)}}),{data:{tiers:s=[]}={}}=na(),[l,i]=O.useState("billing-period"),{startDate:h,endDate:g}=O.useMemo(()=>re(a),[a]),c=O.useMemo(()=>H(h),[h]),o=O.useMemo(()=>H(g),[g]),j=O.useMemo(()=>s.filter(m=>m.type==="paid"&&m.active).map(m=>({id:m.id,name:m.name})),[s]),A=O.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const m=t.stats,v=B(c),C=B(o),S=m.filter(P=>{const M=B(P.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((P,M)=>new Date(P.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=O.useMemo(()=>{if(!n?.stats)return[];const m=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(m)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,P="url(#gradientPurple)",M="var(--chart-purple)";return d==="month"?(D="Monthly",P="url(#gradientPurple)",M="var(--chart-purple)"):d==="year"?(D="Annual",P="url(#gradientTeal)",M="var(--chart-teal)"):d==="complimentary"&&(D="Complimentary",P="url(#gradientBlue)",M="var(--chart-blue)"),{id:`cadence-${y}`,name:D,count:k,fill:P,color:M}})},[n,c,o,A]),w=O.useMemo(()=>{if(!n?.stats||j.length===0)return[];const m=B(c),v=B(o),C=n.stats.filter(D=>{const P=B(D.date);return P.isSameOrAfter(m)&&P.isSameOrBefore(v)}).reduce((D,P)=>{const M=P.tier;return D[M]||(D[M]=0),D[M]+=P.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"var(--chart-purple)"},{gradient:"url(#gradientTeal)",solid:"var(--chart-teal)"},{gradient:"url(#gradientBlue)",solid:"var(--chart-blue)"},{gradient:"url(#gradientRose)",solid:"var(--chart-rose)"},{gradient:"url(#gradientOrange)",solid:"var(--chart-orange)"},{gradient:"url(#gradientGreen)",solid:"var(--chart-green)"},{gradient:"url(#gradientAmber)",solid:"var(--chart-amber)"},{gradient:"url(#gradientYellow)",solid:"var(--chart-yellow)"},{gradient:"url(#gradientDarkblue)",solid:"var(--chart-darkblue)"},{gradient:"url(#gradientGray)",solid:"var(--chart-darkgray)"}];return[...j.map(D=>{const P=C[D.id]||0;return{id:D.id,name:D.name,count:P}})].sort((D,P)=>P.count-D.count).map((D,P)=>{const M=P%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),u=l==="billing-period"?x:w,b=O.useMemo(()=>u.reduce((m,v)=>m+v.count,0),[u]),N=O.useMemo(()=>{const m={count:{label:"Subscriptions"}};return u.forEach(v=>{m[v.id]={label:v.name,color:v.color}}),m},[u]),p=O.useMemo(()=>b===0?[]:u.map(m=>({label:m.name,count:m.count,percentage:m.count/b*100,color:m.color})),[u,b]);if(r||!n?.stats)return null;const f=u.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Oe,{children:["New paid subscriptions ",W(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:m=>i(m),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Ze,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:f?e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-purple)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-purple)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-teal)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-teal)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-rose)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-rose)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-blue)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-blue)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-orange)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-orange)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-green)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-green)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-amber)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-amber)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-yellow)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-yellow)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-darkblue)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-darkblue)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-darkgray)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-darkgray)",stopOpacity:.6})]})]}),e.jsx(He,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:u,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(Ue,{content:({viewBox:m})=>{if(m&&"cx"in m&&"cy"in m)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:m.cx,y:m.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:m.cx,y:m.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:m.cx,y:(m.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(m=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:m.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:m.label,children:m.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(m.percentage)||0),"%"]})]},m.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${W(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(r,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=r.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:s}=re(a),l=B(s).diff(B(t),"days"),i=bt(a,l,"sum",n),h=new Map(r.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(s).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(s).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(s);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=r=>{if(r===-1){const{startDate:a,endDate:n}=re(r);return B(n).diff(B(a),"days")}return r},Ta=r=>{const a=at(r);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=r=>{const a=at(r);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:r,memberData:a,range:n,isLoading:t})=>{const[s,l]=O.useState(()=>Le(n));O.useEffect(()=>{l(Le(n))},[n]);const i=O.useMemo(()=>Ta(n),[n]),h=O.useMemo(()=>{switch(s){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[s]),g=O.useMemo(()=>{if(r&&r.length>0){if(n===1){const f=B().format("YYYY-MM-DD"),m=r.find(v=>v.date===f);return[{date:z(f,n),rawDate:f,new:m?.signups||0,cancelled:-(m?.cancellations||0)}]}const x=oe(r,n,"signups","sum",h),w=oe(r,n,"cancellations","sum",h),u=new Map(w.map(f=>[f.date,f])),b=x.map(f=>({date:f.date,signups:f.signups||0,cancellations:u.get(f.date)?.cancellations||0})),N=new Set(b.map(f=>f.date));return w.forEach(f=>{N.has(f.date)||b.push({date:f.date,signups:0,cancellations:f.cancellations||0})}),b.sort((f,m)=>new Date(f.date).getTime()-new Date(m.date).getTime()),Ca(b,n,h).map(f=>{let m=n;return s==="weekly"&&n<91?m=91:s==="monthly"&&n<365&&(m=365),{date:z(f.date,m),rawDate:f.date,new:f.signups||0,cancelled:-(f.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),f=a.find(m=>m.date===p);return[{date:z(p,n),rawDate:p,new:f?.paid_subscribed||0,cancelled:-(f?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",h),w=oe(a,n,"paid_canceled","sum",h),u=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:u.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,f)=>new Date(p.date).getTime()-new Date(f.date).getTime()),b.map(p=>{let f=n;return s==="weekly"&&n<91?f=91:s==="monthly"&&n<365&&(f=365),{date:z(p.date,f),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,r,n,h,s]),c={new:{label:"New",color:"var(--chart-teal)"},cancelled:{label:"Cancelled",color:"var(--chart-rose)"}},o=O.useMemo(()=>{const x=g.reduce((u,b)=>u+b.new,0),w=g.reduce((u,b)=>u+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Oe,{children:["New and cancelled paid subscriptions ",W(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:s,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Ze,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(We,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(Ot,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"var(--border)",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(He,{content:e.jsx(sa,{className:"min-w-[120px]! px-3 py-2",formatter:(x,w,u,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const f=Number(u?.payload?.new||0),m=Number(u?.payload?.cancelled||0),v=f+m,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=u?.payload?.date;return u?.payload?.rawDate&&(s==="monthly"?S=z(u.payload.rawDate,366):s==="weekly"?S=z(u.payload.rawDate,91):S=z(u.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${W(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(r,a,n)=>{const t=r??30,s=a??"mrr desc",{startDate:l,endDate:i}=O.useMemo(()=>re(t),[t]),h=O.useMemo(()=>{const o={date_from:H(l),date_to:H(i),order:s};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,s,n]),g=Object.fromEntries(Object.entries(h).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},br=()=>{const{range:r,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),s=De(),[l,i]=O.useState("free_members desc"),[h,g]=O.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=O.useState(j);O.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:u,totals:b,currencySymbol:N,subscriptionData:p}=ma(r),{data:f,isLoading:m}=ka(r,l,h),v=O.useMemo(()=>{const k=(f?.stats||[]).reduce((_,E)=>{const $=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!$)return _;if(!_.has($))_.set($,E);else{const q=_.get($);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set($,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),P=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&P>0?E=_.paid_members/P:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[f,l]),C=w,S=w||m;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:u,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:u,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:u,range:r,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:r})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Mt(h)}),e.jsx(Oe,{children:Rt(h,r,W)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pt-0 [&>th]:pb-2",children:[e.jsx(U,{className:"min-w-[320px] pl-0",children:e.jsx($e,{defaultValue:h,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs(Ve,{children:[e.jsx(ue,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(ue,{value:Q.POSTS,children:"Posts"}),e.jsx(ue,{value:Q.PAGES,children:"Pages"}),e.jsx(ue,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(U,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(U,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),h===Q.SOURCES?e.jsx(wa,{limit:20,range:r,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto p-0 text-left leading-tight font-medium whitespace-normal hover:underline!",title:"View post analytics",variant:"link",onClick:kt(d.attribution_url,d.post_id,a.url||"",s,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Pe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Pe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(Z(d.mrr))]})]})]},`${h}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:bg-transparent!",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${W(r)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{br as default};
|
|
3
|
+
the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=s.filter(function(d){return J(d,N,0)!==0}).length,f=(b>=360?p:p-1)*g,m=b-p*x-f,v=s.reduce(function(d,k){var y=J(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=s.map(function(d,k){var y=J(d,N,0),D=J(d,o,k),P=(Z(y)?y:0)/v,M;k?M=S.endAngle+he(u)*g*(y!==0?1:0):M=i;var _=M+he(u)*((y!==0?x:0)+P*m),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],rt=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:P,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:rt},d),w),{},{value:J(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:he(u)*g}),S})}return R(R({},w),{},{sectors:C,data:s})});var va=aa({chartName:"PieChart",GraphicalChild:G,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:ia},{axisType:"radiusAxis",AxisComp:oa}],formatAxisMap:ra,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const tt=({className:r})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:r,description:"Enable member source tracking in settings to see which content drives member growth.",title:"Member sources have been disabled",children:e.jsx(St,{})})},ja=r=>r==="total-members"||r==="free-members"||r==="paid-members"||r==="mrr",ya=({active:r,payload:a,range:n,color:t,showBreakdown:s})=>{if(!r||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:h,label:g,comped:c}=l,o=l.value-(c||0);return e.jsxs("div",{className:"min-w-[200px] rounded-lg border bg-background px-3 py-2 shadow-lg",children:[i&&e.jsx("div",{className:"mb-1 text-sm text-foreground",children:z(i,n||0)}),e.jsxs("div",{className:"flex flex-col gap-1",children:[s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Paid subscriptions"}),e.jsx("div",{className:"font-mono text-xs",children:T(o)})]})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Complimentary"}),e.jsx("div",{className:"font-mono text-xs",children:c!==void 0&&c>0?T(c):"0"})]})}),e.jsx(lt,{})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:t||"var(--chart-purple)"}}),e.jsxs("div",{className:"flex grow items-center justify-between gap-5",children:[g&&e.jsx("div",{className:"text-sm text-muted-foreground",children:g}),e.jsx("div",{className:"font-mono font-medium",children:h})]})]})]})]})},Sa=({chartData:r,totals:a,initialTab:n,currencySymbol:t,isLoading:s,onTabChange:l})=>{const i=ja(n)?n:"total-members",[h,g]=O.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();O.useEffect(()=>{g(i)},[i]);const x=S=>{g(S);const d=new URLSearchParams(A);d.set("tab",S),j(`?${d.toString()}`,{replace:!0}),l&&l(S)},{totalMembers:w,freeMembers:u,paidMembers:b,mrr:N,percentChanges:p,directions:f}=a,m=O.useMemo(()=>{if(!r||r.length===0)return[];let S=[],d="value";switch(h){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(r,c,d,"exact");let k=[];switch(h){case"free-members":k=S.map(y=>({...y,value:y.free,formattedValue:T(y.free),label:"Free members"}));break;case"paid-members":k=S.map(y=>({...y,value:y.paid,formattedValue:T(y.paid),label:"Paid members",comped:y.comped,paid_subscribed:y.paid_subscribed}));break;case"mrr":k=S.map(y=>({...y,value:Q(y.mrr),formattedValue:`${t}${T(Q(y.mrr))}`,label:"MRR"}));break;default:k=S.map(y=>{const D=y.free+y.paid;return{...y,value:D,formattedValue:T(D),label:"Total members"}})}return k},[h,r,c,t]),v={"total-members":{color:"var(--chart-darkblue)"},"free-members":{color:"var(--chart-blue)"},"paid-members":{color:"var(--chart-purple)"},mrr:{color:"var(--chart-teal)"}};return s?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(st,{})}):e.jsxs(Ve,{defaultValue:i,variant:"kpis",children:[e.jsxs($e,{className:`-mx-6 ${o?.paidMembersEnabled?"hidden grid-cols-4 lg:visible! lg:grid!":"grid grid-cols-4"}`,children:[e.jsx(me,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"var(--chart-darkblue)",diffDirection:c===$.allTime.value?"hidden":f.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(me,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"var(--chart-blue)",diffDirection:c===$.allTime.value?"hidden":f.free,diffValue:p.free,label:"Free members",value:T(u)})}),e.jsx(me,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"var(--chart-purple)",diffDirection:c===$.allTime.value?"hidden":f.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(me,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"var(--chart-teal)",diffDirection:c===$.allTime.value?"hidden":f.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(Q(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[h==="total-members"&&e.jsx(Y,{color:"var(--chart-darkblue)",diffDirection:c===$.allTime.value?"hidden":f.total,diffValue:p.total,label:"Total members",value:T(w)}),h==="free-members"&&e.jsx(Y,{color:"var(--chart-blue)",diffDirection:c===$.allTime.value?"hidden":f.free,diffValue:p.free,label:"Free members",value:T(u)}),h==="paid-members"&&e.jsx(Y,{color:"var(--chart-purple)",diffDirection:c===$.allTime.value?"hidden":f.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),h==="mrr"&&e.jsx(Y,{color:"var(--chart-teal)",diffDirection:c===$.allTime.value?"hidden":f.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(Q(N))}`})]})}),e.jsxs(ot,{align:"end",className:"w-56",children:[e.jsx(de,{onClick:()=>x("total-members"),children:"Total members"}),e.jsx(de,{onClick:()=>x("free-members"),children:"Free members"}),e.jsx(de,{onClick:()=>x("paid-members"),children:"Paid members"}),e.jsx(de,{onClick:()=>x("mrr"),children:"MRR"})]})]}),e.jsx("div",{className:"my-4 [&_.recharts-cartesian-axis-tick-value]:fill-gray-500",children:e.jsx(wt,{className:"-mb-3 h-[16vw] max-h-[320px] w-full min-h-[180px]",color:v[h].color,data:m,dataFormatter:h==="mrr"?S=>`${t}${T(S)}`:T,id:h,range:c,tooltipContent:h==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(r,a="signups desc",n=50)=>{const{startDate:t,endDate:s,timezone:l}=re(r),i={date_from:W(t),date_to:W(s),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:r,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const s=n?r.slice(0,n):r,{appSettings:l}=je();return e.jsx(le,{children:s.map(i=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pt,{defaultSourceIconUrl:t,displayName:i.displayName,iconSrc:i.iconSrc}),i.linkUrl?e.jsx("a",{className:"hover:underline",href:i.linkUrl,rel:"noreferrer",target:"_blank",children:i.displayName}):e.jsx("span",{children:i.displayName})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.free_members)]}),l?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",T(i.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:["+",a,T(Q(i.mrr))]})]})]},i.source))})},wa=({range:r,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:s})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:h}=je(),[g,c]=O.useState("free_members desc"),o=t||g,j=s||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(r,A,a),u=l?.url,b="https://www.google.com/s2/favicons?domain=ghost.org&sz=64",N=I.useMemo(()=>{if(i?.stats&&i?.meta?.totals){const v=i.meta.totals;let C=v[0];if(!C)return Se("usd");for(const S of v)S.mrr>C.mrr&&(C=S);return Se(C.currency)}return Se("usd")},[i]),p=I.useMemo(()=>x?.stats?x.stats.map(v=>{const C=v.source||"Direct",{domain:S}=Bt(C,u),d=S?`https://www.faviconextractor.com/favicon/${S}?larger=true`:b,k=S&&C!=="Direct"?`https://${S}`:void 0;return{source:C,free_members:v.signups,paid_members:v.paid_conversions,mrr:v.mrr,iconSrc:d,displayName:C,linkUrl:k}}):[],[x,u]),f="Top sources",m=`Where did your growth come from ${H(r)}`;return h?.analytics.membersTrackSources?w?e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})})}):e.jsxs(e.Fragment,{children:[p.length>0?e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b,limit:a}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:h?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${H(r)}`,children:e.jsx(dt,{strokeWidth:1.5})})})})}),n&&p.length>a&&e.jsx(Et,{className:"border-none bg-transparent hover:bg-transparent!",children:e.jsx(K,{children:e.jsx(F,{className:"border-none bg-transparent px-0 pb-0 hover:bg-transparent!",colSpan:4,children:e.jsxs(mt,{children:[e.jsx(ut,{asChild:!0,children:e.jsxs(Ce,{variant:"outline",children:["View all ",e.jsx(At,{})]})}),e.jsxs(pt,{className:"overflow-y-auto pt-0 sm:max-w-[600px]",children:[e.jsxs(ft,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ht,{children:f}),e.jsx(xt,{children:m})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(U,{children:"Source"}),e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),h?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(U,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),e.jsx(Fe,{currencySymbol:N,data:p,defaultSourceIconUrl:b})]})})]})]})})})})]}):e.jsx(le,{children:e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:h?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:r,payload:a})=>{if(r&&a&&a.length){const n=a[0];return e.jsx("div",{className:"rounded-lg border bg-background p-2 shadow-sm",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:n.payload.color}}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono",children:T(n.value)})]})})}return null},Da=({isLoading:r,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(re(a).startDate)}}),{data:{tiers:s=[]}={}}=na(),[l,i]=O.useState("billing-period"),{startDate:h,endDate:g}=O.useMemo(()=>re(a),[a]),c=O.useMemo(()=>W(h),[h]),o=O.useMemo(()=>W(g),[g]),j=O.useMemo(()=>s.filter(m=>m.type==="paid"&&m.active).map(m=>({id:m.id,name:m.name})),[s]),A=O.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const m=t.stats,v=B(c),C=B(o),S=m.filter(P=>{const M=B(P.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((P,M)=>new Date(P.date).getTime()-new Date(M.date).getTime()),k=d[0].comped,D=d[d.length-1].comped-k;return D>0?D:0},[t,c,o]),x=O.useMemo(()=>{if(!n?.stats)return[];const m=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(m)&&k.isSameOrBefore(v)}).reduce((d,k)=>{const y=k.cadence;return d[y]||(d[y]=0),d[y]+=k.signups,d},{});return A>0&&(C.complimentary=A),Object.entries(C).map(([d,k],y)=>{let D=d,P="url(#gradientPurple)",M="var(--chart-purple)";return d==="month"?(D="Monthly",P="url(#gradientPurple)",M="var(--chart-purple)"):d==="year"?(D="Annual",P="url(#gradientTeal)",M="var(--chart-teal)"):d==="complimentary"&&(D="Complimentary",P="url(#gradientBlue)",M="var(--chart-blue)"),{id:`cadence-${y}`,name:D,count:k,fill:P,color:M}})},[n,c,o,A]),w=O.useMemo(()=>{if(!n?.stats||j.length===0)return[];const m=B(c),v=B(o),C=n.stats.filter(D=>{const P=B(D.date);return P.isSameOrAfter(m)&&P.isSameOrBefore(v)}).reduce((D,P)=>{const M=P.tier;return D[M]||(D[M]=0),D[M]+=P.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"var(--chart-purple)"},{gradient:"url(#gradientTeal)",solid:"var(--chart-teal)"},{gradient:"url(#gradientBlue)",solid:"var(--chart-blue)"},{gradient:"url(#gradientRose)",solid:"var(--chart-rose)"},{gradient:"url(#gradientOrange)",solid:"var(--chart-orange)"},{gradient:"url(#gradientGreen)",solid:"var(--chart-green)"},{gradient:"url(#gradientAmber)",solid:"var(--chart-amber)"},{gradient:"url(#gradientYellow)",solid:"var(--chart-yellow)"},{gradient:"url(#gradientDarkblue)",solid:"var(--chart-darkblue)"},{gradient:"url(#gradientGray)",solid:"var(--chart-darkgray)"}];return[...j.map(D=>{const P=C[D.id]||0;return{id:D.id,name:D.name,count:P}})].sort((D,P)=>P.count-D.count).map((D,P)=>{const M=P%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),u=l==="billing-period"?x:w,b=O.useMemo(()=>u.reduce((m,v)=>m+v.count,0),[u]),N=O.useMemo(()=>{const m={count:{label:"Subscriptions"}};return u.forEach(v=>{m[v.id]={label:v.name,color:v.color}}),m},[u]),p=O.useMemo(()=>b===0?[]:u.map(m=>({label:m.name,count:m.count,percentage:m.count/b*100,color:m.color})),[u,b]);if(r||!n?.stats)return null;const f=u.length>0&&b>0;return e.jsxs(be,{children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscription breakdown"}),e.jsxs(Oe,{children:["New paid subscriptions ",H(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:m=>i(m),children:[e.jsx(Xe,{className:"w-full",children:e.jsx(Je,{})}),e.jsxs(Qe,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:f?e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"mx-auto aspect-square h-[250px] min-h-[250px] w-full",config:N,children:e.jsxs(va,{children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"gradientPurple",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-purple)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-purple)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientTeal",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-teal)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-teal)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientRose",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-rose)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-rose)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientBlue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-blue)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-blue)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientOrange",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-orange)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-orange)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGreen",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-green)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-green)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientAmber",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-amber)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-amber)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientYellow",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-yellow)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-yellow)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientDarkblue",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-darkblue)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-darkblue)",stopOpacity:.6})]}),e.jsxs("linearGradient",{id:"gradientGray",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--chart-darkgray)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--chart-darkgray)",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:u,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(Ue,{content:({viewBox:m})=>{if(m&&"cx"in m&&"cy"in m)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:m.cx,y:m.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:m.cx,y:m.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:m.cx,y:(m.cy||0)+20,children:"Total"})]})}})})]})}),p.length>0&&e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-x-6 gap-y-1 text-sm text-muted-foreground",children:p.map(m=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:m.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:m.label,children:m.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(m.percentage)||0),"%"]})]},m.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${H(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(r,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=r.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:s}=re(a),l=B(s).diff(B(t),"days"),i=bt(a,l,"sum",n),h=new Map(r.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(s).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"month")}}else if(i==="weekly"){const o=B(t).startOf("week"),j=B(s).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0})}o.add(1,"week")}}else{const o=B(t),j=B(s);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=h.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=r=>{if(r===-1){const{startDate:a,endDate:n}=re(r);return B(n).diff(B(a),"days")}return r},Ta=r=>{const a=at(r);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=r=>{const a=at(r);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:r,memberData:a,range:n,isLoading:t})=>{const[s,l]=O.useState(()=>Le(n));O.useEffect(()=>{l(Le(n))},[n]);const i=O.useMemo(()=>Ta(n),[n]),h=O.useMemo(()=>{switch(s){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[s]),g=O.useMemo(()=>{if(r&&r.length>0){if(n===1){const f=B().format("YYYY-MM-DD"),m=r.find(v=>v.date===f);return[{date:z(f,n),rawDate:f,new:m?.signups||0,cancelled:-(m?.cancellations||0)}]}const x=oe(r,n,"signups","sum",h),w=oe(r,n,"cancellations","sum",h),u=new Map(w.map(f=>[f.date,f])),b=x.map(f=>({date:f.date,signups:f.signups||0,cancellations:u.get(f.date)?.cancellations||0})),N=new Set(b.map(f=>f.date));return w.forEach(f=>{N.has(f.date)||b.push({date:f.date,signups:0,cancellations:f.cancellations||0})}),b.sort((f,m)=>new Date(f.date).getTime()-new Date(m.date).getTime()),Ca(b,n,h).map(f=>{let m=n;return s==="weekly"&&n<91?m=91:s==="monthly"&&n<365&&(m=365),{date:z(f.date,m),rawDate:f.date,new:f.signups||0,cancelled:-(f.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),f=a.find(m=>m.date===p);return[{date:z(p,n),rawDate:p,new:f?.paid_subscribed||0,cancelled:-(f?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",h),w=oe(a,n,"paid_canceled","sum",h),u=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:u.get(p.date)?.paid_canceled||0})),N=new Set(b.map(p=>p.date));return w.forEach(p=>{N.has(p.date)||b.push({date:p.date,paid_subscribed:0,paid_canceled:p.paid_canceled||0})}),b.sort((p,f)=>new Date(p.date).getTime()-new Date(f.date).getTime()),b.map(p=>{let f=n;return s==="weekly"&&n<91?f=91:s==="monthly"&&n<365&&(f=365),{date:z(p.date,f),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,r,n,h,s]),c={new:{label:"New",color:"var(--chart-teal)"},cancelled:{label:"Cancelled",color:"var(--chart-rose)"}},o=O.useMemo(()=>{const x=g.reduce((u,b)=>u+b.new,0),w=g.reduce((u,b)=>u+Math.abs(b.cancelled),0);return{new:x,cancelled:w}},[g]);if(t)return null;const j=g.length>0&&(o.new>0||o.cancelled>0),A=x=>x.charAt(0).toUpperCase()+x.slice(1);return e.jsxs(be,{"data-testid":"paid-members-change-card",children:[e.jsx(_e,{children:e.jsxs("div",{className:"flex items-start justify-between gap-1.5",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ke,{children:"Paid subscriptions"}),e.jsxs(Oe,{children:["New and cancelled paid subscriptions ",H(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:s,onValueChange:x=>l(x),children:[e.jsx(Xe,{className:"w-[110px]",children:e.jsx(Je,{})}),e.jsx(Qe,{align:"end",children:i.map(x=>e.jsx(we,{value:x,children:A(x)},x))})]})})]})}),e.jsx(ge,{children:j?e.jsxs("div",{children:[e.jsx(He,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(Ot,{data:g,stackOffset:"sign",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tealGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-new)",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-new)",stopOpacity:.6})]})}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"roseGradient",x1:"0",x2:"0",y1:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"var(--color-cancelled)",stopOpacity:.6}),e.jsx("stop",{offset:"100%",stopColor:"var(--color-cancelled)",stopOpacity:.8})]})}),e.jsx(Nt,{stroke:"var(--border)",vertical:!1}),e.jsx(Dt,{axisLine:!1,dataKey:"date",tickFormatter:()=>"",tickLine:!1,tickMargin:10}),e.jsx(Ct,{axisLine:!1,tickFormatter:x=>x<0?T(x*-1):T(x),tickLine:!1}),e.jsx(We,{content:e.jsx(sa,{className:"min-w-[120px]! px-3 py-2",formatter:(x,w,u,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const f=Number(u?.payload?.new||0),m=Number(u?.payload?.cancelled||0),v=f+m,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=u?.payload?.date;return u?.payload?.rawDate&&(s==="monthly"?S=z(u.payload.rawDate,366):s==="weekly"?S=z(u.payload.rawDate,91):S=z(u.payload.rawDate,30)),e.jsxs("div",{className:"flex w-full flex-col",children:[b===0&&e.jsx("div",{className:"mb-1 text-sm font-medium text-foreground",children:S}),e.jsxs("div",{className:"flex w-full items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--color-bg)] opacity-50",style:{"--color-bg":`var(--color-${w})`}}),e.jsx("span",{className:"text-sm text-muted-foreground",children:c[w]?.label||w})]}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums",children:p})]}),b===1&&e.jsxs("div",{className:"mt-1 flex w-full items-center justify-between gap-4 border-t pt-1",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Net change"}),e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium text-foreground tabular-nums",children:C})]})]})},hideLabel:!0}),cursor:!1,isAnimationActive:!1,position:{y:10}}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"new",fill:"url(#tealGradient)",fillOpacity:.75,maxBarSize:32,minPointSize:3,radius:[4,4,0,0],stackId:"a"}),e.jsx(Ee,{activeBar:{fillOpacity:1},dataKey:"cancelled",fill:"url(#roseGradient)",fillOpacity:.75,maxBarSize:32,radius:[4,4,0,0],stackId:"a"})]})}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.new.color}}),e.jsx("span",{children:"New"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.new)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:c.cancelled.color}}),e.jsx("span",{children:"Cancelled"}),e.jsx("span",{className:"font-medium text-foreground",children:T(o.cancelled)})]})]})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No paid subscription changes ${H(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(r,a,n)=>{const t=r??30,s=a??"mrr desc",{startDate:l,endDate:i}=O.useMemo(()=>re(t),[t]),h=O.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:s};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,s,n]),g=Object.fromEntries(Object.entries(h).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},br=()=>{const{range:r,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),s=De(),[l,i]=O.useState("free_members desc"),[h,g]=O.useState(X.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=O.useState(j);O.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:u,totals:b,currencySymbol:N,subscriptionData:p}=ma(r),{data:f,isLoading:m}=ka(r,l,h),v=O.useMemo(()=>{const k=(f?.stats||[]).reduce((_,E)=>{const V=E.post_id||(E.title&&E.title.trim()!==""?E.title:E.attribution_url);if(!V)return _;if(!_.has(V))_.set(V,E);else{const q=_.get(V);q.free_members+=E.free_members,q.paid_members+=E.paid_members,q.mrr+=E.mrr,_.set(V,q)}return _},new Map),y=Array.from(k.values()),D=y.reduce((_,E)=>_+E.free_members,0),P=y.reduce((_,E)=>_+E.paid_members,0),M=y.reduce((_,E)=>_+E.mrr,0);return y.map(_=>{let E=0;return l.includes("free_members")&&D>0?E=_.free_members/D:l.includes("paid_members")&&P>0?E=_.paid_members/P:l.includes("mrr")&&M>0&&(E=_.mrr/M),{title:_.title||_.attribution_url,post_id:_.post_id,attribution_url:_.attribution_url,attribution_type:_.attribution_type,attribution_id:_.attribution_id,free_members:_.free_members,paid_members:_.paid_members,mrr:_.mrr,percentage:E,published_at:_.published_at,url_exists:_.url_exists??!0}})},[f,l]),C=w,S=w||m;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx(Vt,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:u,isLoading:!1,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(be,{"data-testid":"total-members-card",children:e.jsx(ge,{children:e.jsx(Sa,{chartData:u,currencySymbol:N,initialTab:j,isLoading:C,totals:b,onTabChange:x})})}),o?.paidMembersEnabled&&A==="paid-members"&&e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2 xl:grid-cols-[2fr_minmax(460px,1fr)]",children:[e.jsx(_a,{isLoading:C,memberData:u,range:r,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:r})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Mt(h)}),e.jsx(Oe,{children:Rt(h,r,H)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pt-0 [&>th]:pb-2",children:[e.jsx(U,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:h,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(ue,{value:X.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(ue,{value:X.POSTS,children:"Posts"}),e.jsx(ue,{value:X.PAGES,children:"Pages"}),e.jsx(ue,{value:X.SOURCES,children:"Sources"})]})})}),e.jsx(U,{className:"w-[140px] text-right",children:o?.paidMembersEnabled?e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"free_members desc",children:"Free members"}):e.jsx(e.Fragment,{children:"Free members"})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(U,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),h===X.SOURCES?e.jsx(wa,{limit:20,range:r,setSortBy:d=>i(d),showViewAll:!0,sortBy:l}):e.jsx(le,{children:S?e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-2",colSpan:1,children:e.jsx(Ge,{containerClassName:"space-y-2",count:5,maxWidth:75,randomize:!0})})}):o?.analytics.membersTrackSources?v.length>0?v.map((d,k)=>e.jsxs(K,{className:"last:border-none",children:[e.jsx(F,{children:e.jsxs("div",{className:"group/link inline-flex flex-col items-start gap-px",children:[d.post_id&&d.attribution_type==="post"?e.jsx(Ce,{className:"h-auto p-0 text-left leading-tight font-medium whitespace-normal hover:underline!",title:"View post analytics",variant:"link",onClick:kt(d.attribution_url,d.post_id,a.url||"",s,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Pe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Pe(d.published_at,t)]})]})}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.free_members>0&&"+",T(d.free_members)]}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.paid_members>0&&"+",T(d.paid_members)]}),e.jsxs(F,{className:"text-right font-mono text-sm",children:[d.mrr>0&&"+",N,T(Q(d.mrr))]})]})]},`${h}-${d.post_id||`${d.title}-${k}`}`)):e.jsx(K,{className:"border-none",children:e.jsx(F,{className:"py-12 group-hover:bg-transparent!",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${H(r)}`,children:e.jsx(da,{strokeWidth:1.5})})})}):e.jsx(K,{className:"last:border-none",children:e.jsx(F,{className:"border-none py-12 group-hover:bg-transparent!",colSpan:o?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})]})})]})]})]})};export{br as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c}from"./index-ZuWSQ3L6.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|
|
1
|
+
import{r as c}from"./index-JMWMnGGt.js";const z=(n,t)=>n==null?t:t==null?n:Math.max(n,t),C=new WeakMap,ut={onUpdate(n,t,e){if(C.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),a=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));C.set(e,z(r?.pos,a?.pos))},getDelta(n,t,e){const i=n-t,s=C.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}},y=(n,t,e)=>{const i=document.createElement(n),[s,r]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),r?.forEach(a=>i.appendChild(a)),i},J=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},G=n=>n.offsetWidth>0&&n.offsetHeight>0,Y=(n,t)=>{!customElements.get(n)&&customElements.define(n,t)};function Z(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}function q(n,t,e,i){const s=t.formatToParts(n);e&&s.unshift({type:"prefix",value:e}),i&&s.push({type:"suffix",value:i});const r=[],a=[],o=[],l=[],u={},p=d=>`${d}:${u[d]=(u[d]??-1)+1}`;let f="",m=!1,g=!1;for(const d of s){f+=d.value;const h=d.type==="minusSign"||d.type==="plusSign"?"sign":d.type;h==="integer"?(m=!0,a.push(...d.value.split("").map(A=>({type:h,value:parseInt(A)})))):h==="group"?a.push({type:h,value:d.value}):h==="decimal"?(g=!0,o.push({type:h,value:d.value,key:p(h)})):h==="fraction"?o.push(...d.value.split("").map(A=>({type:h,value:parseInt(A),key:p(h),pos:-1-u[h]}))):(m||g?l:r).push({type:h,value:d.value,key:p(h)})}const M=[];for(let d=a.length-1;d>=0;d--){const h=a[d];M.unshift(h.type==="integer"?{...h,key:p(h.type),pos:u[h.type]}:{...h,key:p(h.type)})}return{pre:r,integer:M,fraction:o,post:l,valueAsString:f,value:typeof n=="string"?parseFloat(n):n}}const Q=String.raw,K=(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0})(),tt=typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),w=typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,E="--_number-flow-d-opacity",U="--_number-flow-d-width",R="--_number-flow-dx",k="--_number-flow-d",et=(()=>{try{return CSS.registerProperty({name:E,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:R,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:U,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:k,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),it="var(--number-flow-char-height, 1em)",v="var(--number-flow-mask-height, 0.25em)",N=`calc(${v} / 2)`,$="var(--number-flow-mask-width, 0.5em)",_=`calc(${$} / var(--scale-x))`,b="#000 0, transparent 71%",P=Q`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${it} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${U}) / var(--width));transform:translateX(var(${R})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${_},#000 calc(100% - ${_}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${v},#000 calc(100% - ${v}),transparent 100% ),radial-gradient(at bottom right,${b}),radial-gradient(at bottom left,${b}),radial-gradient(at top left,${b}),radial-gradient(at top right,${b});-webkit-mask-size:100% calc(100% - ${v} * 2),calc(100% - ${_} * 2) 100%,${_} ${v},${_} ${v},${_} ${v},${_} ${v};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${R})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${N} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${E}))}`,st=HTMLElement,B=tt&&K&&et;let S;class I extends st{constructor(){super(),this.created=!1,this.batched=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var e;if(t==null)return;const{pre:i,integer:s,fraction:r,post:a,value:o}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,o):this.trend,this.computedAnimated=B&&this._animated&&(!this.respectMotionPreference||!(w!=null&&w.matches))&&G(this),(e=this.plugins)==null||e.forEach(u=>{var p;return(p=u.onUpdate)==null?void 0:p.call(u,t,l,this)}),this.batched||this.willUpdate(),this._pre.update(i),this._num.update({integer:s,fraction:r}),this._post.update(a),this.batched||this.didUpdate()}else{this._data=t,this.attachShadow({mode:"open"});try{this._internals??(this._internals=this.attachInternals()),this._internals.role="img"}catch{}if(typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)S||(S=new CSSStyleSheet,S.replaceSync(P)),this.shadowRoot.adoptedStyleSheets=[S];else{const l=document.createElement("style");l.textContent=P,this.shadowRoot.appendChild(l)}this._pre=new F(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new nt(this,s,r),this.shadowRoot.appendChild(this._num.el),this._post=new F(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el),this.created=!0}try{this._internals.ariaLabel=t.valueAsString}catch{}}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}I.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class nt{constructor(t,e,i,{className:s,...r}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=y("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=y("span",{...r,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[R]:[`${e}px`,"0px"],[U]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class D{constructor(t,e,{justify:i,className:s,...r},a){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=y("span",{...r,className:`section section--justify-${i} ${s??""}`},a?a(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new X(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new at(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.removeAttribute("inert"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${J(e.el,this.justify)}px`}),t.forEach(e=>{e.el.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",r=s?"prepend":"append";if(Z(t,a=>{let o;this.children.has(a.key)?(o=this.children.get(a.key),i.set(a,o),this.unpop(o),o.present=!0):(o=this.addChar(a,{startDigitsAtZero:!0,animateIn:!0}),e.set(a,o)),this.el[r](o.el)},{reverse:s}),this.flow.computedAnimated){const a=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(a)})}e.forEach((a,o)=>{a.update(o.value)}),i.forEach((a,o)=>{a.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof X&&i.update(0)}),this.pop(e)}}class F extends D{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(r=>r.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class x{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[E]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[E]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class W extends x{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class X extends W{constructor(t,e,i,s,r){var a,o;const l=(((o=(a=t.flow.digits)==null?void 0:a[s])==null?void 0:o.max)??9)+1,u=Array.from({length:l}).map((f,m)=>{const g=y("span",{className:"digit__num"},[document.createTextNode(String(m))]);return m!==i&&g.setAttribute("inert",""),g.style.setProperty("--n",String(m)),g}),p=y("span",{part:`digit ${e}-digit`,className:"digit"},u);p.style.setProperty("--current",String(i)),p.style.setProperty("--length",String(l)),super(t,i,p,r),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=u,this.length=l}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,r=this.section.justify==="left"?i+s:i-s,a=this._prevCenter-r;a&&this.el.animate({transform:[`translateX(${a}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[k]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const s of this.flow.plugins){const r=(t=s.getDelta)==null?void 0:t.call(s,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class at extends W{constructor(t,e,i,s){const r=y("span",{className:"symbol__value",textContent:i});super(t,i,y("span",{part:`symbol ${e}`,className:"symbol"},[r]),s),this.type=e,this._children=new Map,this._onChildRemove=a=>()=>{this._children.delete(a)},this._children.set(i,new x(this.flow,r,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);e&&(e.present=!1);const i=this._children.get(t);if(i)i.present=!0;else{const s=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(s),this._children.set(t,new x(this.flow,s,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const rt=parseInt(c.version.match(/^(\d+)\./)?.[1]),j=rt>=19,ot=["data","digits"];class T extends I{attributeChangedCallback(t,e,i){this[t]=JSON.parse(i)}}T.observedAttributes=j?[]:ot;Y("number-flow-react",T);const lt={},O=j?n=>n:JSON.stringify;function V(n){const{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o,...l}=n;return[{transformTiming:t,spinTiming:e,opacityTiming:i,animated:s,respectMotionPreference:r,trend:a,plugins:o},l]}class ht extends c.Component{updateProperties(t){if(!this.el)return;this.el.batched=!this.props.isolate;const[e]=V(this.props);Object.entries(e).forEach(([i,s])=>{this.el[i]=s??T.defaultProps[i]}),t?.onAnimationsStart&&this.el.removeEventListener("animationsstart",t.onAnimationsStart),this.props.onAnimationsStart&&this.el.addEventListener("animationsstart",this.props.onAnimationsStart),t?.onAnimationsFinish&&this.el.removeEventListener("animationsfinish",t.onAnimationsFinish),this.props.onAnimationsFinish&&this.el.addEventListener("animationsfinish",this.props.onAnimationsFinish)}componentDidMount(){this.updateProperties(),j&&this.el&&(this.el.digits=this.props.digits,this.el.data=this.props.data)}getSnapshotBeforeUpdate(t){if(this.updateProperties(t),t.data!==this.props.data){if(this.props.group)return this.props.group.willUpdate(),()=>this.props.group?.didUpdate();if(!this.props.isolate)return this.el?.willUpdate(),()=>this.el?.didUpdate()}return null}componentDidUpdate(t,e,i){i?.()}handleRef(t){this.props.innerRef&&(this.props.innerRef.current=t),this.el=t}render(){const[t,{innerRef:e,className:i,data:s,willChange:r,isolate:a,group:o,digits:l,onAnimationsStart:u,onAnimationsFinish:p,...f}]=V(this.props);return c.createElement("number-flow-react",{ref:this.handleRef,"data-will-change":r?"":void 0,class:i,...f,dangerouslySetInnerHTML:{__html:""},suppressHydrationWarning:!0,digits:O(l),data:O(s)})}constructor(t){super(t),this.handleRef=this.handleRef.bind(this)}}const ft=c.forwardRef(function({value:t,locales:e,format:i,prefix:s,suffix:r,...a},o){c.useImperativeHandle(o,()=>l.current,[]);const l=c.useRef(),u=c.useContext(H);u?.useRegister(l);const p=c.useMemo(()=>e?JSON.stringify(e):"",[e]),f=c.useMemo(()=>i?JSON.stringify(i):"",[i]),m=c.useMemo(()=>{const g=lt[`${p}:${f}`]??=new Intl.NumberFormat(e,i);return q(t,g,s,r)},[t,p,f,s,r]);return c.createElement(ht,{...a,group:u,data:m,innerRef:l})}),H=c.createContext(void 0);function mt({children:n}){const t=c.useRef(new Set),e=c.useRef(!1),i=c.useRef(new WeakMap),s=c.useMemo(()=>({useRegister(r){c.useEffect(()=>(t.current.add(r),()=>{t.current.delete(r)}),[])},willUpdate(){e.current||(e.current=!0,t.current.forEach(r=>{const a=r.current;!a||!a.created||(a.willUpdate(),i.current.set(a,!0))}))},didUpdate(){t.current.forEach(r=>{const a=r.current;!a||!i.current.get(a)||(a.didUpdate(),i.current.delete(a))}),e.current=!1}}),[]);return c.createElement(H.Provider,{value:s},n)}const ct=()=>c.useSyncExternalStore(()=>()=>{},()=>B,()=>!1),dt=()=>c.useSyncExternalStore(n=>(w?.addEventListener("change",n),()=>w?.removeEventListener("change",n)),()=>w.matches,()=>!1);function gt({respectMotionPreference:n=!0}={}){const t=ct(),e=dt();return t&&(!n||!e)}export{T as NumberFlowElement,mt as NumberFlowGroup,ut as continuous,ft as default,gt as useCanAnimate,ct as useIsSupported,dt as usePrefersReducedMotion};
|