1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ForYouSection-j51oADoC.js","assets/vendor-data-BwcWGEsa.js","assets/rolldown-runtime-M0oDzQ_3.js","assets/vendor-react-BK73EwAN.js","assets/chevron-left-D_4mGLus.js","assets/createLucideIcon-BBBB7OBy.js","assets/chevron-right-CejzDIR0.js","assets/refresh-cw-dz9G8Tu5.js","assets/sparkles-B_ubz5O3.js","assets/triangle-alert-n-SskdNm.js","assets/CompactBookCard-YhGEzXZq.js","assets/proxy-B16EueI6.js","assets/index-Bhvx0-ct.js","assets/defineProperty-CkKLuKw5.js","assets/arrow-left-B_Ixnu3o.js","assets/bell-C8bIKvRf.js","assets/book-open-PWQIawMS.js","assets/clock-DTQt8uc9.js","assets/settings-oQoyF2GI.js","assets/trophy-Bwd7Gm_w.js","assets/supabase-C5lAo7mf.js","assets/Popover-BQ-5hxwj.js","assets/utils-Dxo0lxcD.js","assets/bundle-mjs-DRfmn-Pm.js","assets/AuthContext-DecS5GCe.js","assets/adminMode-CWVc3RLz.js","assets/isPaidStatus-YyvLKkHl.js","assets/AnalyticsService-CIS6thDy.js","assets/platform-D00atzh8.js","assets/useNotifications-60UOvS2I.js","assets/ProviderAvailabilityService-DfGx2tY0.js","assets/SecureContentService-NR9DsHsx.js","assets/contentUrls-DB4ooyH1.js","assets/legalHold-C_9EGpge.js","assets/routes-oA-ZsG_Z.js","assets/scrollIdeaSelection-DA_PJ2O5.js","assets/index-BKtUt3kZ.css","assets/AddToCollectionButton-lto0Vy8P.js","assets/bookmark-nDmOc7qL.js","assets/check-BO0RcrH5.js","assets/chevron-down-Bi5BlOmC.js","assets/circle-check-big-uf5VIAIA.js","assets/folder-BD2qdBUR.js","assets/heart-BNwO2fIy.js","assets/plus-DkAbSNHZ.js","assets/useCollections-B8kMa6su.js","assets/CollectionService-D2qugMHz.js","assets/useFavorites-C7B2hVOR.js","assets/InAppReviewService-DapwnoBN.js","assets/FreeBadge-DugLOzjd.js","assets/Chip-M54y8j2g.js","assets/useRecommendations-25kjuWOg.js","assets/NpsSurvey-CuNf6bLg.js","assets/Dialog-D30fkc27.js","assets/x-cBmH4UyD.js","assets/betaEvents-ChqBgO9a.js","assets/BetaFeedbackService-YrQNRtDF.js","assets/BetaConversionBanner-CPrr4B__.js","assets/AnimatePresence-D119C_uX.js","assets/crown-DtnpovBO.js","assets/BookBuddyDashboardHero-BYHMBl4e.js","assets/arrow-right-cqcrLAgG.js","assets/DueReviewModal-bKcCCF0w.js","assets/loader-circle-CdxwvVl2.js","assets/useRecordIdeaReview-CaFF7s7v.js","assets/DailyReviewCard-CObmfZgv.js","assets/Card-j2WymbDT.js","assets/ReviewService-B_0cXwDL.js","assets/DailyPickHero-DjE_yR8b.js","assets/useDailyPick-JpqXMVhA.js","assets/StartHereCard-BKBhfLUL.js","assets/useOnboarding-fx01cTqg.js","assets/OnboardingService-DKIQdhlv.js","assets/ChallengeCard-CXI4r1O7.js","assets/flame-BvIua86V.js"])))=>i.map(i=>d[i]); 2import{a as ws}from"./rolldown-runtime-M0oDzQ_3.js";import{c as f,h as Ke,v as Ns,y as I}from"./vendor-react-BK73EwAN.js";import{O as Cs,i as de,k as _s,o as Ss}from"./vendor-data-BwcWGEsa.js";import{t as K}from"./proxy-B16EueI6.js";import{t as Es}from"./AnimatePresence-D119C_uX.js";import{t as te}from"./supabase-C5lAo7mf.js";import{s as D,t as _}from"./AnalyticsService-CIS6thDy.js";import{n as Ge}from"./AuthContext-DecS5GCe.js";import"./utils-Dxo0lxcD.js";import{t as Is}from"./arrow-right-cqcrLAgG.js";import{t as le}from"./book-open-PWQIawMS.js";import{t as Rs}from"./calendar-B6bUHjyt.js";import{t as Ts}from"./chevron-down-Bi5BlOmC.js";import{t as F}from"./chevron-right-CejzDIR0.js";import{t as Ls}from"./crown-DtnpovBO.js";import{t as Ps}from"./file-text-CwSYTkZv.js";import{t as Je}from"./film-Zro1TiRm.js";import{t as As}from"./flame-BvIua86V.js";import{t as $s}from"./EmptyState-BDmnM8Uq.js";import{t as Ds}from"./loader-circle-CdxwvVl2.js";import{t as ze}from"./refresh-cw-dz9G8Tu5.js";import{t as Fs}from"./route-Bo3Ce4DW.js";import{t as Bs}from"./star-DNxba_je.js";import{t as Hs}from"./triangle-alert-n-SskdNm.js";import{t as Os}from"./x-cBmH4UyD.js";import{t as Ms}from"./legalHold-C_9EGpge.js";import{a as Us}from"./routes-oA-ZsG_Z.js";import{D as Vs,E as qs,J as zs,Nt as Qe,S as Ye,Vt as Ys,W as Xe,Wt as Ws,Z as We,lt as ye,m as Ks,nt as Gs,o as Js,rt as Ne,s as Qs,tt as Xs}from"./index-Bhvx0-ct.js";import{t as Zs}from"./ConceptService-DZf0FlMp.js";import{t as Y}from"./Skeleton-CdI1Cp3H.js";import{t as Ce}from"./ui-DMgQNDEI.js";import{t as ce}from"./Card-j2WymbDT.js";import{t as et}from"./Chip-M54y8j2g.js";import{n as _e,t as st}from"./useMinimalMode-CdIfLumo.js";import{n as Se,t as G}from"./surfaceFlags-BOFWKRCQ.js";import{t as tt}
2from"./useDailyPick-JpqXMVhA.js";import{t as at}from"./FreeBadge-DugLOzjd.js";import{a as rt,n as nt,o as ot,r as it}from"./useGamification-CartC8PM.js";import{t as lt}from"./ReviewService-B_0cXwDL.js";import{r as dt}from"./useDashboard-BMIDyx2T.js";import{s as ct}from"./useJourneys-c_RH0DM6.js";import{n as ut,r as mt,t as xt}from"./ReferralService-CMV7qvm_.js";import{t as Ze}from"./design-system-BHnT5BOl.js";import{a as ht,i as pt,t as es}from"./useConceptFollows-CtiMV2VJ.js";import{l as bt}from"./useCreatorStudio-By6Qpz7h.js";import{t as ft}from"./studioRoutes-CWxmmYzZ.js";import{t as J}from"./ideaFabricCapability-B4wXgagy.js";import"./ActivityHeatmap-B5KceExH.js";import{n as gt}from"./useScrollBookSlugs-Bkvf0o2E.js";import{t as vt}from"./useScrollEntryVisible-DZInoOZy.js";import{t as jt}from"./ChapterLabel-DNsJJhoi.js";var r=ws(_s(),1),kt={streakDays:0,ideasLocked:0,dueCount:0,dueToday:0};function yt(s){return{streakDays:s.streak_days??0,ideasLocked:s.ideas_locked??0,dueCount:s.due_count??0,dueToday:s.due_today??0}}async function wt(){const{data:s,error:t}=await te.rpc("get_learning_summary"),a=Array.isArray(s)?s[0]:s;return t||!a?kt:yt(a)}function Nt(s,t=!0){return de({queryKey:["actor-learning-summary"],queryFn:wt,enabled:(Xe||Ne)&&t&&s,staleTime:60*1e3,retry:!1})}var e=Cs();function Ct({summary:s,loading:t,domainColor:a,onReview:i}){return t||!s?(0,e.jsx)("div",{"data-testid":"learning-strip-skeleton",className:"h-16 w-full animate-pulse rounded-2xl bg-stone-100 dark:bg-white/[0.04]"}):!i||s.dueCount<=0?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)("button",{type:"button",onClick:i,className:"w-full flex items-center justify-center rounded-2xl border border-stone-200/80 bg-white px-4 py-3 text-sm font-semibold dark:border-white/[0.08] dark:bg-white/[0.03]",style:{color:a},children:[s.dueCount," worth a second look"]})}function _t(s){return de({queryKey:["book-metadata",s],queryFn:async()=>{if(!s)return null;const{data:t,error:a}=await te.from("book_catalog").select("subtitle, publication_year, page_count, goodreads_rating, tags, what_youll_learn, perfect_for, publisher").eq("id",s).neq("review_status",Ms).eq("hidden_for_legal",!1).single();return a?(console.error("[useBookMetadata] Error fetching metadata:",a),null):{subtitle:t?.subtitle??void 0,publicationYear:t?.publication_year??void 0,pageCount:t?.page_count??void 0,rating:t?.goodreads_rating??void 0,tags:t?.tags??void 0,whatYoullLearn:t?.what_youll_learn??void 0,perfectFor:t?.perfect_for??void 0,publisher:t?.publisher??void 0}},enabled:!!s,staleTime:900*1e3,gcTime:1800*1e3})}function St(){return(0,e.jsx)(ce,{padding:"none","data-testid":"continue-reading-hero-skeleton",className:"p-4 sm:p-6",children:(0,e.jsxs)("div",{className:"flex gap-4 md:gap-6",children:[(0,e.jsxs)("div",{className:"flex-1 min-w-0 space-y-3",children:[(0,e.jsx)("div",{className:"h-4 w-16 bg-stone-200 dark:bg-stone-800 rounded-full animate-pulse"}),(0,e.jsx)("div",{className:"h-6 sm:h-7 w-3/4 bg-stone-200 dark:bg-stone-800 rounded animate-pulse"}),(0,e.jsx)("div",{className:"h-4 w-1/3 bg-stone-100 dark:bg-stone-800/50 rounded animate-pulse"}),(0,e.jsx)("div",{className:"h-2 w-full bg-stone-100 dark:bg-stone-800/50 rounded-full animate-pulse mt-6"}),(0,e.jsx)("div",{className:"h-9 sm:h-10 w-28 sm:w-32 bg-stone-200 dark:bg-stone-800 rounded-xl animate-pulse mt-2"})]}),(0,e.jsx)("div",{className:"flex-shrink-0 self-start",style:{width:100},children:(0,e.jsx)("div",{className:"rounded-xl bg-stone-200 dark:bg-stone-800 animate-pulse",style:{aspectRatio:"2/3"}})})]})})}function Et(s,t){if(!s||!s.startsWith("#")||s.length<7)return`rgba(0,0,0,${t})`;const a=parseInt(s.slice(1,3),16),i=parseInt(s.slice(3,5),16),d=parseInt(s.slice(5,7),16);return isNaN(a)||isNaN(i)||isNaN(d)?`rgba(0,0,0,${t})`:`rgba(${a},${i},${d},${t})`}function It({domainColor:s,bookSlug:t,onContinueTapped:a}){return(0,e.jsxs)(f,{to:`/scroll/${t}`,onClick:a,"data-cta-priority":"primary",className:"relative flex min-h-[46px] w-full items-center justify-center gap-2 overflow-hidden rounded-xl text-sm font-bold text-white active:opacity-80",style:{background:s,boxShadow:`0 4px 16px ${Et(s,.35)}`},children:[(0,e.jsx)(Je,{className:"h-4 w-4","aria-hidden":"true"}),"Scroll this book"]})}function Rt(s){const t=s.length;return t<=22?"text-2xl sm:text-3xl":t<=36?"text-xl sm:text-2xl":t<=50?"text-lg sm:text-xl":t<=65?"text-base sm:text-lg":"text-sm sm:text-base"}function W({items:s,isLoading:t,topMetrics:a=[]}){const[i,d]=(0,r.useState)(!1),{chapterInfo:l,isPlaying:m}=Ys(),b=Ke(),o=s[0],{data:v}=Ks(o?.bookId||""),{data:p}=_t(o?.bookId);if(t)return(0,e.jsx)(St,{});if(s.length===0)return(0,e.jsx)($s,{icon:le,title:"Nothing in progress",description:"Explore the library to start your first read.",action:{label:"Explore",onClick:()=>b("/explore")}});const S=m&&!!l&&(l.chapterPath.includes(`/topic/${o.bookSlug}`)||l.chapterPath.includes(`/scroll/${o.bookSlug}`)),c=Ze(o.domainSlug).primary,B=`/scroll/${o.bookSlug}`,j=o.totalChapters||10,h=o.completedChapters||0,k=Math.max(0,(j-h)*4),H=Math.min(j,10),R=Array.from({length:H},(x,O)=>{const L=O+1,N=v?.find(y=>y.orderIndex===L);return{index:L,name:N?.title??`Chapter ${L}`,slug:N?.slug}}),u=h===0?1:h<j?h+1:j+1,ue=R.find(x=>x.index===u)?.name||"Next chapter",T=(v?.find(x=>x.orderIndex===u)??(o.lastChapterSlug?v?.find(x=>x.slug===o.lastChapterSlug):void 0))?.id??null,Q=()=>{_.track(_e.CONTINUE_HERO_TAPPED,{bookId:o.bookId,chapterId:T})};return(0,e.jsx)(K.div,{initial:{opacity:0,y:20}
2,animate:{opacity:1,y:0},className:"md:max-w-[800px]",children:(0,e.jsxs)(ce,{padding:"none",className:"overflow-hidden transition-all duration-300",style:{borderColor:S?`${c}55`:void 0,boxShadow:S?`0 0 0 2px ${c}22, 0 4px 20px ${c}18`:void 0},children:[a.length>0&&(0,e.jsx)("div",{className:"border-b border-stone-100/90 px-4 py-2 dark:border-stone-800/80 sm:px-5",children:(0,e.jsx)("div",{className:"flex gap-1.5 overflow-x-auto scrollbar-hide",children:a.map(x=>(0,e.jsxs)(f,{to:x.href,className:"flex min-w-[88px] flex-shrink-0 items-baseline gap-1 rounded-full border border-stone-200/80 bg-stone-50/85 px-2.5 py-1.5 transition-colors hover:border-stone-300 hover:bg-white dark:border-stone-800 dark:bg-stone-950/40 dark:hover:border-stone-700 dark:hover:bg-stone-950/70",children:[(0,e.jsx)("span",{className:"text-[13px] font-bold leading-none text-stone-950 dark:text-white",children:x.value}),(0,e.jsx)("span",{className:"truncate text-[11px] font-bold uppercase tracking-[0.14em] text-stone-500 dark:text-stone-400",children:x.label})]},x.label))})}),(0,e.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_100px] gap-x-3 sm:grid-cols-[minmax(0,1fr)_130px] sm:gap-x-5 md:grid-cols-[130px_minmax(0,1fr)]",children:[(0,e.jsxs)("div",{className:"min-w-0 p-4 sm:p-5 relative overflow-hidden md:col-start-2 md:row-start-1",children:[(0,e.jsx)("div",{className:"absolute top-0 left-0 right-0 h-28 pointer-events-none",style:{background:`linear-gradient(150deg, ${c}14 0%, transparent 72%)`}}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-2 flex-wrap",children:[(0,e.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-[0.14em] text-stone-500 dark:text-stone-400",children:"Continue reading"}),S&&(0,e.jsxs)(K.span,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider w-fit",style:{backgroundColor:`${c}22`,color:c,border:`1px solid ${c}44`},children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:c}}),"Now Playing"]})]}),(0,e.jsxs)(f,{to:`/domain/${o.domainSlug}/topic/${o.bookSlug}`,className:"group/title block",children:[(0,e.jsx)("h2",{className:`font-display font-extrabold leading-snug text-stone-900 dark:text-white truncate group-hover/title:text-gold-600 dark:group-hover/title:text-gold-400 transition-colors tracking-tight ${Rt(o.bookTitle)}`,children:o.bookTitle}),p?.subtitle&&(0,e.jsx)("p",{className:"text-[11px] sm:text-xs text-stone-600 dar
2k:text-stone-300 mt-1 line-clamp-1 italic leading-relaxed",children:p.subtitle})]}),(0,e.jsx)("p",{className:"text-[11px] sm:text-xs text-stone-700 dark:text-stone-200 mt-1 font-medium",children:o.author}),(0,e.jsx)("p",{className:"text-[11px] sm:text-xs text-stone-600 dark:text-stone-300 mt-1",children:h>=j?"Completed · ready to revisit":`${k} min left at your current pace`}),T&&(0,e.jsx)("div",{className:"mt-1.5",children:(0,e.jsx)(jt,{variant:"hero",bookId:o.bookId,chapterId:T,className:"text-[11px] sm:text-xs text-stone-500 dark:text-stone-400"})}),p&&(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 mt-2 mb-1",children:[p.rating&&(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)(Bs,{className:"w-3 h-3 fill-gold-400 text-gold-400"}),(0,e.jsx)("span",{className:"text-[11px] font-bold text-stone-700 dark:text-stone-300",children:p.rating.toFixed(1)})]}),p.publicationYear&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"w-0.5 h-0.5 rounded-full bg-stone-300 dark:bg-stone-600"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)(Rs,{className:"w-3 h-3 text-stone-400"}
2),(0,e.jsx)("span",{className:"text-[11px] text-stone-600 dark:text-stone-300",children:p.publicationYear})]})]}),p.pageCount&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("span",{className:"w-0.5 h-0.5 rounded-full bg-stone-300 dark:bg-stone-600"}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,e.jsx)(Ps,{className:"w-3 h-3 text-stone-400"}),(0,e.jsxs)("span",{className:"text-[11px] text-stone-600 dark:text-stone-300",children:[p.pageCount," pages"]})]})]})]}),h<j&&(0,e.jsxs)("div",{className:"flex items-center gap-1.5 mt-2.5 min-w-0",children:[(0,e.jsxs)("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[11px] font-bold uppercase tracking-wider flex-shrink-0",style:{backgroundColor:`${c}18`,color:c},children:[(0,e.jsx)(F,{className:"w-2 h-2"}),"Up Next"]}),(0,e.jsx)("span",{className:"text-[11px] text-stone-500 dark:text-stone-400 truncate",children:ue})]})]})]}),(0,e.jsx)(f,{to:B,className:"row-start-1 col-start-2 px-3 pt-4 pb-2 sm:py-4 flex items-start sm:items-center justify-center group/card md:col-start-1",children:(0,e.jsxs)(K.div,{layoutId:`hero-cover-${o.bookId}`,className:"relative w-[100px] sm:w-[130px] aspect-[2/3] rounded-xl shadow-lg bg-stone-200 dark:bg-stone-800 overflow-hidden ring-1 ring-black/5 dark:ring-white/10 transition-all duration-300 group-hover/card:shadow-2xl group-hover/card:translate-y-[-4px]",children:[(0,e.jsx)("div",{className:"absolute top-1.5 left-1.5 z-30 pointer-events-none",children:(0,e.jsx)(at,{bookId:o.bookId,size:"sm"})}),o.bookCoverUrl?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("img",{src:o.bookCoverUrl,alt:"",className:"absolute inset-0 w-full h-full object-cover blur-2xl opacity-40 scale-150","aria-hidden":"true"}),(0,e.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-0.5",children:(0,e.jsx)("img",{src:o.bookCoverUrl,alt:o.bookTitle,className:"w-full h-full object-cover rounded-lg shadow-sm",fetchPriority:"high",decoding:"async"})}),(0,e.jsx)("div",{className:"absolute inset-0 rounded-xl shadow-[inset_0_0_20px_rgba(0,0,0,0.15)] pointer-events-none"})]}):(0,e.jsx)("div",{"data-testid":"continue-reading-cover-fallback",className:"w-full h-full flex items-center justify-center bg-stone-100 dark:bg-stone-800",children:(0,e.jsx)(le,{className:"w-12 h-12",style:{color:c}})})]})}),(0,e.jsx)("div",{className:"col-span-2 px-4 pb-3 pt-2 md:col-start-1 md:col-end-3 md:px-5",children:(0,e.jsx)(It,{domainColor:c,bookSlug:o.bookSlug,onContinueTapped:Q})})]}),(0,e.jsxs)("button",{type:"button",onClick:()=>d(!i),"aria-expanded":i,"aria-controls":"chapter-list",className:"w-full flex items-center justify-center gap-1.5 py-2.5 border-t border-stone-100 dark:border-stone-800 hover:bg-stone-50 dark:hover:bg-stone-800/30 active:bg-stone-100 dark:active:bg-stone-800/50 transition-colors",children:[(0,e.jsxs)("span",{className:"text-[11px] font-semibold text-stone-500 dark:text-stone-500 uppercase tracking-wider",children:[h," / ",j," chapters"]}),(0,e.jsx)(K.span,{animate:{rotate:i?180:0},transition:{duration:.2},className:"inline-flex text-stone-300 dark:text-stone-700",children:(0,e.jsx)(Ts,{className:"w-3.5 h-3.5"})})]}),(0,e.jsx)("div",{id:"chapter-list",children:(0,e.jsx)(Es,{initial:!1,children:i&&(0,e.jsx)(K.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22,ease:"easeInOut"},className:"overflow-hidden",children:(0,e.jsx)("div",{className:"border-t border-stone-100 dark:border-stone-800",children:R.map(({index:x,name:O,slug:L})=>{const N=x<u,y=x===u;return(0,e.jsxs)(f,{to:L?`/scroll/${o.bookSlug}?chapters=1&chapter=${encodeURIComponent(L)}`:`/scroll/${o.bookSlug}?chapters=1`,className:`flex items-center gap-2.5 px-4 sm:px-5 py-2.5 sm:py-2 transition-colors active:bg-stone-100 dark:active:bg-stone-800/50 ${y?"bg-stone-50 dark:bg-white/5":"hover:bg-stone-50 dark:hover:bg-stone-800/30"}`,children:[(0,e.jsx)("span",{className:`text-[11px] font-bold tabular-nums w-5 flex-shrink-0 ${N?"text-emerald-500 dark:text-emerald-400":y?"font-extrabold":"text-stone-300 dark:text-stone-600"}`,style:y?{color:c}:void 0,children:N?"â":String(x).padStart(2,"0")}),(0,e.jsx)("span",{className:`text-xs flex-1 min-w-0 truncate ${N?"text-stone-400 dark:text-stone-500":y?"font-semibold text-stone-800 dark:text-stone-100":"text-stone-500 dark:text-stone-500"}`,children:O}),y&&(0,e.jsx)("span",{className:"text-[11px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full text-white flex-shrink-0",style:{backgroundColor:c},children:"Up Next"}),!N&&!y&&(0,e.jsx)(F,{className:"w-3 h-3 text-stone-300 dark:text-stone-700 flex-shrink-0"})]},x)})})})})})]})})}var Tt=88,Lt=6,Pt=(Tt-Lt)/2,sr=2*Math.PI*Pt;function At({slug:s,title:t,booksCompleted:a,bookCount:i}){const d=Math.min(100,Math.round(a/Math.max(1,i)*100));return(0,e.jsx)(f,{to:`/journeys/${s}`,className:"block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)] rounded-[var(--sb-radius-surface)]",children:(0,e.jsxs)(ce,{variant:"interactive",padding:"none",className:"p-4 sm:p-5 shadow-[var(--sb-shadow-1)]",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[var(--sb-radius-control)] bg-[var(--sb-surface-subtle)] text-[var(--sb-accent)]",children:(0,e.jsx)(Fs,{className:"h-5 w-5","aria-hidden":"true"})}),(0,e.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,e.jsx)("p",{className:"text-xs font-semibold text-[var(--sb-ink-muted)]",children:"Continue your Journey"}),(0,e.jsx)("h2",{className:"truncate text-base font-bold text-[var(--sb-ink)]",children:t}),(0,e.jsxs)("p",{className:"mt-0.5 text-xs text-[var(--sb-ink-muted)]",children:[a," of ",i," books complete"]})]}),(0,e.jsx)("span",{className:"hidden text-xs font-semibold text-[var(--sb-accent)] sm:inline",children:"Continue"}),(0,e.jsx)(F,{className:"h-5 w-5 shrink-0 text-[var(--sb-ink-muted)]","aria-hidden":"true"})]}),(0,e.jsx)("div",{className:"mt-3 h-1.5 overflow-hidden rounded-full bg-[var(--sb-surface-subtle)]","aria-hidden":"true",children:(0,e.jsx)("div",{className:"h-full rounded-full bg-[var(--sb-accent)]",style:{width:`${d}%`}})})]})})}var we=te;function $t({compact:s=!1}){const{user:t}=Ge(),[a,i]=(0,r.useState)(),[d,l]=(0,r.useState)(),[m,b]=(0,r.useState)(!1),[o,v]=(0,r.useState)(!1),[p,S]=(0,r.useState)(!1),c=(0,r.useRef)(t?.id);c.current=t?.id,(0,r.useEffect)(()=>
2{if(i(void 0),l(void 0),b(!1),v(!1),S(!1),!t?.id)return;let h=!1;return(async()=>{const k=await we.from("referral_codes").select("code").eq("owner_user_id",t.id).maybeSingle();h||(i(k.data?.code??null),l(t.id))})(),()=>{h=!0}},[t?.id]);const B=async()=>{if(!t?.id||d!==t.id||a===void 0||o)return;const h=t.id;if(S(!1),!a){v(!0);const k=ut(),{error:H}=await we.from("referral_codes").insert({code:k,owner_user_id:h});if(!H)c.current===h&&i(k);else{const R=await we.from("referral_codes").select("code").eq("owner_user_id",h).maybeSingle();c.current===h&&(R.data?.code?i(R.data.code):S(!0))}c.current===h&&v(!1);return}try{await navigator.clipboard.writeText(xt(a)),b(!0),setTimeout(()=>b(!1),1800)}catch{b(!1)}};if(!t?.id||d!==t.id||a===void 0)return null;const j=a?m?"â Copied!":"Copy link":o?"Creatingâ¦":p?"Try again":"Create link";return s?(0,e.jsxs)("button",{type:"button","data-testid":"referral-banner",onClick:B,disabled:o,className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-amber-50 dark:bg-amber-950/40 border border-amber-200/60 dark:border-amber-800/50 text-[11px] font-medium text-amber-700 dark:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/50 transition-colors",children:[(0,e.jsx)("span",{children:"ð"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Invite 1 friend â free shelf"}),(0,e.jsx)("span",{className:"sm:hidden",children:"Invite & earn"}),(0,e.jsx)("span",{className:"font-bold",children:j})]}):(0,e.jsxs)("div",{"data-testid":"referral-banner",className:"flex items-center justify-between gap-3 px-4 py-2 bg-amber-50 dark:bg-amber-950/30 rounded-lg text-sm",children:[(0,e.jsx)("span",{children:"ð Invite 1 friend â unlock another shelf free"}),(0,e.jsx)("button",{type:"button",onClick:B,disabled:o,className:"font-semibold underline hover:no-underline",children:j})]})}async function Dt(s){if(!s)return new Set;const{data:t}=await te.from("scroll_feed_events").select("book_slug").eq("user_id",s).eq("event_type","view");return new Set((t||[]).map(a=>a.book_slug).filter(a=>!!a))}function Ft(s,t){const a=t?.enabled??!0;return de({queryKey:["watched-scroll-slugs",s],queryFn:()=>Dt(s||""),enabled:a&&!!s,staleTime:300*1e3,gcTime:900*1e3})}var Bt=[G.TIER_0,G.TIER_1,G.TIER_2,G.TIER_3];function Ht(s){return Se(Bt[s])!==!1}function Ot(){const s=it(7).data??[];return(0,r.useMemo)(()=>{const t=Date.now()-6048e5,a=s.filter(i=>{const d=new Date(i.date).getTime();return!Number.isNaN(d)&&d>=t&&i.intensityLevel>0});return{daysThisWeek:a.length,paused:a.length===0,totalDaysOnRecord:s.length}},[s])}function Mt(){const s=Ot(),{enabled:t}=st(),a=Se(G.WIDGET_RHYTHM_PILL);if(t||a===!1)return null;const i=s.paused?"Rhythm paused":`${s.daysThisWeek} days this week`,d=s.paused?"#9CA3AF":"#B8924A";return(0,e.jsxs)(et,{interactive:!0,variant:"outline",tone:"neutral",size:"md",onClick:()=>_.track(_e.RHYTHM_PILL_TAPPED,{days_this_week:s.daysThisWeek}),"aria-label":`Reading rhythm, ${s.daysThisWeek} days this week`,className:"bg-white/80 dark:bg-stone-900/80 backdrop-blur font-medium text-stone-600 dar
2k:text-stone-300 hover:text-stone-900 dark:hover:text-white",children:[(0,e.jsx)("span",{className:"w-1.5 h-1.5 rounded-full mr-1",style:{background:d},"aria-hidden":!0}),i]})}function Ut(){const{data:s=[]}=rt();if(Se(G.WIDGET_GOAL_BAR)===!1)return null;const t=s.find(i=>i.goalType==="daily_minutes");if(!t)return null;const a=Math.min(100,Math.max(0,Math.round(t.currentValue/t.targetValue*100)));return(0,e.jsxs)(f,{to:"/achievements",onClick:()=>_.track(_e.GOAL_BAR_TAPPED,{progressPercent:a}),"aria-label":`${t.currentValue} of ${t.targetValue} minutes today`,className:"block px-4 md:px-6 py-2 group",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between text-[11px] font-medium text-stone-500 dark:text-stone-400 mb-1",children:[(0,e.jsxs)("span",{children:[t.currentValue," of ",t.targetValue," min today"]}),(0,e.jsx)("span",{className:"opacity-0 group-hover:opacity-100 transition-opacity",children:"Adjust â"})]}),(0,e.jsx)("div",{className:"h-1 bg-stone-200/60 dark:bg-stone-800 rounded-full overflow-hidden",children:(0,e.jsx)("div",{className:"h-full rounded-full transition-all",style:{width:`${a}%`,background:"#B8924A"}})})]})}var Vt=[{kind:"resume",signal:"resume"},{kind:"generation",signal:"generation"},{kind:"review",signal:"review"},{kind:"followed-idea",signal:"followedIdea"},{kind:"journey",signal:"journey"},{kind:"recommendation",signal:"recommendation"}];function qt(s){return s.filter(t=>t.status==="generating"||t.status==="failed").reduce((t,a)=>t?Date.parse(a.updated_at)>Date.parse(t.updated_at)?a:t:a,null)}function zt(s){for(const t of Vt){const a=s[t.signal];if(a==="loading")return{kind:"loading",waitingFor:t.kind};if(a==="available")return{kind:t.kind}}return{kind:"start"}}function Yt({idea:s}){const t=J.crossSurfaceAuthoredLinks?s.updatedCardCount:0,a=`${t} new ${t===1?"card":"cards"}`,i=`${s.updatedChapterCount} new ${s.updatedChapterCount===1?"chapter":"chapters"}`,d=[t>0?a:null,s.updatedChapterCount>0?i:null].filter(Boolean).join(" · ")||"new activity";return(0,e.jsx)(f,{to:Us.concept(s.slug),state:es(s),"aria-label":`Explore ${d} for ${s.label}`,className:"block rounded-[var(--sb-radius-surface)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)]",children:(0,e.jsx)(ce,{variant:"interactive",padding:"none",className:"p-4 shadow-[var(--sb-shadow-1)] sm:p-5",children:(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[var(--sb-radius-control)] bg-[var(--sb-surface-subtle)] text-[var(--sb-accent)]",children:(0,e.jsx)(Qe,{className:"h-5 w-5","aria-hidden":"true"})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block text-xs font-semibold text-[var(--sb-ink-muted)]",children:"New in a followed Idea"}),(0,e.jsx)("span",{className:"block truncate text-base font-bold text-[var(--sb-ink)]",children:s.label}),(0,e.jsx)("span",{className:"mt-0.5 line-clamp-1 block text-xs text-[var(--sb-ink-muted)]",children:d})]}),(0,e.jsx)("span",{className:"hidden text-xs font-semibold text-[var(--sb-accent)] sm:inline",children:"Continue"}),(0,e.jsx)(F,{className:"h-5 w-5 shrink-0 text-[var(--sb-ink-muted)]","aria-hidden":"true"})]})})})}function Wt({concepts:s,discovery:t,updates:a}){if(s.length===0)return null;const i=new Map(t.map(l=>[l.slug,l])),d=new Map(a.map(l=>[l.conceptId,l]));return(0,e.jsxs)("section",{"data-testid":"home-followed-ideas",className:"order-2 border-t border-[var(--sb-border)] pt-4",children:[(0,e.jsx)(Ce,{eyebrow:"Following",title:"Ideas you follow",titleVariant:"h3",action:(0,e.jsxs)(f,{to:"/library?view=ideas&tab=following",className:"inline-flex min-h-11 items-center gap-1 px-1 text-xs font-semibold text-[var(--sb-accent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)]",children:["See all ",(0,e.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":"true"})]}),className:"mb-2"}),(0,e.jsx)("div",{className:"flex snap-x snap-mandatory gap-2 overflow-x-auto pb-1 scrollbar-hide overscroll-x-contain",children:s.slice(0,6).map(l=>{const m=i.get(l.slug),b=d.get(l.conceptId),o=J.crossSurfaceAuthoredLinks?b?.updatedCardCount??0:0;return(0,e.jsxs)(f,{to:`/concept/${l.slug}`,state:b?es(l):void 0,onClick:()=>_.track(D.CONCEPT_CHIP_CLICKED,{source_surface:"home_following",concept_slug:l.slug}),className:"flex w-[min(82vw,320px)] shrink-0 snap-start gap-3 rounded-[var(--sb-radius-surface)] border border-[var(--sb-border)] bg-[var(--sb-surface)] p-3 transition-colors hover:bg-[var(--sb-surface-subtle)] focu
2s-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)] sm:w-72",children:[m?.coverUrls.length?(0,e.jsx)("span",{className:"relative h-16 w-12 shrink-0","aria-hidden":"true",children:m.coverUrls.slice(0,3).map((v,p)=>(0,e.jsx)("img",{src:v,alt:"",loading:"lazy",className:"absolute top-0 h-16 w-10 rounded-[3px] border border-[var(--sb-border)] object-cover shadow-sm",style:{left:`${p*5}px`,zIndex:3-p}},v))}):(0,e.jsx)("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-[var(--sb-radius-control)] bg-[var(--sb-surface-selected)] text-[var(--sb-accent)]",children:(0,e.jsx)(Qe,{className:"h-5 w-5","aria-hidden":"true"})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block truncate text-sm font-semibold text-[var(--sb-ink)]",children:l.label}),(m?.definition||l.definition)&&(0,e.jsx)("span",{className:"mt-0.5 line-clamp-2 block text-xs leading-4 text-[var(--sb-ink-muted)]",children:m?.definition||l.definition}),m&&(0,e.jsxs)("span",{className:"mt-1 block text-[11px] text-[var(--sb-ink-faint)]",children:[J.crossSurfaceAuthoredLinks&&m.cardCount>0?`${m.cardCount} ${m.cardCount===1?"card":"cards"} · `:"",m.chapterCount," Chapters · ",m.bookCount," books"]}),b&&(0,e.jsxs)("span",{className:"mt-1 inline-flex rounded-full bg-[var(--sb-surface-selected)] px-2 py-0.5 text-[10px] font-semibold text-[var(--sb-accent)]",children:[o>0?`${o} new ${o===1?"card":"cards"}`:"",o>0&&b.updatedChapterCount>0?" · ":"",b.updatedChapterCount>0?`${b.updatedChapterCount} new ${b.updatedChapterCount===1?"Chapter":"Chapters"}`:""]})]})]},l.conceptId)})})]})}function Kt({project:s}){const t=s.status==="failed",a=t?Hs:Ds,i=t?"Build needs attention":"Making your Scrollbook",d=t?"Open the project to retry the chapters that stopped.":"Your chapters are being assembled. You can follow progress or read what is ready.",l=t?"Fix build":"View progress";return(0,e.jsx)("div",{className:"px-4 md:px-6 pt-1",children:(0,e.jsxs)(f,{to:ft(s),"aria-label":`${l}: ${s.title}
2`,className:"group flex min-h-[116px] items-center gap-4 rounded-lg border border-[var(--sb-border)] bg-[var(--sb-surface)] p-4 text-left shadow-[var(--sb-shadow-1)] transition-colors hover:border-[var(--sb-border-strong)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)]",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-[var(--sb-accent-soft)] text-[var(--sb-accent)]",children:(0,e.jsx)(a,{className:`h-5 w-5 ${t?"":"animate-spin motion-reduce:animate-none"}`,strokeWidth:1.8})}),(0,e.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,e.jsx)("span",{className:"block text-xs font-semibold text-[var(--sb-accent)]",children:i}),(0,e.jsx)("span",{className:"mt-1 block truncate text-lg font-semibold text-[var(--sb-ink)]",children:s.title}),(0,e.jsx)("span",{className:"mt-1 block text-sm leading-5 text-[var(--sb-ink-muted)]",children:d})]}),(0,e.jsxs)("span",{className:"hidden shrink-0 items-center gap-1 text-sm font-semibold text-[var(--sb-accent)] sm:flex",children:[l,(0,e.jsx)(Is,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5","aria-hidden":"true"})]})]})})}var Gt=(0,r.lazy)(()=>I(()=>import("./ForYouSection-j51oADoC.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]))),Jt=(0,r.lazy)(()=>I(()=>import("./NpsSurvey-CuNf6bLg.js").then(s=>({default:s.NpsSurvey})),__vite__mapDeps([52,1,2,53,3,54,5,22,23,55,27,56,20]))),Qt=(0,r.lazy)(()=>I(()=>import("./BetaConversionBanner-CPrr4B__.js").then(s=>({default:s.BetaConversionBanner})),__vite__mapDeps([57,1,2,3,11,12,13,5,14,15,16,17,7,18,8,9,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,58,59,54,55]))),Xt=(0,r.lazy)(()=>I(()=>import("./BookBuddyDashboardHero-BYHMBl4e.js").then(s=>({default:s.BookBuddyDashboardHero})),__vite__mapDeps([60,1,2,3,61,5,8,22,23]))),Zt=(0,r.lazy)(()=>I(()=>import("./DueReviewModal-bKcCCF0w.js").then(s=>({default:s.DueReviewModal})),__vite__mapDeps([62,1,2,12,13,3,5,14,15,16,17,7,18,8,9,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,39,63,53,54,64]))),ea=(0,r.lazy)(()=>I(()=>import("./DailyReviewCard-CObmfZgv.js").then(s=>({default:s.DailyReviewCard})),__vite__mapDeps([65,1,2,12,13,3,5,14,15,16,17,7,18,8,9,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,6,66,67]))),sa=(0,r.lazy)(()=>I(()=>import("./DailyPickHero-DjE_yR8b.js").then(s=>({default:s.DailyPickHero})),__vite__mapDeps([68,1,2,3,6,5,8,69,24,20,25,26,27,28,51,46,13,12,14,15,16,17,7,18,9,19,21,22,23,29,30,31,32,33,34,35,36]))),ta=(0,r.lazy)(()=>I(()=>import("./StartHereCard-BKBhfLUL.js").then(s=>({default:s.StartHereCard})),__vite__mapDeps([70,1,2,3,16,5,8,24,20,25,26,27,28,71,72,51,46,13,12,14,15,17,7,18,9,19,21,22,23,29,30,31,32,33,34,35,36]))),aa=(0,r.lazy)(()=>I(()=>import("./ChallengeCard-CXI4r1O7.js").then(s=>({default:s.ChallengeCard})),__vite__mapDeps([73,1,2,3,39,5,74,24,20,25,26,27,28,51,46,13,12,14,15,16,17,7,18,8,9,19,21,22,23,29,30,31,32,33,34,35,36])));function tr(){(0,r.useEffect)(()=>{_.track(D.DASHBOARD_VIEWED)},[]);const{activePeriod:s,dismiss:t,markShown:a}=mt(),i=vt(),[d,l]=Ns(),[m,b]=(0,r.useState)(()=>d.get("upgraded")==="1"),[o]=(0,r.useState)(m),v=(0,r.useRef)(!1),[p,S]=(0,r.useState)(!1),[c,B]=(0,r.useState)(!1),[j,h]=(0,r.useState)(!1),{profile:k,refreshProfile:H,isPremium:R,user:u}=Ge(),ue=Xe&&k?.isAdmin===!0,T=(Ne||ue)&&!!u,{data:Q,isLoading:x,refetch:O}=Nt(!!u,T),[L,N]=(0,r.useState)(!1),[y,me]=(0,r.useState)(null),[ss,ts]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(!ye||!u){me(0);return}let n=!1;return lt.getDueCount(u.id).then(w=>{n||me(w)}),()=>{n=!0}},[ss,u]);const ae=ye&&!!u&&y===null,X=ye&&!!u&&(y??0)>0,re=T&&x,Z=T&&!x&&(Q?.dueCount??0)>0,as=We&&k?.isAdmin===!0,Ee=We&&!!u?.id,{data:rs=[],isLoading:ns,refetch:Ie}=bt(void 0,{enabled:Ee}),xe=qt(rs);(0,r.useEffect)(()=>{if(!m||v.current)return;v.current=!0,_.track(D.PAYWALL_CHECKOUT_RETURN,{surface:"dashboard"});const n=new URLSearchParams(d);n.delete("upgraded"),l(n,{replace:!0})},[d,l,m]),(0,r.useEffect)(()=>
2{if(!o)return;const n=setTimeout(()=>H(),1500);return()=>{clearTimeout(n)}},[H,o]);const{stats:ne,continueReading:he,lastViewed:M,isLoading:ee,error:pe,secondaryErrorCount:os=0,refetchPrimary:is,refetchAll:be}=dt(),A=!ee,U=he.length>0;(0,r.useEffect)(()=>{A&&Ws("dashboard",{content_state:pe?"error":U?"continue":"discovery"})},[pe,U,A]);const V=j&&A,fe=J.canonicalDiscovery&&!!u&&V,{data:ge=[]}=ht(fe),Re=J.canonicalDiscovery&&!!u&&A&&!U&&!ae&&!X&&!re&&!Z,{data:Te=[],isLoading:Le,refetch:Pe}=pt(Re||fe),oe=Te[0]??null,ve=(0,r.useMemo)(()=>ge.slice(0,6).map(n=>n.slug),[ge]),{data:ls=[]}=de({queryKey:["followed-idea-discovery",ve],queryFn:()=>Zs.getIdeaDiscovery(ve,6),enabled:fe&&ve.length>0,staleTime:5*6e4}),{unlockedCount:ds,totalCount:Ae}=nt(),{data:E}=ot(),{data:cs}=gt({enabled:V}),{data:us}=Ft(u?.id,{enabled:V}),ms=Ke(),ie=Ss(),$e=Ht(1),De=!!u&&A&&!U&&!ae&&!X&&!re&&!Z&&!Le&&oe===null,{data:xs=[],isLoading:Fe,refetch:Be}=ct({enabled:V||De}),$=xs.find(({progress:n})=>n.completedAt===null)??null,He=Xs&&A&&!U&&!ae&&!X&&!re&&!Z&&!Fe&&$===null,je=tt(He),g=zt({generation:Ee?ns?"loading":xe?"available":"unavailable":"unavailable",resume:ee?"loading":U?"available":"unavailable",review:ae||re?"loading":X||Z?"available":"unavailable",followedIdea:Re?Le?"loading":oe?"available":"unavailable":"unavailable",journey:De?Fe?"loading":$?"available":"unavailable":"unavailable",recommendation:He?je.isLoading?"loading":je.pick?"available":"unavailable":"unavailable"}),hs=Js(g.kind==="loading"),ps=(0,r.useCallback)(()=>{if(g.kind==="loading")switch(g.waitingFor){case"generation":Ie();return;case"review":me(null),ts(n=>n+1),O();return;case"journey":Be();return;case"followed-idea":Pe();return;case"recommendation":ie.invalidateQueries({queryKey:["recommendations"]});return;default:be()}},[g,ie,be,Ie,Pe,Be,O]);(0,r.useEffect)(()=>{let n=null,w=null;const P=()=>{(0,r.startTransition)(()=>{h(!0)})};return typeof window<"u"&&"requestIdleCallback"in window?w=window.requestIdleCallback(()=>P(),{timeout:450}):n=setTimeout(P,180),()=>{n&&clearTimeout(n),w!==null&&typeof window<"u"&&"cancelIdleCallback"in window&&window.cancelIdleCallback(w)}},[]);const ke=d.get("upgraded"),[Oe,bs]=(0,r.useState)(!1);(0,r.useEffect)(()=>{if(ke!=="1")return;let n=0;const w=15;let P=!1;const q=[],z=async()=>{if(P)return;const{data:qe}=await te.from("user_profiles").select("subscription_status").eq("user_id",u?.id??"").single();if(!P){if(qe?.subscription_status&&qe.subscription_status!=="free"){l({}),ie.invalidateQueries({queryKey:["user-profile"]});return}if(n++,n<w){const ys=setTimeout(z,2e3);q.push(ys)}else bs(!0)}},ks=setTimeout(z,1e3);return q.push(ks),()=>{P=!0,q.forEach(clearTimeout)}},[ie,l,ke,u?.id]);const Me=k?.subscriptionCurrentPeriodEnd??null,fs=k?.subscriptionStatus??"free",se=Me?Math.ceil((new Date(Me).getTime()-Date.now())/(1e3*60*60*24)):null,gs=fs==="trialing"&&se!==null&&se<=5,vs=!ee&&(ne?.totalChaptersCompleted??0)===0&&(ne?.totalBooksStarted??0)===0&&he.length===0&&M.length===0,Ue=c?M:M.slice(0,5),js=Math.max(0,M.length-Ue.length),Ve=Math.round(E?.progressPercent??0),C=[];return ke==="1"&&!R&&!Oe&&C.push({id:"activating",content:(0,e.jsxs)("div",{className:"px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/30 flex items-center gap-3",children:[(0,e.jsx)("div",{className:"w-4 h-4 border-2 border-amber-400 border-t-transparent rounded-full animate-spin flex-shrink-0"}),(0,e.jsx)("p",{className:"text-sm text-amber-300 font-medium",children:"Activating your Premium access..."})]})}),Oe&&!R&&C.push({id:"payment-processing",content:(0,e.jsxs)("div",{className:"px-4 py-3 rounded-xl bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-amber-800 dark:text-amber-200 mb-1",children:"Your payment is still processing"}),(0,e.jsxs)("p",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Refresh in a minute, or email"," ",(0,e.jsx)("a",{href:"mailto:[email protected]?subject=Payment%20processing%20delay",className:"underline font-medium",children:"[email protected]"}
2)," ","if it doesn't activate."]})]})}),m&&C.push({id:"upgraded",content:(0,e.jsxs)("div",{className:"rounded-xl bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 px-4 py-3 flex items-center gap-3",children:[(0,e.jsx)(qs,{icon:Ls,size:"sm-plus",shape:"circle",variant:"warning",className:"flex-shrink-0"}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("p",{className:"text-sm font-bold text-amber-800 dark:text-amber-200",children:"Welcome to Premium!"}),(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:"You now have unlimited access to every chapter in every book."})]}),(0,e.jsx)("button",{onClick:()=>b(!1),"aria-label":"Dismiss",className:"w-11 h-11 flex items-center justify-center rounded-lg text-amber-400 hover:text-amber-600 dark:hover:text-amber-300 hover:bg-amber-100 dark:hover:bg-amber-900/30 transition-colors flex-shrink-0 touch-manipulation focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-400/50",children:(0,e.jsx)(Os,{className:"w-4 h-4"})})]})}),gs&&C.push({id:"trial-expiry",content:(0,e.jsxs)("div",{className:"px-4 py-3 rounded-xl bg-amber-500/10 border border-amber-500/30 flex items-center justify-between gap-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[(0,e.jsx)("span",{className:"text-lg flex-shrink-0",children:"â°"}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("p",{className:"text-sm font-medium text-amber-300",children:["Your free trial ends ",se===0?"today":`in ${se} day${se===1?"":"s"}`]}),(0,e.jsx)("p",{className:"text-xs text-amber-400/70",children:"Upgrade to keep full access after your trial."})]})]}),(0,e.jsx)("button",{onClick:()=>ms("/pricing"),className:"flex-shrink-0 px-3 py-1.5 rounded-lg bg-amber-500 text-stone-950 text-xs font-semibold hover:bg-amber-400 transition-colors",children:"Keep Premium"})]})}),(0,e.jsxs)("div",{className:"min-h-screen bg-[var(--sb-canvas)] text-[var(--sb-ink)] pb-[calc(env(safe-area-inset-bottom)+5.5rem)] md:pb-12",children:[(0,e.jsxs)("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 pt-4 md:pt-7 space-y-6 sm:space-y-7",children:[(0,e.jsxs)("header",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 border-b border-[var(--sb-border)] pb-4 max-md:grid-cols-[minmax(0,1fr)_auto] md:pb-5",children:[(0,e.jsx)("div",{className:"min-w-0",children:(0,e.jsx)(Vs,{variant:"h1",className:"portal-page-title leading-none",children:"Home"})}),as&&(0,e.jsx)("div",{className:"min-w-0 max-md:col-span-2 max-md:order-3",children:(0,e.jsx)(r.Suspense,{fallback:null,children:(0,e.jsx)(Xt,{compact:!0})})}),$e&&(0,e.jsx)(Mt,{})]}),k?.isBetaUser&&(0,e.jsx)(r.Suspense,{fallback:null,children:(0,e.jsx)(Qt,{})}),C.length>0&&(0,e.jsxs)("section",{className:"space-y-2",children:[(0,e.jsx)("div",{children:C[0].content}),C.length>1&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("button",{onClick:()=>S(n=>!n),className:"min-h-11 px-2 text-xs font-semibold text-[var(--sb-accent)] hover:text-[var(--sb-accent-hover)] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)] rounded",children:p?"Hide extra updates":`Show ${C.length-1} more update${C.length-1===1?"":"s"}`}),p&&(0,e.jsx)("div",{className:"space-y-2",children:C.slice(1).map(n=>(0,e.jsx)("div",{children:n.content},n.id))})]})]}),(0,e.jsxs)("section",{className:"space-y-3","data-testid":"home-primary-action",children:[(0,e.jsxs)("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,13fr)_minmax(0,7fr)]",children:[(0,e.jsxs)("div",{className:"min-w-0",children:[hs&&g.kind==="loading"?(0,e.jsx)(Qs,{title:"Still loading your next action",description:"Retry without losing your place on Home.",onRetry:ps}):g.kind==="loading"?(0,e.jsx)(W,{items:[],isLoading:!0}):g.kind==="generation"&&xe?(0,e.jsx)("div",{onClick:()=>_.track(D.HOME_SECTION_CLICK,{section:"generation"}),children:(0,e.jsx)(Kt,{project:xe})}):g.kind==="resume"?(0,e.jsx)("div",{onClick:()=>_.track(D.HOME_SECTION_CLICK,{section:"continue"}),children:(0,e.jsx)(W,{items:he,isLoading:ee})}):g.kind==="review"&&X&&u?(0,e.jsx)(r.Suspense,{fallback:(0,e.jsx)(W,{items:[],isLoading:!0}),children:(0,e.jsx)(ea,{userId:u.id,dueCount:y??0})}):g.kind==="review"&&Z?(0,e.jsx)("div",{className:"px-4 md:px-6 pt-1",children:(0,e.jsx)(Ct,{summary:Q,loading:!1,domainColor:"#F59E0B",onReview:()=>N(!0)})}):g.kind==="followed-idea"&&oe?(0,e.jsx)(Yt,{idea:oe}):g.kind==="journey"&&$?(0,e.jsx)(At,{slug:$.journey.slug,title:$.journey.title,booksCompleted:$.progress.booksCompleted,bookCount:$.journey.bookCount}):g.kind==="recommendation"?(0,e.jsx)(r.Suspense,{fallback:(0,e.jsx)(W,{items:[],isLoading:!0}),children:(0,e.jsx)(sa,{result:je})}):Gs&&vs?(0,e.jsx)(r.Suspense,{fallback:(0,e.jsx)(W,{items:[],isLoading:!0}),children:(0,e.jsx)(ta,{isNewUser:!0})}):(0,e.jsx)(W,{items:[],isLoading:!1}),pe&&!ee&&(0,e.jsxs)("div",{"data-testid":"home-reading-degraded",role:"status",className:"mx-4 flex items-center gap-3 border-t border-[var(--sb-border)] py-3 text-sm text-[var(--sb-ink-muted)] md:mx-6",children:[(0,e.jsx)("span",{className:"flex-1",children:"Reading activity did not refresh. Other Home options remain available."}),(0,e.jsxs)(Ye,{"aria-label":"Retry reading activity",onClick:()=>is(),tone:"ghost",size:"sm",className:"shrink-0",children:[(0,e.jsx)(ze,{className:"h-3.5 w-3.5"}),"Retry"]})]})]}),Ae>0&&(0,e.jsxs)(f,{to:"/achievements","aria-label":`Today: Level ${E?.currentLevel??1}, ${E?.xpToNextLevel??0} XP to the next level, ${ne?.currentStreak??0} day streak`,className:"relative grid min-h-36 grid-cols-[auto_1fr] gap-x-4 gap-y-3 overflow-hidden rounded-[var(--sb-radius-surface)] border border-[var(--sb-border)] bg-[var(--sb-surface-subtle)] px-4 py-4 transition-colors hover:bg-[var(--sb-surface)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)] lg:min-h-full",children:[(0,e.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-[var(--sb-radius-control)] bg-[var(--sb-accent)]/12 text-xl font-bold tabular-nums text-[var(--sb-accent)]",children:E?.currentLevel??1}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("p",{className:"text-[11px] font-bold uppercase tracking-[0.14em] text-[var(--sb-ink-muted)]",children:"Reading progress"}),(0,e.jsxs)("p",{className:"mt-1 truncate text-base font-semibold text-[var(--sb-ink)]",children:[E?.levelTitle??"Newcomer"," · Level ",E?.currentLevel??1]}),(0,e.jsxs)("p",{className:"mt-0.5 text-xs text-[var(--sb-ink-muted)]",children:[E?.totalXp??0," XP total"]})]}),(0,e.jsxs)("div",{className:"col-span-2 space-y-1.5",children:[(0,e.jsx)("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--sb-surface)]",children:(0,e.jsx)("div",{className:"h-full rounded-full bg-[var(--sb-accent)] transition-[width] duration-300",style:{width:`${Ve}%`}})}),(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs text-[var(--sb-ink-muted)]",children:[(0,e.jsxs)("span",{children:[Ve,"% to next level"]}),(0,e.jsxs)("span",{children:[E?.xpToNextLevel??0," XP to Level ",(E?.currentLevel??1)+1]})]})]}),(0,e.jsxs)("div",{className:"col-span-2 grid grid-cols-2 border-t border-[var(--sb-border)] pt-3",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 border-r border-[var(--sb-border)] pr-3",children:[(0,e.jsx)(As,{className:"h-4 w-4 text-[var(--sb-accent)]","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"text-xs text-[var(--sb-ink-muted)]",children:[(0,e.jsx)("strong",{className:"text-[var(--sb-ink)]",children:ne?.currentStreak??0})," day streak"]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2 pl-3",children:[(0,e.jsx)(le,{className:"h-4 w-4 text-[var(--sb-accent)]","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"text-xs text-[var(--sb-ink-muted)]",children:[(0,e.jsx)("strong",{className:"text-[var(--sb-ink)]",children:Q?.dueToday??0})," reviews due"]})]})]}),(0,e.jsxs)("div",{className:"col-span-2 flex items-center justify-between text-xs text-[var(--sb-ink-muted)]",children:[(0,e.jsxs)("span",{children:[ds," of ",Ae," achievements"]}),(0,e.jsx)("span",{className:"font-semibold text-[var(--sb-accent)]",children:"See progress â"})]})]})]}),$e&&(0,e.jsx)(Ut,{})]}),A&&g.kind!=="loading"&&(0,e.jsxs)("section",{"aria-label":"Library activity",className:"space-y-5 border-t border-[var(--sb-border)] pt-5 sm:space-y-6",children:[!V&&(0,e.jsxs)("div",{className:"space-y-5",children:[(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Y,{className:"h-3 w-24"}),(0,e.jsx)(Y,{className:"h-4 w-52"}),(0,e.jsx)(Y,{className:"h-28 rounded-2xl"})]}),(0,e.jsxs)("div",{className:"space-y-1.5",children:[(0,e.jsx)(Y,{className:"h-3 w-28"}),(0,e.jsx)(Y,{className:"h-4 w-40"}),(0,e.jsx)(Y,{className:"h-44 rounded-2xl"})]})]}),V&&(0,e.jsxs)("div",{className:"flex flex-col gap-5",children:[Ne&&J.authoredFeed&&(0,e.jsx)("div",{className:"order-0 flex justify-end",children:(0,e.jsxs)(f,{to:"/library?view=ideas&tab=review",onClick:()=>_.track(D.HOME_SECTION_CLICK,{section:"saved_ideas"}),className:"inline-flex min-h-11 items-center gap-1 rounded-[var(--sb-radius-control)] px-3 text-xs font-semibold text-[var(--sb-accent)] transition-colors hover:bg-[var(--sb-surface-subtle)] focu
2s-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)]",children:["Saved ideas",(0,e.jsx)(F,{className:"h-3.5 w-3.5","aria-hidden":"true"})]})}),M.length>0&&(0,e.jsxs)("section",{className:"order-1 pt-1",children:[(0,e.jsx)(Ce,{eyebrow:"Browsing History",title:"Reviewed books and scrolls",titleVariant:"h3",action:(0,e.jsxs)(f,{to:"/library",className:"hidden min-h-11 items-center gap-1 rounded px-2 text-[11px] font-semibold text-stone-500 transition-colors hover:bg-[var(--sb-surface-subtle)] hover:text-stone-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--sb-focus)] dark:text-stone-400 dark:hover:text-stone-200 sm:inline-flex",children:["Reading hub",(0,e.jsx)(F,{className:"w-3 h-3"})]}),className:"mb-2"}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1 snap-x snap-mandatory overscroll-x-contain",children:Ue.map(n=>{const w=Ze(n.domainSlug).primary,P=!!us?.has(n.bookSlug),q=cs?.get(n.bookSlug),z=i&&P&&!!q;return(0,e.jsxs)(f,{to:z?`/scroll/${n.bookSlug}`:`/domain/${n.domainSlug}/topic/${n.bookSlug}`,onClick:()=>_.track(D.HOME_SECTION_CLICK,{section:"recent"}),className:"flex-shrink-0 group snap-start",children:[(0,e.jsxs)(K.div,{layoutId:`recently-viewed-cover-${n.bookId}`,className:"relative w-[66px] sm:w-[72px] aspect-[2/3] rounded-lg overflow-hidden shadow-sm border border-stone-200/30 dark:border-stone-700/50 group-hover:scale-[1.03] group-hover:shadow-md transition-all duration-200",children:[z?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("img",{src:q,alt:`${n.bookTitle} scroll`,className:"w-full h-full object-cover",loading:"lazy"}),(0,e.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/45 via-transparent to-transparent pointer-events-none"}),(0,e.jsxs)("div",{className:"absolute bottom-1 left-1 inline-flex items-center gap-1 rounded-full bg-black/55 px-1 py-0.5 backdrop-blur-sm",children:[(0,e.jsx)(Je,{className:"w-2 h-2 text-white"}),(0,e.jsx)("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-white",children:"Scroll"})]})]}):n.bookCoverUrl?(0,e.jsx)("img",{src:n.bookCoverUrl,alt:n.bookTitle,className:"w-full h-full object-cover",loading:"lazy"}):(0,e.jsx)("div",{className:"w-full h-full flex items-center justify-center",style:{backgroundColor:`${w}15`},children:(0,e.jsx)(le,{className:"w-4 h-4",style:{color:w}})}),!z&&n.progressPercent!=null&&n.progressPercent>0&&(0,e.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-[3px] bg-black/20",children:(0,e.jsx)("div",{className:"h-full transition-[width] duration-700 ease-out",style:{width:`${n.progressPercent}%`,backgroundColor:w}})})]}),(0,e.jsx)("p",{className:"mt-1 text-[11px] font-medium text-stone-600 dar
2k:text-stone-400 leading-tight line-clamp-2 text-center w-[66px] sm:w-[72px]",children:n.bookTitle})]},n.bookId)})}),(0,e.jsx)("div",{className:"absolute top-0 right-0 bottom-1 w-8 bg-gradient-to-l from-[#f8f7f4] dark:from-stone-950 to-transparent pointer-events-none"})]}),M.length>5&&(0,e.jsx)("button",{onClick:()=>B(n=>!n),className:"mt-2 text-[11px] font-semibold text-stone-500 hover:text-stone-700 dark:text-stone-400 dark:hover:text-stone-200 transition-colors",children:c?"Show less history":`Show ${js} more from history`})]}),(0,e.jsx)(Wt,{concepts:ge,discovery:ls,updates:Te}),(0,e.jsxs)("section",{"data-testid":"home-recommendations",className:"order-3 border-t border-[var(--sb-border)] pt-4",children:[(0,e.jsx)(Ce,{title:"Recommended",titleVariant:"h3",className:"mb-1.5"}),(0,e.jsx)(r.Suspense,{fallback:(0,e.jsx)("div",{className:"h-64 bg-stone-100 dark:bg-stone-900 animate-pulse rounded-3xl"}),children:(0,e.jsx)(Gt,{})})]}),zs&&(0,e.jsx)("div",{className:"order-4",children:(0,e.jsx)(r.Suspense,{fallback:null,children:(0,e.jsx)(aa,{})})}),os>0&&(0,e.jsxs)("div",{"data-testid":"home-secondary-degraded",className:"order-5 flex items-center gap-3 border-t border-[var(--sb-border)] px-1 py-3 text-xs text-[var(--sb-ink-muted)]",children:[(0,e.jsx)("span",{className:"flex-1",children:"Some optional Home sections could not refresh."}),(0,e.jsxs)(Ye,{tone:"ghost",size:"sm",onClick:()=>be(),children:[(0,e.jsx)(ze,{className:"h-3.5 w-3.5"}),"Retry"]})]}),(0,e.jsx)("div",{className:"order-6",children:(0,e.jsx)($t,{compact:!0})})]})]})]}),s&&(0,e.jsx)(r.Suspense,{fallback:null,children:(0,e.jsx)(Jt,{period:s,onDismiss:t,onShown:a})}),T&&L&&(0,e.jsx)(r.Suspense,{fallback:null,children:(0,e.jsx)(Zt,{domainColor:"#F59E0B",onClose:()=>N(!1)})})]})}export{tr as DashboardPage,tr as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.