ghost 6.17.0 → 6.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/components/tryghost-i18n-6.17.1.tgz +0 -0
  2. package/components/{tryghost-parse-email-address-6.17.0.tgz → tryghost-parse-email-address-6.17.1.tgz} +0 -0
  3. package/core/built/admin/assets/{PolarAngleAxis-sYvwhg8d.js → PolarAngleAxis-DVj7Sw2n.js} +1 -1
  4. package/core/built/admin/assets/{_baseAssignValue-DKQ9pw63.js → _baseAssignValue-CrCkbXur.js} +1 -1
  5. package/core/built/admin/assets/{a-large-small-CCJbivJB.js → a-large-small-BLquRSNr.js} +1 -1
  6. package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +2 -2
  7. package/core/built/admin/assets/admin-x-settings/{code-editor-view-CdDTmDO_.mjs → code-editor-view-BzvYs1fs.mjs} +2 -2
  8. package/core/built/admin/assets/admin-x-settings/{index-D19Kl7F3.mjs → index-BXChUyr6.mjs} +5703 -5668
  9. package/core/built/admin/assets/admin-x-settings/{index-NuuHxngw.mjs → index-DYEF3NiM.mjs} +2 -2
  10. package/core/built/admin/assets/admin-x-settings/{index-DWAeZxhW.mjs → index-DdMo_pvD.mjs} +2 -2
  11. package/core/built/admin/assets/admin-x-settings/{modals-C-PAZhri.mjs → modals-Ck3AHDx3.mjs} +8065 -8057
  12. package/core/built/admin/assets/{at-sign-BpRvqAQI.js → at-sign-Cj4_ORaa.js} +1 -1
  13. package/core/built/admin/assets/{audience-DyCuv1si.js → audience-ACTBvUSt.js} +1 -1
  14. package/core/built/admin/assets/{avatar-flipboard-BfziFfAR.js → avatar-flipboard-BeKL4BEF.js} +1 -1
  15. package/core/built/admin/assets/{bluesky-sharing-D-LC_G4e.js → bluesky-sharing-CP7ej5rz.js} +1 -1
  16. package/core/built/admin/assets/{chart-BvckKrZJ.js → chart-B6jk72FT.js} +1 -1
  17. package/core/built/admin/assets/{chunk.524.c76823170fc310a35d9a.js → chunk.524.6c12997c856012ea06f5.js} +7 -7
  18. package/core/built/admin/assets/{chunk.582.78cee8a07d88a486d8d3.js → chunk.582.a0abd5b93eb1bc50335a.js} +10 -10
  19. package/core/built/admin/assets/{code-editor-view-BEwQJYgg.js → code-editor-view-CVRtsOBM.js} +1 -1
  20. package/core/built/admin/assets/{comments-1fqIGh0f.js → comments-CxjhZH_T.js} +1 -1
  21. package/core/built/admin/assets/{copy-BywnwlHN.js → copy-YhtJexiS.js} +1 -1
  22. package/core/built/admin/assets/{data-list--hSCIzLC.js → data-list-BPSXm3ej.js} +1 -1
  23. package/core/built/admin/assets/{deleted-feed-item-DYKurQBy.js → deleted-feed-item-D8BHDEHh.js} +1 -1
  24. package/core/built/admin/assets/{edit-profile-yzEMlJ_t.js → edit-profile-FrkkXMG7.js} +1 -1
  25. package/core/built/admin/assets/{empty-indicator-1p7S45xr.js → empty-indicator-SsCyCd50.js} +1 -1
  26. package/core/built/admin/assets/{en-DtAty2DP.js → en-ZWZBSdFY.js} +1 -1
  27. package/core/built/admin/assets/{feed-DB25J9B-.js → feed-BvVJCTy8.js} +1 -1
  28. package/core/built/admin/assets/{filters-cN8zP798.js → filters-BupJ4mUj.js} +1 -1
  29. package/core/built/admin/assets/{gh-chart-CVItDGhq.js → gh-chart-Dp9VXeON.js} +1 -1
  30. package/core/built/admin/assets/{ghost-f424e37f7e8f90122e3a13866d2b1f91.css → ghost-78b420974adc056bf1c9570275a46535.css} +1 -1
  31. package/core/built/admin/assets/{ghost-10e648bbdbb5f2e55418e88f15d302e2.js → ghost-a9268074d0a9b02198594a05ecd7a626.js} +2 -2
  32. package/core/built/admin/assets/{growth-Lbkwu9SJ.js → growth-CRDHOGrZ.js} +1 -1
  33. package/core/built/admin/assets/{hash-BQl75WLf.js → hash-CPAX2PwN.js} +1 -1
  34. package/core/built/admin/assets/{inbox-BMxFzv7J.js → inbox-DuT2edmx.js} +1 -1
  35. package/core/built/admin/assets/{index-oARkCq-e.js → index--Nwo3958.js} +1 -1
  36. package/core/built/admin/assets/{index-SafJnMjy.js → index-8ECl7z0l.js} +1 -1
  37. package/core/built/admin/assets/{index-CIheyf0S.js → index-B1rQYn0h.js} +1 -1
  38. package/core/built/admin/assets/{index-BQ6KbriB.js → index-B2oDZJ9B.js} +1 -1
  39. package/core/built/admin/assets/{index-KqwA5am_.css → index-BBrewxpF.css} +1 -1
  40. package/core/built/admin/assets/{index-oanahlHO.js → index-BPYePamp.js} +1 -1
  41. package/core/built/admin/assets/{index-8pnhFllL.js → index-BX3kQzlo.js} +1 -1
  42. package/core/built/admin/assets/{index-CoyIDbjB.js → index-BwUQiVrX.js} +1 -1
  43. package/core/built/admin/assets/{index-C5Mf4zlN.js → index-ByYZ5TiM.js} +1 -1
  44. package/core/built/admin/assets/{index-DG5ENBXM.js → index-CQP2hNBo.js} +1 -1
  45. package/core/built/admin/assets/{index-voIsrI4j.js → index-CeFAaI2v.js} +1 -1
  46. package/core/built/admin/assets/{index-DQny1_Ij.js → index-CjzFwwKZ.js} +1 -1
  47. package/core/built/admin/assets/{index-DR3xU0-B.js → index-Dk-Wh_Fw.js} +1 -1
  48. package/core/built/admin/assets/{index-C6_sy_zU.js → index-DnY4rls4.js} +1 -1
  49. package/core/built/admin/assets/{index-BrYABbTV.js → index-bl5YmBtG.js} +1 -1
  50. package/core/built/admin/assets/{index-BeAhXwae.js → index-exFCQBCk.js} +9 -9
  51. package/core/built/admin/assets/{koenig-lexical-uhDY2cN7.js → koenig-lexical-eRS1y7PS.js} +1 -1
  52. package/core/built/admin/assets/{kpi-card-DieTCZ1Z.js → kpi-card-DShFKtte.js} +1 -1
  53. package/core/built/admin/assets/{kpis-Dg2Sav4t.js → kpis-Bxyr_zYY.js} +1 -1
  54. package/core/built/admin/assets/{label-Cs4FoZGu.js → label-hgdYQhmm.js} +1 -1
  55. package/core/built/admin/assets/{links-DwbtAH6y.js → links-5NNDFN65.js} +1 -1
  56. package/core/built/admin/assets/{lucide-react-CTYGYE5A.js → lucide-react-f58FO8MB.js} +1 -1
  57. package/core/built/admin/assets/{main-layout-DgFdHzFw.js → main-layout-BDz_2UZs.js} +1 -1
  58. package/core/built/admin/assets/{message-square-text-42zfcaLO.js → message-square-text-6dTKbQKA.js} +1 -1
  59. package/core/built/admin/assets/{minus-vbx9q5AE.js → minus-D2C19Fiu.js} +1 -1
  60. package/core/built/admin/assets/{modals-B1LK0GFs.js → modals-DzetQgXf.js} +2 -2
  61. package/core/built/admin/assets/{moderation-DBHou9Tg.js → moderation-87QsKbyf.js} +1 -1
  62. package/core/built/admin/assets/{newsletter-C_C5cbBQ.js → newsletter-BhI9Lgkn.js} +1 -1
  63. package/core/built/admin/assets/{newsletters-COhRGj2b.js → newsletters-adLgF_Re.js} +1 -1
  64. package/core/built/admin/assets/{note-Bs7yEUc9.js → note-BbPR57Yw.js} +1 -1
  65. package/core/built/admin/assets/{overview-DgkHUK_G.js → overview-CqyRlIVM.js} +1 -1
  66. package/core/built/admin/assets/{pagemenu-aMfaU2cA.js → pagemenu-DlQF5jN4.js} +1 -1
  67. package/core/built/admin/assets/{post-analytics-BFOeo-LR.js → post-analytics-BudH7GCA.js} +1 -1
  68. package/core/built/admin/assets/{post-analytics-context-BR5b-9nb.js → post-analytics-context-CxuzZluw.js} +1 -1
  69. package/core/built/admin/assets/{post-analytics-header-Cj_Vf_UF.js → post-analytics-header-BV_8onIF.js} +1 -1
  70. package/core/built/admin/assets/{post-share-modal-CP1NDQhS.js → post-share-modal-CnM21JFK.js} +1 -1
  71. package/core/built/admin/assets/{posts-BQJit53V.js → posts-C5zAbpdG.js} +1 -1
  72. package/core/built/admin/assets/{repeat-DBbPJ4Vq.js → repeat-BbSnXois.js} +1 -1
  73. package/core/built/admin/assets/{reply-DlcWrPL1.js → reply-CuCJJfZj.js} +1 -1
  74. package/core/built/admin/assets/{select-wir-gl-P.js → select-Bv-dkHeU.js} +1 -1
  75. package/core/built/admin/assets/{settings-CpDtcACU.js → settings-Cit2-dRQ.js} +25 -25
  76. package/core/built/admin/assets/{settings-CtzZEQJ2.js → settings-wlK_oNsg.js} +1 -1
  77. package/core/built/admin/assets/{sort-button-CecMSgfo.js → sort-button-Dmyldyzm.js} +1 -1
  78. package/core/built/admin/assets/{source-icon-CveBuH3b.js → source-icon-DjyV6RS6.js} +1 -1
  79. package/core/built/admin/assets/{sprout-Beunj00B.js → sprout-jOQR37se.js} +1 -1
  80. package/core/built/admin/assets/{square-DTB79BvA.js → square-IrYxuAJL.js} +1 -1
  81. package/core/built/admin/assets/{stats-C2A4PNUn.js → stats-C4LbW8IV.js} +1 -1
  82. package/core/built/admin/assets/{stats-view-XXduvFiP.js → stats-view-BwaLDryw.js} +1 -1
  83. package/core/built/admin/assets/{step-1-Dhctc4sb.js → step-1-C0QApeYD.js} +1 -1
  84. package/core/built/admin/assets/{step-2-CfG-dkZM.js → step-2-h0b6Njyb.js} +1 -1
  85. package/core/built/admin/assets/{step-3-D_7ttapi.js → step-3-CaM-Hz3F.js} +1 -1
  86. package/core/built/admin/assets/{table-D-JhwxMn.js → table-P4FGxGxN.js} +1 -1
  87. package/core/built/admin/assets/{tabs-DvTZ848X.js → tabs-Cj65mCsJ.js} +1 -1
  88. package/core/built/admin/assets/{tags-Pad-cSDy.js → tags-CDvEkvxr.js} +1 -1
  89. package/core/built/admin/assets/{tags-dgsPPBjR.js → tags-Dnv6zTag.js} +1 -1
  90. package/core/built/admin/assets/{tiers-DFi-MWJ-.js → tiers-Y3OCOT03.js} +1 -1
  91. package/core/built/admin/assets/{toggle-group-DMvy3Ce1.js → toggle-group-kZZo_vdJ.js} +1 -1
  92. package/core/built/admin/assets/{topic-filter-Is3xj8qt.js → topic-filter-Cn1_Z9I7.js} +1 -1
  93. package/core/built/admin/assets/{trash-CT37Asdf.js → trash-ln90Rlgi.js} +1 -1
  94. package/core/built/admin/assets/{url-helpers-Bf57BBzr.js → url-helpers-B5_oMSPb.js} +1 -1
  95. package/core/built/admin/assets/{use-growth-stats-DXoeaAKq.js → use-growth-stats-DQsJauHH.js} +1 -1
  96. package/core/built/admin/assets/{use-infinite-virtual-scroll-COKeWLQm.js → use-infinite-virtual-scroll-4OIpSNMH.js} +1 -1
  97. package/core/built/admin/assets/{use-simple-pagination-BQBxprZe.js → use-simple-pagination-BedA-MMT.js} +1 -1
  98. package/core/built/admin/assets/{user-round-check-C5Iux98g.js → user-round-check-CYI147XP.js} +1 -1
  99. package/core/built/admin/assets/{wallet-cards-Hfikexmn.js → wallet-cards-xpilOd6G.js} +1 -1
  100. package/core/built/admin/assets/{web-B-GYQeG7.js → web-VPMnLvnh.js} +1 -1
  101. package/core/built/admin/index.html +6 -6
  102. package/package.json +5 -5
  103. package/components/tryghost-i18n-6.17.0.tgz +0 -0
@@ -1,3 +1,3 @@
1
- import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-BeAhXwae.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-XXduvFiP.js";import{E as ce}from"./empty-indicator-1p7S45xr.js";import{A as St,a as At}from"./wallet-cards-Hfikexmn.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-CVItDGhq.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-DvTZ848X.js";import{g as _t}from"./audience-DyCuv1si.js";import{S as te,B as kt}from"./sort-button-CecMSgfo.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-Bf57BBzr.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-D-JhwxMn.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-C2A4PNUn.js";import{u as Gt,a as Vt}from"./tiers-DFi-MWJ-.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-aMfaU2cA.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-BvckKrZJ.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-wir-gl-P.js";import{P as ia,a as oa}from"./PolarAngleAxis-sYvwhg8d.js";import{n as la,o as ca,l as da}from"./lucide-react-CTYGYE5A.js";import{u as ua}from"./use-growth-stats-DXoeaAKq.js";import"./message-square-text-42zfcaLO.js";import"./sprout-Beunj00B.js";import"./index-C6_sy_zU.js";import"./_baseAssignValue-DKQ9pw63.js";import"./a-large-small-CCJbivJB.js";import"./at-sign-BpRvqAQI.js";import"./copy-BywnwlHN.js";import"./hash-BQl75WLf.js";import"./inbox-BMxFzv7J.js";import"./minus-vbx9q5AE.js";import"./tags-dgsPPBjR.js";import"./square-DTB79BvA.js";import"./user-round-check-C5Iux98g.js";import"./repeat-DBbPJ4Vq.js";import"./reply-DlcWrPL1.js";import"./trash-CT37Asdf.js";var xe;function re(s){"@babel/helpers - typeof";return re=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},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){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(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,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(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{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 r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=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=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.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,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,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 m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.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(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=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),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),N=c;ae(c)&&ae(j)?(Re(!1,`Use "dataKey" to specify the value of pie,
1
+ import{e as I,aH as ye,r as P,aP as De,j as e,B as Ce,bV as Te,bW as je,bG as Ke,aj as T,cA as J,aQ as rt,cB as $,bH as nt,ap as it,bI as ot,bJ as de,cU as z,aR as lt,af as se,aX as ct,ag as W,S as Ge,cz as dt,by as ut,bz as mt,bA as pt,bB as ht,bC as ft,bD as xt,ah as B,bR as Oe}from"./index-exFCQBCk.js";import{s as oe,g as U,d as bt,S as gt,a as vt,D as jt,b as yt}from"./stats-view-BwaLDryw.js";import{E as ce}from"./empty-indicator-SsCyCd50.js";import{A as St,a as At}from"./wallet-cards-xpilOd6G.js";import{G as wt,C as Nt,X as Dt,Y as Ct}from"./gh-chart-Dp9VXeON.js";import{T as Ve,a as $e,K as ue,d as Y,e as Tt,b as me}from"./tabs-Cj65mCsJ.js";import{g as _t}from"./audience-ACTBvUSt.js";import{S as te,B as kt}from"./sort-button-Dmyldyzm.js";import{S as Pt,C as Q,g as Ot,c as Mt,b as Rt}from"./url-helpers-B5_oMSPb.js";import{e as le,c as K,f as F,g as Et,a as Ye,b as ze,d as H}from"./table-P4FGxGxN.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-C4LbW8IV.js";import{u as Gt,a as Vt}from"./tiers-Y3OCOT03.js";import{C as be,a as _e,b as ke,f as Pe,c as ge,j as $t}from"./pagemenu-DlQF5jN4.js";import{h as ne,F as Yt,T as zt,b as he,r as Ae,H as ae,L as ie,o as X,c as Ht,S as Ut,A as Wt,I as qt,i as Me,d as Qt,J as Z,u as He,e as Xt,K as Jt,G as Zt,m as fe,l as ea,n as ta,M as aa,N as pe,O as Re,g as sa,s as ra,C as Ue,a as We,v as na,B as Ee}from"./chart-B6jk72FT.js";import{S as qe,a as Qe,b as Xe,c as Je,f as we}from"./select-Bv-dkHeU.js";import{P as ia,a as oa}from"./PolarAngleAxis-DVj7Sw2n.js";import{n as la,o as ca,l as da}from"./lucide-react-f58FO8MB.js";import{u as ua}from"./use-growth-stats-DQsJauHH.js";import"./message-square-text-6dTKbQKA.js";import"./sprout-jOQR37se.js";import"./index-DnY4rls4.js";import"./_baseAssignValue-CrCkbXur.js";import"./a-large-small-BLquRSNr.js";import"./at-sign-Cj4_ORaa.js";import"./copy-YhtJexiS.js";import"./hash-CPAX2PwN.js";import"./inbox-DuT2edmx.js";import"./minus-D2C19Fiu.js";import"./tags-Dnv6zTag.js";import"./square-IrYxuAJL.js";import"./user-round-check-CYI147XP.js";import"./repeat-BbSnXois.js";import"./reply-CuCJJfZj.js";import"./trash-ln90Rlgi.js";var xe;function re(s){"@babel/helpers - typeof";return re=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},re(s)}function ee(){return ee=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(s[t]=n[t])}return s},ee.apply(this,arguments)}function Be(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);a&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),n.push.apply(n,t)}return n}function R(s){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(s,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(n,t))})}return s}function ma(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Ie(s,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(s,et(t.key),t)}}function pa(s,a,n){return a&&Ie(s.prototype,a),n&&Ie(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function ha(s,a,n){return a=ve(a),fa(s,Ze()?Reflect.construct(a,n||[],ve(s).constructor):a.apply(s,n))}function fa(s,a){if(a&&(re(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xa(s)}function xa(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ze(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ze=function(){return!!s})()}function ve(s){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ve(s)}function ba(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Ne(s,a)}function Ne(s,a){return Ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},Ne(s,a)}function L(s,a,n){return a=et(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function et(s){var a=ga(s,"string");return re(a)=="symbol"?a:a+""}function ga(s,a){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var t=n.call(s,a);if(re(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var G=(function(s){function a(n){var t;return ma(this,a),t=ha(this,a,[n]),L(t,"pieRef",null),L(t,"sectorRefs",[]),L(t,"id",Jt("recharts-pie-")),L(t,"handleAnimationEnd",function(){var r=t.props.onAnimationEnd;t.setState({isAnimationFinished:!0}),ne(r)&&r()}),L(t,"handleAnimationStart",function(){var r=t.props.onAnimationStart;t.setState({isAnimationFinished:!1}),ne(r)&&r()}),t.state={isAnimationFinished:!n.isAnimationActive,prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,sectorToFocus:0},t}return ba(a,s),pa(a,[{key:"isActiveIndex",value:function(t){var r=this.props.activeIndex;return Array.isArray(r)?r.indexOf(t)!==-1:t===r}},{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 r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var l=this.props,i=l.label,f=l.labelLine,g=l.dataKey,c=l.valueKey,o=he(this.props,!1),j=he(i,!1),A=he(f,!1),x=i&&i.offsetRadius||20,w=t.map(function(m,b){var N=(m.startAngle+m.endAngle)/2,p=Ae(m.cx,m.cy,m.outerRadius+x,N),h=R(R(R(R({},o),m),{},{stroke:"none"},j),{},{index:b,textAnchor:a.getTextAnchor(p.x,m.cx)},p),u=R(R(R(R({},o),m),{},{fill:"none",stroke:m.fill},A),{},{index:b,points:[Ae(m.cx,m.cy,m.outerRadius,N),p]}),v=g;return ae(g)&&ae(c)?v="value":ae(g)&&(v=c),I.createElement(ie,{key:"label-".concat(m.startAngle,"-").concat(m.endAngle,"-").concat(m.midAngle,"-").concat(b)},f&&a.renderLabelLineItem(f,u,"line"),a.renderLabelItem(i,h,X(m,v)))});return I.createElement(ie,{className:"recharts-pie-labels"},w)}},{key:"renderSectorsStatically",value:function(t){var r=this,l=this.props,i=l.activeShape,f=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=r.isActiveIndex(o),A=g&&r.hasActiveIndex()?g:null,x=j?i:A,w=R(R({},c),{},{stroke:f?c.fill:c.stroke,tabIndex:-1});return I.createElement(ie,ee({ref:function(b){b&&!r.sectorRefs.includes(b)&&r.sectorRefs.push(b)},tabIndex:-1,className:"recharts-pie-sector"},Ht(r.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,r=this.props,l=r.sectors,i=r.isAnimationActive,f=r.animationBegin,g=r.animationDuration,c=r.animationEasing,o=r.animationId,j=this.state,A=j.prevSectors,x=j.prevIsAnimationActive;return I.createElement(Wt,{begin:f,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 m=w.t,b=[],N=l&&l[0],p=N.startAngle;return l.forEach(function(h,u){var v=A&&A[u],C=u>0?qt(h,"paddingAngle",0):0;if(v){var S=Me(v.endAngle-v.startAngle,h.endAngle-h.startAngle),d=R(R({},h),{},{startAngle:p+C,endAngle:p+S(m)+C});b.push(d),p=d.endAngle}else{var k=h.endAngle,y=h.startAngle,D=Me(0,k-y),O=D(m),M=R(R({},h),{},{startAngle:p+C,endAngle:p+O+C});b.push(M),p=M.endAngle}}),I.createElement(ie,null,t.renderSectorsStatically(b))})}},{key:"attachKeyboardHandlers",value:function(t){var r=this;t.onkeydown=function(l){if(!l.altKey)switch(l.key){case"ArrowLeft":{var i=++r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[i].focus(),r.setState({sectorToFocus:i});break}case"ArrowRight":{var f=--r.state.sectorToFocus<0?r.sectorRefs.length-1:r.state.sectorToFocus%r.sectorRefs.length;r.sectorRefs[f].focus(),r.setState({sectorToFocus:f});break}case"Escape":{r.sectorRefs[r.state.sectorToFocus].blur(),r.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var t=this.props,r=t.sectors,l=t.isAnimationActive,i=this.state.prevSectors;return l&&r&&r.length&&(!i||!Qt(i,r))?this.renderSectorsWithAnimation():this.renderSectorsStatically(r)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var t=this,r=this.props,l=r.hide,i=r.sectors,f=r.className,g=r.label,c=r.cx,o=r.cy,j=r.innerRadius,A=r.outerRadius,x=r.isAnimationActive,w=this.state.isAnimationFinished;if(l||!i||!i.length||!Z(c)||!Z(o)||!Z(j)||!Z(A))return null;var m=ye("recharts-pie",f);return I.createElement(ie,{tabIndex:this.props.rootTabIndex,className:m,ref:function(N){t.pieRef=N}},this.renderSectors(),g&&this.renderLabels(i),He.renderCallByParent(this.props,null,!1),(!x||w)&&Xt.renderCallByParent(this.props,i,!1))}}],[{key:"getDerivedStateFromProps",value:function(t,r){return r.prevIsAnimationActive!==t.isAnimationActive?{prevIsAnimationActive:t.isAnimationActive,prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:[],isAnimationFinished:!0}:t.isAnimationActive&&t.animationId!==r.prevAnimationId?{prevAnimationId:t.animationId,curSectors:t.sectors,prevSectors:r.curSectors,isAnimationFinished:!0}:t.sectors!==r.curSectors?{curSectors:t.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(t,r){return t>r?"start":t<r?"end":"middle"}},{key:"renderLabelLineItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);if(ne(t))return t(r);var i=ye("recharts-pie-label-line",typeof t!="boolean"?t.className:"");return I.createElement(Yt,ee({},r,{key:l,type:"linear",className:i}))}},{key:"renderLabelItem",value:function(t,r,l){if(I.isValidElement(t))return I.cloneElement(t,r);var i=l;if(ne(t)&&(i=t(r),I.isValidElement(i)))return i;var f=ye("recharts-pie-label-text",typeof t!="boolean"&&!ne(t)?t.className:"");return I.createElement(zt,ee({},r,{alignmentBaseline:"middle",className:f}),i)}}])})(P.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(s,a){var n=fe(a-s),t=Math.min(Math.abs(a-s),360);return n*t});L(G,"getRealPieData",function(s){var a=s.data,n=s.children,t=he(s,!1),r=ea(n,ta);return a&&a.length?a.map(function(l,i){return R(R(R({payload:l},t),l),r&&r[i]&&r[i].props)}):r&&r.length?r.map(function(l){return R(R({},t),l.props)}):[]});L(G,"parseCoordinateOfPie",function(s,a){var n=a.top,t=a.left,r=a.width,l=a.height,i=aa(r,l),f=t+pe(s.cx,r,r/2),g=n+pe(s.cy,l,l/2),c=pe(s.innerRadius,i,0),o=pe(s.outerRadius,i,i*.8),j=s.maxRadius||Math.sqrt(r*r+l*l)/2;return{cx:f,cy:g,innerRadius:c,outerRadius:o,maxRadius:j}});L(G,"getComposedData",function(s){var a=s.item,n=s.offset,t=a.type.defaultProps!==void 0?R(R({},a.type.defaultProps),a.props):a.props,r=xe.getRealPieData(t);if(!r||!r.length)return null;var l=t.cornerRadius,i=t.startAngle,f=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),m=xe.parseDeltaAngle(i,f),b=Math.abs(m),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
3
  the props "valueKey" will be deprecated in 1.1.0`),N=j);var p=r.filter(function(d){return X(d,N,0)!==0}).length,h=(b>=360?p:p-1)*g,u=b-p*x-h,v=r.reduce(function(d,k){var y=X(k,N,0);return d+(Z(y)?y:0)},0),C;if(v>0){var S;C=r.map(function(d,k){var y=X(d,N,0),D=X(d,o,k),O=(Z(y)?y:0)/v,M;k?M=S.endAngle+fe(m)*g*(y!==0?1:0):M=i;var _=M+fe(m)*((y!==0?x:0)+O*u),E=(M+_)/2,V=(w.innerRadius+w.outerRadius)/2,q=[{name:D,value:y,payload:d,dataKey:N,type:A}],st=Ae(w.cx,w.cy,V,E);return S=R(R(R({percent:O,cornerRadius:l,name:D,tooltipPayload:q,midAngle:E,middleRadius:V,tooltipPosition:st},d),w),{},{value:X(d,N),startAngle:M,endAngle:_,payload:d,paddingAngle:fe(m)*g}),S})}return R(R({},w),{},{sectors:C,data:r})});var va=sa({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:s})=>{const a=De();return e.jsx(ce,{actions:e.jsx(Ce,{variant:"outline",onClick:()=>a("/settings/analytics",{crossApp:!0}),children:"Open settings"}),className:s,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=s=>s==="total-members"||s==="free-members"||s==="paid-members"||s==="mrr",ya=({active:s,payload:a,range:n,color:t,showBreakdown:r})=>{if(!s||!a?.length)return null;const l=a[0].payload,{date:i,formattedValue:f,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:[r&&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||"hsl(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:f})]})]})]})]})},Sa=({chartData:s,totals:a,initialTab:n,currencySymbol:t,isLoading:r,onTabChange:l})=>{const i=ja(n)?n:"total-members",[f,g]=P.useState(i),{range:c}=Te(),{appSettings:o}=je(),j=De(),[A]=Ke();P.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:m,paidMembers:b,mrr:N,percentChanges:p,directions:h}=a,u=P.useMemo(()=>{if(!s||s.length===0)return[];let S=[],d="value";switch(f){case"free-members":d="free";break;case"paid-members":d="paid";break;case"mrr":{d="mrr";break}default:d="value"}S=oe(s,c,d,"exact");let k=[];switch(f){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:J(y.mrr),formattedValue:`${t}${T(J(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},[f,s,c,t]),v={"total-members":{color:"hsl(var(--chart-darkblue))"},"free-members":{color:"hsl(var(--chart-blue))"},"paid-members":{color:"hsl(var(--chart-purple))"},mrr:{color:"hsl(var(--chart-teal))"}};return r?e.jsx("div",{className:"-mb-6 flex h-[calc(16vw+132px)] w-full items-start justify-center",children:e.jsx(rt,{})}):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(ue,{className:o?.paidMembersEnabled?"":"cursor-auto after:hidden",value:"total-members",onClick:()=>{o?.paidMembersEnabled&&x("total-members")},children:e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)})}),o?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{value:"free-members",onClick:()=>{x("free-members")},children:e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)})}),e.jsx(ue,{value:"paid-members",onClick:()=>{x("paid-members")},children:e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)})}),e.jsx(ue,{value:"mrr",onClick:()=>{x("mrr")},children:e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(N))}`})})]})]}),o?.paidMembersEnabled&&e.jsxs(nt,{children:[e.jsx(it,{className:"lg:hidden",asChild:!0,children:e.jsxs(Tt,{children:[f==="total-members"&&e.jsx(Y,{color:"hsl(var(--chart-darkblue))",diffDirection:c===$.allTime.value?"hidden":h.total,diffValue:p.total,label:"Total members",value:T(w)}),f==="free-members"&&e.jsx(Y,{color:"hsl(var(--chart-blue))",diffDirection:c===$.allTime.value?"hidden":h.free,diffValue:p.free,label:"Free members",value:T(m)}),f==="paid-members"&&e.jsx(Y,{color:"hsl(var(--chart-purple))",diffDirection:c===$.allTime.value?"hidden":h.paid,diffValue:p.paid,label:"Paid members",value:T(b)}),f==="mrr"&&e.jsx(Y,{color:"hsl(var(--chart-teal))",diffDirection:c===$.allTime.value?"hidden":h.mrr,diffValue:p.mrr,label:"MRR",value:`${t}${T(J(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[f].color,data:u,dataFormatter:f==="mrr"?S=>`${t}${T(S)}`:T,id:f,range:c,tooltipContent:f==="paid-members"?e.jsx(ya,{color:v["paid-members"].color,range:c,showBreakdown:!0}):void 0})})]})},Aa=(s,a="signups desc",n=50)=>{const{startDate:t,endDate:r,timezone:l}=se(s),i={date_from:W(t),date_to:W(r),member_status:_t(ct),order:a,limit:n.toString()};return l&&(i.timezone=l),Gt({searchParams:i})},Fe=({data:s,currencySymbol:a,limit:n,defaultSourceIconUrl:t})=>{const r=n?s.slice(0,n):s,{appSettings:l}=je();return e.jsx(le,{children:r.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(J(i.mrr))]})]})]},i.source))})},wa=({range:s,limit:a=20,showViewAll:n=!1,sortBy:t,setSortBy:r})=>{const{data:l}=Te(),{data:i}=It(),{appSettings:f}=je(),[g,c]=P.useState("free_members desc"),o=t||g,j=r||c,A=o.replace("free_members","signups").replace("paid_members","paid_conversions"),{data:x,isLoading:w}=Aa(s,A,a),m=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,m),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,m]),h="Top sources",u=`Where did your growth come from ${U(s)}`;return f?.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:f?.paidMembersEnabled?4:2,children:e.jsx(ce,{description:"Try adjusting your date range to see more data.",title:`No conversions ${U(s)}`,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(ut,{children:[e.jsx(mt,{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(ht,{className:"sticky top-0 z-40 -mx-6 bg-background/60 p-6 backdrop-blur",children:[e.jsx(ft,{children:h}),e.jsx(xt,{children:u})]}),e.jsx("div",{className:"group/datalist",children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{children:[e.jsx(H,{children:"Source"}),e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"free_members desc",children:"Free members"})}),f?.paidMembersEnabled&&e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-[110px] text-right",children:e.jsx(te,{activeSortBy:o,setSortBy:j,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{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:f?.paidMembersEnabled?4:2,children:e.jsx(tt,{})})})})},Na=({active:s,payload:a})=>{if(s&&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:s,range:a})=>{const{data:n}=Ft(),{data:t}=Lt({searchParams:{date_from:W(se(a).startDate)}}),{data:{tiers:r=[]}={}}=Vt(),[l,i]=P.useState("billing-period"),{startDate:f,endDate:g}=P.useMemo(()=>se(a),[a]),c=P.useMemo(()=>W(f),[f]),o=P.useMemo(()=>W(g),[g]),j=P.useMemo(()=>r.filter(u=>u.type==="paid"&&u.active).map(u=>({id:u.id,name:u.name})),[r]),A=P.useMemo(()=>{if(!t?.stats||t.stats.length===0)return 0;const u=t.stats,v=B(c),C=B(o),S=u.filter(O=>{const M=B(O.date);return M.isSameOrAfter(v)&&M.isSameOrBefore(C)});if(S.length===0)return 0;const d=[...S].sort((O,M)=>new Date(O.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=P.useMemo(()=>{if(!n?.stats)return[];const u=B(c),v=B(o),C=n.stats.filter(d=>{const k=B(d.date);return k.isSameOrAfter(u)&&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,O="url(#gradientPurple)",M="hsl(var(--chart-purple))";return d==="month"?(D="Monthly",O="url(#gradientPurple)",M="hsl(var(--chart-purple))"):d==="year"?(D="Annual",O="url(#gradientTeal)",M="hsl(var(--chart-teal))"):d==="complimentary"&&(D="Complimentary",O="url(#gradientBlue)",M="hsl(var(--chart-blue))"),{id:`cadence-${y}`,name:D,count:k,fill:O,color:M}})},[n,c,o,A]),w=P.useMemo(()=>{if(!n?.stats||j.length===0)return[];const u=B(c),v=B(o),C=n.stats.filter(D=>{const O=B(D.date);return O.isSameOrAfter(u)&&O.isSameOrBefore(v)}).reduce((D,O)=>{const M=O.tier;return D[M]||(D[M]=0),D[M]+=O.signups,D},{}),S=[{gradient:"url(#gradientPurple)",solid:"hsl(var(--chart-purple))"},{gradient:"url(#gradientTeal)",solid:"hsl(var(--chart-teal))"},{gradient:"url(#gradientBlue)",solid:"hsl(var(--chart-blue))"},{gradient:"url(#gradientRose)",solid:"hsl(var(--chart-rose))"},{gradient:"url(#gradientOrange)",solid:"hsl(var(--chart-orange))"},{gradient:"url(#gradientGreen)",solid:"hsl(var(--chart-green))"},{gradient:"url(#gradientAmber)",solid:"hsl(var(--chart-amber))"},{gradient:"url(#gradientYellow)",solid:"hsl(var(--chart-yellow))"},{gradient:"url(#gradientDarkblue)",solid:"hsl(var(--chart-darkblue))"},{gradient:"url(#gradientGray)",solid:"hsl(var(--chart-darkgray))"}];return[...j.map(D=>{const O=C[D.id]||0;return{id:D.id,name:D.name,count:O}})].sort((D,O)=>O.count-D.count).map((D,O)=>{const M=O%S.length;return{...D,fill:S[M].gradient,color:S[M].solid}})},[n,j,c,o]),m=l==="billing-period"?x:w,b=P.useMemo(()=>m.reduce((u,v)=>u+v.count,0),[m]),N=P.useMemo(()=>{const u={count:{label:"Subscriptions"}};return m.forEach(v=>{u[v.id]={label:v.name,color:v.color}}),u},[m]),p=P.useMemo(()=>b===0?[]:m.map(u=>({label:u.name,count:u.count,percentage:u.count/b*100,color:u.color})),[m,b]);if(s||!n?.stats)return null;const h=m.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(Pe,{children:["New paid subscriptions ",U(a)]})]}),j.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:l,onValueChange:u=>i(u),children:[e.jsx(Qe,{className:"w-full",children:e.jsx(Xe,{})}),e.jsxs(Je,{align:"end",children:[e.jsx(we,{value:"billing-period",children:"Billing period"}),e.jsx(we,{value:"tiers",children:"Tiers"})]})]})})]})}),e.jsx(ge,{children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ue,{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:"hsl(var(--chart-purple))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-teal))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-rose))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-blue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-orange))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-green))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-amber))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-yellow))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-darkblue))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(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:"hsl(var(--chart-darkgray))",stopOpacity:.8}),e.jsx("stop",{offset:"100%",stopColor:"hsl(var(--chart-darkgray))",stopOpacity:.6})]})]}),e.jsx(We,{content:e.jsx(Na,{}),cursor:!1}),e.jsx(G,{animationBegin:0,animationDuration:1e3,data:m,dataKey:"count",innerRadius:70,nameKey:"name",strokeWidth:5,children:e.jsx(He,{content:({viewBox:u})=>{if(u&&"cx"in u&&"cy"in u)return e.jsxs("text",{dominantBaseline:"middle",textAnchor:"middle",x:u.cx,y:u.cy,children:[e.jsx("tspan",{className:"fill-foreground text-2xl font-semibold tracking-tight",x:u.cx,y:u.cy,children:T(b)}),e.jsx("tspan",{className:"fill-muted-foreground",x:u.cx,y:(u.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(u=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"size-2 rounded-full opacity-50",style:{backgroundColor:u.color}}),e.jsx("span",{className:"max-w-[150px] truncate whitespace-nowrap",title:u.label,children:u.label}),e.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(Number(u.percentage)||0),"%"]})]},u.label))})]}):e.jsx("div",{className:"py-12",children:e.jsx(ce,{description:`No new paid subscriptions ${U(a)}.`,title:"No new subscribers",children:e.jsx(la,{strokeWidth:1.5})})})})]})},Ca=(s,a,n)=>{if(a===1){const o=B().format("YYYY-MM-DD"),j=s.find(A=>A.date===o);return[{date:o,signups:j?.signups||0,cancellations:j?.cancellations||0}]}const{startDate:t,endDate:r}=se(a),l=B(r).diff(B(t),"days"),i=bt(a,l,"sum",n),f=new Map(s.map(o=>[o.date,o])),g=[],c=new Set;if(i==="monthly"){const o=B(t).startOf("month"),j=B(r).startOf("month");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.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(r).startOf("week");for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD");if(!c.has(A)){c.add(A);const x=f.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(r);for(;o.isSameOrBefore(j);){const A=o.format("YYYY-MM-DD"),x=f.get(A);x?g.push(x):g.push({date:A,signups:0,cancellations:0}),o.add(1,"day")}}return g},at=s=>{if(s===-1){const{startDate:a,endDate:n}=se(s);return B(n).diff(B(a),"days")}return s},Ta=s=>{const a=at(s);return a<30?["daily"]:a>=91?["weekly","monthly"]:["daily","weekly"]},Le=s=>{const a=at(s);return a<30?"daily":a>=91?"monthly":"weekly"},_a=({subscriptionData:s,memberData:a,range:n,isLoading:t})=>{const[r,l]=P.useState(()=>Le(n));P.useEffect(()=>{l(Le(n))},[n]);const i=P.useMemo(()=>Ta(n),[n]),f=P.useMemo(()=>{switch(r){case"daily":return"none";case"weekly":return"weekly";case"monthly":return"monthly"}},[r]),g=P.useMemo(()=>{if(s&&s.length>0){if(n===1){const h=B().format("YYYY-MM-DD"),u=s.find(v=>v.date===h);return[{date:z(h,n),rawDate:h,new:u?.signups||0,cancelled:-(u?.cancellations||0)}]}const x=oe(s,n,"signups","sum",f),w=oe(s,n,"cancellations","sum",f),m=new Map(w.map(h=>[h.date,h])),b=x.map(h=>({date:h.date,signups:h.signups||0,cancellations:m.get(h.date)?.cancellations||0})),N=new Set(b.map(h=>h.date));return w.forEach(h=>{N.has(h.date)||b.push({date:h.date,signups:0,cancellations:h.cancellations||0})}),b.sort((h,u)=>new Date(h.date).getTime()-new Date(u.date).getTime()),Ca(b,n,f).map(h=>{let u=n;return r==="weekly"&&n<91?u=91:r==="monthly"&&n<365&&(u=365),{date:z(h.date,u),rawDate:h.date,new:h.signups||0,cancelled:-(h.cancellations||0)}})}else{if(!a||a.length===0)return[];if(n===1){const p=B().format("YYYY-MM-DD"),h=a.find(u=>u.date===p);return[{date:z(p,n),rawDate:p,new:h?.paid_subscribed||0,cancelled:-(h?.paid_canceled||0)}]}const x=oe(a,n,"paid_subscribed","sum",f),w=oe(a,n,"paid_canceled","sum",f),m=new Map(w.map(p=>[p.date,p])),b=x.map(p=>({date:p.date,paid_subscribed:p.paid_subscribed||0,paid_canceled:m.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,h)=>new Date(p.date).getTime()-new Date(h.date).getTime()),b.map(p=>{let h=n;return r==="weekly"&&n<91?h=91:r==="monthly"&&n<365&&(h=365),{date:z(p.date,h),rawDate:p.date,new:p.paid_subscribed||0,cancelled:-(p.paid_canceled||0)}})}},[a,s,n,f,r]),c={new:{label:"New",color:"hsl(var(--chart-teal))"},cancelled:{label:"Cancelled",color:"hsl(var(--chart-rose))"}},o=P.useMemo(()=>{const x=g.reduce((m,b)=>m+b.new,0),w=g.reduce((m,b)=>m+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(Pe,{children:["New and cancelled paid subscriptions ",U(n)]})]}),i.length>1&&e.jsx("div",{children:e.jsxs(qe,{value:r,onValueChange:x=>l(x),children:[e.jsx(Qe,{className:"w-[110px]",children:e.jsx(Xe,{})}),e.jsx(Je,{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(Ue,{className:"aspect-auto h-[200px] w-full md:h-[220px] xl:h-[260px]",config:c,children:e.jsxs(kt,{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:"hsl(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(na,{className:"!min-w-[120px] px-3 py-2",formatter:(x,w,m,b)=>{const N=Number(x);let p="0";N===0?p="0":p=N<0?T(N*-1):T(N);const h=Number(m?.payload?.new||0),u=Number(m?.payload?.cancelled||0),v=h+u,C=v===0?"0":v>0?`+${T(v)}`:T(v);let S=m?.payload?.date;return m?.payload?.rawDate&&(r==="monthly"?S=z(m.payload.rawDate,366):r==="weekly"?S=z(m.payload.rawDate,91):S=z(m.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 tabular-nums text-foreground",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 tabular-nums text-foreground",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 ${U(n)}.`,title:"No paid member changes",children:e.jsx(ca,{strokeWidth:1.5})})})})]})},ka=(s,a,n)=>{const t=s??30,r=a??"mrr desc",{startDate:l,endDate:i}=P.useMemo(()=>se(t),[t]),f=P.useMemo(()=>{const o={date_from:W(l),date_to:W(i),order:r};return n==="posts"?o.post_type="post":n==="pages"&&(o.post_type="page"),o},[l,i,r,n]),g=Object.fromEntries(Object.entries(f).filter(([,o])=>o!==void 0));return Kt({searchParams:g})},ps=()=>{const{range:s,site:a,settings:n}=Te(),t=String(n.find(d=>d.key==="timezone")?.value||"Etc/UTC"),r=De(),[l,i]=P.useState("free_members desc"),[f,g]=P.useState(Q.POSTS_AND_PAGES),[c]=Ke(),{appSettings:o}=je(),j=c.get("tab")||"total-members",[A,x]=P.useState(j);P.useEffect(()=>{j!==A&&x(j)},[j]);const{isLoading:w,chartData:m,totals:b,currencySymbol:N,subscriptionData:p}=ua(s),{data:h,isLoading:u}=ka(s,l,f),v=P.useMemo(()=>{const k=(h?.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),O=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")&&O>0?E=_.paid_members/O: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}})},[h,l]),C=w,S=w||u;return e.jsxs(gt,{children:[e.jsx(vt,{children:e.jsx($t,{children:e.jsx(jt,{})})}),e.jsxs(yt,{data:C?void 0:m,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:m,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:m,range:s,subscriptionData:p}),e.jsx(Da,{isLoading:C,range:s})]}),e.jsxs(be,{className:"w-full overflow-x-auto","data-testid":"top-content-card",children:[e.jsxs(_e,{children:[e.jsx(ke,{children:Ot(f)}),e.jsx(Pe,{children:Mt(f,s,U)})]}),e.jsx(ge,{children:e.jsxs(Ye,{children:[e.jsx(ze,{children:e.jsxs(K,{className:"[&>th]:h-auto [&>th]:pb-2 [&>th]:pt-0",children:[e.jsx(H,{className:"min-w-[320px] pl-0",children:e.jsx(Ve,{defaultValue:f,variant:"button-sm",onValueChange:d=>{g(d)},children:e.jsxs($e,{children:[e.jsx(me,{value:Q.POSTS_AND_PAGES,children:"Posts & pages"}),e.jsx(me,{value:Q.POSTS,children:"Posts"}),e.jsx(me,{value:Q.PAGES,children:"Pages"}),e.jsx(me,{value:Q.SOURCES,children:"Sources"})]})})}),e.jsx(H,{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(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"paid_members desc",children:"Paid members"})}),e.jsx(H,{className:"w-[140px] text-right",children:e.jsx(te,{activeSortBy:l,setSortBy:i,sortBy:"mrr desc",children:"MRR impact"})})]})]})}),f===Q.SOURCES?e.jsx(wa,{limit:20,range:s,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 whitespace-normal p-0 text-left font-medium leading-tight hover:!underline",title:"View post analytics",variant:"link",onClick:Rt(d.attribution_url,d.post_id,a.url||"",r,d.attribution_type),children:d.title}):e.jsx("span",{className:"font-medium",children:d.title}),d.published_at&&Oe&&new Date(d.published_at).getTime()>0&&e.jsxs("span",{className:"text-muted-foreground",children:["Published on ",Oe(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(J(d.mrr))]})]})]},`${f}-${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 ${U(s)}`,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{ps as default};
@@ -1,4 +1,4 @@
1
- import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bu as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bm as bn,bn as he}from"./index-BeAhXwae.js";import{M as me}from"./minus-vbx9q5AE.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-DYKurQBy.js";import{T as xe}from"./topic-filter-Is3xj8qt.js";import{E as vn}from"./empty-indicator-1p7S45xr.js";import{I as yn}from"./inbox-BMxFzv7J.js";import"./trash-CT37Asdf.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
1
+ import{r as o,j as n,cq as Cn,cr as Sn,B as A,ch as Wn,ct as zn,cs as Kn,e as rn,cV as Vn,b as En,d1 as gn,S as E,P as Yn,A as Qn,h as Zn,g as fn,d as Jn,n as Xn,bu as Gn,f as pn,F as an,i as on,d2 as ne,o as ee,a as te,u as ae,p as oe,L as re,aR as ie,D as de,t as ce,v as se,w as le,a9 as ge,d3 as pe,d4 as ue,bm as bn,bn as he}from"./index-exFCQBCk.js";import{M as me}from"./minus-D2C19Fiu.js";import{u as ke,D as fe,A as be,S as xn}from"./deleted-feed-item-D8BHDEHh.js";import{T as xe}from"./topic-filter-Cn1_Z9I7.js";import{E as vn}from"./empty-indicator-SsCyCd50.js";import{I as yn}from"./inbox-DuT2edmx.js";import"./trash-ln90Rlgi.js";const un=["1.5rem","1.6rem","1.7rem","1.8rem","2rem"],U={BACKGROUND_COLOR:"ghost-ap-background-color",FONT_SIZE:"ghost-ap-font-size",FONT_STYLE:"ghost-ap-font-style"},P={SYSTEM:{id:"system",color:"#fff",background:"bg-white dark:bg-black",button:"bg-white dark:bg-black",border:"border-black/[8%] dark:border-gray-950"},SEPIA:{id:"sepia",color:"#FCF8F1",background:"bg-[#FCF8F1]",button:"bg-[#FCF8F1] hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%]"},LIGHT:{id:"light",color:"#fff",background:"bg-white",button:"hover:bg-black/[3%] text-black hover:text-black",border:"border-black/[8%] dark:border-gray-950"},DARK:{id:"dark",color:"#15171a",background:"bg-black",button:"text-white dark:bg-black dark:hover:bg-gray-900",border:"border-black/[8%] dark:border-gray-950"}},ve=()=>{const[a,s]=o.useState(()=>localStorage.getItem(U.BACKGROUND_COLOR)?.toUpperCase()||"SYSTEM"),[t,p]=o.useState(()=>{const r=localStorage.getItem(U.FONT_SIZE);return r?parseInt(r):2}),[c,k]=o.useState(()=>localStorage.getItem(U.FONT_STYLE)||"sans"),i=r=>{s(r),localStorage.setItem(U.BACKGROUND_COLOR,P[r].id)};return o.useEffect(()=>{localStorage.setItem(U.FONT_SIZE,t.toString())},[t]),o.useEffect(()=>{localStorage.setItem(U.FONT_STYLE,c)},[c]),{backgroundColor:a,currentFontSizeIndex:t,fontStyle:c,handleColorChange:i,setFontStyle:k,increaseFontSize:()=>{p(r=>Math.min(r+1,un.length-1))},decreaseFontSize:()=>{p(r=>Math.max(r-1,0))},resetFontSize:()=>p(2),fontSize:un[t]}},wn=({backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,onColorChange:p,onFontStyleChange:c,onDecreaseFontSize:k,onIncreaseFontSize:i,onResetFontSize:u,onOpenChange:v})=>{const h=l=>a===l,r=l=>t===l;return n.jsx(ye,{backgroundColor:a,currentFontSizeIndex:s,fontStyle:t,isActiveColor:h,isActiveFont:r,onColorChange:p,onDecreaseFontSize:k,onFontStyleChange:c,onIncreaseFontSize:i,onOpenChange:v,onResetFontSize:u})},ye=({backgroundColor:a,isActiveColor:s,isActiveFont:t,onColorChange:p,onFontStyleChange:c,currentFontSizeIndex:k,onDecreaseFontSize:i,onIncreaseFontSize:u,onResetFontSize:v,onOpenChange:h})=>n.jsxs(Cn,{modal:!1,onOpenChange:h,children:[n.jsx(Sn,{asChild:!0,children:n.jsx(A,{className:`size-9 rounded-full ${P[a].button}`,variant:"ghost",children:n.jsx(Wn.Typography,{className:"!size-[18px]"})})}),n.jsx(zn,{align:"end",className:"w-[224px]",onCloseAutoFocus:r=>r.preventDefault(),onOpenAutoFocus:r=>r.preventDefault(),children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-gray-200 p-0 text-[1.1rem] text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px] ${s("SYSTEM")?"outline outline-2 outline-green":""}`,variant:"secondary",onClick:()=>p("SYSTEM"),children:"Auto"}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-[#ece6d9] p-0 hover:bg-[#ece6d9] ${s("SEPIA")?"outline outline-2 outline-green":"border border-[#ece6d9]"}`,onClick:()=>p("SEPIA")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-white p-0 hover:bg-white ${s("LIGHT")?"outline outline-2 outline-green":"border border-gray-200"}`,onClick:()=>p("LIGHT")}),n.jsx(A,{className:`h-7 flex-1 rounded-[6px] bg-black p-0 hover:bg-black dark:border dark:border-gray-925 ${s("DARK")?"outline outline-2 outline-green":""}`,onClick:()=>p("DARK")})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("sans")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("sans"),children:[n.jsx("span",{className:"text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"text-[1.1rem]",children:"System"})]}),n.jsxs(A,{className:`flex h-auto w-full flex-col gap-1 rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 ${t("serif")&&"outline outline-2 outline-green"}`,variant:"secondary",onClick:()=>c("serif"),children:[n.jsx("span",{className:"pt-1 font-serif text-[2rem] font-bold leading-none",children:"Aa"}),n.jsx("span",{className:"font-serif text-[1.2rem]",children:"Serif"})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===0,variant:"secondary",onClick:i,children:n.jsx(me,{})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900",variant:"secondary",onClick:v,children:n.jsx("span",{className:"text-[1.6rem] font-bold",children:"Aa"})}),n.jsx(A,{className:"h-8 w-full rounded-[6px] bg-gray-200 text-black hover:bg-gray-250 dark:bg-gray-925 dark:text-white dark:hover:bg-gray-900 [&_svg]:size-[14px]",disabled:k===un.length-1,variant:"secondary",onClick:u,children:n.jsx(Kn,{})})]})]})})]}),we=({tocItems:a,iframeElement:s,modalRef:t,className:p="!visible absolute inset-y-0 right-7 z-40 hidden lg:!block",onOpenChange:c})=>{const[k,i]=o.useState(null),u=rn.useRef(!1),v=h=>{if(!s?.contentDocument)return;const r=s.contentDocument.getElementById(h);r&&t.current&&(u.current=!0,i(h),t.current.scrollTo({top:r.offsetTop-20,behavior:"smooth"}),setTimeout(()=>{u.current=!1},1e3))};return o.useEffect(()=>{if(!s?.contentDocument||a.length<=1)return;const h=t.current;if(!h)return;const r=()=>{if(u.current)return;const d=s.contentDocument;if(!d)return;const _=h.scrollTop,F=100,D=a.map(S=>d.getElementById(S.id)).filter(S=>S!==null).map(S=>({id:S.id,top:S.offsetTop}));if(!D.length)return;const L=D.reduce((S,M)=>M.top-F<=_?M:S);i(L?.id||null)},l=()=>{requestAnimationFrame(r)};return h.addEventListener("scroll",l),r(),()=>{h.removeEventListener("scroll",l)}},[s,a,t]),a.length<=1?null:n.jsx("div",{className:p,children:n.jsx("div",{className:"sticky top-1/2 -translate-y-1/2",children:n.jsx(Se,{activeHeading:k||"",items:a,onItemClick:v,onOpenChange:c})})})},je={1:"w-3",2:"w-2",3:"w-1"},Ce={1:"pl-2",2:"pl-6",3:"pl-10"},Se=({items:a,activeHeading:s,onItemClick:t,onOpenChange:p})=>{const[c,k]=o.useState(!1),i=rn.useRef();if(rn.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]),a.length===0)return null;const u=d=>Math.min(d,3),v=d=>je[u(d)],h=d=>Ce[u(d)],r=()=>{i.current&&clearTimeout(i.current),k(!0),p?.(!0)},l=()=>{i.current=setTimeout(()=>{k(!1),p?.(!1)},100)};return n.jsxs(Cn,{modal:!1,open:c,onOpenChange:k,children:[n.jsx(Sn,{asChild:!0,children:n.jsx("div",{className:"absolute right-2 top-1/2 flex -translate-y-1/2 flex-col items-end gap-2 rounded-md p-2 text-base dark:bg-black",onMouseEnter:r,onMouseLeave:l,children:a.map(d=>n.jsx("div",{className:`h-[2px] rounded-sm ${s===d.id?"bg-black dark:bg-white":"bg-gray-400 dark:bg-gray-700"} pr-1 transition-all ${v(d.level)}`},d.id))})}),n.jsx(zn,{align:"center",className:"w-[240px] p-2",side:"left",sideOffset:-28,onCloseAutoFocus:d=>d.preventDefault(),onMouseEnter:r,onMouseLeave:l,onOpenAutoFocus:d=>d.preventDefault(),children:n.jsx("nav",{"aria-label":"Table of contents navigation",className:"max-h-[60vh] overflow-y-auto",role:"navigation",children:a.map(d=>n.jsx("button",{className:`line-clamp-2 block w-full cursor-pointer rounded py-1 text-left text-sm leading-tight ${s===d.id?"text-black dark:text-white":"text-gray-700 dark:text-gray-600"} hover:bg-gray-75 hover:text-gray-900 dark:hover:bg-grey-925 dark:hover:text-white ${h(d.level)}`,type:"button",onClick:()=>t(d.id),children:n.jsx("span",{className:"line-clamp-2",children:d.text})},d.id))})})]})},ze=()=>`<style>
2
2
 
3
3
  /* Variables */
4
4
 
@@ -1 +1 @@
1
- import{j as t,bq as F,e as u,b as g,br as T,r as j,bm as z,bn as E,L as S,E as M,c as P,bs as U,S as w,A as $,B as L,be as B,n as C,h as v,d as W,s as _,bt as D,bu as H,f as O,P as q}from"./index-BeAhXwae.js";import{A as V}from"./at-sign-BpRvqAQI.js";import{R as G,U as K}from"./user-round-check-C5Iux98g.js";import{R as Q}from"./reply-DlcWrPL1.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",o=l==="sm"?13:20,c=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:o,strokeWidth:c}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:c}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:o,strokeWidth:c}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:o,strokeWidth:c}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:o,strokeWidth:c}),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"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere 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 o=`_${te(s.createdAt)}`,c=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${o}${c}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${o}${c}`);break;case"follow":n=`follow_${o}${c}`;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(),o=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:c=>{c?.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:[o," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[o," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[o," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return o;break;case"mention":return o}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 o=c=>{const y=c.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(c.preventDefault(),c.stopPropagation(),v(x,s))}};return n.addEventListener("click",o),()=>{n.removeEventListener("click",o)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},oe=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:o,error:c,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=T("index"),k=o?.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 c&&z(c)?t.jsx(E,{errorCode:c.code,statusCode:c.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 -bottom-1 -right-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(L,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${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(B,{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 flex items-center justify-between gap-4 break-anywhere",onClick:A=>{A?.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-pretty text-sm 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 space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{oe as default};
1
+ import{j as t,bq as F,e as u,b as g,br as T,r as j,bm as z,bn as E,L as S,E as M,c as P,bs as U,S as w,A as $,B as L,be as B,n as C,h as v,d as W,s as _,bt as D,bu as H,f as O,P as q}from"./index-exFCQBCk.js";import{A as V}from"./at-sign-Cj4_ORaa.js";import{R as G,U as K}from"./user-round-check-CYI147XP.js";import{R as Q}from"./reply-CuCJJfZj.js";const I=({notificationType:a,size:l="lg",className:i})=>{let r,s="";const n="white",o=l==="sm"?13:20,c=l==="sm"?2:1.5;switch(a){case"follow":r=t.jsx(K,{className:`-mr-0.5 -mt-0.5 ${l==="sm"&&"size-[11px]"}`,color:n,size:o,strokeWidth:c}),s="bg-blue-600";break;case"like":r=t.jsx(F,{className:`${l==="sm"?"size-[11px]":"mt-px size-5"}`,color:n,strokeWidth:c}),s="bg-pink-600";break;case"reply":r=t.jsx(Q,{className:"mb-px mr-px",color:n,size:o,strokeWidth:c}),s="bg-purple-600";break;case"repost":r=t.jsx(G,{color:n,size:o,strokeWidth:c}),s="bg-green-500";break;case"mention":r=t.jsx(V,{className:`${l==="sm"?"size-[12px]":"size-5"}`,color:n,size:o,strokeWidth:c}),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"} cursor-pointer grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 rounded-lg px-4 py-5 text-left break-anywhere 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 o=`_${te(s.createdAt)}`,c=`_seq${r}`;switch(s.type){case"like":s.post?.id&&(n=`like_${s.post.id}${o}${c}`);break;case"reply":n=`reply_${s.id}`;break;case"repost":s.post?.id&&(n=`repost_${s.post.id}${o}${c}`);break;case"follow":n=`follow_${o}${c}`;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(),o=t.jsxs(t.Fragment,{children:[t.jsx(q,{actor:l,align:"center",isCurrentUser:!1,children:t.jsx("span",{className:s,onClick:c=>{c?.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:[o," followed you"]});case"like":return t.jsxs(t.Fragment,{children:[o," liked your ",a.post?.type==="article"?"post":"note"]});case"repost":return t.jsxs(t.Fragment,{children:[o," reposted your ",a.post?.type==="article"?"post":"note"]});case"reply":if(a.inReplyTo&&typeof a.inReplyTo!="string")return o;break;case"mention":return o}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 o=c=>{const y=c.target.closest("a[data-profile]");if(y){const x=y.getAttribute("data-profile")?.trim();/^@([\w.-]+)@([\w-]+\.[\w.-]+[a-zA-Z])$/.test(x||"")&&x&&(c.preventDefault(),c.stopPropagation(),v(x,s))}};return n.addEventListener("click",o),()=>{n.removeEventListener("click",o)}},[s,a]),t.jsx("div",{dangerouslySetInnerHTML:{__html:_(a||"",i)},ref:r,className:l})},oe=()=>{const[a,l]=u.useState({}),i=g(),r=e=>{l(d=>({...d,[e]:!d[e]}))},s=()=>{},n=5,{data:o,error:c,fetchNextPage:f,hasNextPage:y,isFetchingNextPage:x,isLoading:b}=T("index"),k=o?.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 c&&z(c)?t.jsx(E,{errorCode:c.code,statusCode:c.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 -bottom-1 -right-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(L,{className:`group flex items-center gap-0.5 text-gray-700 hover:bg-transparent hover:text-black dark:text-gray-600 dark:hover:text-white ${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(B,{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 flex items-center justify-between gap-4 break-anywhere",onClick:A=>{A?.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-pretty text-sm 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 space-y-4 text-center",children:t.jsx(O,{size:"md"})})]})]})})};export{oe as default};
@@ -1 +1 @@
1
- import{aP as Y,r as _,bV as C,bW as W,j as e,S as j,bR as se,B as T,aT as M,aj as u,y as $,ai as Q,cz as te,aQ as oe,cA as O,e as le,cB as q,cC as ce,bE as de,cD as X,bK as me,cE as ue,af as pe,ag as z,aW as I,_ as xe,aX as he}from"./index-BeAhXwae.js";import{g as H,S as ge,a as fe,D as be,b as je}from"./stats-view-XXduvFiP.js";import{C as D,a as E,b as F,f as R,c as V,E as ve,K as Ne,d as we,e as ye,u as ke,j as _e}from"./pagemenu-aMfaU2cA.js";import{E as P}from"./empty-indicator-1p7S45xr.js";import{P as Ce}from"./post-share-modal-CP1NDQhS.js";import{g as Ae,c as Te}from"./post-helpers-gInwAwEv.js";import{S as Le,U as ae}from"./wallet-cards-Hfikexmn.js";import{C as ze,h as K,d as Me,i as We,L as $e,j as J,k as Z,l as De}from"./lucide-react-CTYGYE5A.js";import{G as B}from"./gh-chart-CVItDGhq.js";import{g as Ee}from"./audience-DyCuv1si.js";import{u as Fe}from"./use-growth-stats-DXoeaAKq.js";import{u as Re}from"./posts-BQJit53V.js";import{h as Ve,i as Ue}from"./stats-C2A4PNUn.js";import"./select-wir-gl-P.js";import"./message-square-text-42zfcaLO.js";import"./sprout-Beunj00B.js";import"./a-large-small-CCJbivJB.js";import"./at-sign-BpRvqAQI.js";import"./copy-BywnwlHN.js";import"./hash-BQl75WLf.js";import"./inbox-BMxFzv7J.js";import"./minus-vbx9q5AE.js";import"./tags-dgsPPBjR.js";import"./square-DTB79BvA.js";import"./user-round-check-C5Iux98g.js";import"./repeat-DBbPJ4Vq.js";import"./reply-DlcWrPL1.js";import"./trash-CT37Asdf.js";import"./chart-BvckKrZJ.js";import"./_baseAssignValue-DKQ9pw63.js";import"./currency-fEUUCkj0.js";const Ie=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Be=({latestPostStats:s,isLoading:o})=>{const t=Y(),[r,i]=_.useState(!1),{site:n,settings:x}=C(),{appSettings:l}=W(),{emailTrackClicks:c,emailTrackOpens:h}=l?.analytics||{},m=n.title||String(x.find(g=>g.key==="title")?.value||"Ghost Site"),a=String(x.find(g=>g.key==="timezone")?.value||"Etc/UTC"),d=s?Ae(s,{membersTrackSources:l?.analytics.membersTrackSources}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer";return e.jsxs(D,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs(E,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(R,{className:"hidden",children:"How your last post did"})]}),e.jsxs(V,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(j,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(j,{className:"w-full max-w-[420px]"}),e.jsx(j,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]})]})})]}),!o&&s&&d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!o&&s&&t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(g=>g.name).join(", ")," – ",se(s.published_at,a)]}),e.jsx("div",{className:"mt-0.5",children:Ie(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ce,{author:s.authors?.map(g=>g.name).join(", ")||"",description:"",faviconURL:n.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:m,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(T,{onClick:()=>i(!0),children:[e.jsx(Le,{})," Share post"]})}),e.jsxs(T,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:[e.jsx(ze,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[d.showWebMetrics&&l?.analytics.webAnalytics&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{t(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:u(s.visitors)})]}),d.showMemberGrowth&&e.jsxs("div",{className:$(b,d.showEmailMetrics&&(!d.showWebMetrics||!l?.analytics.webAnalytics)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{t(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ae,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",u(s.member_delta)]}):0})]}),d.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(K,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),c&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(Me,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!o&&e.jsx(P,{actions:e.jsx(T,{variant:"secondary",onClick:()=>{t("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},Ge=()=>{const{data:s}=C();return{isLimited:t=>{const r=s?.config;return r?.hostSettings?.limits&&t==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},G=({title:s,iconName:o,description:t,color:r,diffDirection:i,diffValue:n,formattedValue:x,trendingFromValue:l,children:c,onClick:h})=>{const{range:m}=C(),a=o&&$e[o],d=le.useMemo(()=>{if(!i||i==="empty"||m===q.allTime.value||!n)return"";const b=i==="up"?"up":i==="down"?"down":"at",N=H(m).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:x})," compared to the ",e.jsx("span",{className:"font-semibold",children:N})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[b," ",n]})," from ",e.jsx("span",{className:"font-semibold",children:l})," compared to the ",N]})},[i,n,l,x,m]);return e.jsxs(D,{className:"group","data-testid":s,children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(R,{children:t})]}),e.jsxs(Ne,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(we,{className:h&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),a&&e.jsx(a,{size:16,strokeWidth:1.5}),s]}),e.jsx(ye,{diffDirection:m===q.allTime.value?"hidden":i,diffTooltip:d,diffValue:n,value:x})]}),h&&e.jsx(T,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:h,children:"View more"})]}),e.jsx(V,{children:c})]})},Se=({kpiValues:s,visitorsChartData:o,visitorsYRange:t,growthTotals:r,membersChartData:i,mrrChartData:n,currencySymbol:x,isLoading:l})=>{const c=Y(),{range:h}=C(),{appSettings:m}=W(),d=Ge().isLimited("limitAnalytics"),b="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(l)return e.jsx(ve,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(oe,{})});const g=m?.analytics.webAnalytics,N=d&&!g,y=!0,L=m?.paidMembersEnabled,w=[g,N,y,L].filter(Boolean).length;let A="lg:grid-cols-3";w===2?A="lg:grid-cols-2":w===1&&(A="lg:grid-cols-1");const U=`flex flex-col lg:grid ${A} gap-6`;return e.jsxs("div",{className:U,children:[g&&!N&&e.jsx(G,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{c("/analytics/web/")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-blue))",data:o,id:"visitors",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:t})}),N&&e.jsxs(D,{children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(R,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(V,{className:"flex h-full items-center justify-center p-6",children:e.jsx(P,{actions:e.jsx(T,{variant:"outline",onClick:()=>c("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx(We,{})})})]}),e.jsx(G,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:u(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${u(i[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=total-members")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),L&&e.jsx(G,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${x}${u(O(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${x}${u(n[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=mrr")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-teal))",data:n,id:"mrr",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},Oe=({className:s})=>e.jsx("div",{className:$("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(ce,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),S=({className:s,metrics:o,title:t})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:$("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),He=({topPostsData:s,isLoading:o})=>{const t=Y(),{range:r,settings:i}=C(),{appSettings:n}=W(),x=String(i.find(a=>a.key==="timezone")?.value||"Etc/UTC"),l=n?.analytics.webAnalytics,c=n?.analytics.emailTrackClicks,h=n?.analytics.emailTrackOpens,m="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs(D,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs(E,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",H(r)]}),e.jsx(R,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(V,{children:o?e.jsx(de,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(a=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{t(`/posts/analytics/${a.post_id}`,{crossApp:!0})},children:[a.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${a.feature_image})`}}):e.jsx(Oe,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:a.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",a.authors," – ",se(a.published_at,x)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Te(a)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/web`,{crossApp:!0})},children:[e.jsx(S,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:u(a.views)}],title:"Web traffic"}),e.jsxs("div",{className:m,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.views)]})]}),a.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(S,{className:`${n?.analytics.membersTrackSources?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(J,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:u(a.sent_count||0)},...h?[{icon:e.jsx(K,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:u(a.opened_count||0)}]:[],...c?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:u(a.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:m,children:h?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.open_rate?`${Math.round(a.open_rate)}%`:"0%"]}):c?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.click_rate?`${Math.round(a.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.sent_count||0)]})})]}),n?.analytics.membersTrackSources&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/growth`,{crossApp:!0})},children:[e.jsx(S,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(me,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:a.free_members>0?`+${u(a.free_members)}`:"0"},...n?.paidMembersEnabled?[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:a.paid_members>0?`+${u(a.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:m,children:[e.jsx(ae,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.members>0?`+${u(a.members)}`:"0"]})]})]})]},a.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(P,{className:"w-full pb-10",title:`No posts ${H(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ke=()=>{const{data:{posts:[s]}={posts:[]},isLoading:o}=Re({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),t=s,r=Ve(t?.id||"",{enabled:!!t?.id}),{data:i,isLoading:n}=r;return{data:_.useMemo(()=>{if(!t)return null;const l=i?.stats?.[0]||{id:t.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:t.id,uuid:t.uuid,title:t.title||"",slug:t.slug||"",feature_image:t.feature_image||null,published_at:t.published_at||"",url:t.url||"",excerpt:t.excerpt||"",email_only:t.email_only||!1,status:t.status,email:t.email,count:t.count,authors:t.authors||[],recipient_count:l.recipient_count,opened_count:l.opened_count,open_rate:l.open_rate,member_delta:l.member_delta,free_members:l.free_members,paid_members:l.paid_members,visitors:l.visitors,click_rate:null}},[t,i]),isLoading:o||!!t?.id&&n}},ee=({className:s,title:o,description:t,url:r,children:i})=>e.jsx("a",{className:$("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:o}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:t})]})]})}),ks=()=>{const{appSettings:s}=W(),{statsConfig:o,isLoading:t,range:r}=C(),{startDate:i,endDate:n,timezone:x}=pe(r),{isLoading:l,chartData:c,totals:h,currencySymbol:m}=Fe(r),{data:a,isLoading:d}=Ke(),{data:b,isLoading:g}=Ue({searchParams:{date_from:z(i),date_to:z(n),limit:"5",timezone:x}}),N={site_uuid:o?.id||"",date_from:z(i),date_to:z(n),timezone:x,member_status:Ee(he)},{data:y,loading:L}=ke({endpoint:"api_kpis",statsConfig:o,params:N}),w=_.useMemo(()=>I(y||[],r,"visits","sum")?.map(f=>{const v=Number(f.visits),k=isNaN(v)?0:v;return{date:String(f.date),value:k,formattedValue:u(k),label:"Visitors"}}),[y,r]),A=_.useMemo(()=>{const f=[0,1];if(!w||w.length===0)return f;const v=w.map(p=>p.value).filter(p=>p>=0);return v.length===0?f:[0,Math.max(...v)||f[1]]},[w]),U=_.useMemo(()=>{if(!c||c.length===0)return[];let f=[];return f=I(c,r,"value","exact"),f.map(p=>({date:p.date,value:p.free+p.paid,formattedValue:u(p.free+p.paid),label:"Members"}))},[c,r]),re=_.useMemo(()=>{if(!s?.paidMembersEnabled||!c||c.length===0)return[];let f=[];return f=I(c,r,"mrr","exact"),f.map(p=>({date:p.date,value:O(p.mrr),formattedValue:`${m}${u(O(p.mrr))}`,label:"MRR"}))},[c,r,m,s]),ie=_.useMemo(()=>{if(!y?.length)return{visits:"0"};const f=y.reduce((v,k)=>{const p=Number(k.visits);return v+(isNaN(p)?0:p)},0);return{visits:u(f)}},[y]),ne=t;return e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsx(_e,{children:e.jsx(be,{excludeRanges:["today"]})})}),e.jsxs(je,{isLoading:ne,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Se,{currencySymbol:m,growthTotals:h,isLoading:L||l,kpiValues:ie,membersChartData:U,mrrChartData:re,visitorsChartData:w,visitorsYRange:A}),e.jsx(Be,{isLoading:d,latestPostStats:a}),e.jsx(He,{isLoading:g,topPostsData:b}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(xe,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(De,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{ks as default};
1
+ import{aP as Y,r as _,bV as C,bW as W,j as e,S as j,bR as se,B as T,aT as M,aj as u,y as $,ai as Q,cz as te,aQ as oe,cA as O,e as le,cB as q,cC as ce,bE as de,cD as X,bK as me,cE as ue,af as pe,ag as z,aW as I,_ as xe,aX as he}from"./index-exFCQBCk.js";import{g as H,S as ge,a as fe,D as be,b as je}from"./stats-view-BwaLDryw.js";import{C as D,a as E,b as F,f as R,c as V,E as ve,K as Ne,d as we,e as ye,u as ke,j as _e}from"./pagemenu-DlQF5jN4.js";import{E as P}from"./empty-indicator-SsCyCd50.js";import{P as Ce}from"./post-share-modal-CnM21JFK.js";import{g as Ae,c as Te}from"./post-helpers-gInwAwEv.js";import{S as Le,U as ae}from"./wallet-cards-xpilOd6G.js";import{C as ze,h as K,d as Me,i as We,L as $e,j as J,k as Z,l as De}from"./lucide-react-f58FO8MB.js";import{G as B}from"./gh-chart-Dp9VXeON.js";import{g as Ee}from"./audience-ACTBvUSt.js";import{u as Fe}from"./use-growth-stats-DQsJauHH.js";import{u as Re}from"./posts-C5zAbpdG.js";import{h as Ve,i as Ue}from"./stats-C4LbW8IV.js";import"./select-Bv-dkHeU.js";import"./message-square-text-6dTKbQKA.js";import"./sprout-jOQR37se.js";import"./a-large-small-BLquRSNr.js";import"./at-sign-Cj4_ORaa.js";import"./copy-YhtJexiS.js";import"./hash-CPAX2PwN.js";import"./inbox-DuT2edmx.js";import"./minus-D2C19Fiu.js";import"./tags-Dnv6zTag.js";import"./square-IrYxuAJL.js";import"./user-round-check-CYI147XP.js";import"./repeat-BbSnXois.js";import"./reply-CuCJJfZj.js";import"./trash-ln90Rlgi.js";import"./chart-B6jk72FT.js";import"./_baseAssignValue-CrCkbXur.js";import"./currency-fEUUCkj0.js";const Ie=s=>s.email_only?"Sent":s.email?"Published and sent":"Published",Be=({latestPostStats:s,isLoading:o})=>{const t=Y(),[r,i]=_.useState(!1),{site:n,settings:x}=C(),{appSettings:l}=W(),{emailTrackClicks:c,emailTrackOpens:h}=l?.analytics||{},m=n.title||String(x.find(g=>g.key==="title")?.value||"Ghost Site"),a=String(x.find(g=>g.key==="timezone")?.value||"Etc/UTC"),d=s?Ae(s,{membersTrackSources:l?.analytics.membersTrackSources}):null,b="group mr-2 flex flex-col gap-1.5 hover:cursor-pointer";return e.jsxs(D,{className:"group/card bg-gradient-to-tr from-muted/40 to-muted/0 to-50%","data-testid":"latest-post",children:[e.jsxs(E,{children:[e.jsx(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:"Latest post performance"}),e.jsx(R,{className:"hidden",children:"How your last post did"})]}),e.jsxs(V,{className:"flex flex-col gap-6 px-0 lg:flex-row xl:grid xl:grid-cols-3",children:[o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex w-full items-center gap-6 px-6 xl:col-span-2",children:[e.jsx("div",{className:"w-full max-w-[232px] grow",children:e.jsx(j,{className:"aspect-[16/10] rounded-md"})}),e.jsxs("div",{className:"w-full grow",children:[e.jsx(j,{className:"w-full max-w-[420px]"}),e.jsx(j,{className:"w-1/2"})]})]}),e.jsx("div",{className:"flex flex-col items-stretch gap-2 px-6 text-sm",children:e.jsxs("div",{className:"grid grid-cols-2 gap-5",children:[e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]}),e.jsxs("div",{children:[e.jsx(j,{className:"w-3/4"}),e.jsx(j,{className:"h-10 w-1/3"})]})]})})]}),!o&&s&&d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-6 px-6 transition-all md:flex-row md:items-start xl:col-span-2",children:[s.feature_image&&e.jsx("div",{className:"aspect-[16/10] w-full min-w-[100px] rounded-sm bg-cover bg-center sm:max-w-[170px] lg:max-w-[170px] xl:max-w-[232px]",style:{backgroundImage:`url(${s.feature_image})`}}),e.jsxs("div",{className:"flex grow flex-col items-start justify-center self-stretch",children:[e.jsx("div",{className:"text-lg font-semibold leading-tighter tracking-tight hover:cursor-pointer hover:opacity-75",onClick:()=>{!o&&s&&t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:s.title}),e.jsxs("div",{className:"mt-0.5 text-sm text-muted-foreground",children:[s.authors&&s.authors.length>0&&e.jsxs("div",{children:["By ",s.authors.map(g=>g.name).join(", ")," – ",se(s.published_at,a)]}),e.jsx("div",{className:"mt-0.5",children:Ie(s)})]}),e.jsxs("div",{className:"mt-6 flex items-center gap-2",children:[!s.email_only&&e.jsx(Ce,{author:s.authors?.map(g=>g.name).join(", ")||"",description:"",faviconURL:n.icon||"",featureImageURL:s.feature_image||"",open:r,postExcerpt:s.excerpt||"",postTitle:s.title,postURL:s.url||"",siteTitle:m,onClose:()=>i(!1),onOpenChange:i,children:e.jsxs(T,{onClick:()=>i(!0),children:[e.jsx(Le,{})," Share post"]})}),e.jsxs(T,{className:s.email_only?"w-full":"",variant:"outline",onClick:()=>{t(`/posts/analytics/${s.id}`,{crossApp:!0})},children:[e.jsx(ze,{}),e.jsx("span",{className:"hidden md:!visible md:!block",children:s.email_only?"Post analytics":"Analytics"})]})]})]})]}),e.jsx("div",{className:"-ml-4 flex w-full flex-col items-stretch gap-2 pr-6 text-sm xl:h-full xl:max-w-none",children:e.jsxs("div",{className:"grid grid-cols-2 gap-6 pl-10 lg:border-l xl:h-full",children:[d.showWebMetrics&&l?.analytics.webAnalytics&&e.jsxs("div",{className:b,"data-testid":"latest-post-visitors",onClick:()=>{t(`/posts/analytics/${s.id}/web`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(M,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Visitors"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:u(s.visitors)})]}),d.showMemberGrowth&&e.jsxs("div",{className:$(b,d.showEmailMetrics&&(!d.showWebMetrics||!l?.analytics.webAnalytics)&&"row-[2/3] col-[1/2]"),"data-testid":"latest-post-members",onClick:()=>{t(`/posts/analytics/${s.id}/growth`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(ae,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden md:!visible md:!block",children:"Members"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.member_delta?e.jsxs(e.Fragment,{children:["+",u(s.member_delta)]}):0})]}),d.showEmailMetrics&&s.email&&e.jsxs(e.Fragment,{children:[h&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(K,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Opens"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count?Q((s.email.opened_count||0)/s.email.email_count):"0%"})]}),c&&e.jsxs("div",{className:b,onClick:()=>{t(`/posts/analytics/${s.id}/newsletter`,{crossApp:!0})},children:[e.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-muted-foreground transition-all group-hover:text-foreground",children:[e.jsx(Me,{size:16,strokeWidth:1.25}),e.jsx("span",{className:"hidden whitespace-nowrap md:!visible md:!block",children:"Clicks"})]}),e.jsx("span",{className:"text-[2.2rem] font-semibold leading-none tracking-tighter",children:s.email.email_count&&s.count?.clicks?Q((s.count.clicks||0)/s.email.email_count):"0%"})]})]})]})})]}):!o&&e.jsx(P,{actions:e.jsx(T,{variant:"secondary",onClick:()=>{t("/editor/post",{crossApp:!0})},children:"New post"}),className:"w-full pb-10 xl:col-span-3",description:"Once it's live, you can track performance here",title:"Publish your first post",children:e.jsx(te,{strokeWidth:1.5})})]})]})},Ge=()=>{const{data:s}=C();return{isLimited:t=>{const r=s?.config;return r?.hostSettings?.limits&&t==="limitAnalytics"?r.hostSettings.limits.limitAnalytics?.disabled===!0:!1}}},G=({title:s,iconName:o,description:t,color:r,diffDirection:i,diffValue:n,formattedValue:x,trendingFromValue:l,children:c,onClick:h})=>{const{range:m}=C(),a=o&&$e[o],d=le.useMemo(()=>{if(!i||i==="empty"||m===q.allTime.value||!n)return"";const b=i==="up"?"up":i==="down"?"down":"at",N=H(m).replace("in the ","").replace(/^\(|\)$/g,"");return i==="same"?e.jsxs("span",{children:["You're trending at the same level as ",e.jsx("span",{className:"font-semibold",children:x})," compared to the ",e.jsx("span",{className:"font-semibold",children:N})]}):e.jsxs("span",{children:["You're trending ",e.jsxs("span",{className:"font-semibold",children:[b," ",n]})," from ",e.jsx("span",{className:"font-semibold",children:l})," compared to the ",N]})},[i,n,l,x,m]);return e.jsxs(D,{className:"group","data-testid":s,children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:s}),e.jsx(R,{children:t})]}),e.jsxs(Ne,{className:"relative flex grow flex-row items-start justify-between gap-5 border-none pb-2 xl:pb-4",children:[e.jsxs("div",{className:"flex grow flex-col gap-1.5 border-none pb-0",children:[e.jsxs(we,{className:h&&"transition-all group-hover:text-foreground",children:[r&&e.jsx("span",{className:"inline-block size-2 rounded-full opacity-50",style:{backgroundColor:r}}),a&&e.jsx(a,{size:16,strokeWidth:1.5}),s]}),e.jsx(ye,{diffDirection:m===q.allTime.value?"hidden":i,diffTooltip:d,diffValue:n,value:x})]}),h&&e.jsx(T,{className:"absolute right-6 translate-x-10 opacity-0 transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100",size:"sm",variant:"outline",onClick:h,children:"View more"})]}),e.jsx(V,{children:c})]})},Se=({kpiValues:s,visitorsChartData:o,visitorsYRange:t,growthTotals:r,membersChartData:i,mrrChartData:n,currencySymbol:x,isLoading:l})=>{const c=Y(),{range:h}=C(),{appSettings:m}=W(),d=Ge().isLimited("limitAnalytics"),b="-mb-3 h-[10vw] max-h-[200px] min-h-[100px] hover:!cursor-pointer";if(l)return e.jsx(ve,{className:"flex h-[calc(10vw+116px)] max-h-[416px] min-h-20 items-center justify-center hover:!cursor-pointer",children:e.jsx(oe,{})});const g=m?.analytics.webAnalytics,N=d&&!g,y=!0,L=m?.paidMembersEnabled,w=[g,N,y,L].filter(Boolean).length;let A="lg:grid-cols-3";w===2?A="lg:grid-cols-2":w===1&&(A="lg:grid-cols-1");const U=`flex flex-col lg:grid ${A} gap-6`;return e.jsxs("div",{className:U,children:[g&&!N&&e.jsx(G,{description:"Number of individual people who visited your website",diffDirection:"empty",formattedValue:s.visits,iconName:"Globe",linkto:"/analytics/web/",title:"Unique visitors",onClick:()=>{c("/analytics/web/")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-blue))",data:o,id:"visitors",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts",yAxisRange:t})}),N&&e.jsxs(D,{children:[e.jsxs(E,{className:"hidden",children:[e.jsx(F,{children:"Unlock web analytics"}),e.jsx(R,{children:"Get the full picture of what's working with detailed, cookie-free traffic analytics."})]}),e.jsx(V,{className:"flex h-full items-center justify-center p-6",children:e.jsx(P,{actions:e.jsx(T,{variant:"outline",onClick:()=>c("/pro",{crossApp:!0}),children:"Upgrade now"}),className:"py-10",description:"Get the full picture of what's working with detailed, cookie-free traffic analytics.",title:"Unlock web analytics",children:e.jsx(We,{})})})]}),e.jsx(G,{description:"How number of members of your publication changed over time",diffDirection:r.directions.total,diffValue:r.percentChanges.total,formattedValue:u(r.totalMembers),iconName:"User",linkto:"/analytics/growth/",title:"Members",trendingFromValue:`${u(i[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=total-members")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-darkblue))",data:i,id:"members",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})}),L&&e.jsx(G,{description:"Monthly recurring revenue changes over time",diffDirection:r.directions.mrr,diffValue:r.percentChanges.mrr,formattedValue:`${x}${u(O(r.mrr))}`,iconName:"Coins",linkto:"/analytics/growth/",title:"MRR",trendingFromValue:`${x}${u(n[0].value)}`,onClick:()=>{c("/analytics/growth/?tab=mrr")},children:e.jsx(B,{className:b,color:"hsl(var(--chart-teal))",data:n,id:"mrr",range:h,showHorizontalLines:!0,showYAxisValues:!1,syncId:"overview-charts"})})]})},Oe=({className:s})=>e.jsx("div",{className:$("rounded-sm bg-muted dark:bg-[#36373a] flex flex-col items-center justify-center gap-1 p-6",s),children:e.jsx(ce,{className:"text-muted-foreground/50",size:18,strokeWidth:1.5})}),S=({className:s,metrics:o,title:t})=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:$("pointer-events-none absolute bottom-[calc(100%+2px)] left-1/2 z-50 min-w-[160px] -translate-x-1/2 rounded-md bg-background p-3 text-sm opacity-0 shadow-md transition-all group-hover/tooltip:bottom-[calc(100%+12px)] group-hover/tooltip:opacity-100",s),children:[e.jsx("div",{className:"mb-1.5 whitespace-nowrap border-b pb-1.5 pr-10 font-medium text-muted-foreground",children:t}),e.jsx("div",{className:"flex flex-col gap-1.5",children:o?.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 whitespace-nowrap",children:[r.icon,r.label]}),e.jsx("span",{className:"font-mono",children:r.metric})]},r.label))})]})}),He=({topPostsData:s,isLoading:o})=>{const t=Y(),{range:r,settings:i}=C(),{appSettings:n}=W(),x=String(i.find(a=>a.key==="timezone")?.value||"Etc/UTC"),l=n?.analytics.webAnalytics,c=n?.analytics.emailTrackClicks,h=n?.analytics.emailTrackOpens,m="flex items-center justify-end gap-1 rounded-md px-2 py-1 font-mono text-gray-800 hover:bg-muted-foreground/10 group-hover:text-foreground";return e.jsxs(D,{className:"group/card w-full lg:col-span-2","data-testid":"top-posts-card",children:[e.jsxs(E,{children:[e.jsxs(F,{className:"flex items-baseline justify-between font-medium leading-snug text-muted-foreground",children:["Top posts ",H(r)]}),e.jsx(R,{className:"hidden",children:"Most viewed posts in this period"})]}),e.jsx(V,{children:o?e.jsx(de,{className:"mt-6"}):e.jsxs(e.Fragment,{children:[s?.stats?.map(a=>e.jsxs("div",{className:'group relative flex w-full items-start justify-between gap-5 border-t border-border/50 py-4 before:absolute before:-inset-x-4 before:inset-y-0 before:z-0 before:hidden before:rounded-md before:bg-accent before:opacity-80 before:content-[""] first:!border-border hover:cursor-pointer hover:border-transparent hover:before:block md:items-center dark:before:bg-accent/50 [&+div]:hover:border-transparent',children:[e.jsxs("div",{className:"z-10 flex min-w-[160px] grow items-start gap-4 md:items-center lg:min-w-[320px]",onClick:()=>{t(`/posts/analytics/${a.post_id}`,{crossApp:!0})},children:[a.feature_image?e.jsx("div",{className:"hidden aspect-[16/10] w-[80px] shrink-0 rounded-sm bg-cover bg-center sm:!visible sm:!block lg:w-[100px]",style:{backgroundImage:`url(${a.feature_image})`}}):e.jsx(Oe,{className:"hidden aspect-[16/10] w-[80px] shrink-0 group-hover:bg-muted-foreground/10 sm:!visible sm:!flex lg:w-[100px]"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"line-clamp-2 text-lg font-semibold leading-[1.35em]",children:a.title}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["By ",a.authors," – ",se(a.published_at,x)]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:Te(a)})]})]}),e.jsxs("div",{className:"z-10 flex flex-col items-end justify-center gap-0.5 text-sm md:flex-row md:items-center md:justify-end md:gap-3",children:[l&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-visitors",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/web`,{crossApp:!0})},children:[e.jsx(S,{metrics:[{icon:e.jsx(M,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Unique visitors",metric:u(a.views)}],title:"Web traffic"}),e.jsxs("div",{className:m,children:[e.jsx(M,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.views)]})]}),a.sent_count!==null&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/newsletter`,{crossApp:!0})},children:[e.jsx(S,{className:`${n?.analytics.membersTrackSources?"":"left-auto right-0 translate-x-0"}`,metrics:[{icon:e.jsx(J,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Sent",metric:u(a.sent_count||0)},...h?[{icon:e.jsx(K,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Opens",metric:u(a.opened_count||0)}]:[],...c?[{icon:e.jsx(Z,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Clicks",metric:u(a.clicked_count||0)}]:[]],title:"Newsletter performance"}),e.jsx("div",{className:m,children:h?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.open_rate?`${Math.round(a.open_rate)}%`:"0%"]}):c?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.click_rate?`${Math.round(a.click_rate)}%`:"0%"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),X(a.sent_count||0)]})})]}),n?.analytics.membersTrackSources&&e.jsxs("div",{className:"group/tooltip relative flex w-[66px] lg:w-[92px]","data-testid":"statistics-members",onClick:d=>{d.stopPropagation(),t(`/posts/analytics/${a.post_id}/growth`,{crossApp:!0})},children:[e.jsx(S,{className:"left-auto right-0 translate-x-0",metrics:[{icon:e.jsx(me,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Free",metric:a.free_members>0?`+${u(a.free_members)}`:"0"},...n?.paidMembersEnabled?[{icon:e.jsx(ue,{className:"shrink-0 text-muted-foreground",size:16,strokeWidth:1.5}),label:"Paid",metric:a.paid_members>0?`+${u(a.paid_members)}`:"0"}]:[]],title:"New members"}),e.jsxs("div",{className:m,children:[e.jsx(ae,{className:"text-muted-foreground group-hover:text-foreground",size:16,strokeWidth:1.5}),a.members>0?`+${u(a.members)}`:"0"]})]})]})]},a.post_id)),(!s?.stats||s.stats.length===0)&&e.jsx(P,{className:"w-full pb-10",title:`No posts ${H(r)}`,children:e.jsx(te,{strokeWidth:1.5})})]})})]})},Ke=()=>{const{data:{posts:[s]}={posts:[]},isLoading:o}=Re({searchParams:{filter:"status:[published,sent]",order:"published_at DESC",limit:"1",include:"authors,email,count.clicks"}}),t=s,r=Ve(t?.id||"",{enabled:!!t?.id}),{data:i,isLoading:n}=r;return{data:_.useMemo(()=>{if(!t)return null;const l=i?.stats?.[0]||{id:t.id,recipient_count:null,opened_count:null,open_rate:null,member_delta:0,free_members:0,paid_members:0,visitors:0};return{id:t.id,uuid:t.uuid,title:t.title||"",slug:t.slug||"",feature_image:t.feature_image||null,published_at:t.published_at||"",url:t.url||"",excerpt:t.excerpt||"",email_only:t.email_only||!1,status:t.status,email:t.email,count:t.count,authors:t.authors||[],recipient_count:l.recipient_count,opened_count:l.opened_count,open_rate:l.open_rate,member_delta:l.member_delta,free_members:l.free_members,paid_members:l.paid_members,visitors:l.visitors,click_rate:null}},[t,i]),isLoading:o||!!t?.id&&n}},ee=({className:s,title:o,description:t,url:r,children:i})=>e.jsx("a",{className:$("block rounded-xl border bg-card p-6 transition-all hover:shadow-xs hover:bg-accent/50 group/card",s),href:r,rel:"noreferrer",target:"_blank",children:e.jsxs("div",{className:"flex items-center gap-6",children:[i,e.jsxs("div",{className:"flex flex-col gap-0.5 leading-tight",children:[e.jsx("span",{className:"text-base font-semibold",children:o}),e.jsx("span",{className:"text-sm font-normal text-gray-700",children:t})]})]})}),ks=()=>{const{appSettings:s}=W(),{statsConfig:o,isLoading:t,range:r}=C(),{startDate:i,endDate:n,timezone:x}=pe(r),{isLoading:l,chartData:c,totals:h,currencySymbol:m}=Fe(r),{data:a,isLoading:d}=Ke(),{data:b,isLoading:g}=Ue({searchParams:{date_from:z(i),date_to:z(n),limit:"5",timezone:x}}),N={site_uuid:o?.id||"",date_from:z(i),date_to:z(n),timezone:x,member_status:Ee(he)},{data:y,loading:L}=ke({endpoint:"api_kpis",statsConfig:o,params:N}),w=_.useMemo(()=>I(y||[],r,"visits","sum")?.map(f=>{const v=Number(f.visits),k=isNaN(v)?0:v;return{date:String(f.date),value:k,formattedValue:u(k),label:"Visitors"}}),[y,r]),A=_.useMemo(()=>{const f=[0,1];if(!w||w.length===0)return f;const v=w.map(p=>p.value).filter(p=>p>=0);return v.length===0?f:[0,Math.max(...v)||f[1]]},[w]),U=_.useMemo(()=>{if(!c||c.length===0)return[];let f=[];return f=I(c,r,"value","exact"),f.map(p=>({date:p.date,value:p.free+p.paid,formattedValue:u(p.free+p.paid),label:"Members"}))},[c,r]),re=_.useMemo(()=>{if(!s?.paidMembersEnabled||!c||c.length===0)return[];let f=[];return f=I(c,r,"mrr","exact"),f.map(p=>({date:p.date,value:O(p.mrr),formattedValue:`${m}${u(O(p.mrr))}`,label:"MRR"}))},[c,r,m,s]),ie=_.useMemo(()=>{if(!y?.length)return{visits:"0"};const f=y.reduce((v,k)=>{const p=Number(k.visits);return v+(isNaN(p)?0:p)},0);return{visits:u(f)}},[y]),ne=t;return e.jsxs(ge,{children:[e.jsx(fe,{children:e.jsx(_e,{children:e.jsx(be,{excludeRanges:["today"]})})}),e.jsxs(je,{isLoading:ne,loadingComponent:e.jsx(e.Fragment,{}),children:[e.jsx(Se,{currencySymbol:m,growthTotals:h,isLoading:L||l,kpiValues:ie,membersChartData:U,mrrChartData:re,visitorsChartData:w,visitorsYRange:A}),e.jsx(Be,{isLoading:d,latestPostStats:a}),e.jsx(He,{isLoading:g,topPostsData:b}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[e.jsx(xe,{className:"-mb-4 mt-4 lg:col-span-2",children:"Grow your audience"}),e.jsx(ee,{description:"Find out how to review the performance of your content and get the most out of post analytics in Ghost.",title:"Understanding analytics in Ghost",url:"https://ghost.org/help/native-analytics",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tr from-[#14B8FF]/20 to-[#00BBA7]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(De,{className:"text-[#00BBA7]",size:20,strokeWidth:1.5})})}),e.jsx(ee,{description:"Use these content distribution tactics to get more people to discover your work and increase engagement.",title:"How to get your content seen online",url:"https://ghost.org/resources/content-distribution/",children:e.jsx("div",{className:"flex h-18 w-[100px] min-w-[100px] items-center justify-center rounded-md bg-gradient-to-tl from-[#FDC700]/20 to-[#FF2056]/20 p-4 opacity-80 transition-all group-hover/card:opacity-100",children:e.jsx(M,{className:"text-[#FE9A00]",size:20,strokeWidth:1.5})})})]})]})]})};export{ks as default};
@@ -1 +1 @@
1
- import{r as c}from"./index-BeAhXwae.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-exFCQBCk.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};