PageSourceSearch

https://www.blogsareback.com/_next/static/chunks/298b74ed4786f85b.js?dpl=dpl_2AoYzJN76fgCzbjZUujwxkzXrRk6

js blogsareback.com collected 2026-10-04 22:47:45 UTC 416,727 bytes, 28 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,342081,e=>{"use strict";let t,r;var s,a=e.i(843476),o=e.i(770703),n=e.i(672464),i=e.i(107233),l=e.i(239616),c=e.i(245077),d=e.i(811522),u=e.i(167881),m=e.i(902135),h=e.i(412894),f=e.i(568385),p=e.i(271645),g=e.i(646683),x=e.i(10248),b=e.i(584540),y=e.i(994179),v=e.i(728231),j=e.i(658041),w=e.i(727927),N=e.i(553475),k=e.i(657212),C=e.i(16715),A=e.i(647163);function S({className:e}){let t=(0,f.useIsCloudSyncEnabled)(),r=function(){let e=(0,f.useStorage)(),[t,r]=(0,p.useState)(null),s=(0,p.useRef)(null);return(0,p.useEffect)(()=>{if(!(e instanceof g.HybridAdapter)){null!==s.current&&(s.current=null,r(null));return}let t=e=>{var t;(t=s.current)===e||t&&e&&t.isSyncing===e.isSyncing&&t.lastSyncAt===e.lastSyncAt&&t.queueSize===e.queueSize&&t.deadLetterCount===e.deadLetterCount&&t.errors.length===e.errors.length&&t.errors.every((t,r)=>t===e.errors[r])||(s.current=e,r(e))};e.getSyncStatus().then(t);let a=setInterval(()=>{e.getSyncStatus().then(t)},3e4);return()=>{clearInterval(a)}},[e]),t}(),{isOnline:s}=(0,x.useNetworkStatus)(),o=(0,n.useSetAtom)(b.settingsDialogOpenAtom),i=(0,n.useSetAtom)(b.settingsTabSelectionAtom),l=t?{icon:(0,a.jsx)(w.Cloud,{className:"size-3"}),label:"Cloud",color:"bg-emerald-500/20 text-emerald-700 dark:text-emerald-400 border-emerald-500/30",description:"Local-first with cloud backup"}:{icon:(0,a.jsx)(j.Database,{className:"size-3"}),label:"Local",color:"bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-500/30",description:"Data stored locally in your browser"};return(0,a.jsx)(v.TooltipProvider,{delayDuration:300,children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("div",{onClick:()=>{i("sync"),o(!0)},className:(0,A.cn)("flex items-center gap-1.5 px-1 py-1 rounded-md border text-xs font-medium select-none cursor-pointer transition-opacity hover:opacity-80",l.color,e),children:[l.icon,(0,a.jsx)("span",{children:l.label}),t&&r?.isSyncing&&(0,a.jsx)(C.RefreshCw,{className:"size-3 animate-spin opacity-70"}),t&&r&&r.queueSize>0&&!r.isSyncing&&(0,a.jsx)(y.Badge,{variant:"secondary",className:"h-4 px-1 text-[10px] font-normal",children:r.queueSize}),t&&r&&r.deadLetterCount>0&&(0,a.jsx)("div",{className:"size-2 bg-red-500 rounded-full"}),(0,a.jsx)("div",{className:"ml-0.5",children:s?(0,a.jsx)(N.Wifi,{className:"size-3 opacity-70"}):(0,a.jsx)(k.WifiOff,{className:"size-3 opacity-70"})})]})}),(0,a.jsx)(v.TooltipContent,{side:"top",className:"max-w-xs",children:(0,a.jsxs)("div",{className:"space-y-1 text-center items-center justify-center flex flex-col",children:[(0,a.jsx)("div",{className:"font-semibold",children:l.label}),(0,a.jsx)("div",{className:"text-xs text-secondary",children:l.description}),t&&r&&(0,a.jsxs)("div",{className:"w-full flex flex-col items-center justify-center p-2 bg-secondary/15 rounded-md",children:[(0,a.jsx)("div",{className:"flex items-center gap-1 w-full justify-center",children:r.isSyncing?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(C.RefreshCw,{className:"size-3 animate-spin"}),(0,a.jsx)("span",{children:"Syncing..."})]}):r.queueSize>0?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("span",{className:"text-amber-600 dark:text-amber-400",children:["● ",r.queueSize," pending"]})}):(0,a.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400",children:"● Synced"})}),(0,a.jsxs)("div",{className:"w-full font-light",children:["Last sync: ",(e=>{if(!e)return"Never synced";let t=Math.floor((Date.now()-e)/1e3);return t<60?"Just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`})(r.lastSyncAt)]}),r.deadLetterCount>0&&(0,a.jsxs)("div",{className:"w-full text-red-500 dark:text-red-400 font-light",children:[r.deadLetterCount," failed sync",1===r.deadLetterCount?"":"s"]})]}),(0,a.jsx)("div",{className:"text-xs text-secondary mb-1 w-full",children:s?(0,a.jsx)("span",{className:"text-emerald-600 dark:text-emerald-400",children:"● Online"}
1):(0,a.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"● Offline"})}),!s&&!t&&(0,a.jsx)("div",{className:"text-xs text-secondary",children:"All features available offline"}),!s&&t&&(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Changes will sync when you're back online"}),!t&&s&&(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Sign in to enable cloud backup"})]})})]})})}var T=e.i(786681),E=e.i(39312),M=e.i(25652),_=e.i(951445);function z({className:e}){let t=(0,n.useAtomValue)(T.extensionStatsAtom),r=(0,n.useAtomValue)(T.pendingExtensionSubscriptionsAtom),s=(0,n.useSetAtom)(T.extensionQueueModalOpenAtom),o=(0,n.useAtomValue)(T.desktopAppAtom),[l,c]=(0,p.useState)(!1),d=(0,p.useRef)(null),u=r.length;(0,p.useEffect)(()=>{if(!d.current)return;let e=new ResizeObserver(e=>{for(let t of e)c(t.contentRect.width<85)});return e.observe(d.current),()=>e.disconnect()},[]);let m=t.feedsFetchedViaExtension+t.feedsFetchedViaProxy;return o?(0,a.jsx)(v.TooltipProvider,{delayDuration:300,children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("div",{ref:d,className:(0,A.cn)("flex items-center gap-1.5 px-1 py-1 rounded-md border text-xs font-medium select-none transition-all cursor-default","bg-gradient-to-r from-blue-500/15 via-purple-500/15 to-blue-500/15","text-blue-700 dark:text-blue-400 border-blue-500/30","animate-in fade-in duration-500",e),children:[(0,a.jsx)(_.Monitor,{className:"size-3"}),(0,a.jsx)("span",{children:l?"App":"Desktop"})]})}),(0,a.jsx)(v.TooltipContent,{side:"top",className:"max-w-xs",children:(0,a.jsxs)("div",{className:"space-y-1 text-center flex flex-col items-center pb-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(_.Monitor,{className:"size-4 text-blue-500"}),(0,a.jsx)("div",{className:"font-semibold",children:"Desktop App"})]}),(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Fetching feeds natively"})]})})]})}):(0,a.jsx)(v.TooltipProvider,{delayDuration:300,children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("div",{ref:d,onClick:()=>{u>0&&s(!0)},className:(0,A.cn)("flex items-center gap-1.5 px-1 py-1 rounded-md border text-xs font-medium select-none transition-all","bg-gradient-to-r from-amber-500/15 via-orange-500/15 to-amber-500/15","text-amber-700 dark:text-amber-400 border-amber-500/30","animate-in fade-in duration-500",u>0?"cursor-pointer hover:opacity-80":"cursor-default",e),children:[(0,a.jsx)(E.Zap,{className:"size-3 fill-current"}),(0,a.jsx)("span",{children:l?"Ext":"Extension"}),u>0&&(0,a.jsx)(y.Badge,{variant:"secondary",className:"h-4 px-1 text-[10px] font-normal",children:u})]})}),(0,a.jsx)(v.TooltipContent,{side:"top",className:"max-w-xs",children:(0,a.jsxs)("div",{className:"space-y-2 text-center items-center justify-center flex flex-col pb-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(E.Zap,{className:"size-4 fill-amber-500 text-amber-500"}),(0,a.jsx)("div",{className:"font-semibold",children:"Extension Connected"})]}),(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Fetching feeds directly in your browser"}),u>0&&(0,a.jsxs)("div",{className:"w-full flex flex-col gap-1 p-2 bg-emerald-500/10 rounded-md border border-emerald-500/20",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 justify-center text-xs text-emerald-700 dark:text-emerald-400",children:[(0,a.jsx)(i.Plus,{className:"size-3"}),(0,a.jsxs)("span",{className:"font-medium",children:[u," blog",1!==u?"s":""," queued"]})]}),(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Click to review and add"})]}),m>0&&(0,a.jsxs)("div",{className:"w-full flex flex-col gap-1.5 p-2 bg-secondary/15 rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 justify-center text-xs",children:[(0,a.jsx)(M.TrendingUp,{className:"size-3"}),(0,a.jsx)("span",{className:"font-medium",children:"Usage Stats"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Via Extension"}
1),(0,a.jsx)("div",{className:"font-semibold text-amber-600 dark:text-amber-400",children:t.feedsFetchedViaExtension})]}),(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Via Proxy"}),(0,a.jsx)("div",{className:"font-semibold",children:t.feedsFetchedViaProxy})]})]}),(t.textExtractionsViaExtension>0||t.textExtractionsViaProxy>0)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"border-t border-border/50 pt-1.5 mt-0.5"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Extractions"}),(0,a.jsx)("div",{className:"font-semibold text-amber-600 dark:text-amber-400",children:t.textExtractionsViaExtension})]}),(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Proxy"}),(0,a.jsx)("div",{className:"font-semibold",children:t.textExtractionsViaProxy})]})]})]})]}),0===m&&0===u&&(0,a.jsx)("div",{className:"text-xs text-secondary",children:"Ready to fetch feeds faster"})]})})]})})}function R({className:e}){return(0,n.useAtomValue)(T.extensionAvailableAtom)?(0,a.jsx)(z,{className:e}):null}var P=e.i(151363),I=e.i(120679),L=e.i(618393),D=e.i(643531),F=e.i(37727),O=e.i(63209),B=e.i(178583),$=e.i(983123),U=e.i(555436);function V({className:e}){let t=(0,n.useAtomValue)(P.customProxyConfigAtom),r=(0,n.useAtomValue)(P.hasCustomProxyAtom),{stats:s}=(0,I.useProxyStats)(),[o,i]=(0,p.useState)(!1),l=(0,p.useRef)(null),c=(0,n.useSetAtom)(b.settingsDialogOpenAtom),d=(0,n.useSetAtom)(b.settingsTabSelectionAtom);if((0,p.useEffect)(()=>{if(!l.current)return;let e=new ResizeObserver(e=>{for(let t of e)i(t.contentRect.width<85)});return e.observe(l.current),()=>e.disconnect()},[]),!t)return null;let u=t.isValidated,m=t.isEnabled,h=!!t.lastError,f=u?m?h?{bg:"bg-red-500/20 border-red-500/30",text:"text-red-700 dark:text-red-400",border:"border-red-500/30",icon:(0,a.jsx)(O.AlertCircle,{className:"size-3"})}:{bg:"bg-sky-500/20 border-sky-500/30",text:"text-sky-700 dark:text-sky-400",border:"border-sky-500/30",icon:(0,a.jsx)(L.Server,{className:"size-3"})}:{bg:"bg-secondary/50",text:"text-muted-foreground",border:"border-border",icon:(0,a.jsx)(L.Server,{className:"size-3"})}:{bg:"bg-yellow-500/20 border-yellow-500/30",text:"text-yellow-700 dark:text-yellow-400",border:"border-yellow-500/30",icon:(0,a.jsx)(O.AlertCircle,{className:"size-3"})};return(0,a.jsx)(v.TooltipProvider,{delayDuration:300,children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("div",{ref:l,onClick:()=>{d("advanced"),c(!0)},className:(0,A.cn)("flex items-center gap-1.5 px-1 py-1 rounded-md border text-xs font-medium select-none transition-all",f.bg,f.text,f.border,"animate-in fade-in duration-500 cursor-pointer",e),children:[f.icon,(0,a.jsx)("span",{children:o?"Proxy":"Custom Proxy"})]})}),(0,a.jsx)(v.TooltipContent,{side:"top",className:"max-w-xs",children:(0,a.jsxs)("div",{className:"space-y-2 text-center items-center justify-center flex flex-col pb-1",children:[(0,a.jsx)("div",{className:"flex items-center gap-1.5",children:(0,a.jsx)("div",{className:"font-semibold",children:r?"Custom Proxy Active":"Custom Proxy Configured"})}),(0,a.jsxs)("div",{className:"text-xs text-secondary",children:[!u&&"Needs validation",u&&!m&&"Validated but disabled",u&&m&&t.mobileOnly&&"Active on mobile only",u&&m&&!t.mobileOnly&&"Active for all devices"]}),u&&(0,a.jsxs)("div",{className:"w-full flex flex-col gap-1.5 p-2 bg-secondary/15 rounded-md",children:[(0,a.jsx)("div",{className:"text-xs font-medium",children:"Capabilities"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-center gap-3 text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)($.Rss,{className:"size-3"}),(0,a.jsx)("span",{children:"Fetch"}),t.capabilities.fetch?(0,a.jsx)(D.Check,{className:"size-3 text-lime-500 dark:text-lime-600",strokeWidth:3}):(0,a.jsx)(F.X,{className:"size-3 text-red-500"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(B.FileText,{className:"size-3"}),(0,a.jsx)("span",{children:"Parse"}),t.capabilities.parse?(0,a.jsx)(D.Check,{className:"size-3 text-lime-500 dark:text-lime-600",strokeWidth:3}):(0,a.jsx)(F.X,{className:"size-3 text-muted-foreground"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(U.Search,{className:"size-3"}),(0,a.jsx)("span",{children:"Discover"}),t.capabilities?.discover&&!0==t.capabilities.discover?(0,a.jsx)(D.Check,{className:"size-3 text-lime-500 dark:text-lime-600",strokeWidth:3}):(0,a.jsx)(F.X,{className:"size-3 text-muted-foreground"})]})]}),!t.capabilities.parse&&(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Parse requires Node.js runtime (Vercel/Docker)"})]}),h&&(0,a.jsxs)("div",{className:"w-full flex flex-col gap-1 p-2 bg-red-500/10 rounded-md border border-red-500/20",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 justify-center text-xs text-red-700 dark:text-red-400",children:[(0,a.jsx)(O.AlertCircle,{className:"size-3"}),(0,a.jsx)("span",{className:"font-medium",children:"Error"})]}),(0,a.jsx)("div",{className:"text-xs text-secondary truncate max-w-[200px]",children:t.lastError})]}),(s.feedsFetched>0||s.parseOperations>0)&&(0,a.jsxs)("div",{className:"w-full flex flex-col gap-1.5 p-2 bg-secondary/15 rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 justify-center text-xs",children:[(0,a.jsx)(M.TrendingUp,{className:"size-3"}),(0,a.jsx)("span",{className:"font-medium",children:"Session Stats"})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Feeds Fetched"}),(0,a.jsx)("div",{className:"font-semibold text-emerald-600 dark:text-emerald-400",children:s.feedsFetched})]}),(0,a.jsxs)("div",{className:"text-left",children:[(0,a.jsx)("div",{className:"text-secondary",children:"Parse Ops"}),(0,a.jsx)("div",{className:"font-semibold text-emerald-600 dark:text-emerald-400",children:s.parseOperations})]})]})]}),t.provider&&(0,a.jsxs)("div",{className:"text-[10px] text-muted-foreground",children:[t.provider,t.version&&` v${t.version}`]})]})})]})})}function q({className:e}){return(0,n.useAtomValue)(P.customProxyConfigAtom)?(0,a.jsx)(V,{className:e}):null}var H=e.i(531278),G=e.i(503116),W=e.i(340842);let K={"service-worker":"Service Worker","app-shell":"App Shell","reader-assets":"Reader Assets"};function Y({status:e}){return"ready"===e?(0,a.jsx)(D.Check,{className:"size-3 text-emerald-500",strokeWidth:3}):"error"===e?(0,a.jsx)(F.X,{className:"size-3 text-red-500",strokeWidth:3}):(0,a.jsx)(G.Clock,{className:"size-3 text-amber-500"})}function Q({className:e}){let t=(0,n.useAtomValue)(W.offlineReadinessAtom),r=(0,n.useAtomValue)(W.offlineReadyAtom),s=(0,n.useAtomValue)(W.swUpdatingAtom),o=(0,n.useAtomValue)(W.swDevModeAtom),i=(0,n.useAtomValue)(W.cacheValidationAtom),[l,c]=(0,p.useState)(!1),d=(0,p.useRef)(null),u=(0,n.use
1SetAtom)(b.settingsDialogOpenAtom),m=(0,n.useSetAtom)(b.settingsTabSelectionAtom),h=(0,n.useSetAtom)(b.settingsScrollTargetAtom);(0,p.useEffect)(()=>{if(!d.current)return;let e=new ResizeObserver(e=>{for(let t of e)c(t.contentRect.width<85)});return e.observe(d.current),()=>e.disconnect()},[]);let f="error"===t["service-worker"],g=!r&&!f,x=f?{bg:"bg-red-500/20 border-red-500/30",text:"text-red-700 dark:text-red-400",border:"border-red-500/30",icon:(0,a.jsx)(O.AlertCircle,{className:"size-3"})}:g?{bg:"bg-amber-500/20 border-amber-500/30",text:"text-amber-700 dark:text-amber-400",border:"border-amber-500/30",icon:(0,a.jsx)(H.Loader2,{className:"size-3 animate-spin"})}:{bg:"bg-emerald-500/20 border-emerald-500/30",text:"text-emerald-700 dark:text-emerald-400",border:"border-emerald-500/30",icon:(0,a.jsx)(k.WifiOff,{className:"size-3"})};return(0,a.jsx)(v.TooltipProvider,{delayDuration:300,children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)("div",{ref:d,onClick:()=>{m("desktop"),h("offline-readiness"),u(!0)},className:(0,A.cn)("flex items-center gap-1.5 px-1 py-1 rounded-md border text-xs font-medium select-none transition-all",x.bg,x.text,x.border,"animate-in fade-in duration-500 cursor-pointer",e),children:[x.icon,(0,a.jsx)("span",{children:l?"Offline":"Offline Ready"})]})}),(0,a.jsx)(v.TooltipContent,{side:"top",className:"max-w-xs",children:(0,a.jsxs)("div",{className:"space-y-2 text-center items-center justify-center flex flex-col pb-1",children:[(0,a.jsx)("div",{className:"font-semibold",children:f?"Offline Error":g?"Preparing Offline...":"Offline Ready"}),(0,a.jsx)("div",{className:"w-full flex flex-col gap-1.5 p-2 bg-secondary/15 rounded-md",children:Object.entries(t).map(([e,t])=>(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,a.jsx)("span",{children:K[e]||e}),(0,a.jsx)(Y,{status:t})]},e))}),i&&(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Caches: ",i.valid?"verified":"missing"]}),s&&(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[(0,a.jsx)(H.Loader2,{className:"size-3 animate-spin"}),(0,a.jsx)("span",{children:"Updating..."})]}),o&&(0,a.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Dev mode"})]})})]})})}function X({className:e}){let t=(0,c.useIsDesktopApp)(),r=(0,n.useAtomValue)(b.showOfflineStatusAtom);return t||r?(0,a.jsx)(Q,{className:e}):null}var Z=e.i(111369),J=e.i(598522),ee=e.i(664659),et=e.i(595494),er=e.i(440453);let es=({className:e,...t})=>{let r=(0,n.useAtomValue)(er.blogsAtom),[s,o]=(0,n.useAtom)(b.selectedTagsAtom),[i,l]=(0,n.useAtom)(b.tagFilterModeAtom),[c,u]=(0,n.useAtom)(b.tagFilterSectionOpenAtom),[m,h]=(0,n.useAtom)(b.selectedBlogIdAtom),f=(0,p.useMemo)(()=>(0,et.getUniqueTags)(r),[r]);return 0===f.length?null:(0,a.jsx)(Z.Collapsible,{open:c,onOpenChange:u,className:(0,A.cn)("group/filter-tags-collapsible",e),...t,children:(0,a.jsxs)(d.SidebarGroup,{className:"py-1.5",children:[(0,a.jsx)(d.SidebarGroupLabel,{asChild:!0,children:(0,a.jsx)(Z.CollapsibleTrigger,{className:"w-full",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ee.ChevronDown,{className:"transition-transform group-data-[state=open]/filter-tags-collapsible:rotate-0 group-data-[state=closed]/filter-tags-collapsible:-rotate-90 size-4"}),(0,a.jsx)("span",{children:"Tags"})]})})}),(0,a.jsx)(d.SidebarGroupAction,{onClick:()=>{l("any"===i?"all":"any")},title:"any"===i?"Switch to AND mode (all tags required)":"Switch to OR mode (any tag matches)",className:"group-data-[state=closed]/filter-tags-collapsible:hidden",children:(0,a.jsx)("div",{className:"flex items-center text-xs bg-accent rounded-sm px-2 py-1 font-semibold",children:"any"===i?"OR":"AND"})}),(0,a.jsx)(Z.CollapsibleContent,{children:(0,a.jsx)(d.SidebarGroupContent,{children:(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 px-2 py-2",children:f.map(e=>{let t=s.includes(e);return(0,a.jsx)("button",{onClick:()=>{s.includes(e)?o(s.filter(t=>t!==e)):o([...s,e]),h(null)},className:(0,A.cn)("cursor-pointer hover:opacity-100 transition-all duration-200 hover:scale-105 active:scale-95",t?"opacity-100":"opacity-60"),title:t?`Remove ${e} filter`:`Filter by ${e}`,children:(0,a.jsx)(J.TagBadge,{tag:e})},e)})})})})]})})};var ea=e.i(989214),eo=e.i(78535);let en=({className:e,...t})=>{let r=(0,n.useAtomValue)(er.blogsAtom),[s,o]=(0,n.useAtom)(b.selectedSourcesAtom),[i,l]=(0,n.useAtom)(b.selectedCategoriesAtom),[c,u]=(0,n.useAtom)(ea.selectedDashboardLanguagesAtom),[m,h]=(0,n.useAtom)(b.sourceCategoryFilterSectionOpenAtom),[f,g]=(0,n.useAtom)(b.selectedBlogIdAtom),x=(0,n.useAtomValue)(ea.enableLanguageFilterSidebarAtom),v=(0,p.useMemo)(()=>{let e={custom:0,directory:0,community:0};return r.forEach(t=>{"custom"===t.source?e.custom++:"directory"===t.source?e.directory++:"community"===t.source&&e.community++}),e},[r]),j=(0,p.useMemo)(()=>
1{let e={indie:0,publication:0,corporate:0,unknown:0};return r.forEach(t=>{if(("directory"===t.source||"community"===t.source)&&t.category){let r=t.category;r in e&&e[r]++}}),e},[r]),w=(0,p.useMemo)(()=>x?(0,eo.getLanguagesFromBlogs)(r):[],[r,x]),N=s.length+i.length+c.length;if(0===r.length)return null;let k=[v.custom,v.directory,v.community].filter(e=>e>0).length>1,C=v.directory>0||v.community>0,S=x&&w.length>0;if(!k&&!C&&!S)return null;let T=[{key:"custom",label:"Custom",count:v.custom},{key:"directory",label:"Directory",count:v.directory},{key:"community",label:"Community",count:v.community}].filter(e=>e.count>0),E=[{key:"indie",label:"Personal",count:j.indie},{key:"publication",label:"Publication",count:j.publication},{key:"corporate",label:"Corporate",count:j.corporate},{key:"unknown",label:"Unknown",count:j.unknown}].filter(e=>e.count>0);return(0,a.jsx)(Z.Collapsible,{open:m,onOpenChange:h,className:(0,A.cn)("group/filter-source-category-collapsible",e),...t,children:(0,a.jsxs)(d.SidebarGroup,{className:"py-1.5",children:[(0,a.jsx)(d.SidebarGroupLabel,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsxs)(Z.CollapsibleTrigger,{className:"flex items-center gap-2",children:[(0,a.jsx)(ee.ChevronDown,{className:"transition-transform group-data-[state=open]/filter-source-category-collapsible:rotate-0 group-data-[state=closed]/filter-source-category-collapsible:-rotate-90 size-4"}),(0,a.jsx)("span",{children:"Filters"})]}),N>0&&(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),o([]),l([]),u([])},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:"Clear"})]})}),(0,a.jsx)(Z.CollapsibleContent,{children:(0,a.jsx)(d.SidebarGroupContent,{children:(0,a.jsxs)("div",{className:"space-y-3 px-2 py-2",children:[k&&T.length>1&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-1",children:"Source"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:T.map(e=>{let t=s.includes(e.key);return(0,a.jsxs)(y.Badge,{variant:t?"default":"outline",className:(0,A.cn)("cursor-pointer transition-all duration-200 hover:scale-105 active:scale-95",t?"opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>{var t;return t=e.key,void(s.includes(t)?o(s.filter(e=>e!==t)):o([...s,t]),g(null))},children:[e.label,(0,a.jsx)("span",{className:"ml-1.5 text-[10px] opacity-70",children:e.count})]},e.key)})})]}),C&&E.length>0&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-1",children:"Type"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:E.map(e=>{let t=i.includes(e.key);return(0,a.jsxs)(y.Badge,{variant:t?"default":"outline",className:(0,A.cn)("cursor-pointer transition-all duration-200 hover:scale-105 active:scale-95",t?"opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>{var t;return t=e.key,void(i.includes(t)?l(i.filter(e=>e!==t)):l([...i,t]),g(null))},children:[e.label,(0,a.jsx)("span",{className:"ml-1.5 text-[10px] opacity-70",children:e.count})]},e.key)})})]}),S&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold text-muted-foreground uppercase tracking-wide px-1",children:"Language"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:w.map(e=>{let t=c.includes(e.code);return(0,a.jsxs)(y.Badge,{variant:t?"default":"outline",className:(0,A.cn)("cursor-pointer transition-all duration-200 hover:scale-105 active:scale-95",t?"opacity-100":"opacity-60 hover:opacity-100"),onClick:()=>{var t;return t=e.code,void(c.includes(t)?u(c.filter(e=>e!==t)):u([...c,t]),g(null))},children:[(0,eo.getLanguageName)(e.code),(0,a.jsx)("span",{className:"ml-1.5 text-[10px] opacity-70",children:e.count})]},e.code)})})]})]})})})]})})};var ei=e.i(332102),el=e.i(870273),ec=e.i(571930),ed=e.i(87316),eu=e.i(489853),em=e.i(394908),eh=e.i(722915),ef=e.i(618566),ep=e.i(215324),eg=e.i(461731),ex=e.i(105069);let eb=()=>{let e=(0,ef.useRouter)(),t=(0,ex.default)(),{data:r}=(0,eg.useUserSettings)(),[s,a]=(0,n.useAtom)(b.exploreModeAtom),[,o]=(0,n.useAtom)(b.searchModeAtom),[i,l]=(0,n.useAtom)(b.mobileViewAtom),[,c]=(0,n.useAtom)(b.selectedBlogIdAtom),[,d
1]=(0,n.useAtom)(b.selectedTagsAtom),[u,m]=(0,n.useAtom)(b.viewFilterAtom),h=()=>{if(t?l("explore"):a(!0),o(!1),c(null),d([]),r?.url_routing_enabled??!0){let t=(0,ep.getExploreDashboardUrl)();e.push(t)}},f=s=>{if(t?l("list"):a(!1),c(null),d([]),s&&m(s),r?.url_routing_enabled??!0){let t=(0,ep.getDashboardUrl)(s||u);e.push(t)}};return{navigateToExplore:h,exitExploreMode:f,toggleExploreMode:()=>{(t?"explore"===i:s)?f():h()},isInExploreMode:t?"explore"===i:s}};var ey=e.i(853419),ev=e.i(919403);function ej({icon:e,label:t,count:r,isActive:s,onClick:o}){return(0,a.jsx)(d.SidebarMenuItem,{children:(0,a.jsxs)(d.SidebarMenuButton,{isActive:s,onClick:o,className:(0,A.cn)("smart-view-item relative group","transition-all duration-200",s&&"font-medium"),"data-active":s,children:[(0,a.jsx)("span",{className:(0,A.cn)("absolute left-0 top-1/2 -translate-y-1/2 w-0.5 rounded-r-full bg-primary","h-0 opacity-0 transition-all duration-200",s&&"h-4 opacity-100")}),(0,a.jsx)(e,{className:(0,A.cn)("size-4 transition-colors duration-200",s?"text-primary":"text-muted-foreground group-hover:text-foreground")}),(0,a.jsx)("span",{className:"flex-1",children:t}),void 0!==r&&r>0&&(0,a.jsx)("span",{className:(0,A.cn)("smart-view-count ml-auto","font-medium","min-w-[1.25rem] px-1.5 py-0.5 rounded-full","text-[10px] leading-none text-center","transition-all duration-200",s?"bg-primary/15 text-primary":"bg-muted/60 text-muted-foreground"),children:r>999?"999+":r})]})})}let ew=({className:e,...t})=>{let r=(0,ef.usePathname)(),[s,o]=(0,n.useAtom)(b.viewFilterAtom),i=(0,n.useAtomValue)(b.selectedBlogIdAtom),l=(0,n.useAtomValue)(er.unreadCountAtom),c=(0,n.useAtomValue)(er.starredCountAtom),u=(0,n.useAtomValue)(er.readLaterCountAtom),m=(0,n.useAtomValue)(er.savedPostsCountAtom),h=(0,n.useAtomValue)(b.showUnreadCountInSmartViewsAtom),f=(0,ev.useSavedPostsEnabled)(),p=(0,n.use
1SetAtom)(er.stickyUnreadGuidsAtom),{toggleExploreMode:g,exitExploreMode:x,isInExploreMode:y}=eb(),{toggleSearchMode:v,exitSearchMode:j,isInSearchMode:w}=(()=>{let e=(0,ef.useRouter)(),t=(0,ex.default)(),{data:r}=(0,eg.useUserSettings)(),[s,a]=(0,n.useAtom)(b.searchModeAtom),[o,i]=(0,n.useAtom)(b.mobileViewAtom),l=(0,n.useSetAtom)(b.exploreModeAtom),c=(0,n.useSetAtom)(b.selectedBlogIdAtom),d=(0,n.useSetAtom)(b.selectedTagsAtom),u=(0,n.useSetAtom)(er.selectedPostIdAtom),m=(0,n.useSetAtom)(er.searchSelectedPostAtom),h=(0,n.useAtomValue)(b.viewFilterAtom),f=()=>{if(t?i("search"):a(!0),l(!1),u(null),m(null),c(null),d([]),r?.url_routing_enabled??!0){let t=(0,ep.getSearchDashboardUrl)();e.push(t)}},p=s=>{if(t?i("list"):a(!1),u(null),m(null),r?.url_routing_enabled??!0){let t=(0,ep.getDashboardUrl)(s||h);e.push(t)}};return{navigateToSearch:f,exitSearchMode:p,toggleSearchMode:()=>{(t?"search"===o:s)?p():f()},isInSearchMode:t?"search"===o:s}})(),N=[{id:"all",icon:$.Rss,label:"All Posts",isActive:"all"===s&&!i&&!y&&!w},{id:"unread",icon:ei.Inbox,label:"Unread",count:h?l:void 0,isActive:"unread"===s&&!y&&!w},{id:"starred",icon:el.Star,label:"Starred",count:h?c:void 0,isActive:"starred"===s&&!y&&!w},{id:"readLater",icon:ec.Bookmark,label:"Read Later",count:h?u:void 0,isActive:"readLater"===s&&!y&&!w},...f?[{id:"saved",icon:eh.Archive,label:"Saved",count:h?m:void 0,isActive:"saved"===s&&!y&&!w}]:[],{id:"today",icon:ed.Calendar,label:"Today",isActive:"today"===s&&!y&&!w},{id:"week",icon:eu.CalendarDays,label:"This Week",isActive:"week"===s&&!y&&!w}];return(0,a.jsxs)(d.SidebarGroup,{className:(0,A.cn)("py-1.5",e),...t,children:[(0,a.jsx)(d.SidebarGroupLabel,{className:"text-[11px] uppercase tracking-wider text-muted-foreground/70 font-medium",children:"Views"}),(0,a.jsx)(d.SidebarGroupContent,{children:(0,a.jsxs)(d.SidebarMenu,{children:[N.map(e=>(0,a.jsx)(ej,{icon:e.icon,label:e.label,count:e.count,isActive:e.isActive,onClick:()=>{var t;return t=e.id,void((0,ey.trackViewFilterChanged)(t),p(new Set),w&&j(t),x(t))}},e.id)),(0,a.jsxs)("div",{className:"mt-1 pt-1 border-t border-border/30",children:[(0,a.jsx)(ej,{icon:em.Compass,label:"Explore Blogs",isActive:y,onClick:g}),(0,a.jsx)(ej,{icon:U.Search,label:"Search Posts",isActive:w||"/dashboard/search"===r,onClick:v})]})]})})]})};var eN=e.i(522247),ek=e.i(370956),eC=e.i(475254);let eA=(0,eC.default)("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);var eS=e.i(788699),eT=e.i(463059),eE=e.i(794771),eM=e.i(174886),e_=e.i(727612),ez=e.i(778917),eR=e.i(878894),eP=e.i(495242);let eI=(0,eC.default)("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var eL=e.i(361653),eL=eL,eD=e.i(671428);function eF(){return(0,a.jsxs)("div",{className:"space-y-4 p-2",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2",children:[(0,a.jsx)(eD.Skeleton,{className:"size-4"}),(0,a.jsx)(eD.Skeleton,{className:"h-4 w-24"}),(0,a.jsx)(eD.Skeleton,{className:"ml-auto h-4 w-6"})]}),(0,a.jsx)("div",{className:"ml-6 space-y-1",children:Array.from({length:3}).map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,a.jsx)(eD.Skeleton,{className:"size-4 rounded-xs"}),(0,a.jsx)(eD.Skeleton,{className:"h-3 flex-1"})]},t))})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2",children:[(0,a.jsx)(eD.Skeleton,{className:"size-4"}),(0,a.jsx)(eD.Skeleton,{className:"h-4 w-28"}),(0,a.jsx)(eD.Skeleton,{className:"ml-auto h-4 w-6"})]}),(0,a.jsx)("div",{className:"ml-6 space-y-1",children:Array.from({length:2}).map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[(0,a.jsx)(eD.Skeleton,{className:"size-4 rounded-xs"}),(0,a.jsx)(eD.Skeleton,{className:"h-3 flex-1"})]},t))})]})]})}var eO=e.i(981140),eB=e.i(30030),e$=e.i(248425),eU=e.i(832006),eV=e.i(30207),eq=e.i(369340),eH="ContextMenu",[eG,eW]=(0,eB.createContextScope)(eH,[eU.createMenuScope]),eK=(0,eU.createMenuScope)(),[eY,eQ]=eG(eH),eX=e=>{let{__scopeContextMenu:t,children:r,onOpenChange:s,dir:o,modal:n=!0}=e,[i,l]=p.useState(!1),c=eK(t),d=(0,eV.useCallbackRef)(s),u=p.useCallback(e=>{l(e),d(e)},[d]);return(0,a.jsx)(eY,{scope:t,open:i,onOpenChange:u,modal:n,children:(0,a.jsx)(eU.Root,{...c,dir:o,open:i,onOpenChange:u,modal:n,children:r})})};eX.displayName=eH;var eZ="ContextMenuTrigger",eJ=p.forwardRef((e,t)=>
1{let{__scopeContextMenu:r,disabled:s=!1,...o}=e,n=eQ(eZ,r),i=eK(r),l=p.useRef({x:0,y:0}),c=p.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=p.useRef(0),u=p.useCallback(()=>window.clearTimeout(d.current),[]),m=e=>{l.current={x:e.clientX,y:e.clientY},n.onOpenChange(!0)};return p.useEffect(()=>u,[u]),p.useEffect(()=>void(s&&u()),[s,u]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eU.Anchor,{...i,virtualRef:c}),(0,a.jsx)(e$.Primitive.span,{"data-state":n.open?"open":"closed","data-disabled":s?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:(0,eO.composeEventHandlers)(e.onContextMenu,e=>{u(),m(e),e.preventDefault()}),onPointerDown:s?e.onPointerDown:(0,eO.composeEventHandlers)(e.onPointerDown,tn(e=>{u(),d.current=window.setTimeout(()=>m(e),700)})),onPointerMove:s?e.onPointerMove:(0,eO.composeEventHandlers)(e.onPointerMove,tn(u)),onPointerCancel:s?e.onPointerCancel:(0,eO.composeEventHandlers)(e.onPointerCancel,tn(u)),onPointerUp:s?e.onPointerUp:(0,eO.composeEventHandlers)(e.onPointerUp,tn(u))})]})});eJ.displayName=eZ;var e0=e=>{let{__scopeContextMenu:t,...r}=e,s=eK(t);return(0,a.jsx)(eU.Portal,{...s,...r})};e0.displayName="ContextMenuPortal";var e1="ContextMenuContent",e2=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eQ(e1,r),n=eK(r),i=p.useRef(!1);return(0,a.jsx)(eU.Content,{...n,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&i.current&&t.preventDefault(),i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||o.modal||(i.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});e2.displayName=e1;var e5=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.Group,{...o,...s,ref:t})});e5.displayName="ContextMenuGroup";var e3=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.Label,{...o,...s,ref:t})});e3.displayName="ContextMenuLabel";var e4=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.Item,{...o,...s,ref:t})});e4.displayName="ContextMenuItem";var e6=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.CheckboxItem,{...o,...s,ref:t})});e6.displayName="ContextMenuCheckboxItem";var e8=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.RadioGroup,{...o,...s,ref:t})});e8.displayName="ContextMenuRadioGroup";var e7=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.RadioItem,{...o,...s,ref:t})});e7.displayName="ContextMenuRadioItem";var e9=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.ItemIndicator,{...o,...s,ref:t})});e9.displayName="ContextMenuItemIndicator";var te=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.Separator,{...o,...s,ref:t})});te.displayName="ContextMenuSeparator";var tt=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.Arrow,{...o,...s,ref:t})});tt.displayName="ContextMenuArrow";var tr="ContextMenuSub",ts=e=>{let{__scopeContextMenu:t,children:r,onOpenChange:s,open:o,defaultOpen:n}=e,i=eK(t),[l,c]=(0,eq.useControllableState)({prop:o,defaultProp:n??!1,onChange:s,caller:tr});return(0,a.jsx)(eU.Sub,{...i,open:l,onOpenChange:c,children:r})};ts.displayName=tr;var ta=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.SubTrigger,{...o,...s,ref:t})});ta.displayName="ContextMenuSubTrigger";var to=p.forwardRef((e,t)=>{let{__scopeContextMenu:r,...s}=e,o=eK(r);return(0,a.jsx)(eU.SubContent,{...o,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});function tn(e){return t=>
1"mouse"!==t.pointerType?e(t):void 0}to.displayName="ContextMenuSubContent",e.s(["Arrow",()=>tt,"CheckboxItem",()=>e6,"Content",()=>e2,"ContextMenu",()=>eX,"ContextMenuArrow",()=>tt,"ContextMenuCheckboxItem",()=>e6,"ContextMenuContent",()=>e2,"ContextMenuGroup",()=>e5,"ContextMenuItem",()=>e4,"ContextMenuItemIndicator",()=>e9,"ContextMenuLabel",()=>e3,"ContextMenuPortal",()=>e0,"ContextMenuRadioGroup",()=>e8,"ContextMenuRadioItem",()=>e7,"ContextMenuSeparator",()=>te,"ContextMenuSub",()=>ts,"ContextMenuSubContent",()=>to,"ContextMenuSubTrigger",()=>ta,"ContextMenuTrigger",()=>eJ,"Group",()=>e5,"Item",()=>e4,"ItemIndicator",()=>e9,"Label",()=>e3,"Portal",()=>e0,"RadioGroup",()=>e8,"RadioItem",()=>e7,"Root",()=>eX,"Separator",()=>te,"Sub",()=>ts,"SubContent",()=>to,"SubTrigger",()=>ta,"Trigger",()=>eJ,"createContextMenuScope",()=>eW],79602);var ti=e.i(79602),ti=ti;function tl({...e}){return(0,a.jsx)(ti.Root,{"data-slot":"context-menu",...e})}function tc({...e}){return(0,a.jsx)(ti.Trigger,{"data-slot":"context-menu-trigger",...e})}function td({className:e,...t}){return(0,a.jsx)(ti.Portal,{children:(0,a.jsx)(ti.Content,{"data-slot":"context-menu-content",className:(0,A.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...t})})}function tu({className:e,inset:t,variant:r="default",...s}){return(0,a.jsx)(ti.Item,{"data-slot":"context-menu-item","data-inset":t,"data-variant":r,className:(0,A.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer",e),...s})}function tm({className:e,...t}){return(0,a.jsx)(ti.Separator,{"data-slot":"context-menu-separator",className:(0,A.cn)("bg-border -mx-1 my-1 h-px",e),...t})}e.i(678784),e.i(233565),e.i(733498);var th=e.i(846696),tf=e.i(583263),tp=e.i(70955),tg=e.i(912598),tx=e.i(494913),tb=e.i(59377),ty=e.i(62870),tv=e.i(330009),tj=e.i(269638),tw=e.i(373884);function tN(e,t){let r="string"==typeof e?e:e.message,s=r.toLowerCase();if(s.includes("rate_limit:")||s.includes("reading limit")){let e=r.match(/(\d+)\s*seconds/);return{message:"You've reached the free reading limit.",type:"rate_limit",httpStatus:t||429,isTransient:!1,suggestion:"Install the browser extension for unlimited access, or wait for the limit to reset.",extensionRequired:!0,retryAfter:e?parseInt(e[1],10):60}}if(s.includes("proxy_disabled")||s.includes("proxy disabled")||s.includes("proxy is temporarily disabled"))return{message:"Feed proxy is temporarily disabled due to high server load.",type:"proxy_disabled",httpStatus:t||503,isTransient:!1,suggestion:"Install the browser extension to continue reading feeds without the proxy.",extensionRequired:!0};if(s.includes("cors")||s.includes("network")||s.includes("failed to fetch")||s.includes("networkerror"))return{message:r,type:"cors",isTransient:!0,suggestion:"This might be a temporary connection issue. Try again in a few minutes."};if(s.includes("timeout")||s.includes("timed out")||s.includes("aborted")||"object"==typeof e&&null!==e&&"name"in e&&"AbortError"===e.name)return{message:"Feed request timed out",type:"timeout",isTransient:!0,suggestion:"The feed took too long to respond. Try again later."};if(s.includes("parse")||s.includes("invalid xml")||s.includes("malformed"))return{message:r,type:"parsing",isTransient:!1,suggestion:"This feed may be broken or incorrectly formatted. Consider pausing or removing it."};if(s.includes("blocked")||s.includes("ssrf")||s.includes("invalid url"))return{message:r,type:"validation",isTransient:!1,suggestion:"This feed URL is invali
1d or blocked for security reasons."};if(t){if(404===t||410===t)return{message:r,type:"http",httpStatus:t,isTransient:!1,suggestion:"This feed no longer exists. Consider removing it."};if(429===t)return{message:r,type:"http",httpStatus:t,isTransient:!0,suggestion:"This site is rate limiting requests. The feed will be automatically paused."};if(t>=500)return{message:r,type:"http",httpStatus:t,isTransient:!0,suggestion:"The server is having issues. Try again later."}}return{message:r,type:"unknown",httpStatus:t,isTransient:!0,suggestion:"An unexpected error occurred. Try again later."}}function tk(e){let t=e.feed_status||"active",r=e.feed_error_count||0,s=e.feed_paused_until?new Date(e.feed_paused_until):null,a=e.feed_last_success_at?new Date(e.feed_last_success_at):null,o=new Date;if("paused"===t&&s&&s>o){let e=Math.ceil((s.getTime()-o.getTime())/6e4),t=Math.floor(e/60),r=Math.floor(t/24),a="";return a=r>0?`${r} day${r>1?"s":""}`:t>0?`${t} hour${t>1?"s":""}`:`${e} minute${e>1?"s":""}`,{status:"paused",statusText:"Paused",statusColor:"warning",icon:"paused",canRetry:!0,pausedUntilText:`Resumes in ${a}`}}if("disabled"===t)return{status:"disabled",statusText:"Disabled",statusColor:"error",icon:"disabled",canRetry:!1};if("error"===t||r>=3)return{status:"error",statusText:`Failed (${r} errors)`,statusColor:"error",icon:"error",canRetry:!0};if(a){let e=Math.floor((o.getTime()-a.getTime())/864e5);if(e>=7)return{status:"active",statusText:`Stale (${e} days)`,statusColor:"warning",icon:"stale",canRetry:!0}}return{status:"active",statusText:"Active",statusColor:"success",icon:"active",canRetry:!0}}var tC=e.i(954616),tA=e.i(432575),tS=e.i(611573),tT=e.i(838345),tE=e.i(359933);function tM(e){e&&window.open(e,"_blank","noopener")}var t_=e.i(66283);function tz({blog:e,children:t,onUnfollow:r}){let s,o,i,l,c,d,m,h,g,x,v,j,w,[N,k]=(0,p.useState)(!1),[A,S]=(0,p.useState)("3600"),[T,E]=(0,p.useState)(!1),[M,_]=(0,n.useAtom)(b.selectedBlogIdAtom),z=(0,f.useStorage)(),R=(0,f.useUserId)(),P=(0,p.useMemo)(()=>(0,er.createBlogFailedFeedAtom)(e.id),[e.id]),I=(0,n.useAtomValue)(P),L=tk(e),D=(0,tg.useQueryClient)(),F=I?.error||e.feed_last_error,O=I?(e.feed_error_count||0)+1:e.feed_error_count||0,B=I?.timestamp||(e.feed_last_error_at?new Date(e.feed_last_error_at):null),$=(s=(0,tg.useQueryClient)(),o=(0,f.useUserId)(),i=(0,f.useStorage)(),(0,tC.useMutation)({networkMode:"always",mutationFn:async({blog:e,durationSeconds:t})=>{await i.pauseFeed?.(o,e,t)},onSuccess:(e,{blog:t,durationSeconds:r})=>{s.invalidateQueries({queryKey:["blogs","followed",o]});let a=Math.floor(r/3600),n=Math.floor(r%3600/60),i="";i=a>0&&n>0?`${a} hour${a>1?"s":""} and ${n} minute${n>1?"s":""}`:a>0?`${a} hour${a>1?"s":""}`:`${n} minute${n>1?"s":""}`,th.toast.success(`Paused ${t.title} for ${i}`)},onError:(e,{blog:t})=>{console.error("Error pausing feed:",e),th.toast.error(`Failed to pause ${t.title}`)}})),U=(l=(0,tg.useQueryClient)(),c=(0,f.useUserId)(),d=(0,f.useStorage)(),(0,tC.useMutation)({networkMode:"always",mutationFn:async({blog:e})=>{await d.enableFeed?.(c,e)},onSuccess:(e,{blog:t})=>{l.invalidateQueries({queryKey:["blogs","followed",c]}),th.toast.success(`Resumed ${t.title}`)},onError:(e,{blog:t})=>{console.error("Error enabling feed:",e),th.toast.error(`Failed to resume ${t.title}`)}})),V=(m=(0,tg.useQueryClient)(),h=(0,f.useUserId)(),g=(0,f.useStorage)(),(0,tC.useMutation)({networkMode:"always",mutationFn:async({blog:e})=>{await g.disableFeed?.(h,e)},onSuccess:(e,{blog:t})=>{m.invalidateQueries({queryKey:["blogs","followed",h]}),th.toast.success(`Disabled ${t.title}`)},onError:(e,{blog:t})=>{console.error("Error disabling feed:",e),th.toast.error(`Failed to disable ${t.title}`)}})),q=(x=(0,tg.useQueryClient)(),v=(0,f.useUserId)(),j=(0,f.useStorage)(),w=(0,n.useAtomValue)(tE.historyLimitsAtom),(0,tC.useMutation)({mutationFn:async({blog:e})=>{let t=await (0,tA.parseFeed)(e.feed_url);return await (0,tS.setCachedFeed)(e.feed_url,t),t.posts=(0,tT.applyHistoryLimits)(t.posts,w),await j.recordFeedSuccess?.(v,e),t},onSuccess:(e,{blog:t})=>{x.invalidateQueries({queryKey:["blogs","followed",v]}
1),x.invalidateQueries({queryKey:["timeline"]}),th.toast.success(`Successfully fetched ${t.title}`,{description:`Loaded ${e.posts.length} posts`})},onError:async(e,{blog:t})=>{console.error("Error retrying feed:",e);let r=e instanceof Error?e.message:String(e);await j.recordFeedError?.(v,t,r),x.invalidateQueries({queryKey:["blogs","followed",v]}),th.toast.error(`Failed to fetch ${t.title}`,{description:r.substring(0,100)})}})),H=async()=>{await q.mutateAsync({blog:e}),await Promise.all([D.refetchQueries({queryKey:["blogs","followed",R]}),D.refetchQueries({queryKey:["timeline"]})]),k(!1)},W=async()=>{let t=parseInt(A,10);await $.mutateAsync({blog:e,durationSeconds:t}),await Promise.all([D.refetchQueries({queryKey:["blogs","followed",R]}),D.refetchQueries({queryKey:["timeline"]})]),k(!1)},K=async()=>{await U.mutateAsync({blog:e}),await Promise.all([D.refetchQueries({queryKey:["blogs","followed",R]}),D.refetchQueries({queryKey:["timeline"]})]),k(!1)},Y=async()=>{await V.mutateAsync({blog:e}),await Promise.all([D.refetchQueries({queryKey:["blogs","followed",R]}),D.refetchQueries({queryKey:["timeline"]})]),k(!1)},Q=async()=>{(await (0,tp.deleteBlog)(z,R,e.id,e.source)).success?(th.toast.success(`Unfollowed ${e.title}`),M===e.id&&_(null),D.invalidateQueries({queryKey:["followed-blogs"]}),D.invalidateQueries({queryKey:["timeline"]}),E(!1),k(!1),r&&r()):th.toast.error(`Failed to unfollow ${e.title}`)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(tb.Popover,{open:N,onOpenChange:k,children:[(0,a.jsx)(tb.PopoverTrigger,{asChild:!0,children:t}),(0,a.jsx)(tb.PopoverContent,{className:"w-96",align:"start",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("h4",{className:"font-medium text-sm",children:"Feed Health"}),(0,a.jsx)(y.Badge,{variant:(()=>{switch(L.statusColor){case"success":return"default";case"warning":return"secondary";case"error":return"destructive";default:return"outline"}})(),children:L.statusText})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground truncate",children:e.title})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[e.feed_last_success_at&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs",children:[(0,a.jsx)(tj.CheckCircle,{className:"size-3.5 text-green-500 mt-0.5 shrink-0"}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:["Last updated ",(0,tx.formatDistanceToNow)(new Date(e.feed_last_success_at),{addSuffix:!0})]})]}),F&&(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs",children:[(0,a.jsx)(tw.XCircle,{className:"size-3.5 text-destructive mt-0.5 shrink-0"}),(0,a.jsxs)("div",{className:"space-y-1 flex-1 min-w-0",children:[(0,a.jsxs)("span",{className:"text-destructive font-medium block",children:[O," consecutive error",1!==O?"s":"",I&&!I.isBackgroundRefresh&&" (just now)"]}),(0,a.jsx)("p",{className:"text-muted-foreground break-words",children:F}),I?.suggestion&&!I.extensionRequired&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground italic break-words",children:["💡 ",I.suggestion]}),B&&(0,a.jsx)("span",{className:"text-muted-foreground block",children:(0,tx.formatDistanceToNow)(B,{addSuffix:!0})})]})]}),I?.extensionRequired&&(0,a.jsx)(t_.ExtensionInstallPrompt,{variant:"compact",message:I.error?.toLowerCase().includes("rate_limit")||I.error?.toLowerCase().includes("reading limit")?"Install extension for unlimited reading":"Install extension to continue reading",className:"mt-2"})]}),L.pausedUntilText&&(0,a.jsxs)("div",{className:"flex items-start gap-2 text-xs",children:[(0,a.jsx)(G.Clock,{className:"size-3.5 text-amber-500 mt-0.5 shrink-0"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:L.pausedUntilText})]})]}),(0,a.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[L.canRetry&&"disabled"!==L.status&&(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:H,disabled:q.isPending,children:[(0,a.jsx)(C.RefreshCw,{className:`size-4 mr-2 ${q.isPending?"animate-spin":""}`}),q.isPending?"Retrying...":"Retry Now"]}),"paused"===L.status?(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:K,disabled:U.isPending,children:[(0,a.jsx)(C.RefreshCw,{className:"size-4 mr-2"}),"Resume Feed"]}):"disabled"!==L.status&&(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(ty.Select,{value:A,onValueChange:S,children:[(0,a.jsx)(ty.SelectTrigger,{className:"h-8 text-xs flex-1",children:(0,a.jsx)(ty.SelectValue,{})}),(0,a.jsxs)(ty.SelectContent,{children:[(0,a.jsx)(ty.SelectItem,{value:"3600",children:"1 hour"}),(0,a.jsx)(ty.SelectItem,{value:"21600",children:"6 hours"}),(0,a.jsx)(ty.SelectItem,{value:"86400",children:"1 day"}),(0,a.jsx)(ty.SelectItem,{value:"259200",children:"3 days"}),(0,a.jsx)(ty.SelectItem,{value:"604800",children:"1 week"})]})]}),(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",onClick:W,disabled:$.isPending,children:[(0,a.jsx)(eP.Pause,{className:"size-4 mr-2"}),"Pause"]})]}),"disabled"===L.status?(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:K,disabled:U.isPending,children:[(0,a.jsx)(C.RefreshCw,{className:"size-4 mr-2"}),"Enable Feed"]}):(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-destructive",onClick:Y,disabled:V.isPending,children:[(0,a.jsx)(eI,{className:"size-4 mr-2"}),"Disable Feed"]}),(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:()=>{tM(e.url),k(!1)},children:[(0,a.jsx)(ez.ExternalLink,{className:"size-4 mr-2"}),"Open Blog"]}),(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>E(!0),children:[(0,a.jsx)(e_.Trash2,{className:"size-4 mr-2"}),"Unfollow"]})]})]})})]}),(0,a.jsx)(tv.AlertDialog,{open:T,onOpenChange:E,children:(0,a.jsxs)(tv.AlertDialogContent,{children:[(0,a.jsxs)(tv.AlertDialogHeader,{children:[(0,a.jsxs)(tv.AlertDialogTitle,{children:["Unfollow ",e.title,"?"]}),(0,a.jsx)(tv.AlertDialogDescription,{children:"This will remove the blog from your feed. You can always follow it again later."})]}),(0,a.jsxs)(tv.AlertDialogFooter,{children:[(0,a.jsx)(tv.AlertDialogCancel,{children:"Cancel"}),(0,a.jsx)(tv.AlertDialogAction,{onClick:Q,children:"Unfollow"})]})]})})]})}var tR=e.i(18958);let tP=(0,p.memo)(function({blog:e,feedsLoading:t}){let r=(0,p.useMemo)(()=>(0,er.createBlogFailedFeedAtom)(e.id),[e.id]),s=(0,n.useAtomValue)(r);if(t)return null;
1let o=s&&!s.isBackgroundRefresh,i=tk(e),l=!t&&!s;if("stale"===i.icon&&l||!(o||"active"!==i.status||"active"!==i.icon))return null;let c=eR.AlertTriangle,d="text-amber-500";if(o)c=eL.default,d="text-destructive";else switch(i.icon){case"error":c=eL.default,d="text-destructive";break;case"paused":c=eP.Pause,d="text-amber-500";break;case"disabled":c=eI,d="text-muted-foreground";break;case"stale":c=eR.AlertTriangle,d="text-amber-500"}return(0,a.jsx)(tz,{blog:e,children:(0,a.jsx)("div",{className:"shrink-0 hover:opacity-70 transition-opacity",onClick:e=>{e.stopPropagation()},children:(0,a.jsx)(c,{className:(0,A.cn)("size-3",d)})})})}),tI=(0,p.memo)(function({blog:e,isActive:t,feedsLoading:r,showUnreadCountPerBlog:s,showTagsInFlatList:o,onSelect:i,onMarkAllAsRead:l,onUnfollow:c}){let u=(0,tR.getEffectiveBlogId)(e),m=(0,p.useMemo)(()=>(0,er.createBlogUnreadCountAtom)(u),[u]),h=(0,n.useAtomValue)(m),f=e.tags&&e.tags.length>0?e.tags:["Untagged"];return(0,a.jsx)(d.SidebarMenuItem,{children:(0,a.jsx)(tD,{blog:e,onMarkAllAsRead:()=>l(u),onUnfollow:()=>c(e),children:(0,a.jsx)(d.SidebarMenuButton,{isActive:t,onClick:()=>i(e),className:"cursor-pointer h-auto py-2",children:(0,a.jsxs)("div",{className:"flex items-start gap-2 w-full min-w-0",children:[e.site_icon&&(0,a.jsx)("img",{src:e.site_icon,alt:"",className:"size-4 rounded-xs mt-0.5 shrink-0",onError:e=>{e.currentTarget.style.display="none"},loading:"lazy"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 w-full justify-between",children:[(0,a.jsx)("span",{className:"truncate text-sm",children:e.title}),(0,a.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,a.jsx)(tP,{blog:e,feedsLoading:r}),s&&h>0&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:h})]})]}),o&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:f.map(e=>(0,a.jsx)(J.TagBadge,{tag:e},e))})]})]})})})})}),tL=(0,p.memo)(function({blog:e,isActive:t,feedsLoading:r,showUnreadCountPerBlog:s,onSelect:o,onMarkAllAsRead:i,onUnfollow:l}){let c=(0,tR.getEffectiveBlogId)(e),u=(0,p.useMemo)(()=>(0,er.createBlogUnreadCountAtom)(c),[c]),m=(0,n.useAtomValue)(u);return(0,a.jsx)(d.SidebarMenuSubItem,{children:(0,a.jsx)(tD,{blog:e,onMarkAllAsRead:()=>i(c),onUnfollow:()=>l(e),children:(0,a.jsxs)(d.SidebarMenuSubButton,{isActive:t,onClick:()=>o(e),className:"cursor-pointer",children:[e.site_icon&&(0,a.jsx)("img",{src:e.site_icon,alt:"",className:"size-4 rounded-xs",onError:e=>{e.currentTarget.style.display="none"}}),(0,a.jsx)("span",{className:"truncate",children:e.title}),(0,a.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[(0,a.jsx)(tP,{blog:e,feedsLoading:r}),s&&m>0&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:m})]})]})})})});function tD({blog:e,children:t,onMarkAllAsRead:r,onUnfollow:s}){return(0,a.jsxs)(tl,{children:[(0,a.jsx)(tc,{asChild:!0,children:t}),(0,a.jsxs)(td,{className:"w-48",children:[(0,a.jsxs)(tu,{onClick:r,children:[(0,a.jsx)(eE.CheckCheck,{className:"size-4 mr-2"}),"Mark all as read"]}),(0,a.jsxs)(tu,{onClick:()=>{tM(e.url)},children:[(0,a.jsx)(ez.ExternalLink,{className:"size-4 mr-2"}),"Open blog"]}),(0,a.jsxs)(tu,{onClick:()=>{navigator.clipboard.writeText(e.feed_url),th.toast.success("Feed URL copied to clipboard")},children:[(0,a.jsx)(eM.Copy,{className:"size-4 mr-2"}),"Copy feed URL"]}),(0,a.jsx)(tm,{}),(0,a.jsxs)(tu,{onClick:s,variant:"destructive",children:[(0,a.jsx)(e_.Trash2,{className:"size-4 mr-2"}),"Unfollow"]})]})]})}let tF=({className:e,...t})=>{let r=(0,n.useAtomValue)(er.blogsAtom),s=(0,n.useStore)(),{navigateToExplore:o}=eb(),[i,l]=(0,n.useAtom)(b.blogsSectionOpenAtom),[c,m]=(0,n.useAtom)(b.selectedBlogIdAtom),[h,g]=(0,n.useAtom)(b.selectedTagsAtom),x=(0,n.useSetAtom)(b.viewFilterAtom),[y,v]=(0,n.useAtom)(b.blogTagGroupsOpenAtom),j=(0,n.useSetAtom)(b.collapsedSectionsAtom),w=(0,n.useAtomValue)(b.feedsLoadingAtom),N=(0,n.useAtomValue)(b.showTagsInFlatListAtom),k=(0,n.useAtomValue)(b.showUnreadCountPerBlogAtom),C=(0,n.useSetAtom)(b.manageBlogsDialogOpenAtom),S=(0,n.use
1SetAtom)(er.stickyUnreadGuidsAtom),T=(0,tf.useMarkAllAsRead)(),E=(0,tg.useQueryClient)(),M=(0,f.useStorage)(),_=(0,f.useUserId)(),[z,R]=(0,n.useAtom)(b.forceFlatViewAtom),P=(0,p.useMemo)(()=>{let e=new Map;return r.forEach(t=>{(t.tags&&t.tags.length>0?t.tags:["Untagged"]).forEach(r=>{e.has(r)||e.set(r,[]),e.get(r).push(t)})}),new Map(Array.from(e.entries()).sort(([e],[t])=>"Untagged"===e?1:"Untagged"===t?-1:e.localeCompare(t)))},[r]),I=(0,p.useMemo)(()=>{let e=new Set;return r.filter(t=>!e.has(t.id)&&(e.add(t.id),!0)).sort((e,t)=>e.title.localeCompare(t.title))},[r]),L=z||h.length>0,D=(0,p.useCallback)(e=>{let t=(0,tR.getEffectiveBlogId)(e);S(new Set),m(t),x("all"),g([]),j(e=>e.filter(e=>e!==t))},[S,m,x,g,j]),F=(0,p.useCallback)(e=>{let t=s.get(er.postsAtom),r=s.get(er.readPostGuidsAtom),a=t.filter(t=>t.blogId===e).filter(e=>e.guid&&!(0,er.isGuidInSet)(e.guid,r,e.guidHash)).map(e=>e.guid);a.length>0?(T(a),th.toast.success(`Marked ${a.length} ${1===a.length?"post":"posts"} as read`)):th.toast.info("No unread posts in this blog")},[s,T]),O=(0,p.useCallback)(async e=>{(await (0,tp.deleteBlog)(M,_,e.id,e.source)).success?(th.toast.success(`Unfollowed ${e.title}`),c===e.id&&m(null),E.invalidateQueries({queryKey:["blogs","followed",_]}),E.invalidateQueries({queryKey:["timeline"]})):th.toast.error(`Failed to unfollow ${e.title}`)},[M,_,c,m,E]);return(0,a.jsx)(Z.Collapsible,{open:i,onOpenChange:l,className:(0,A.cn)("group/blogs-collapsible",e),...t,children:(0,a.jsxs)(d.SidebarGroup,{className:"py-1.5",children:[(0,a.jsx)(d.SidebarGroupLabel,{asChild:!0,children:(0,a.jsx)(Z.CollapsibleTrigger,{className:"w-full",children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ee.ChevronDown,{className:"transition-transform group-data-[state=open]/blogs-collapsible:rotate-0 group-data-[state=closed]/blogs-collapsible:-rotate-90 size-4"}),(0,a.jsx)("span",{children:"Blogs"})]}),(0,a.jsx)("div",{className:"flex items-center gap-2"})]})})}),(0,a.jsx)(eN.TooltipWrapper,{content:z?"Display by tags":"Display as blog list",children:(0,a.jsx)(d.SidebarGroupAction,{onClick:()=>R(!z),title:z?"Switch to smart view (auto-groups when not filtering)":"Switch to flat list (always show all blogs)",className:z?"opacity-100":"",children:z?(0,a.jsx)(ek.List,{className:"size-4"}):(0,a.jsx)(eA,{className:"size-4"})})}),(0,a.jsxs)(Z.CollapsibleContent,{children:[(0,a.jsx)(d.SidebarGroupContent,{children:w&&0===r.length?(0,a.jsx)(eF,{}):L?(0,a.jsx)(d.SidebarMenu,{children:I.map(e=>(0,a.jsx)(tI,{blog:e,isActive:c===(0,tR.getEffectiveBlogId)(e),feedsLoading:w,showUnreadCountPerBlog:k,showTagsInFlatList:N,onSelect:D,onMarkAllAsRead:F,onUnfollow:O},e.id))}):(0,a.jsx)(d.SidebarMenu,{children:Array.from(P.entries()).map(([e,t])=>(0,a.jsx)(Z.Collapsible,{open:y[e]??!1,onOpenChange:t=>{v(r=>({...r,[e]:t}))},className:"group/collapsible",children:(0,a.jsxs)(d.SidebarMenuItem,{children:[(0,a.jsx)(Z.CollapsibleTrigger,{asChild:!0,children:(0,a.jsxs)(d.SidebarMenuButton,{className:"w-full",children:[e,(0,a.jsx)(eT.ChevronRight,{className:"ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"})]})}),(0,a.jsx)(Z.CollapsibleContent,{children:(0,a.jsx)(d.SidebarMenuSub,{children:t.map(e=>(0,a.jsx)(tL,{blog:e,isActive:c===(0,tR.getEffectiveBlogId)(e),feedsLoading:w,showUnreadCountPerBlog:k,onSelect:D,onMarkAllAsRead:F,onUnfollow:O},e.id))})})]})},e))})}),(0,a.jsxs)("div",{className:"px-2 py-2 flex items-center justify-center gap-2",children:[(0,a.jsxs)(u.Button,{variant:"outline",size:"xs",onClick:()=>o(),children:[(0,a.jsx)(em.Compass,{className:"size-4"}),"Explore"]}),(0,a.jsxs)(u.Button,{variant:"outline",size:"xs",onClick:()=>C(!0),children:[(0,a.jsx)(eS.Pencil,{}),"Manage"]})]})]})]})})};var tO=e.i(514764),tB=e.i(810980),t$=e.i(974875),tU=e.i(686311);let tV=(0,eC.default)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);var tq=e.i(248256),tH=e.i(522016),tG=e.i(217227),tW=e.i(463415),tK=e.i(957470);function tY(){let e=(0,c.useExtensionAvailable)(),t={...!e&&{extension:[{href:"/extension",label:"Get the Extension",icon:tG.default,featured:!0}]},navigation:[{href:"/explore",label:"Explore Directory",icon:em.Compass},{href:"/submit",label:"Submit Your Blog",icon:tO.Send},{href:"/our-blog",label:"Our Blog",icon:tB.BookOpen}],resources:[{href:"/faq",label:"FAQ",icon:t$.HelpCircle},{href:"/guides/how-to-rss",label:"RSS Guide",icon:$.Rss},{href:"/guides/enable-cors",label:"CORS Guide",icon:tq.Globe}],support:[{href:"/contact",label:"Contact Us",icon:tU.MessageSquare},{href:"/report",label:"Report Issue",icon:tV}]},r=({href:e,label:t,icon:r,featured:s})=>s?(0,a.jsx)(tW.DropdownMenuItem,{asChild:!0,className:"p-0 focus:bg-transparent my-1",children:(0,a.jsxs)(tH.default,{href:e,target:"_blank",className:"featured-extension-link relative flex items-center gap-2.5 px-3 py-2 mx-1 rounded-lg cursor-pointer group transition-transform duration-150 ease-out active:scale-[0.97] active:duration-75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent",children:[(0,a.jsx)("div",{className:"glow-layer absolute inset-0 rounded-lg bg-gradient-to-r from-[#997396] via-[#7094b8] to-[#acc4ed] opacity-80 blur-[2px] transition-all duration-300 group-hover:opacity-100 group-hover:blur-[3px] group-active:opacity-60 group-active:blur-[1px]"}),(0,a.jsx)("div",{className:"absolute inset-[1px] rounded-[7px] bg-gradient-to-r from-[#997396] via-[#7094b8] to-[#acc4ed] dark:from-[#997396]/90 dark:via-[#7094b8]/90 dark:to-[#acc4ed]/90 transition-all duration-75 group-active:from-[#8a6889] group-active:via-[#6384a8] group-active:to-[#9bb3dc]"}),(0,a.jsx)("div",{className:"absolute inset-[1px] rounded-[7px] bg-gradient-to-b from-white/25 to-transparent transition-opacity duration-75 group-active:from-white/10"}),r&&p.default.createElement(r,{className:"relative size-4 text-white drop-shadow-sm transition-transform duration-200 group-hover:scale-110 group-active:scale-100"}),(0,a.jsx)("span",{className:"relative font-semibold text-white drop-shadow-sm",children:t})]})},e):(0,a.jsx)(tW.DropdownMenuItem,{asChild:!0,children:(0,a.jsxs)(tH.default,{href:e,target:"_blank",className:"flex items-center gap-2 cursor-pointer",children:[r&&p.default.createElement(r,{className:"size-4"}),t]})},e),s={...!e&&{extension:{title:"Recommended",items:t.extension}},navigation:{title:"Navigation",items:t.navigation},resources:{title:"Resources",items:t.resources},support:{title:"Support",items:t.support}};return(0,a.jsxs)(tW.DropdownMenu,{children:[(0,a.jsx)(tW.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsxs)(u.Button,{variant:"ghost",className:"flex items-center gap-2 px-2! py-2! hover:bg-accent duration-300 m-0!",children:[(0,a.jsx)("img",{src:"/icon/favicon-48x48.png",alt:tK.APP_NAME,className:"size-6"}),(0,a.jsx)("h2",{className:"text-base tracking-tight font-semibold",children:tK.APP_NAME}),(0,a.jsx)(ee.ChevronDown,{className:"size-4 opacity-50"})]})}),(0,a.jsx)(tW.DropdownMenuContent,{align:"start",className:"w-56",children:Object.values(s).map((e,t)=>(0,a.jsxs)(p.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(tW.DropdownMenuLabel,{children:e.title}),e.items.map(e=>(0,a.jsx)(r,{...e},e.href))]},e.title),t<Object.values(s).length-1&&(0,a.jsx)(tW.DropdownMenuSeparator,{})]},t))})]})}function tQ({className:e,...t}
1){let r=(0,n.useSetAtom)(b.settingsDialogOpenAtom),s=(0,n.useSetAtom)(b.addFeedDialogOpenAtom),o=(0,c.useIsDesktopApp)()&&window.electronBridge?.platform==="darwin";return(0,a.jsxs)(d.Sidebar,{className:(0,A.cn)("thin-scrollbars",e),...t,children:[(0,a.jsx)(d.SidebarHeader,{className:(0,A.cn)("border-b px-3 py-3"),children:(0,a.jsxs)("div",{className:(0,A.cn)("flex items-center justify-between",o&&"ml-20"),children:[o?(0,a.jsx)("div",{className:"flex items-center justify-end shrink-0"}):(0,a.jsx)(tY,{}),(0,a.jsx)(d.SidebarTrigger,{})]})}),(0,a.jsxs)(d.SidebarContent,{className:"gap-0",children:[(0,a.jsx)(ew,{}),(0,a.jsx)(en,{}),(0,a.jsx)(es,{}),(0,a.jsx)(tF,{})]}),(0,a.jsxs)(d.SidebarFooter,{className:"border-t p-3 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsx)(S,{className:"flex-1 justify-center"}),(0,a.jsx)(R,{className:"flex-1 justify-center"}),(0,a.jsx)(q,{className:"flex-1 justify-center"}),(0,a.jsx)(X,{className:"flex-1 justify-center"})]}),(0,a.jsx)(h.ThemeSelector,{}),(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>s(!0),children:[(0,a.jsx)(i.Plus,{className:"mr-2 size-4"}),"Add Feed"]}),(0,a.jsx)(m.default,{}),(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:()=>r(!0),children:(0,a.jsx)(l.Settings,{className:"size-4"})})]})]})]})}var tX=e.i(174080);function tZ(e,t,r){let s,a=r.initialDeps??[],o=!0;function n(){var n,i,l;let c,d;r.key&&(null==(n=r.debug)?void 0:n.call(r))&&(c=Date.now());let u=e();if(!(u.length!==a.length||u.some((e,t)=>a[t]!==e)))return s;if(a=u,r.key&&(null==(i=r.debug)?void 0:i.call(r))&&(d=Date.now()),s=t(...u),r.key&&(null==(l=r.debug)?void 0:l.call(r))){let e=Math.round((Date.now()-c)*100)/100,t=Math.round((Date.now()-d)*100)/100,s=t/16,a=(e,t)=>{for(e=String(e);e.length<t;)e=" "+e;return e};console.info(`%c⏱ ${a(t,5)} /${a(e,5)} ms`,`
2            font-size: .6rem;
3            font-weight: bold;
4            color: hsl(${Math.max(0,Math.min(120-120*s,120))}deg 100% 31%);`,null==r?void 0:r.key)}return(null==r?void 0:r.onChange)&&!(o&&r.skipInitialOnChange)&&r.onChange(s),o=!1,s}return n.updateDeps=e=>{a=e},n}function tJ(e,t){if(void 0!==e)return e;throw Error(`Unexpected undefined${t?`: ${t}`:""}`)}e.i(247167);let t0=e=>{let{offsetWidth:t,offsetHeight:r}=e;return{width:t,height:r}},t1=e=>e,t2=e=>{let t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1),s=[];for(let e=t;e<=r;e++)s.push(e);return s},t5=(e,t)=>{let r=e.scrollElement;if(!r)return;let s=e.targetWindow;if(!s)return;let a=e=>{let{width:r,height:s}=e;t({width:Math.round(r),height:Math.round(s)})};if(a(t0(r)),!s.ResizeObserver)return()=>{};let o=new s.ResizeObserver(t=>{let s=()=>{let e=t[0];if(null==e?void 0:e.borderBoxSize){let t=e.borderBoxSize[0];if(t)return void a({width:t.inlineSize,height:t.blockSize})}a(t0(r))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return o.observe(r,{box:"border-box"}),()=>{o.unobserve(r)}},t3={passive:!0},t4="u"<typeof window||"onscrollend"in window,t6=(e,t)=>{var r,s;let a,o=e.scrollElement;if(!o)return;let n=e.targetWindow;if(!n)return;let i=0,l=e.options.useScrollendEvent&&t4?()=>void 0:(r=()=>{t(i,!1)},s=e.options.isScrollingResetDelay,function(...e){n.clearTimeout(a),a=n.setTimeout(()=>r.apply(this,e),s)}),c=r=>()=>{let{horizontal:s,isRtl:a}=e.options;i=s?o.scrollLeft*(a&&-1||1):o.scrollTop,l(),t(i,r)},d=c(!0),u=c(!1);o.addEventListener("scroll",d,t3);let m=e.options.useScrollendEvent&&t4;return m&&o.addEventListener("scrollend",u,t3),()=>{o.removeEventListener("scroll",d),m&&o.removeEventListener("scrollend",u)}},t8=(e,t,r)=>{if(null==t?void 0:t.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[r.options.horizontal?"inlineSize":"blockSize"])}return e[r.options.horizontal?"offsetWidth":"offsetHeight"]},t7=(e,{adjustments:t=0,behavior:r},s)=>{var a,o;null==(o=null==(a=s.scrollElement)?void 0:a.scrollTo)||o.call(a,{[s.options.horizontal?"left":"top"]:e+t,behavior:r})};class t9{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let e=null,t=()=>e||(this.targetWindow&&this.targetWindow.ResizeObserver?e=new this.targetWindow.ResizeObserver(e=>
vendor: 2,310 bytes, line 4
4{e.forEach(e=>{let t=()=>{this._measureElement(e.target,e)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}):null);return{disconnect:()=>{var r;null==(r=t())||r.disconnect(),e=null},observe:e=>{var r;return null==(r=t())?void 0:r.observe(e,{box:"border-box"})},unobserve:e=>{var r;return null==(r=t())?void 0:r.unobserve(e)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,r])=>{void 0===r&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:t1,rangeExtractor:t2,onChange:()=>{},measureElement:t8,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var t,r;null==(r=(t=this.options).onChange)||r.call(t,this,e)},this.maybeNotify=tZ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var e;let t=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==t){if(this.cleanup(),!t)return void this.maybeNotify();this.scrollElement=t,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=(null==(e=this.scrollElement)?void 0:e.window)??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?"forward":"backward":null,this.scrollOffset=e,this.isScrolling=t,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}}
4,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??("function"==typeof this.options.initialOffset?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let r=new Map,s=new Map;for(let a=t-1;a>=0;a--){let t=e[a];if(r.has(t.lane))continue;let o=s.get(t.lane);if(null==o||t.end>o.end?s.set(t.lane,t):t.end<o.end&&r.set(t.lane,!0),r.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=tZ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,t,r,s,a,o)=>(void 0!==this.prevLanes&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:r,getItemKey:s,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=tZ(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:r,getItemKey:s,enabled:a,lanes:o},n)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),0!==this.measurementsCache.length||this.lanesSettling||(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let i=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,i),c=Array(o).fill(void 0);for(let e=0;e<i;e++){let t=l[e];t&&(c[t.lane]=e)}for(let a=i;a<e;a++){let e,o,i=s(a),d=this.laneAssignments.get(a);if(void 0!==d&&this.options.lanes>1){let s=c[e=d],a=void 0!==s?l[s]:void 0;o=a?a.end+this.options.gap:t+r}else{let s=1===this.options.lanes?l[a-1]:this.getFurthestMeasurement(l,a);o=s?s.end+this.options.gap:t+r,e=s?s.lane:a%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(a,e)}let u=n.get(i),m="number"==typeof u?u:this.options.estimateSize(a),h=o+m;l[a]={index:a,start:o,size:m,end:h,key:i,lane:e},c[e]=a}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=tZ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,r,s)=>this.range=e.length>0&&t>0?function({measurements:e,outerSize:t,scrollOffset:r,lanes:s}){let a=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:a};let o=re(0,a,t=>e[t].start,r),n=o;if(1===s)for(;n<a&&e[n].end<r+t;)n++;else if(s>1){let i=Array(s).fill(0);for(;n<a&&i.some(e=>e<r+t);){let t=e[n];i[t.lane]=t.end,n++}let l=Array(s).fill(r+t);for(;o>=0&&l.some(e=>e>=r);){let t=e[o];l[t.lane]=t.start,o--}o=Math.max(0,o-o%s),n=Math.min(a,n+(s-1-n%s))}return{startIndex:o,endIndex:n}}({measurements:e,outerSize:t,scrollOffset:r,lanes:s}):null,{key:!1,debug:()=>this.options.debug}
4),this.getVirtualIndexes=tZ(()=>{let e=null,t=null,r=this.calculateRange();return r&&(e=r.startIndex,t=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,r,s,a)=>null===s||null===a?[]:e({startIndex:s,endIndex:a,overscan:t,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,r=e.getAttribute(t);return r?parseInt(r,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this._measureElement=(e,t)=>{let r=this.indexFromElement(e),s=this.measurementsCache[r];if(!s)return;let a=s.key,o=this.elementsCache.get(a);o!==e&&(o&&this.observer.unobserve(o),this.observer.observe(e),this.elementsCache.set(a,e)),e.isConnected&&this.resizeItem(r,this.options.measureElement(e,t,this))},this.resizeItem=(e,t)=>{let r=this.measurementsCache[e];if(!r)return;let s=t-(this.itemSizeCache.get(r.key)??r.size);0!==s&&((void 0!==this.shouldAdjustScrollPositionOnItemSizeChange?this.shouldAdjustScrollPositionOnItemSizeChange(r,s,this):r.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,t)),this.notify(!1))},this.measureElement=e=>{e?this._measureElement(e,void 0):this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))})},this.getVirtualItems=tZ(()=>
4[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let r=[];for(let s=0,a=e.length;s<a;s++){let a=t[e[s]];r.push(a)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(0!==t.length)return tJ(t[re(0,t.length-1,e=>tJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,r=0)=>{if(!this.scrollElement)return 0;let s=this.getSize(),a=this.getScrollOffset();return"auto"===t&&(t=e>=a+s?"end":"start"),"center"===t?e+=(r-s)/2:"end"===t&&(e-=s),Math.max(Math.min(this.getMaxScrollOffset(),e),0)},this.getOffsetForIndex=(e,t="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.measurementsCache[e];if(!r)return;let s=this.getSize(),a=this.getScrollOffset();if("auto"===t)if(r.end>=a+s-this.options.scrollPaddingEnd)t="end";else{if(!(r.start<=a+this.options.scrollPaddingStart))return[a,t];t="start"}if("end"===t&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let o="end"===t?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,t,r.size),t]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(e,{align:t="start",behavior:r}={})=>{"smooth"===r&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(e,t),{adjustments:void 0,behavior:r})},this.scrollToIndex=(e,{align:t="auto",behavior:r}={})=>{"smooth"===r&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),e=Math.max(0,Math.min(e,this.options.count-1)),this.currentScrollToIndex=e;let s=0,a=t=>{if(!this.targetWindow)return;let s=this.getOffsetForIndex(e,t);if(!s)return void console.warn("Failed to get offset for index:",e);let[a,n]=s;this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;let t=()=>{if(this.currentScrollToIndex!==e)return;let t=this.getScrollOffset(),r=this.getOffsetForIndex(e,n);r?1.01>Math.abs(r[0]-t)||o(n):console.warn("Failed to get offset for index:",e)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(t):t()})},o=t=>{this.targetWindow&&this.currentScrollToIndex===e&&(++s<10?this.targetWindow.requestAnimationFrame(()=>a(t)):console.warn(`Failed to scroll to index ${e} after 10 attempts.`))};a(t)},this.scrollBy=(e,{behavior:t}={})=>{"smooth"===t&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+e,{adju
4stments:void 0,behavior:t})},this.getTotalSize=()=>{var e;let t,r=this.getMeasurements();if(0===r.length)t=this.options.paddingStart;else if(1===this.options.lanes)t=(null==(e=r[r.length-1])?void 0:e.end)??0;else{let e=Array(this.options.lanes).fill(null),s=r.length-1;for(;s>=0&&e.some(e=>null===e);){let t=r[s];null===e[t.lane]&&(e[t.lane]=t.end),s--}t=Math.max(...e.filter(e=>null!==e))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:r})=>{this.options.scrollToFn(e,{behavior:r,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}}let re=(e,t,r,s)=>{for(;e<=t;){let a=(e+t)/2|0,o=r(a);if(o<s)e=a+1;else{if(!(o>s))return a;t=a-1}}return e>0?e-1:0},rt="u">typeof document?p.useLayoutEffect:p.useEffect;var rr=e.i(363178),rs=e.i(471435);function ra({icon:e,title:t,description:r,action:s,className:o,compact:n=!1,decoration:i="dots"}){return(0,a.jsx)("div",{className:(0,A.cn)("empty-state-editorial flex h-full items-center justify-center text-center",n?"p-4 min-h-[180px]":"p-8 min-h-[280px]",o),children:(0,a.jsxs)("div",{className:(0,A.cn)("max-w-sm",n?"space-y-3":"space-y-5"),style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both"},children:[(0,a.jsx)("div",{className:"empty-icon-container flex justify-center",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:(0,A.cn)("empty-icon-ring relative z-10 flex items-center justify-center rounded-2xl","bg-gradient-to-br from-muted to-muted/50 shadow-sm","border border-border/50",n?"size-14 rounded-xl":"size-20"),style:"none"!==i?{animation:"gentle-breathe 4s ease-in-out infinite"}:void 0,children:(0,a.jsx)(e,{className:(0,A.cn)("empty-icon text-primary/70",n?"size-6":"size-8")})}),"dots"===i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:(0,A.cn)("absolute -top-1.5 right-0 rounded-full bg-primary/40",n?"size-1":"size-1.5"),style:{animation:"gentle-float 3s ease-in-out infinite"}}),(0,a.jsx)("span",{className:(0,A.cn)("absolute -bottom-1 -left-1.5 rounded-full bg-primary/30",n?"size-0.5":"size-1"),style:{animation:"gentle-float 3.5s ease-in-out infinite",animationDelay:"-1s"}}),(0,a.jsx)("span",{className:"absolute top-1/2 -right-2.5 rounded-full bg-primary/20 size-0.5",style:{animation:"gentle-float 4s ease-in-out infinite",animationDelay:"-1.5s"}})]}),"rings"===i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"empty-illustration-ring absolute -inset-2",style:{animationDelay:"0s"}}),(0,a.jsx)("div",{className:"empty-illustration-ring absolute -inset-4",style:{animationDelay:"-1s",animationDuration:"5s"}})]}),"lines"===i&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:(0,A.cn)("absolute left-1/2 -translate-x-1/2 w-px bg-gradient-to-b from-transparent to-border",n?"-top-2 h-1.5":"-top-3 h-2")}),(0,a.jsx)("span",{className:(0,A.cn)("absolute left-1/2 -translate-x-1/2 w-px bg-gradient-to-t from-transparent to-border",n?"-bottom-2 h-1.5":"-bottom-3 h-2")}),(0,a.jsx)("span",{className:(0,A.cn)("absolute top-1/2 -translate-y-1/2 h-px bg-gradient-to-r from-transparent to-border",n?"-left-2 w-1.5":"-left-3 w-2")}),(0,a.jsx)("span",{className:(0,A.cn)("absolute top-1/2 -translate-y-1/2 h-px bg-gradient-to-l from-transparent to-border",n?"-right-2 w-1.5":"-right-3 w-2")})]})]})}),(0,a.jsxs)("div",{className:(0,A.cn)(n?"space-y-1":"space-y-2"),style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"80ms"},children:[(0,a.jsx)("h3",{className:(0,A.cn)("empty-title font-semibold tracking-tight text-foreground",n?"text-sm":"text-base"),children:t}),(0,a.jsx)("p",{className:(0,A.cn)("empty-description text-muted-foreground leading-relaxed",n?"text-xs":"text-sm"),children:r})]}),s&&(0,a.jsx)("div",{className:"pt-1",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"150ms"},children:(0,a.jsx)(u.Button,{onClick:s.onClick,variant:"outline",size:n?"sm":"default",className:(0,A.cn)("empty-action font-medium","hover:bg-primary hover:text-primary-foreground hover:border-primary","transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md"),children:s.label})})]})})}let ro=(0,eC.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);
4var rn=e.i(143527),ri=e.i(733060),rl=e.i(283086),rc=e.i(972520),rd=e.i(892658),ru=e.i(944667),rm=e.i(265172),rh=e.i(979775);let rf=(0,rm.atomWithStorage)((0,rh.getProjectSpecificKey)("onboarding-welcome-modal-shown"),!1),rp=(0,rm.atomWithStorage)((0,rh.getProjectSpecificKey)("onboarding-welcome-modal-dont-show-again"),!1),rg=(0,rm.atomWithStorage)((0,rh.getProjectSpecificKey)("onboarding-in-progress"),!1),rx=(0,rm.atomWithStorage)((0,rh.getProjectSpecificKey)("onboarding-step"),0),rb=(0,rm.atomWithStorage)((0,rh.getProjectSpecificKey)("onboarding-selected-blogs"),[]),ry=["welcome","data-privacy","guide","extension","jumpstart","complete"];function rv(){let e=(0,f.useStorage)(),t=(0,f.useUserId)(),r=(0,tg.useQueryClient)(),[s,a]=(0,n.useAtom)(rx),[o,i]=(0,n.useAtom)(rb),[l,c]=(0,n.useAtom)(rf),[d,u]=(0,n.useAtom)(rp),[m,h]=(0,n.useAtom)(rg),g=(0,n.useAtomValue)(er.blogsAtom),x=(0,n.useAtomValue)(er.blogsLoadingAtom),b=(0,p.useMemo)(()=>!d&&!l&&!x&&!(g.length>0),[d,l,g.length,x]),y=(0,p.useCallback)(()=>{a(e=>{let t=Math.min(e+1,5);return(0,ey.trackOnboardingStepViewed)(ry[t]),t})},[a]),v=(0,p.useCallback)(()=>{a(e=>{let t=Math.max(e-1,0);return(0,ey.trackOnboardingStepViewed)(ry[t]),t})},[a]),j=(0,p.useCallback)(()=>{(0,ey.trackOnboardingSkipped)(ry[s]||"unknown"),c(!0),a(0),i([]),h(!1)},[s,c,a,i,h]),w=(0,p.useCallback)(()=>{(0,ey.trackOnboardingSkipped)(ry[s]||"unknown"),u(!0),c(!0),a(0),i([]),h(!1)},[s,u,c,a,i,h]),N=(0,p.useCallback)(e=>{i(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e])},[i]),k=(0,p.useCallback)(async()=>{if(0===o.length)return void y();try{let s=0,a=0;for(let r of o)try{(await (0,tp.followDirectoryBlog)(e,t,r.id,[],{feed_url:r.feed_url,title:r.title,description:r.description,url:r.url,site_icon:r.site_icon,has_full_content:r.has_full_content,category:r.category,requires_proxy:r.requires_proxy,posts_require_proxy:r.posts_require_proxy,blocks_iframe:r.blocks_iframe})).success?s++:a++}catch(e){console.error(`Error following blog ${r.id}:`,e),a++}await r.invalidateQueries({queryKey:["blogs","followed",t]}),s>0&&th.toast.success(`Followed ${s} blog${s>1?"s":""}!`),a>0&&th.toast.error(`Failed to follow ${a} blog${a>1?"s":""}`),y()}catch(e){console.error("Error following blogs:",e),th.toast.error("Failed to follow blogs. Please try again.")}},[o,e,t,r,y]),C=(0,p.useCallback)(()=>{(0,ey.trackOnboardingComplete)(o.length),c(!0),a(0),i([]),h(!1)},[o.length,c,a,i,h]),A=(0,p.useCallback)(()=>{c(!1),u(!1),a(0),i([]),h(!1)},[c,u,a,i,h]),S=(0,p.useCallback)(()=>{c(!1),a(0),i([]),h(!1)},[c,a,i,h]),T=(0,p.useCallback)(e=>{(0,ey.trackOnboardingStepViewed)(ry[e]),a(e)},[a]);return{shouldShowOnboarding:b,step:s,selectedBlogs:o,selectedCount:o.length,onboardingInProgress:m,setOnboardingInProgress:h,nextStep:y,prevStep:v,skipAll:j,dontShowAgainAndClose:w,goToStep:T,reopenOnboarding:S,toggleBlog:N,followSelectedBlogs:k,completeOnboarding:C,resetOnboarding:A}}function rj({title:e,description:t,icon:r,onClick:s,index:o}){return(0,a.jsx)("button",{onClick:s,className:(0,A.cn)("onboarding-card group w-full text-left","rounded-xl border border-border/60 bg-card/50 backdrop-blur-sm","p-4 mobile:p-3.5","transition-all duration-300 ease-out","hover:border-primary/30","hover:shadow-lg hover:shadow-black/[0.03] dark:hover:shadow-black/20"),style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:`${150+80*o}ms`},children:(0,a.jsxs)("div",{className:"flex items-start gap-4 mobile:gap-3",children:[(0,a.jsx)("div",{className:(0,A.cn)("relative flex-shrink-0 rounded-xl p-3 mobile:p-2.5 transition-all duration-300","bg-muted/80 dark:bg-muted/50","group-hover:scale-105 group-hover:bg-primary/10"),children:(0,a.jsx)(r,{className:"size-5 mobile:size-4 text-foreground/70 group-hover:text-primary transition-colors"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 space-y-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm text-foreground group-hover:text-foreground/90 transition-colors",children:e}),(0,a.jsx)(rc.ArrowRight,{className:(0,A.cn)("size-3.5 text-muted-foreground
4/40","translate-x-0 opacity-0 transition-all duration-300","group-hover:translate-x-1 group-hover:opacity-100")})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed line-clamp-2",children:t})]})]})})}let rw=()=>{let e=(0,n.useSetAtom)(b.addFeedDialogOpenAtom),t=(0,n.useSetAtom)(rd.opmlImportModalOpenAtom),{navigateToExplore:r}=eb(),{reopenOnboarding:s}=rv(),o=(0,ru.useMounted)(),i=(0,ex.default)();if(!o)return null;let l=[{key:"browse",title:"Browse Directory",description:"Discover 100+ curated blogs across tech, design, writing, and more",icon:ro,onClick:()=>{r()},index:0},{key:"add",title:"Add Custom Blog",description:"Follow any blog by pasting its URL or Substack username",icon:tB.BookOpen,onClick:()=>{e(!0)},index:1},{key:"import",title:"Import OPML",description:"Bring your subscriptions from Feedly, Inoreader, or others",icon:rn.FileUp,onClick:()=>{t(!0)},index:2}];return(0,a.jsx)("div",{className:"flex h-full flex-col @container/onboardingemptystate paper-texture",children:(0,a.jsx)("div",{className:"overflow-y-auto thin-scrollbars flex-1",children:(0,a.jsxs)("div",{className:"relative flex flex-col items-center justify-center min-h-full p-8 mobile:p-5",children:[(0,a.jsx)("div",{className:"corner-flourish top-left text-foreground"}),(0,a.jsx)("div",{className:"corner-flourish bottom-right text-foreground"}),(0,a.jsxs)("div",{className:"max-w-md w-full space-y-8 mobile:space-y-6",children:[i&&(0,a.jsx)("div",{className:"flex justify-center",style:{animation:"reveal-up 0.4s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"50ms"},children:(0,a.jsxs)(u.Button,{onClick:s,variant:"outline",size:"sm",className:"gap-2 text-xs border-dashed",children:[(0,a.jsx)(ri.Wand2,{className:"size-3.5"}),"Reopen Setup Wizard"]})}),(0,a.jsxs)("div",{className:"text-center space-y-4",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"0ms"},children:[(0,a.jsx)("div",{className:"flex justify-center mb-6 mobile:mb-4",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"relative z-10 rounded-2xl bg-gradient-to-br from-muted to-muted/50 p-4 shadow-sm border border-border/50",children:(0,a.jsx)(rl.Sparkles,{className:"size-8 mobile:size-6 text-primary"})}),(0,a.jsx)("div",{className:"empty-illustration-ring absolute -inset-3 mobile:-inset-2",style:{animationDelay:"0s"}}),(0,a.jsx)("div",{className:"empty-illustration-ring absolute -inset-6 mobile:-inset-4",style:{animationDelay:"-1s",animationDuration:"5s"}}),(0,a.jsx)("span",{className:"absolute -top-1 -right-1 size-2 rounded-full bg-primary/50",style:{animation:"gentle-float 3s ease-in-out infinite"}}),(0,a.jsx)("span",{className:"absolute -bottom-1 -left-2 size-1.5 rounded-full bg-primary/30",style:{animation:"gentle-float 3.5s ease-in-out infinite",animationDelay:"-1s"}})]})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("h1",{className:"text-2xl mobile:text-xl font-bold tracking-tight text-foreground",children:["Welcome to ",tK.APP_NAME]}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed max-w-sm mx-auto",children:["Your personal, privacy-focused reading corner.",(0,a.jsx)("span",{className:"block mt-1 text-muted-foreground/80",children:"Let's add some blogs to follow."})]})]})]}),(0,a.jsx)("div",{className:"space-y-3 mobile:space-y-2.5",children:l.map(({key:e,...t})=>(0,a.jsx)(rj,{...t},e))}),(0,a.jsx)("div",{className:"text-center",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"400ms"},children:(0,a.jsxs)("p",{className:"text-[11px] text-muted-foreground/60 flex items-center justify-center gap-1.5",children:[(0,a.jsx)("span",{className:"inline-block size-1 rounded-full bg-primary/50"}),"All feed content stays private in your browser"]})})]})]})})})};var rN=e.i(269035);let rk=()=>{let e=(0,n.useAtomValue)(b.feedLoadingProgressAtom);return e?(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 p-6 text-sm text-muted-foreground",children:[(0,a.jsx)(H.Loader2,{className:"size-4 animate-spin"}),(0,a.jsxs)("span",{children:["Loading feeds... ",e.loaded,"/",e.total]})]})}):null};function rC({count:e=5}){return(0,a.jsxs)("div",{children:[(0,a.jsx)(rk,{}),Array.from({length:e}).map((t,r)=>(0,a.jsxs)(p.Fragment,{children:[(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-start justify-between gap-2",children:[(0,a.jsx)(eD.Skeleton,{className:"h-5 w-3/4"}),(0,a.jsx)(eD.Skeleton,{className:"size-4 shrink-0"})]}),(0,a.jsx)(eD.Skeleton,{className:"mb-2 h-4 w-full"}),(0,a.jsx)(eD.Skeleton,{className:"mb-2 h-4 w-2/3"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eD.Skeleton,{className:"h-3 w-20"}),(0,a.jsx)(eD.Skeleton,{className:"h-3 w-24"})]})]}),r<e-1&&(0,a.jsx)(rN.Separator,{})]},r))]})}var rA=e.i(114683),rS=e.i(846932),rT=e.i(88653);function rE({className:e}){let t=(0,ef.useRouter)(),[r,s]=(0,n.useAtom)(b.viewFilterAtom),o=(0,n.use
4SetAtom)(b.selectedBlogIdAtom),i=(0,n.useSetAtom)(b.selectedTagsAtom),l=(0,n.useSetAtom)(b.exploreModeAtom),c=(0,n.useSetAtom)(er.stickyUnreadGuidsAtom),d=(0,n.useAtomValue)(er.unreadCountAtom),u=(0,n.useAtomValue)(er.starredCountAtom),m=(0,n.useAtomValue)(er.readLaterCountAtom),h=(0,n.useAtomValue)(er.savedPostsCountAtom),f=(0,n.useAtomValue)(b.showUnreadCountInSmartViewsAtom),{data:p}=(0,eg.useUserSettings)(),g=[{id:"all",label:"All",icon:ei.Inbox},{id:"unread",label:"Unread",icon:rA.Circle,count:f?d:void 0},{id:"starred",label:"Starred",icon:el.Star,count:f?u:void 0},{id:"readLater",label:"Later",icon:ec.Bookmark,count:f?m:void 0},{id:"saved",label:"Saved",icon:eh.Archive,count:f?h:void 0},{id:"today",label:"Today",icon:ed.Calendar},{id:"week",label:"Week",icon:eu.CalendarDays}];return(0,a.jsx)(rT.AnimatePresence,{mode:"wait",children:(0,a.jsx)(rS.motion.div,{initial:{y:-10,opacity:0},animate:{y:0,opacity:1},exit:{y:-10,opacity:0},transition:{duration:.2},className:(0,A.cn)("bg-background border-b",e),children:(0,a.jsx)("div",{className:"sticky top-0 z-10 overflow-x-auto scrollbar-hide max-w-[100vw]",children:(0,a.jsx)("div",{className:"flex gap-1.5 px-3 py-2 min-w-max",children:g.map(e=>{let n=e.icon,d=r===e.id,u=void 0!==e.count&&e.count>0;return(0,a.jsxs)("button",{onClick:()=>(e=>{if((0,ey.trackViewFilterChanged)(e),c(new Set),l(!1),o(null),i([]),s(e),p?.url_routing_enabled??!0){let r=(0,ep.getDashboardUrl)(e);t.push(r)}})(e.id),className:(0,A.cn)("flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[13px] font-medium transition-all","border whitespace-nowrap","active:scale-95",d?"bg-primary text-primary-foreground border-primary shadow-sm":"bg-background text-muted-foreground border-border hover:bg-accent hover:text-accent-foreground"),children:[(0,a.jsx)(n,{className:"size-3.5"}),(0,a.jsx)("span",{children:e.label}),u&&null!=e.count&&(0,a.jsx)(y.Badge,{variant:d?"secondary":"default",className:(0,A.cn)("ml-0.5 h-4 min-w-4 flex items-center justify-center px-1 text-[10px]",d?"bg-primary-foreground/20 text-primary-foreground":"bg-muted text-muted-foreground"),children:e.count>99?"99+":e.count})]},e.id)})})})})})}var rM=e.i(687130);function r_({onOpenFilters:e,className:t}){let r,s,o,i,l,c,{hasActiveFilters:d,getFilterSummary:u}=(r=(0,n.useAtomValue)(b.selectedTagsAtom),s=(0,n.useAtomValue)(b.tagFilterModeAtom),o=(0,n.useAtomValue)(b.selectedBlogIdAtom),i=(0,n.useAtomValue)(b.viewFilterAtom),l=(0,n.useAtomValue)(b.sortModeAtom),c=(0,n.useAtomValue)(er.blogsAtom),{hasActiveFilters:r.length>0||null!==o||"all"!==i||"newest"!==l,getFilterSummary:()=>{let e=[];
4if("all"!==i?e.push({unread:"Unread",starred:"Starred",readLater:"Read Later",today:"Today",week:"This Week"}[i]||i):e.push("All Posts"),o){let t=c.find(e=>e.id===o||e.directory_blog_id===o);t&&e.push(t.title)}if(r.length>0){let t=r.join(", ");e.push(`${t} (${"all"===s?"AND":"OR"})`)}return e.join(" • ")},getShortFilterSummary:()=>{if("all"!==i)return({unread:"Unread",starred:"Starred",readLater:"Read Later",today:"Today",week:"This Week"})[i]||i;if(o){let e=c.find(e=>e.id===o||e.directory_blog_id===o);if(e)return e.title}return r.length>0?1===r.length?r[0]:`${r.length} tags`:"All Posts"},selectedTags:r,tagFilterMode:s,selectedBlogId:o,viewFilter:i,sortMode:l}),m=(0,n.useSetAtom)(b.selectedTagsAtom),h=(0,n.useSetAtom)(b.selectedBlogIdAtom),f=(0,n.useSetAtom)(b.viewFilterAtom),p=(0,n.useSetAtom)(b.sortModeAtom),g=(0,n.useSetAtom)(er.stickyUnreadGuidsAtom);return d?(0,a.jsx)(rT.AnimatePresence,{children:(0,a.jsxs)(rS.motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:(0,A.cn)("relative overflow-hidden border-b bg-muted/40",t),children:[(0,a.jsx)("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-[2.5px] h-4 rounded-r-full bg-foreground
4/25","aria-hidden":"true"}),(0,a.jsxs)("div",{onClick:e,className:"flex w-full items-center justify-between gap-2 pl-4 pr-3 py-2 text-left hover:bg-muted/60 active:bg-muted/80 transition-colors",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex-shrink-0 flex items-center justify-center size-6 rounded bg-foreground/5",children:(0,a.jsx)(rM.Filter,{className:"size-3 text-muted-foreground"})}),(0,a.jsx)("span",{className:"text-[13px] font-medium text-foreground/80 truncate",children:u()})]}),(0,a.jsxs)("button",{onClick:e=>{e.stopPropagation(),g(new Set),m([]),h(null),f("all"),p("newest")},className:(0,A.cn)("flex items-center gap-1 px-2 py-1 rounded text-[11px] font-medium transition-colors","text-muted-foreground hover:text-foreground","bg-foreground/5 hover:bg-foreground/10"),children:[(0,a.jsx)(F.X,{className:"size-3"}),"Clear"]})]})]})}):null}var rz=e.i(310055);function rR(e,t){return[...e].sort((e,r)=>{let s=e.pubDate?.getTime()??0,a=r.pubDate?.getTime()??0;return"desc"===t?a-s:s-a})}let rP=(0,eC.default)("calendar-fold",[["path",{d:"M3 20a2 2 0 0 0 2 2h10a2.4 2.4 0 0 0 1.706-.706l3.588-3.588A2.4 2.4 0 0 0 21 16V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2z",key:"r586nh"}],["path",{d:"M15 22v-5a1 1 0 0 1 1-1h5",key:"xl3app"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}]]),rI=(0,eC.default)("calendar-clock",[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);function rL({title:e,count:t,icon:r,isActiveSticky:s}){let o,n="today"===(o=e.toLowerCase())?ed.Calendar:"yesterday"===o?rP:"this week"===o?eu.CalendarDays:"last week"===o?rI:"older"===o?eh.Archive:null,i=!n,[l,c]=(0,p.useState)(!1);return(0,a.jsxs)("div",{className:(0,A.cn)("flex w-full items-center gap-2.5 border-b transition-all duration-200","py-2 px-4","bg-muted/70 backdrop-blur-md supp
4orts-backdrop-filter:bg-muted/60",s&&["shadow-md dark:shadow-background/80"],"z-[51]"),children:[i?r&&!l?(0,a.jsx)("img",{src:r,alt:"",className:"size-5 rounded-sm object-cover flex-shrink-0",onError:()=>c(!0)}):(0,a.jsx)(()=>{let t;return(0,a.jsx)("div",{className:(0,A.cn)("size-5 rounded-sm flex-shrink-0 flex items-center justify-center","bg-muted text-muted-foreground text-[10px] font-semibold"),children:(t=e.trim().split(/\s+/)).length>=2?(t[0][0]+t[1][0]).toUpperCase():e.charAt(0).toUpperCase()})},{}):n&&(0,a.jsx)(n,{className:(0,A.cn)("size-4 flex-shrink-0 text-muted-foreground transition-colors",s&&"text-foreground/70")}),(0,a.jsx)("h2",{className:(0,A.cn)("flex-1 text-[13px] font-medium transition-colors truncate","text-foreground/80",s&&"text-foreground"),children:e}),(0,a.jsx)("span",{className:(0,A.cn)("flex-shrink-0 text-[12px] transition-colors","text-muted-foreground",s&&"text-foreground/60"),children:t})]})}var rD=e.i(806795),rF=e.i(639372),rO=e.i(428052);function rB(e,t){let r=new Set;for(let s of e)if(("directory"===s.source||"community"===s.source)&&!0===s.has_full_content||!t&&!0!==s.blocks_iframe){let e=null;e="directory"===s.source&&s.directory_blog_id?s.directory_blog_id:"community"===s.source&&s.community_blog_id?s.community_blog_id:s.id,r.add(e)}return r}function r$(){let e=(0,n.useAtomValue)(T.extensionAvailableAtom),t=(0,n.useAtomValue)(P.hasCustomProxyAtom),r=(0,n.useAtomValue)(er.blogsAtom),s=(0,n.useAtomValue)(b.showOpenBehaviorIndicatorsAtom),{data:a}=(0,rO.useServerCapabilities)(),o=(0,ex.default)(),i=a?.can.fetchPostContentWithoutExtension??!1;return(0,p.useMemo)(()=>{if(e||t||i)return{showIndicators:!1,defaultBehavior:"in-app",defaultBehaviorRatio:100,inAppCount:r.length,externalCount:0,hasFullAccess:!0,isException:()=>!1,getBlogBehavior:()=>"in-app"};let a=rB(r,o),n=a.size,l=r.length-n,c=r.length,d=0===c?"external":n>=l?"in-app":"external",u=c>0?Math.round(("in-app"===d?n:l)/c*100):0;return{showIndicators:s&&("in-app"===d?l:n)>0,defaultBehavior:d,defaultBehaviorRatio:u,inAppCount:n,externalCount:l,hasFullAccess:!1,isException:e=>{if(!e)return!1;let t=a.has(e);return"in-app"===d?!t:t},getBlogBehavior:e=>e&&a.has(e)?"in-app":"external"}},[e,t,i,r,s,o])}(0,rF.atom)(e=>{let t=e(T.extensionAvailableAtom),r=e(P.hasCustomProxyAtom),s=e(er.blogsAtom),a=e(b.showOpenBehaviorIndicatorsAtom);if(t||r)return{showIndicators:!1,defaultBehavior:"in-app",defaultBehaviorRatio:100,inAppCount:s.length,externalCount:0,hasFullAccess:!0,inAppBlogSet:new Set};let o=rB(s,!1),n=o.size,i=s.length-n,l=s.length,c=0===l?"external":n>=i?"in-app":"external",d=l>0?Math.round(("in-app"===c?n:i)/l*100):0;return{showIndicators:a&&("in-app"===c?i:n)>0,defaultBehavior:c,defaultBehaviorRatio:d,inAppCount:n,externalCount:i,hasFullAccess:!1,inAppBlogSet:o}});let rU=(0,eC.default)("star-off",[["path",{d:"m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152",key:"19ctli"}],["path",{d:"m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099",key:"ptqqvy"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),rV=(0,eC.default)("bookmark-minus",[["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]]);var rq=e.i(662031),rH=e.i(786108),rH=rH,rG=e.i(115057);let rW=(0,eC.default)("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]);var rK=e.i(352786),rY=e.i(119638);let rQ=(0,p.memo)(({post:e,index:t,isRead:r,isStarred:s,isReadLater:o,isSelected:n,isLastItem:i,isMobile:l,showBlogName:c,blogTags:d,blogCategory:u,highlightRules:m,isDark:h,isOpeningException:f,opensExternally:g,onPostClick:x,onReadLaterClick:b,onCopyLink:y,onShare:j,onToggleRead:w,onToggleStar:N,onBlogClick:k,isSavedOffline:C,onSaveOffline:S,saveOfflineAvailable:T})=>{let E=(0,p.useMemo)(()=>
4{if(0===m.length||!d?.length&&!u)return;let e=(0,rY.getHighlightForPost)(d||[],u,m,!r);if(e)return{styles:(0,rY.getHighlightStyles)(e.color,e.style,h),hideUnreadBar:e.hideUnreadBar}},[d,u,m,r,h]),M=E?.styles,_=E?.hideUnreadBar??!1,z=t=>{let n=t?tu:tW.DropdownMenuItem,i=t?tm:tW.DropdownMenuSeparator,c=(0,A.cn)(l&&"py-3"),d=(0,A.cn)("mr-2",l?"size-5":"size-4");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),e.link&&tM(e.link)},className:c,children:[(0,a.jsx)(ez.ExternalLink,{className:d}),"Open in new tab"]}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),y(e)},className:c,children:[(0,a.jsx)(eM.Copy,{className:d}),"Copy link"]}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),j(e)},className:c,children:[(0,a.jsx)(rq.Share2,{className:d}),"Share"]}),(0,a.jsx)(i,{}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),w(e)},className:c,children:[(0,a.jsx)(eE.CheckCheck,{className:d}),r?"Mark as unread":"Mark as read"]}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),N(e)},className:c,children:[s?(0,a.jsx)(rU,{className:d}):(0,a.jsx)(el.Star,{className:d}),s?"Remove star":"Add star"]}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),b(t,e)},className:c,children:[o?(0,a.jsx)(rV,{className:d}):(0,a.jsx)(ec.Bookmark,{className:d}),o?"Remove from Read Later":"Add to Read Later"]}),T&&S&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i,{}),(0,a.jsxs)(n,{onClick:t=>{t.stopPropagation(),S(e)},className:c,children:[C?(0,a.jsx)(rK.HardDrive,{className:(0,A.cn)(d,"text-primary")}):(0,a.jsx)(rW,{className:d}),C?"Remove from saved":"Save offline"]})]})]})},R=c?"@max-[300px]/postlist:hidden":"",P="shrink text-clip line-clamp-1",I=(0,a.jsxs)("div",{onClick:()=>x(e),className:(0,A.cn)("max-w-full overflow-hidden relative group/post","cursor-pointer p-4 transition-all duration-200 hover:bg-muted/50",n&&"bg-muted",!r&&!_&&"border-l-2 border-l-primary","hover:translate-x-[4px] ease-in-out "),style:{animation:"fadeInUp 0.2s ease-out both",animationDelay:(t<10?.05*t:.5)+"s"},children:[M&&(0,a.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:M,"aria-hidden":"true"}),(0,a.jsxs)("div",{className:"mb-1 flex items-start justify-between gap-2 max-w-full relative z-[1]",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 flex-1 min-w-0 relative",children:[l&&(0,a.jsxs)(tW.DropdownMenu,{children:[(0,a.jsx)(tW.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsx)("button",{onClick:e=>e.stopPropagation(),className:"shrink-0 rounded p-3 -m-2 hover:bg-muted/80 transition-colors absolute top-0 left-0","aria-label":"Post actions",children:(0,a.jsx)(rH.default,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(tW.DropdownMenuContent,{align:"start",className:"w-56",children:z(!1)})]}),(0,a.jsx)("h3",{className:(0,A.cn)("line-clamp-2 text-sm transition-all flex-1 min-w-0",!r&&"font-semibold",l&&"ml-9"),children:e.title})]}),(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[s&&(0,a.jsx)("div",{className:"post-star-active p-1",children:(0,a.jsx)(el.Star,{className:"size-4 fill-amber-500 text-amber-500 drop-shadow-sm"})}),C&&(0,a.jsx)("div",{className:"post-save-active p-1",children:(0,a.jsx)(rK.HardDrive,{className:"size-3.5 text-primary"})}),e.guid&&(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)("button",{onClick:t=>b(t,e),className:(0,A.cn)("post-action rounded-md p-1.5 transition-all hover:scale-105 active:scale-95",o&&"post-bookmark-active"),children:(0,a.jsx)(ec.Bookmark,{className:(0,A.cn)("size-4 transition-colors",o?"fill-blue-500 text-blue-500":"text-muted-foreground/60 group-hover/post:text-muted-foreground")})})}),(0,a.jsx)(v.TooltipContent,{children:o?"Remove from Read Later":"Add to Read Later"})]})})]})]}),e.description&&(0,a.jsx)("p",{className:(0,A.cn)("mb-2 line-clamp-2 text-xs text-muted-foreground relative z-[1]",l&&"ml-9"),children:e.description}),(0,a.jsxs)("div",{className:(0,A.cn)("flex flex-row items-center gap-2 text-xs text-muted-foreground relative z-[1]",l&&"ml-9"),children:[e.blogTitle&&(0,a.jsxs)(a.Fragment,{children:[e.blogIcon?(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),e.blogId&&e.blogTitle&&k(t,e.blogId,e.blogTitle)},className:(0,A.cn)("shrink-0 rounded hover:opacity-80 transition-opacity",!c&&"hidden"),children:(0,a.jsx)("img",{src:e.blogIcon,alt:e.blogTitle,className:"size-4 rounded-sm object-cover",onError:t=>{let r=t.target,s=document.createElement("span");
4s.className=(0,A.cn)("font-medium text-foreground/70",P),s.textContent=e.blogTitle||"",r.parentNode?.replaceChild(s,r)}})}):(0,a.jsx)("button",{onClick:t=>{t.stopPropagation(),e.blogId&&e.blogTitle&&k(t,e.blogId,e.blogTitle)},className:(0,A.cn)("font-medium text-foreground/70 hover:text-foreground transition-colors",P,!c&&"hidden"),children:e.blogTitle}),(0,a.jsx)("span",{className:(0,A.cn)("shrink-0 opacity-50",!c&&"hidden"),children:(e.author||e.pubDate)&&"·"})]}),e.author&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:(0,A.cn)(P,R),children:e.author}),e.pubDate&&(0,a.jsx)("span",{className:(0,A.cn)("shrink-0 opacity-50",R),children:"·"})]}),e.pubDate&&(0,a.jsx)("span",{className:"shrink-0",children:(0,tx.formatDistanceToNow)(new Date(e.pubDate),{addSuffix:!0})})]}),f&&(0,a.jsx)("div",{className:(0,A.cn)("absolute bottom-2 right-2 pointer-events-none","transition-opacity duration-200","opacity-20 group-hover/post:opacity-50",l&&"opacity-30"),"aria-hidden":"true",children:g?(0,a.jsx)(rG.ArrowUpRight,{className:"size-5 text-muted-foreground"}):(0,a.jsx)(rc.ArrowRight,{className:"size-5 text-muted-foreground"})})]}),L=l?I:(0,a.jsxs)(tl,{children:[(0,a.jsx)(tc,{asChild:!0,children:I}),(0,a.jsx)(td,{className:"w-48",children:z(!0)})]});return(0,a.jsxs)(p.Fragment,{children:[L,!i&&(0,a.jsx)(rN.Separator,{className:"opacity-50"})]},e.guid||t)});rQ.displayName="PostItem";let rX=(0,p.memo)(e=>{var t,r;let s,o,i,l,{post:c}=e,{isRead:d,isStarred:u,isReadLater:m,isSavedOffline:h}=(t=c.guid,r=c.guidHash,s=(0,p.useMemo)(()=>(0,rF.atom)(e=>!!t&&(0,er.isGuidInSet)(t,e(er.readPostGuidsAtom),r)),[t,r]),o=(0,p.useMemo)(()=>(0,rF.atom)(e=>{if(!t)return!1;let s=e(er.starredPostGuidsAtom);return s.has(t)||!!r&&s.has(r)}),[t,r]),i=(0,p.useMemo)(()=>(0,rF.atom)(e=>{if(!t)return!1;let s=e(er.readLaterPostGuidsAtom);return s.has(t)||!!r&&s.has(r)}),[t,r]),l=(0,p.useMemo)(()=>(0,rF.atom)(e=>!!t&&e(er.savedOfflinePostGuidsAtom).has(t)),[t]),{isRead:(0,n.useAtomValue)(s),isStarred:(0,n.useAtomValue)(o),isReadLater:(0,n.useAtomValue)(i),isSavedOffline:(0,n.useAtomValue)(l)});return(0,a.jsx)(rQ,{...e,isRead:d,isStarred:u,isReadLater:m,isSavedOffline:h})},(e,t)=>e.post.guid===t.post.guid&&e.index===t.index&&e.isSelected===t.isSelected&&e.isLastItem===t.isLastItem&&e.isMobile===t.isMobile&&e.showBlogName===t.showBlogName&&e.isDark===t.isDark&&e.isOpeningException===t.isOpeningException&&e.opensExternally===t.opensExternally&&e.highlightRules===t.highlightRules&&e.blogTags===t.blogTags&&e.blogCategory===t.blogCategory&&e.saveOfflineAvailable===t.saveOfflineAvailable&&!0);rX.displayName="ConnectedPostItem";var rZ=e.i(779334);let rJ=()=>{let e=(0,n.useSetAtom)(b.addFeedDialogOpenAtom),{navigateToExplore:t}=eb();return(0,a.jsx)("div",{className:"flex h-full flex-col items-center justify-center px-6 py-8",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-6 max-w-[260px]",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both"},children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("div",{className:"absolute -inset-4",children:[(0,a.jsx)("span",{className:"absolute top-0 right-2 size-1.5 rounded-full bg-primary/40",style:{animation:"gentle-float 3s ease-in-out infinite"}}),(0,a.jsx)("span",{className:"absolute bottom-2 left-0 size-1 rounded-full bg-primary/30",style:{animation:"gentle-float 4s ease-in-out infinite",animationDelay:"-1.5s"}})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:(0,A.cn)("absolute -bottom-1 left-1/2 -translate-x-1/2","w-14 h-10 rounded-lg","bg-gradient-to-br from-muted/80 to-muted/40","border border-border/30","rotate-3")}),(0,a.jsx)("div",{className:(0,A.cn)("absolute -bottom-0.5 left-1/2 -translate-x-1/2","w-14 h-10 rounded-lg","bg-gradient-to-br from-muted/90 to-muted/50","border border-border/40","-rotate-2")}),(0,a.jsx)("div",{className:(0,A.cn)("relative z-10 rounded-xl p-4","bg-gradient-to-br from-muted to-muted/60","border border-border/50","shadow-sm"),style:{animation:"gentle-breathe 4s ease-in-out infinite"},children:(0,a.jsx)(rZ.Newspaper,{className:"size-6 text-primary/80"})})]})]}),(0,a.jsxs)("div",{className:"space-y-1.5 text-center",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"100ms"},children:[(0,a.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Your reading list awaits"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Add some blogs to fill this space with great writing"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"150ms"},children:[(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",onClick:()=>{t()},className:(0,A.cn)("w-full gap-2 group","hover:border-primary/40 hover:bg-primary/5","transition-all duration-200"),children:[(0,a.jsx)(ro,{className:"size-3.5 text-primary"}),(0,a.jsx)("span",{children:"Browse Directory"}),(0,a.jsx)(rc.ArrowRight,{className:(0,A.cn)("size-3 ml-auto text-muted-foreground
4/40","translate-x-0 opacity-0 transition-all duration-200","group-hover:translate-x-0.5 group-hover:opacity-100")})]}),(0,a.jsxs)(u.Button,{variant:"ghost",size:"sm",onClick:()=>{e(!0)},className:"w-full gap-2 text-muted-foreground hover:text-foreground",children:[(0,a.jsx)(i.Plus,{className:"size-3.5"}),"Add by URL"]})]}),(0,a.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 flex items-center gap-1.5",style:{animation:"reveal-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both",animationDelay:"250ms"},children:[(0,a.jsx)("span",{className:"inline-block w-8 h-px bg-gradient-to-r from-transparent via-border to-transparent"}),"More options in the panel",(0,a.jsx)(rc.ArrowRight,{className:"size-2.5"})]})]})})};var r0=e.i(440160);function r1({onRefresh:e,isRefreshing:t}){let r=(0,n.useAtomValue)(er.proxyDisabledFeedsAtom),s=(0,n.useAtomValue)(T.extensionAvailableAtom),o=r.slice(0,5),i=r.length>5;return(0,a.jsx)("div",{className:"flex h-full items-center justify-center p-8",children:(0,a.jsxs)("div",{className:"max-w-md space-y-6 text-center",children:[(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("div",{className:"rounded-full bg-amber-500/20 p-5",children:(0,a.jsx)(k.WifiOff,{className:"size-10 text-amber-600 dark:text-amber-400"})})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold text-foreground",children:"Feed proxy temporarily unavailable"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"We're experiencing high server load and have temporarily disabled the feed proxy. Your feeds are still available — just not through our servers right now."})]}),!s&&(0,a.jsxs)("div",{className:"space-y-4 p-4 rounded-lg bg-gradient-to-r from-amber-500/10 via-orange-500/10 to-amber-500/10 border border-amber-500/20",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 text-left",children:[(0,a.jsx)("div",{className:"p-2 rounded-full bg-amber-500/20 shrink-0",children:(0,a.jsx)(E.Zap,{className:"size-5 text-amber-600 dark:text-amber-400"})}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("h4",{className:"font-medium text-amber-700 dark:text-amber-300",children:"Install the browser extension"}),(0,a.jsx)("p",{className:"text-sm text-amber-600/80 dark:text-amber-400/80",children:"The extension lets your browser fetch feeds directly, bypassing the server proxy entirely. It's faster and works even when the proxy is disabled."})]})]}),(0,a.jsxs)(u.Button,{className:"w-full bg-amber-600 hover:bg-amber-700 text-white",onClick:()=>{window.open(tK.EXTENSION_URLS.LANDING,"_blank","noopener,noreferrer")},children:[(0,a.jsx)(r0.Download,{className:"size-4 mr-2"}
4),"Install Extension",(0,a.jsx)(ez.ExternalLink,{className:"size-3 ml-1.5 opacity-60"})]})]}),o.length>0&&(0,a.jsxs)("div",{className:"text-left space-y-2",children:[(0,a.jsxs)("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Affected feeds (",r.length,")"]}),(0,a.jsxs)("div",{className:"space-y-1",children:[o.map(e=>(0,a.jsx)("div",{className:"text-sm text-muted-foreground truncate px-2 py-1 rounded bg-muted/50",children:e.blogTitle},e.blogId)),i&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground px-2",children:["+",r.length-5," more..."]})]})]}),e&&(0,a.jsxs)(u.Button,{variant:"outline",onClick:e,disabled:t,children:[(0,a.jsx)(C.RefreshCw,{className:`size-4 mr-2 ${t?"animate-spin":""}`}),t?"Refreshing...":"Try Again"]})]})})}var r2=e.i(649582),r5=e.i(323012),rH=rH,r3=e.i(991799),r4=e.i(897250),r6=e.i(23750),r8=e.i(624836);function r7(){let e=(0,n.useAtomValue)(b.feedsLoadingAtom),t=(0,n.useAtomValue)(b.timelineRefetchAtom),r=(0,n.useSetAtom)(b.isManualRefreshAtom),{isOnline:s}=(0,x.useNetworkStatus)(),o=async()=>{if(t){(0,ey.trackFeedRefresh)("all"),(0,r8.clearCatalogSnapshotCache)(),r(!0);try{let e=t();th.toast.promise(e,{loading:"Refreshing feeds...",success:"Feeds refreshed successfully",error:"Failed to refresh feeds"}),await e}finally{r(!1)}}};return(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"outline",size:"icon",onClick:o,disabled:e||!t||!s,children:(0,a.jsx)(rS.motion.div,{animate:e?{rotate:360}:{},transition:{duration:1,repeat:e?1/0:0,ease:"linear"},children:(0,a.jsx)(C.RefreshCw,{className:"size-4"})})})}),(0,a.jsx)(v.TooltipContent,{children:s?"Refresh feeds":"Refresh unavailable offline"})]})})}let r9=(0,eC.default)("satellite-dish",[["path",{d:"M4 10a7.31 7.31 0 0 0 10 10Z",key:"1fzpp3"}],["path",{d:"m9 15 3-3",key:"88sc13"}],["path",{d:"M17 13a6 6 0 0 0-6-6",key:"15cc6u"}],["path",{d:"M21 13A10 10 0 0 0 11 3",key:"11nf8s"}]]);var se=e.i(319036);let st={status:"idle",updatedCount:0,followedCount:0,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:void 0},sr=(0,rF.atom)({isEnabled:!0,directory:{...st},community:{...st},combinedStatus:"idle",totalUpdatedCount:0,totalFollowedCount:0});function ss(e,t){let r=t.directory?{...e.directory,...t.directory}:e.directory,s=t.community?{...e.community,...t.community}:e.community,a=t.isEnabled??e.isEnabled;return{isEnabled:a,directory:r,community:s,combinedStatus:a?"checking"===r.status||"checking"===s.status?"checking":"error"===r.status&&"error"===s.status?"error":"success"===r.status||"success"===s.status?"success":("idle"===r.status&&s.status,"idle"):"disabled",totalUpdatedCount:r.updatedCount+s.updatedCount,totalFollowedCount:r.followedCount+s.followedCount}}function sa(){let e=(0,n.useAtomValue)(sr),{data:t}=(0,eg.useUserSettings)(),r=(0,eg.useUpdateUserSettings)(),s=(0,tg.useQueryClient)();if(!e||"idle"===e.combinedStatus)return null;let{icon:o,variant:i,tooltip:l,buttonClassName:c}=(()=>{switch(e.combinedStatus){case"disabled":return{icon:(0,a.jsx)(r9,{className:"size-4"}),variant:"ghost",tooltip:"Catalog monitor disabled",buttonClassName:"text-muted-foreground opacity-50"};case"checking":return{icon:(0,a.jsx)(H.Loader2,{className:"size-4 animate-spin"}),variant:"ghost",tooltip:"Checking catalog for updates...",buttonClassName:"text-muted-foreground"};case"error":return{icon:(0,a.jsx)(O.AlertCircle,{className:"size-4"}),variant:"ghost",tooltip:"Catalog monitor offline",buttonClassName:"text-destructive hover:text-destructive"};default:let t=e.totalUpdatedCount>0;return{icon:(0,a.jsx)(r9,{className:"size-4"}),variant:"ghost",tooltip:t?`${e.totalUpdatedCount} ${1===e.totalUpdatedCount?"blog has":"blogs have"} new posts`:"Catalog monitor active",buttonClassName:t?"text-primary":"text-muted-foreground"}}})(),d="success"===e.combinedStatus&&e.totalUpdatedCount>0;return(0,a.jsxs)(tb.Popover,{children:[(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(tb.PopoverTrigger,{asChild:!0,children:(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)(u.Button,{variant:i,size:"icon",className:(0,A.cn)("relative",c),children:[o,d&&(0,a.jsx)(y.Badge,{variant:"default",className:"absolute -right-1 -top-1 flex size-5 items-center justify-center p-0 text-[10px]",children:e.totalUpdatedCount})]})})}),(0,a.jsx)(v.TooltipContent,{children:l})]})}),(0,a.jsx)(tb.PopoverContent,{className:"w-80",side:"bottom",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["disabled"===e.combinedStatus&&(0,a.jsx)(r9,{className:"size-4 text-muted-foreground"}),"checking"===e.combinedStatus&&(0,a.jsx)(H.Loader2,{className:"size-4 animate-spin text-muted-foreground"}),"error"===e.combinedStatus&&(0,a.jsx)(O.AlertCircle,{className:"size-4 text-destructive"}),"success"===e.combinedStatus&&(0,a.jsx)(r9,{className:"size-4 text-primary"}),(0,a.jsx)("h4",{className:"font-semibold",children:"Catalog Monitor"}),(0,a.jsxs)(y.Badge,{variant:"error"===e.combinedStatus?"destructive":"secondary",className:"ml-auto",children:["disabled"===e.combinedStatus&&"Disabled","checking"===e.combinedStatus&&"Checking","error"===e.combinedStatus&&"Offline","success"===e.combinedStatus&&"Server assist"]})]}),(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:["disabled"===e.combinedStatus&&(0,a.jsx)("p",{children:"Server-side monitoring is turned off. All catalog blogs will be checked locally on every refresh."}),"checking"===e.combinedStatus&&(0,a.jsx)("p",{children:"Asking the server which catalog blogs have new posts…"}),"error"===e.combinedStatus&&(0,a.jsx)("p",{children:"We could not reach the server-side monitor. All catalog blogs will be fetched locally until it recovers."}),"success"===e.combinedStatus&&(0,a.jsx)(a.Fragment,{children:0===e.totalFollowedCount?(0,a.jsx)("p",{children:"Follow blogs from the catalog to let the server pre-check them for you."}):0===e.totalUpdatedCount?(0,a.jsxs)("p",{children:["All ",e.totalFollowedCount," followed catalog blogs are quiet right now."]}):(0,a.jsxs)("p",{className:"font-medium text-foreground",children:[e.totalUpdatedCount," of your followed catalog blogs have new posts."]})})]}),"success"===e.combinedStatus&&e.directory.followedCount>0&&e.community.followedCount>0&&(0,a.jsxs)("div",{className:"space-y-1 border-t pt-3 text-xs text-muted-foreground",children:[(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{children:"Directory blogs"}),(0,a.jsxs)("span",{children:[e.directory.updatedCount>0?`${e.directory.updatedCount} updated`:"No updates"," ","(",e.directory.followedCount," followed)"]})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{children:"Community blogs"}),(0,a.jsxs)("span",{children:[e.community.updatedCount>0?`${e.community.updatedCount} updated`:"No updates"," ","(",e.community.followedCount," followed)"]})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between border-t pt-3",children:[(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Server-side monitoring"}),(0,a.jsx)(se.Switch,{checked:t?.use_directory_updates??!0,onCheckedChange:e=>{(0,r8.clearCatalogSnapshotCache)(),r.mutate({use_directory_updates:e},{onSuccess:()=>{s.invalidateQueries({queryKey:["timeline"]})}})}})]})]})})]})}let so=(0,eC.default)("square-arrow-out-up-right",[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}
4],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]]),sn=(0,eC.default)("equal-approximately",[["path",{d:"M5 15a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"yrdkhy"}],["path",{d:"M5 9a6.5 6.5 0 0 1 7 0 6.5 6.5 0 0 0 7 0",key:"gzkvyz"}]]),si={"in-app":{label:"Most posts open in reader",shortLabel:"In Reader",icon:tB.BookOpen,iconClass:"text-foreground",badgeClass:"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:border-border",popover:{title:"Opening in Reader",description:"Most of your blogs have full content in their feeds, so posts will open directly in the built-in reader.",note:"Some posts may still open externally if their blog doesn't include full content."}},external:{label:"Most posts open externally",shortLabel:"External",icon:so,iconClass:"text-foreground",badgeClass:"bg-muted/50 border-border/50 text-muted-foreground hover:bg-muted hover:border-border",popover:{title:"Opening Externally",description:"Most posts will open in a new browser tab since your blogs require fetching content from the original site.",note:"Install the browser extension to read all posts in the built-in reader."}}};function sl({config:e,inAppCount:t,externalCount:r,defaultBehavior:s,defaultBehaviorRatio:o}){let n=t+r;return(0,a.jsxs)("div",{className:"flex flex-col gap-2 text-xs",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"shrink-0 text-foreground",children:(0,a.jsx)(e.icon,{className:"size-3.5",strokeWidth:2})}),(0,a.jsx)("div",{className:"font-semibold text-foreground text-sm",children:e.popover.title})]}),(0,a.jsx)("p",{className:"text-muted-foreground leading-relaxed",children:e.popover.description}),n>0&&(0,a.jsxs)("div",{className:"flex items-center gap-1 pt-1.5 border-t border-border/50",children:[(0,a.jsx)(sn,{className:"size-3.5 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-muted-foreground",children:[o,"% of blogs (","in-app"===s?t:r," of ",n,")"]})]}),e.popover.note&&(0,a.jsxs)("div",{className:"flex items-start gap-2 pt-1.5",children:[(0,a.jsx)(O.AlertCircle,{className:"size-3 text-muted-foreground mt-1.5 shrink-0"}),(0,a.jsx)("span",{className:"text-muted-foreground leading-relaxed",children:e.popover.note})]})]})}let sc=({className:e})=>{let[t,r]=(0,p.useState)(!1),[s,o]=(0,p.useState)(!1),[i,l]=(0,n.useAtom)(b.openBehaviorIndicatorDismissedAtom),c=(0,ex.default)(),{showIndicators:d,defaultBehavior:u,defaultBehaviorRatio:m,inAppCount:h,externalCount:f,hasFullAccess:g}=r$();if(g||!d||i)return null;let x=si[u];return(0,a.jsx)("div",{className:(0,A.cn)("px-3 py-1.5 mobile:pt-0",e),children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)(tb.Popover,{open:t||s,onOpenChange:r,children:[(0,a.jsx)(tb.PopoverTrigger,{asChild:!0,children:(0,a.jsxs)(y.Badge,{variant:"outline",className:(0,A.cn)("text-xs mobile:text-sm px-2.5 py-1.5","font-medium","border inline-flex items-center gap-1.5 w-full justify-center","mobile:cursor-pointer cursor-info select-none","transition-colors duration-200","rounded-sm","mx-0.5",c&&"pr-8",x.badgeClass),onMouseEnter:()=>{c||r(!0)},onMouseLeave:()=>{s||c||r(!1)},onClick:e=>{e.stopPropagation(),(s||t)&&(o(!1),r(!1))},children:[(0,a.jsx)(x.icon,{className:"size-3.5 mobile:size-4",strokeWidth:2}),(0,a.jsx)("span",{children:x.label})]})}),(0,a.jsxs)(tb.PopoverContent,{className:"w-72",side:"bottom",align:"center",onPointerDownOutside:()=>{s&&(o(!1),r(!1))},onMouseEnter:()=>{c||r(!0)},onMouseLeave:()=>{s||c||r(!1)},children:[c&&(0,a.jsx)("div",{className:"absolute top-1 right-1",children:(0,a.jsx)("button",{className:"p-1 rounded-sm bg-muted hover:bg-muted/80 duration-200s","aria-label":"Close popover",onClick:e=>{e.stopPropagation(),o(!1),r(!1)},children:(0,a.jsx)(F.X,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(sl,{config:x,inAppCount:h,externalCount:f,defaultBehavior:u,defaultBehaviorRatio:m})]})]}),c&&(0,a.jsx)("button",{className:"absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-sm hover:bg-muted/80 transition-colors","aria-label":"Dismiss indicator",onClick:e=>{e.stopPropagation(),l(!0)},children:(0,a.jsx)(F.X,{className:"size-4 text-muted-foreground"})})]})})};var sd=e.i(977154);let su=(0,p.memo)(function({isMobile:e,sidebarOpen:t,toggleSidebar:r,isMacDesktop:s,onOpenMobileFilters:o}
4){let l,c,d=(0,n.useStore)(),m=(0,n.useAtomValue)(b.searchQueryAtom),h=(0,n.useSetAtom)(b.searchQueryAtom),f=(0,n.useAtomValue)(b.sortModeAtom),g=(0,n.useSetAtom)(b.sortModeAtom),x=(0,n.useAtomValue)(b.viewFilterAtom),y=(0,n.useAtomValue)(er.filteredUnreadCountAtom),j=(0,n.useAtomValue)(er.filteredPostsCountAtom),w=(0,n.useSetAtom)(b.addFeedDialogOpenAtom),N=(0,n.useSetAtom)(b.manageBlogsDialogOpenAtom),k=(0,n.useSetAtom)(b.commandPaletteOpenAtom),{resolvedTheme:C,setTheme:S}=(0,rr.useTheme)(),T=(0,tf.useMarkAllAsRead)(),[E,M]=(0,p.useState)(m);(0,p.useEffect)(()=>{let e=setTimeout(()=>{E!==m&&h(E)},300);return()=>clearTimeout(e)},[E,m,h]);let _=(0,p.useRef)(m);(0,p.useEffect)(()=>{m!==_.current&&m!==E&&M(m),_.current=m},[m,E]);let z=(0,p.useMemo)(()=>(0,sd.getSortModesForView)(x),[x]),R=(0,p.useCallback)(e=>{g(e)},[g]),P=(0,p.useCallback)(()=>{let e=d.get(er.filteredPostsAtom),t=d.get(er.readPostGuidsAtom),r=e.filter(e=>e.guid&&!(0,er.isGuidInSet)(e.guid,t,e.guidHash)).map(e=>e.guid);T(r),th.toast.success(`Marked ${r.length} ${1===r.length?"post":"posts"} as read`)},[d,T]),I=(0,p.useCallback)(()=>w(!0),[w]),L=(0,p.useCallback)(()=>N(!0),[N]),D=(0,p.useCallback)(()=>{S("dark"===C?"light":"dark")},[S,C]);return(0,a.jsxs)("div",{className:"sticky top-0 z-10 shrink-0 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 transition-all duration-200",children:[(0,a.jsxs)("div",{className:(0,A.cn)("overflow-hidden",e?"p-2":"p-4 mobile:pb-0"),children:[(0,a.jsxs)("div",{className:(0,A.cn)("flex items-center justify-between w-full gap-2 desktop:mb-3",s&&!t&&"pl-14"),children:[!t&&(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:r,className:"shrink-0",children:(0,a.jsx)(r5.PanelLeft,{className:"size-4"})}),(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)(U.Search,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),(0,a.jsx)(r6.Input,{placeholder:"Quick search...",value:E,onChange:e=>M(e.target.value),className:"pl-9 pr-14"}),(0,a.jsx)("button",{type:"button",onClick:()=>k(!0),className:"absolute right-2 top-1/2 -translate-y-1/2 hidden items-center gap-0.5 rounded border bg-muted px-1.5 py-0.5 font-mono text-[10px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground sm:flex",children:"⌘K"})]}),(0,a.jsx)(r7,{}),e&&(0,a.jsx)(u.Button,{variant:"outline",size:"icon",onClick:o,children:(0,a.jsx)(r2.SlidersHorizontal,{className:"size-4"})}),e&&(0,a.jsxs)(tW.DropdownMenu,{children:[(0,a.jsx)(tW.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"outline",size:"icon",children:(0,a.jsx)(rH.default,{className:"size-4"})})}),(0,a.jsxs)(tW.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,a.jsxs)(tW.DropdownMenuItem,{onClick:P,disabled:0===y,children:[(0,a.jsx)(eE.CheckCheck,{className:"mr-2 size-4"}),"Mark all read ",y>0&&`(${y})`]}),(0,a.jsx)(tW.DropdownMenuSeparator,{}),z.map(([e,t])=>{let r=t.icon,s=f===e;return(0,a.jsx)(tW.DropdownMenuItem,{onClick:()=>R(e),children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(r,{className:"size-4"}),t.label]}),s&&(0,a.jsx)("span",{className:"text-primary",children:"✓"})]})},e)}),(0,a.jsx)(tW.DropdownMenuSeparator,{}),(0,a.jsxs)(tW.DropdownMenuItem,{onClick:I,children:[(0,a.jsx)(i.Plus,{className:"mr-2 size-4"}),"Add a Blog"]}),(0,a.jsxs)(tW.DropdownMenuItem,{onClick:L,children:[(0,a.jsx)(eS.Pencil,{className:"mr-2 size-4"}),"Manage Blogs"]}),(0,a.jsx)(tW.DropdownMenuSeparator,{}),(0,a.jsx)(tW.DropdownMenuItem,{onClick:D,children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsxs)("div",{className:"flex items-center",children:["dark"===C?(0,a.jsx)(r3.Moon,{className:"mr-2 size-4"}):(0,a.jsx)(r4.Sun,{className:"mr-2 size-4"}),(0,a.jsx)("span",{children:"Theme"})]}),(0,a.jsx)("span",{className:"text-muted-foreground text-xs",children:"dark"===C?"Dark":"Light"})]})})]})]}),!e&&(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"outline",size:"icon",onClick:P,disabled:0===y,children:(0,a.jsx)(eE.CheckCheck,{className:"size-4"})})}),(0,a.jsxs)(v.TooltipContent,{children:["Mark all as read ",y>0&&`(${y})`]})]})})]}),(0,a.jsxs)("div",{className:(0,A.cn)("flex flex-row items-center justify-between gap-2 w-full transition-all duration-200",!t&&"@max-sm/postlist:flex-col @max-sm/postlist:items-start @max-sm/postlist:justify-start",e&&"h-0 opacity-0"),style:{height:e?0:"auto",opacity:+!e},children:[!t&&(0,a.jsxs)("div",{className:"text-sm text-muted-foreground shrink-0",children:[j," ",1===j?"post":"posts",y>0&&(0,a.jsxs)("span",{className:"ml-1.5 text-primary font-medium",children:["· ",y," unread"]})]}),!e&&(0,a.jsxs)("div",{className:(0,A.cn)("flex items-center gap-2 w-full",t?"justify-start":"justify-start @max-sm/postlist:justify-start flex-row-reverse"),children:[(0,a.jsxs)(ty.Select,{value:f,onValueChange:e=>R(e),children:[(0,a.jsx)(ty.SelectTrigger,{className:"saved"===x?"w-[180px]":"w-[130px]",children:(0,a.jsx)(ty.SelectValue,{children:(c=(l=sd.SORT_MODE_CONFIG[f]).icon,(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(c,{className:"size-4"}),l.label]}))})}),(0,a.jsx)(ty.SelectContent,{children:z.map(([e,t])=>{let r=t.icon;return(0,a.jsx)(ty.SelectItem,{value:e,children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(r,{className:"size-4"}),t.label]})},e)})})]}),(0,a.jsx)("div",{className:(0,A.cn)(t?"self-end ml-auto":""),children:(0,a.jsx)(sa,{})})]})]})]}),(0,a.jsx)(sc,{})]})});function sm(){let e=(0,n.useAtomValue)(b.feedsLoadingAtom),t=(0,n.useAtomValue)(b.feedLoadingProgressAtom);if(!t||e)return null;let r=Math.round(t.loaded/t.total*100);return(0,a.jsxs)("div",{className:"border-t bg-muted/50 backdrop-blur-sm supports-backdrop-filter:bg-muted/40 block z-50 absolute bottom-0 left-0 right-0",children:[(0,a.jsx)("div",{className:"h-[2px] w-full bg-foreground
4/5 overflow-hidden",children:(0,a.jsx)("div",{className:"h-full bg-primary/40 transition-all duration-500 ease-out",style:{width:`${r}%`}})}),(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-1.5",children:[(0,a.jsx)(C.RefreshCw,{className:"size-3 text-muted-foreground animate-spin shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Refreshing feeds"}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground/70 tabular-nums ml-auto",children:[t?.loaded,"/",t?.total]})]})]})}var sh=e.i(854280),sf=e.i(772795);let sp=(0,o.default)(()=>e.A(329008).then(e=>({default:e.MobileFiltersDrawer})),{loadableGenerated:{modules:[882691]},ssr:!1});function sg(){let e=(0,n.useAtomValue)(er.blogsAtom),t=(0,n.useAtomValue)(er.filteredPostsAtom),r=(0,n.useAtomValue)(er.selectedPostIdAtom),s=(0,n.useSetAtom)(er.selectedPostIdAtom),o=(0,n.useAtomValue)(b.searchQueryAtom),i=(0,n.useSetAtom)(b.searchQueryAtom),l=(0,n.useStore)(),u=(0,n.useAtomValue)(b.sortByAtom),m=(0,n.useAtomValue)(b.sortOrderAtom),h=(0,n.useAtomValue)(b.feedsLoadingAtom),f=(0,n.useAtomValue)(er.proxyDisabledCountAtom),{open:g,toggleSidebar:x}=(0,d.useSidebar)(),y=(0,n.useSetAtom)(b.mobileHasVisitedSelectedPostAtom),v=(0,n.useSetAtom)(b.exploreModeAtom),j=(0,n.useAtomValue)(b.showBlogNameInPostListAtom),w=(0,n.useAtomValue)(b.selectedBlogIdAtom),N=(0,n.useSetAtom)(b.selectedBlogIdAtom),k=(0,n.useSetAtom)(b.viewFilterAtom),{resolvedTheme:C}=(0,rr.useTheme)(),A=(0,c.useIsDesktopApp)()&&window.electronBridge?.platform==="darwin",S=(0,n.useSetAtom)(er.stickyUnreadGuidsAtom),{showIndicators:T,isException:E,getBlogBehavior:M}=r$(),_=j&&"blog"!==u&&null==w,[z,R]=(0,p.useState)(!1),P=(0,p.useCallback)(()=>{v(!1)},[v]),I=0===e.length,L=(0,tf.useMarkAsRead)(),D=(0,tf.useMarkAsUnread)(),F=(0,tf.useToggleReadLater)(),O=(0,tf.useToggleStar)(),{data:B=[]}=(0,rD.useHighlightRules)(),$="dark"===C,{isAvailable:U,savePost:V,deletePost:q}=(0,sh.useSavePostOffline)(),H=(0,p.useMemo)(()=>{let t=new Map;for(let r of e)t.set(r.id,{tags:r.tags||[],category:r.category});return t},[e]),G=(0,p.useMemo)(()=>w?null:function(e,t,r="desc"){if("unread"===t||"savedAt"===t)return null;let s="date"===t?function(e,t="desc"){let r={today:[],yesterday:[],thisWeek:[],lastWeek:[],older:[]};return e.forEach(e=>{var t;r[!function(e){if(!e)return!1;let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(t=e.pubDate)?!function(e){if(!e)return!1;let t=new Date;return t.setDate(t.getDate()-1),e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}(t)?!function(e){if(!e)return!1;let t=new Date,r=new Date(t);r.setDate(t.getDate()-t.getDay()),r.setHours(0,0,0,0);let s=new Date(r);return s.setDate(r.getDate()+7),e>=r&&e<s}(t)?!function(e){if(!e)return!1;let t=new Date,r=new Date(t);r.setDate(t.getDate()-t.getDay()-7),r.setHours(0,0,0,0);let s=new Date(r);return s.setDate(r.getDate()+7),e>=r&&e<s}(t)?"older":"lastWeek":"thisWeek":"yesterday":"today"].push(e)}),("desc"===t?["today","yesterday","thisWeek","lastWeek","older"]:["older","lastWeek","thisWeek","yesterday","today"]).filter(e=>r[e].length>0).map(e=>({key:e,title:({today:"Today",yesterday:"Yesterday",thisWeek:"This Week",lastWeek:"Last Week",older:"Older"})[e],posts:rR(r[e],t),count:r[e].length}))}(e,r):function(e,t="desc"){let r=new Map;e.forEach(e=>{let t=e.blogId||"unknown",s=e.blogTitle||"Unknown Blog",a=e.blogIcon;r.has(t)||r.set(t,{title:s,icon:a,posts:[]}),r.get(t).posts.push(e)});let s=Array.from(r.entries()).map(([e,{title:r,icon:s,posts:a}])=>({key:e,title:r,posts:rR(a,t),count:a.length,icon:s}));return s.sort((e,r)=>{let s=e.title.localeCompare(r.title,void 0,{sensitivity:"base"});return"desc"===t?s:-s}),s}(e,r);if(0===s.length)return null;let a=[],o=[];for(let e of s)for(let t of(o.push(a.length),a.push({type:"header",key:e.key,title:e.title,count:e.count,icon:e.icon}),e.posts))a.push({type:"post",post:t});return{items:a,stickyIndexes:o}}(t,u,m),[t,u,m,w]),W=(0,p.useMemo)(()=>G?.stickyIndexes??[],[G]),K=(0,p.useRef)(0),Y=(0,p.useCallback)(e=>W.includes(e),[W]),Q=(0,p.useCallback)(e=>K.current===e,[]),X=(0,p.useRef)(null),[Z,J]=(0,p.useState)(null),ee=(0,ex.default)();(0,p.useEffect)(()=>
4{if(X.current){let e=X.current.querySelector("[data-radix-scroll-area-viewport]");e&&J(e)}},[]);let et=(0,p.useCallback)(e=>0===W.length?t2(e):(K.current=[...W].reverse().find(t=>e.startIndex>=t)??0,[...new Set([K.current,...t2(e)])].sort((e,t)=>e-t)),[W]),es=G?.items.length??t.length,ea=(0,p.useCallback)(e=>{if(G){let t=G.items[e];if(t?.type==="header")return`header-${t.key}`;if(t?.type==="post")return`post-${t.post.guid||e}`}let r=t[e];return`post-${r?.guid||e}`},[G,t]),eo=function({useFlushSync:e=!0,...t}){let r=p.useReducer(()=>({}),{})[1],s={...t,onChange:(s,a)=>{var o;e&&a?(0,tX.flushSync)(r):r(),null==(o=t.onChange)||o.call(t,s,a)}},[a]=p.useState(()=>new t9(s));return a.setOptions(s),rt(()=>a._didMount(),[]),rt(()=>a._willUpdate()),a}({observeElementRect:t5,observeElementOffset:t6,scrollToFn:t7,count:es,getScrollElement:()=>Z,estimateSize:e=>{if(G&&Y(e))return 41;let r=G?.items[e],s=r?.type==="post"?r.post:t[e];return s&&!s.description?90:125},overscan:5,enabled:!!Z,rangeExtractor:G?et:void 0,getItemKey:ea});eo.shouldAdjustScrollPositionOnItemSizeChange=(e,t,r)=>e.start<(r.scrollOffset??0);let en=(0,p.useRef)(null);(0,p.useEffect)(()=>{let e=G?G.items.slice(0,3).map(e=>"header"===e.type?`h:${e.key}`:`p:${e.post.guid?.slice(0,8)||"x"}`).join(","):t.slice(0,3).map(e=>e.guid?.slice(0,8)||"x").join(","),r=G?`sectioned-${u}-${G.items.length}-${G.stickyIndexes.length}-${e}`:`flat-${w||"all"}-${t.length}-${e}`;null!==en.current&&en.current!==r&&eo.scrollToOffset(0),en.current=r},[G,t,u,w,eo]);let el=(0,p.useRef)(null);(0,p.useEffect)(()=>()=>{el.current&&(clearTimeout(el.current),el.current=null)},[]);let ec=(0,p.useCallback)(e=>{if(P(),"external"===M(e.blogId)&&e.link){e.guid&&e.blogId&&L(e.guid,e.blogId),tM(e.link);return}y(!1),e.guid&&e.blogId&&(s(e.guid),el.current&&(clearTimeout(el.current),el.current=null),el.current=setTimeout(()=>{l.get(er.unreadExemptionAtom)!==e.guid&&L(e.guid,e.blogId),el.current=null},5e3))},[s,L,P,M,y]),ed=(0,p.useCallback)((e,t)=>{if(e.stopPropagation(),!t.guid||!t.blogId||!t.blogTitle)return;let r=l.get(er.readLaterPostGuidsAtom).has(t.guid);F(t,t.blogId,t.blogTitle,r),th.toast.loading(r?"Removing from Read Later...":"Adding to Read Later...",{id:rz.READ_LATER_TOAST_ID})},[l,F]),eu=(0,p.useCallback)(e=>{e.link&&(navigator.clipboard.writeText(e.link),th.toast.success("Link copied to clipboard"))},[]),em=(0,p.useCallback)(async e=>{if(e.link)if(navigator.share)try{await navigator.share({title:e.title,url:e.link})}catch(e){}else eu(e)},[eu]),eh=(0,p.useCallback)(e=>{e.guid&&e.blogId&&((0,er.isGuidInSet)(e.guid,l.get(er.readPostGuidsAtom),e.guidHash)?(D(e.guid,e.blogId),th.toast.success("Marked as unread")):(L(e.guid,e.blogId),th.toast.success("Marked as read")))},[l,D,L]),ef=(0,p.useCallback)(e=>{if(!e.guid||!e.blogId||!e.blogTitle)return;let t=l.get(er.starredPostGuidsAtom).has(e.guid);O(e,e.blogId,e.blogTitle,t),th.toast.loading(t?"Removing from starred...":"Adding to starred...",{id:rz.STAR_TOAST_ID})},[l,O]),ep=(0,p.useCallback)(async e=>{if(e.guid)if(l.get(er.savedOfflinePostGuidsAtom).has(e.guid))await q(e.guid)?th.toast.success("Removed from saved"):th.toast.error("Failed to remove saved post");else{let t=await V(e);t.alreadySaved?th.toast.info("Already saved"):t.success?((0,ey.trackPostSavedOffline)("manual"),th.toast.success("Saved for offline reading")):th.toast.error("Failed to save post")}},[l,V,q]),eg=(0,p.useCallback)((e,t,r)=>{e.stopPropagation(),S(new Set),N(t),k("all"),P(),th.toast.success(`Filtering by ${r}`)},[S,N,k,P]);return(0,a.jsxs)("div",{className:"flex h-full flex-col overflow-hidden @container/postlist relative",children:[(0,a.jsx)(su,{isMobile:ee,sidebarOpen:g,toggleSidebar:x,isMacDesktop:A,onOpenMobileFilters:()=>R(!0)}),ee&&(0,a.jsx)(rE,{}),ee&&(0,a.jsx)(r_,{onOpenFilters:()=>R(!0)}),(0,a.jsx)(rs.ScrollArea,{className:"flex-1 overflow-auto relative max-h-fit",ref:X,children:(0,a.jsx)("div",{className:"flex-1 relative max-w-full overflow-clip",children:h&&0===t.length?(0,a.jsx)(rC,{count:8}):I&&!h?ee?(0,a.jsx)(rw,{}):(0,a.jsx)(rJ,{}):0===t.length&&f>0&&!o?(0,a.jsx)(r1,{}):0===t.length?(0,a.jsx)(ra,{icon:ei.Inbox,title:o?"No posts found":"No posts yet",description:o?`No posts match your search for "${o}". Try different keywords.`:"You don't have any posts in this view. Follow some blogs to get started!",action:o?{label:"Clear search",onClick:()=>i("")}:void 0}):(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{style:{height:`${eo.getTotalSize()}px`,width:"100%",position:"relative",contain:"strict"},children:eo.getVirtualItems().map(e=>{let s=G?.items[e.index],o=!!G&&Y(e.index)&&Q(e.index);if(s?.type==="header")return(0,a.jsx)("div",{"data-index":e.index,ref:e=>eo.measureElement(e),style:{position:o?"sticky":"absolute",top:0,left:0,width:"100%",transform:o?void 0:`translateY(${e.start}px)`,zIndex:o?50:10},children:(0,a.jsx)(rL,{title:s.title,count:s.count,icon:s.icon,isActiveSticky:o})},e.key);let n=s?.type==="post"?s.post:t[e.index];if(!n)return null;let i=n.blogId?H.get(n.blogId):void 0,l=T&&E(n.blogId),c="external"===M(n.blogId),d=(!G||"blog"!==u)&&_;return(0,a.jsx)("div",{"data-index":e.index,ref:e=>eo.measureElement(e),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${e.start}px)`,zIndex:1},children:(0,a.jsx)(rX,{post:n,index:e.index,isSelected:n.guid===r,isLastItem:e.index===e
4s-1,isMobile:ee,showBlogName:d,blogTags:i?.tags,blogCategory:i?.category,highlightRules:B,isDark:$,isOpeningException:l,opensExternally:c,onPostClick:ec,onReadLaterClick:ed,onCopyLink:eu,onShare:em,onToggleRead:eh,onToggleStar:ef,onBlogClick:eg,onSaveOffline:U?ep:void 0,saveOfflineAvailable:U})},e.key)})})})})}),(0,a.jsx)(sm,{}),ee&&(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"inline",children:(0,a.jsx)(sp,{open:z,onOpenChange:R})})]})}var sx=e.i(655900);function sb({id:e,title:t,details:r}){let[s,o]=(0,p.useState)(!1),[n,i]=(0,p.useState)(!1),l=(0,p.useCallback)(()=>{th.toast.dismiss(e)},[e]),c=(0,p.useCallback)(async()=>{let e=[`Error: ${t}`,r.code?`Code: ${r.code}`:null,`Message: ${r.message}`,r.context?`Context: ${r.context}`:null,r.timestamp?`Time: ${r.timestamp.toISOString()}`:null].filter(Boolean).join("\n");try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),2e3)}catch{}},[t,r]);return(0,a.jsxs)("div",{className:(0,A.cn)("relative w-full max-w-[420px] rounded-lg overflow-hidden","border transition-all duration-200","bg-gradient-to-br from-rose-50/90 via-stone-50 to-orange-50/50","border-rose-200/40 shadow-lg shadow-rose-900/5","dark:from-stone-900 dark:via-stone-900 dark:to-rose-950/30","dark:border-rose-800/20 dark:shadow-none"),children:[(0,a.jsx)("div",{className:"absolute left-0 top-0 bottom-0 w-1 bg-gradient-to-b from-rose-400 to-orange-400 dark:from-rose-500 dark:to-orange-500"}),(0,a.jsxs)("div",{className:"p-4 pl-5 pr-10",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:(0,A.cn)("flex-shrink-0 p-1.5 rounded-full","bg-rose-100/80 dark:bg-rose-900/40"),children:(0,a.jsx)(O.AlertCircle,{className:"size-4 text-rose-600 dar
4k:text-rose-400"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h4",{className:(0,A.cn)("font-medium text-sm leading-tight","text-stone-800 dark:text-stone-100"),children:t}),r.code&&(0,a.jsx)("span",{className:(0,A.cn)("inline-flex mt-1.5 px-1.5 py-0.5 rounded text-[10px] font-mono","bg-rose-100/70 text-rose-700/90","dark:bg-rose-900/40 dark:text-rose-300/90"),children:r.code})]})]}),(0,a.jsx)("button",{onClick:()=>o(!s),className:(0,A.cn)("mt-3 flex items-center gap-1.5 text-xs font-medium","text-stone-600 hover:text-stone-800","dark:text-stone-400 dark:hover:text-stone-200","transition-colors"),children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(sx.ChevronUp,{className:"size-3.5"}),"Hide details"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ee.ChevronDown,{className:"size-3.5"}),"View details"]})}),s&&(0,a.jsxs)("div",{className:(0,A.cn)("mt-3 p-3 rounded-md text-xs space-y-2","bg-white/60 dark:bg-stone-800/40"),children:[(0,a.jsx)("p",{className:"text-stone-700 dark:text-stone-300 leading-relaxed",children:r.message}),r.context&&(0,a.jsx)("p",{className:"text-stone-500 dark:text-stone-400 truncate text-[11px]",children:r.context}),(0,a.jsx)("button",{onClick:c,className:(0,A.cn)("flex items-center gap-1.5 mt-2 text-[10px] font-medium","text-stone-500 hover:text-stone-700","dark:text-stone-400 dark:hover:text-stone-300","transition-colors"),children:n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D.Check,{className:"size-3"}),"Copied"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eM.Copy,{className:"size-3"}),"Copy error details"]})})]})]}),(0,a.jsx)("button",{onClick:l,className:(0,A.cn)("absolute top-3 right-3 p-1.5 rounded-full","text-stone-400 hover:text-stone-600 hover:bg-stone-100/80","dark:text-stone-500 dark:hover:text-stone-300 dark:hover:bg-stone-800/60","transition-colors"),"aria-label":"Dismiss error",children:(0,a.jsx)(F.X,{className:"size-4"})})]})}var sy=e.i(287336),sv=e.i(401851),sj=e.i(286536),sw=e.i(77705),sN=e.i(373375),sk=e.i(871689),sC=e.i(741929),sA=e.i(398361),sS=e.i(726336),sT=e.i(87309);function sE(){let[e,t]=(0,n.useAtom)(b.blogIdToViewModeAtom),r=(0,n.useAtomValue)(T.extensionAvailableAtom),s=(0,n.useAtomValue)(b.defaultExtractionModeAtom),a=(0,p.useCallback)((t,a)=>e&&e[t]?e[t]:!0===a?"content":r?s:"iframe",[e,r,s]),o=(0,p.useCallback)((e,r)=>{t(t=>{t[e]=r})},[t]);return{getPreference:a,setPreference:o,togglePreference:(e,t)=>{let r="content"===t?"iframe":"content";return o(e,r),r},clearPreferences:(0,p.useCallback)(()=>{t(e=>{})},[t]),preferences:e}}var sM="6A5AA1D4EAFF4E9FB37E23D68491D6F4",s_=`wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=${sM}`,sz="143.0.3650.75",sR=sz.split(".")[0],sP=`1-${sz}`;({...{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${sR}.0.0.0 Safari/537.36 Edg/${sR}.0.0.0`,"Accept-Encoding":"gzip, deflate, br, zstd","Accept-Language":"en-US,en;q=0.9"},Authority:"speech.platform.bing.com","Sec-CH-UA":`" Not;A Brand";v="99", "Microsoft Edge";v="${sR}", "Chromium";v="${sR}"`,"Sec-CH-UA-Mobile":"?0",Accept:"*/*","Sec-Fetch-Site":"none","Sec-Fetch-Mode":"cors","Sec-Fetch-Dest":"empty"});var sI=class extends Error{constructor(e){super(e),this.name="EdgeTTSException"}},sL=class extends sI{constructor(e){super(e),this.name="SkewAdjustmentError"}},sD=class extends sI{constructor(e){super(e),this.name="UnknownResponse"}},sF=class extends sI{constructor(e){super(e),this.name="UnexpectedResponse"}},sO=class extends sI{constructor(e){super(e),this.name="NoAudioReceived"}},sB=class extends sI{constructor(e){super(e),this.name="WebSocketError"}},s$=class extends sI{constructor(e){super(e),this.name="ValueError"}},sU=class e{static adjClockSkewSeconds(t){e.clockSkewSeconds+=t}static getUnixTimestamp(){return Date.now()/1e3+e.clockSkewSeconds}static parseRfc2616Date(e){try{return new Date(e).getTime()/1e3}catch(e){return null}}static handleClientResponseError(t){if(!t.headers)throw new sL("No headers in response.");let r=t.headers.date||t.headers.Date;if(!r)throw new sL("No server date in headers.");let s=e.parseRfc2616Date(r);if(null===s)throw new sL(`Failed to parse server date: ${r}`);let a=e.getUnixTimestamp();e.adjClockSkewSeconds(s-a)}static async generateSecMsGec(){let t=e.getUnixTimestamp();t+=0x2b6109100,t-=t%300,t*=1e9/100;let r=`${t.toFixed(0)}${sM}`,s=new TextEncoder().encode(r);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",s))).map(e=>e.toString(16).padStart(2,"0")).join("").toUpperCase()}static generateMuid(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("").toUpperCase()}static headersWithMuid(t){return{...t,Cookie:`muid=${e.generateMuid()};`}}};function sV(){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=15&e[6]|64,e[8]=63&e[8]|128;let t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`.replace(/-/g,"")}function sq(){return new Date().toUTCString().replace("GMT","GMT+0000 (Coordinated Universal Time)")}sU.clockSkewSeconds=0;var sH=class e{constructor({voice:e,rate:t="+0%",volume:r="+0%",pitch:s="+0Hz"}){this.voice=e,this.rate=t,this.volume=r,this.pitch=s,this.validate()}validate(){let t=/^([a-z]{2,})-([A-Z]{2,})-(.+Neural)$/.exec(this.voice);if(t){let[,e]=t,[,,r,s]=t;if(s.includes("-")){let e=s.split("-");r+=`-${e[0]}`,s=e[1]}this.voice=`Microsoft Server Speech Text to Speech Voice (${e}-${r}, ${s})`}e.validateStringParam("voice",this.voice,/^Microsoft Server Speech Text to Speech Voice \(.+,.+\)$/),e.validateStringParam("rate",this.rate,/^[+-]\d+%$/),e.validateStringParam("volume",this.volume,/^[+-]\d+%$/),e.validateStringParam("pitch",this.pitch,/^[+-]\d+Hz$/)}static validateStringParam(e,t,r){if("string"!=typeof t)throw TypeError(`${e} must be a string`);if(!r.test(t))throw new s$(`Invalid ${e} '${t}'.`)}},sG=class{static from(e,t){if("string"==typeof e)return new TextEncoder().encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Uint8Array)return e;throw Error("Unsupported input type for BrowserBuffer.from")}static concat(e){let t=new Uint8Array(e.reduce((e,t)=>
4e+t.length,0)),r=0;for(let s of e)t.set(s,r),r+=s.length;return t}};function sW(e){if(e.length<2)throw Error("Message too short to contain header length");let t=e[0]<<8|e[1],r={};if(t>0&&t+2<=e.length){let s=e.slice(2,t+2);for(let e of new TextDecoder().decode(s).split("\r\n")){let[t,s]=e.split(":",2);t&&s&&(r[t]=s.trim())}}return[r,e.slice(t+2)]}var sK=class{constructor(e,t={}){if(this.state={partialText:sG.from(""),offsetCompensation:0,lastDurationOffset:0,streamWasCalled:!1},this.ttsConfig=new sH({voice:t.voice||"en-US-EmmaMultilingualNeural",rate:t.rate,volume:t.volume,pitch:t.pitch}),"string"!=typeof e)throw TypeError("text must be a string");this.texts=function(e,t){return function*(){let t=new TextEncoder().encode(e);for(;t.length>4096;){let e=4096,r=t.slice(0,4096),s=new TextDecoder().decode(r),a=s.lastIndexOf("\n"),o=s.lastIndexOf(" ");a>0?e=new TextEncoder().encode(s.substring(0,a)).length:o>0&&(e=new TextEncoder().encode(s.substring(0,o)).length);let n=t.slice(0,e),i=new TextDecoder().decode(n).trim();i&&(yield new TextEncoder().encode(i)),t=t.slice(e)}let r=new TextDecoder().decode(t).trim();r&&(yield new TextEncoder().encode(r))}()}(function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}(function(e){return e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g," ")}(e)),0),this.connectionTimeout=t.connectionTimeout}parseMetadata(e){for(let t of JSON.parse(new TextDecoder().decode(e)).Metadata){let e=t.Type;if("WordBoundary"===e||"SentenceBoundary"===e)return{type:e,offset:t.Data.Offset+this.state.offsetCompensation,duration:t.Data.Duration,text:t.Data.text.Text.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")};if("SessionEnd"!==e)throw new sD(`Unknown metadata type: ${e}`)}throw new sF("No WordBoundary metadata found")}async *_stream(){var e,t,r,s,a,o,n,i;let l,c=new WebSocket(`${s_}&Sec-MS-GEC=${await sU.generateSecMsGec()}&Sec-MS-GEC-Version=${sP}&ConnectionId=${sV()}`),d=[],u=null;this.connectionTimeout&&(l=window.setTimeout(()=>{c.close(),d.push(new sB("Connection timeout")),u&&u()},this.connectionTimeout)),c.onmessage=e=>{l&&(window.clearTimeout(l),l=void 0);let t=e.data;if("string"==typeof t){let[e,r]=function(e){let t=new TextDecoder().decode(e),r=t.indexOf("\r\n\r\n"),s={};if(-1!==r)for(let e of t.substring(0,r).split("\r\n")){let[t,r]=e.split(":",2);t&&r&&(s[t]=r.trim())}let a=new TextEncoder().encode(t.substring(0,r+4)).length;return[s,e.slice(a)]}(sG.from(t)),s=e.Path;if("audio.metadata"===s)try{let e=this.parseMetadata(r);this.state.lastDurationOffset=e.offset+e.duration,d.push(e)}catch(e){d.push(e)}else"turn.end"===s?(this.state.offsetCompensation=this.state.lastDurationOffset,this.state.offsetCompensation+=875e4,c.close()):"response"!==s&&"turn.start"!==s&&d.push(new sD(`Unknown path received: ${s}`))}else if(t instanceof ArrayBuffer){let e=sG.from(t);if(e.length<2)d.push(new sF("We received a binary message, but it is missing the header length."));else{let[t,r]=sW(e);"audio"!==t.Path?d.push(new sF("Received binary message, but the path is not audio.")):"audio/mpeg"!==t["Content-Type"]?r.length>0&&d.push(new sF("Received binary message, but with an unexpected Content-Type.")):0===r.length?d.push(new sF("Received binary message, but it is missing the audio data.")):d.push({type:"audio",data:r})}}else t instanceof Blob&&t.arrayBuffer().then(e=>{let t=sG.from(e);if(t.length<2)d.push(new sF("We received a binary message, but it is missing the header length."));else{let[e,r]=sW(t);"audio"!==e.Path?d.push(new sF("Received binary message, but the path is not audio.")):"audio/mpeg"!==e["Content-Type"]?r.length>0&&d.push(new sF("Received binary message, but with an unexpected Content-Type.")):0===r.length?d.push(new sF("Received binary message, but it is missing the audio data.")):d.push({type:"audio",data:r})}u&&u()});u&&u()},c.onerror=e=>{l&&(window.clearTimeout(l),l=void 0),d.push(new sB("WebSocket error occurred")),u&&u()},c.onclose=()=>{l&&(window.clearTimeout(l),l=void 0),d.push("close"),u&&u()},await new Promise((e,t)=>
4{c.onopen=()=>{l&&(window.clearTimeout(l),l=void 0),e()},this.connectionTimeout&&setTimeout(()=>{c.readyState===WebSocket.CONNECTING&&(c.close(),t(new sB("Connection timeout")))},this.connectionTimeout)}),c.send(`X-Timestamp:${sq()}\r
5Content-Type:application/json; charset=utf-8\r
6Path:speech.config\r
7\r
8{"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":"false","wordBoundaryEnabled":"true"},"outputFormat":"audio-24khz-48kbitrate-mono-mp3"}}}}\r
9`),c.send((o=sV(),n=sq(),e=this.ttsConfig.voice,t=this.ttsConfig.rate,r=this.ttsConfig.volume,s=this.ttsConfig.pitch,a=new TextDecoder().decode(this.state.partialText),i=`<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'><voice name='${e}'><prosody pitch='${s}' rate='${t}' volume='${r}'>${a}</prosody></voice></speak>`,`X-RequestId:${o}\r
10Content-Type:application/ssml+xml\r
11X-Timestamp:${n}Z\r
12Path:ssml\r
13\r
14${i}`));let m=!1;for(;;)if(d.length>0){let e=d.shift();if("close"===e){if(!m)throw new sO("No audio was received.");break}if(e instanceof Error)throw e;"audio"===e.type&&(m=!0),yield e}else await new Promise(e=>{u=e,setTimeout(e,50)})}async *stream(){if(this.state.streamWasCalled)throw Error("stream can only be called once.");for(let e of(this.state.streamWasCalled=!0,this.texts))for await(let t of(this.state.partialText=e,this._stream()))yield t}},sY=class{constructor(e,t="Microsoft Server Speech Text to Speech Voice (en-US, EmmaMultilingualNeural)",r={}){this.text=e,this.voice=t,this.rate=r.rate||"+0%",this.volume=r.volume||"+0%",this.pitch=r.pitch||"+0Hz"}async synthesize(){let e=new sK(this.text,{voice:this.voice,rate:this.rate,volume:this.volume,pitch:this.pitch}),t=[],r=[];for await(let s of e.stream())"audio"===s.type&&s.data?t.push(s.data):"WordBoundary"===s.type&&void 0!==s.offset&&void 0!==s.duration&&void 0!==s.text&&r.push({offset:s.offset,duration:s.duration,text:s.text});return{audio:new Blob([function(e){if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),r=0;for(let s of e)s.length>0&&(t.set(s,r),r+=s.length);return t}(t)],{type:"audio/mpeg"}),subtitle:r}}};let sQ="audio",sX=new Map;function sZ(){let e=Date.now(),t=Array.from(sX.entries()),r=t.reduce((e,[,t])=>e+t.size,0);t.sort((e,t)=>e[1].lastAccessedAt-t[1].lastAccessedAt);let s=[];for(let[r,a]of t)e-a.lastAccessedAt>6e5&&s.push(r);if(t.length>20){let e=t.length-20;for(let r=0;r<e;r++){let[e]=t[r];s.includes(e)||s.push(e)}}if(r>0x6400000){let e=r;for(let[r,a]of t){if(e<=0x5000000)break;s.includes(r)||(s.push(r),e-=a.size)}}for(let t of s){let r=sX.get(t);r&&(console.log(`[Audio Cache] Revoking blob URL for ${t} (age: ${Math.round((e-r.lastAccessedAt)/1e3)}s)`),URL.revokeObjectURL(r.url),sX.delete(t))}s.length>0&&console.log(`[Audio Cache] Evicted ${s.length} blob URLs. Cache size: ${sX.size}/20`)}function sJ(e,t){let r=sX.get(e);if(r)return r.lastAccessedAt=Date.now(),console.log(`[Audio Cache] Reusing cached blob URL for ${e}`),r.url;let s=URL.createObjectURL(t);return sX.set(e,{url:s,cacheKey:e,createdAt:Date.now(),lastAccessedAt:Date.now(),size:t.size}),console.log(`[Audio Cache] Created new blob URL for ${e} (${(t.size/1024/1024).toFixed(2)}MB)`),sZ(),s}var s0=e.i(695557),s1=e.i(85377),s2=e.i(253484),s5=e.i(276991),s3=e.i(149012);async function s4(e,t){if(!t?.skipCache)try{let t=await (0,s3.getCachedContent)(e);if(t&&t.textContent)return console.log(`[Text Extractor][Cache] Cache hit for: ${e}`),{success:!0,content:{title:t.title||"Untitled",textContent:t.textContent,htmlContent:t.htmlContent,excerpt:t.excerpt,byline:t.byline,length:t.length||t.textContent.length,url:e,fromCache:!0,cacheSource:t.source}}}catch(e){console.warn("[Text Extractor][Cache] Cache lookup failed, proceeding with extraction:",e)}if((0,s0.shouldUseExtension)())try{console.log("[Text Extractor][Extension] Attempting to extract via browser extension:",e);let r=await (0,s0.extractTextViaExtension)(e);console.log("[Text Extractor][Extension] Successfully extracted via extension:",e),(0,s1.incrementExtensionTextExtraction)();let s={title:r.title,textContent:r.textContent,htmlContent:void 0,excerpt:void 0,byline:void 0,length:r.textContent.length,url:e};return(0,s3.setCachedContent)(e,s,"extension",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:s}}catch(t){(0,s0.isExtensionError)(t)?console.log(`[Text Extractor][Extension] Extension extraction failed for ${e}: ${t.message}`):console.warn(`[Text Extractor][Extension] Unexpected extension error for ${e}:`,t)}let r=(0,s2.getActiveCustomProxyConfig)();if(r?.capabilities.parse)try{console.log("[Text Extractor][Custom Proxy] Attempting to parse via custom proxy:",e);let s=await (0,s2.parseViaCustomProxy)(e,r.url,r.apiKey,"both");if(s.success){console.log("[Text Extractor][Custom Proxy] Successfully parsed via custom proxy:",e);let r=s.content?(0,s5.resolveRelativeUrls)(s.content,e):void 0,a={title:s.title||"Untitled",textContent:s.textContent||"",htmlContent:r,excerpt:s.excerpt||void 0,byline:s.byline||void 0,length:s.length||s.textContent?.length||0,url:e};return(0,s3.setCachedContent)(e,a,"custom-proxy",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:a}}console.log(`[Text Extractor][Custom Proxy] Custom proxy parse failed for ${e}:`,s.error?.message)}catch(t){console.warn(`[Text Extractor][Custom Proxy] Custom proxy error for ${e}:`,t)}try{console.log("[Text Extractor] Parsing URL via server proxy:",e);let r=`/api/proxy/parse?format=text&url=${encodeURIComponent(e)}`,s=await fetch(r,{method:"GET",headers:{Accept:"application/json"}}),a=await s.json();if(!s.ok){if(503===s.status||"PARSE_DISABLED"===a.code)return{success:!1,error:"PROXY_DISABLED: Text extraction is temporarily disabled due to high server load. Please install the browser extension."};if(401===s.status)return{success:!1,error:"Authentication failed. Please check your API configuration."};if(429===s.status)return{success:!1,error:"Too many requests. Please try again later."};if(500===s.status)return{success:!1,error:"Text extraction service is not configured properly. Please check environment variables."};return{success:!1,error:a.error||`HTTP error! status: ${s.status}`}}if(!a.textContent)return{success:!1,error:"No readable content found in the article."};(0,s1.incrementProxyTextExtraction)();let o={title:a.title||"Untitled",textContent:a.textContent,excerpt:a.excerpt,byline:a.byline,length:a.length||a.textContent.length,url:e};return(0,s3.setCachedContent)(e,o,"server",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:o}}catch(e){return console.error("[Text Extractor] Failed to extract text from URL:",e),{success:!1,error:e instanceof Error?e.message:"Failed to extract text from URL"}}}async function s6(e,t){if(!t?.skipCache)try{let t=await (0,s3.getCachedContent)(e);if(t&&t.htmlContent)return console.log(`[Text Extractor][Cache] Cache hit for HTML: ${e}`),{success:!0,content:{title:t.title||"Untitled",textContent:void 0,htmlContent:t.htmlContent,excerpt:t.excerpt,byline:t.byline,length:t.length||t.htmlContent.length,url:e,fromCache:!0,cacheSource:t.source}}}catch(e){console.warn("[Text Extractor][Cache] Cache lookup failed, proceeding with extraction:",e)}if((0,s0.shouldUseExtension)())try{console.log("[Text Extractor][Extension] Attempting to extract HTML via browser extension:",e);let r=await (0,s0.extractHtmlViaExtension)(e);console.log("[Text Extractor][Extension] Successfully extracted HTML via extension:",e),(0,s1.incrementExtensionTextExtraction)();let s=(0,s5.resolveRelativeUrls)(r.htmlContent,e),a={title:r.title,textContent:void 0,htmlContent:s,excerpt:void 0,byline:void 0,length:s.length,url:e};return(0,s3.setCachedContent)(e,a,"extension",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:a}}catch(t){(0,s0.isExtensionError)(t)?console.log(`[Text Extractor][Extension] Extension HTML extraction failed for ${e}: ${t.message}`):console.warn(`[Text Extractor][Extension] Unexpected extension error for ${e}:`,t)}let r=(0,s2.getActiveCustomProxyConfig)();if(r?.capabilities.parse)try{console.log("[Text Extractor][Custom Proxy] Attempting to extract HTML via custom proxy:",e);let s=await (0,s2.parseViaCustomProxy)(e,r.url,r.apiKey,"html");if(s.success&&s.content){console.log("[Text Extractor][Custom Proxy] Successfully extracted HTML via custom proxy:",e);let r=(0,s5.resolveRelativeUrls)(s.content,e),a={title:s.title||"Untitled",textContent:void 0,htmlContent:r,excerpt:s.excerpt||void 0,byline:s.byline||void 0,length:r.length,url:e};return(0,s3.setCachedContent)(e,a,"custom-proxy",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:a}}console.log(`[Text Extractor][Custom Proxy] Custom proxy HTML extraction failed for ${e}:`,s.error?.message)}catch(t){console.warn(`[Text Extractor][Custom Proxy] Custom proxy error for ${e}:`,t)}try{console.log("[Text Extractor] Attempting HTML extraction via authenticated extract endpoint:",e);let r=`/api/proxy/extract?format=html&url=${encodeURIComponent(e)}`,s=await fetch(r,{method:"GET",headers:{Accept:"application/json"},credentials:"include"});if(s.ok){let r=await s.json();if(r.htmlContent||r.textContent){console.log("[Text Extractor] Successfully extracted via authenticated endpoint:",e);let s=r.htmlContent?(0,s5.resolveRelativeUrls)(r.htmlContent,e):void 0,a={title:r.title||"Untitled",textContent:void 0,htmlContent:s,excerpt:r.excerpt||void 0,byline:r.byline||void 0,length:r.length||r.textContent?.length||0,url:e};return(0,s3.setCachedContent)(e,a,"server",{guid:t?.guid,blogId:t?.blogId}).catch(e=>console.warn("[Text Extractor] Failed to cache content:",e)),{success:!0,content:a}}}else 401===s.status||403===s.status?console.log("[Text Extractor] Not authorized for extract endpoint, falling back to text extraction"):console.log(`[Text Extractor] Extract endpoint error: ${s.status}`)}catch(e){console.warn("[Text Extractor] Extract endpoint error, falling back:",e)}try{return console.log("[Text Extractor] Falling back to text extraction"),await s4(e,t)}catch(e){return console.error("[Text Extractor] Failed to extract HTML from URL:",e),{success:!1,error:e instanceof Error?e.message:"Failed to extract HTML from URL"}}}var s8=e.i(930571);let s7={state:"ready",mode:"collect",step:null,result:null,progress:0,currentChunk:0,totalChunks:0,statusText:"",error:null,audioUrl:void 0};function s9(e,t){switch(t.type){case"RESET":return{...s7,mode:e.mode};case"SET_MODE":return{...e,mode:t.mode};case"START":return{...e,state:"processing",step:"extracting",result:null,error:null,statusText:t.status??"Extracting…",progress:0,currentChunk:0,totalChunks:0,audioUrl:void 0};case"STEP":return{...e,step:t.step,statusText:t.status??e.statusText};case"PROGRESS":return{...e,currentChunk:t.currentChunk,totalChunks:t.totalChunks,progress:t.progress,statusText:t.status??e.statusText};case"SUCCESS":return{...e,state:"ready",result:"success",step:null,statusText:t.status??"Done",progress:100,audioUrl:t.audioUrl};case"FAIL":return{...e,state:"error",result:"error",statusText:t.status??"Failed",error:t.error};case"SET_LAST_REQUEST":return{...e,lastRequest:t.request};default:return e}}let ae=(0,p.createContext)(void 0),at="extracts";function ar(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t).toString(36)}async function as(){return new Promise((e,t)=>
14{let r=indexedDB.open("blogsareback-text-cache",1);r.onerror=()=>t(r.error),r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(at)||e.createObjectStore(at,{keyPath:"id"}).createIndex("expiresAt","expiresAt",{unique:!1})},r.onsuccess=()=>e(r.result)})}async function aa(e){try{let t=await as(),r=t.transaction([at],"readonly").objectStore(at),s=ar(e);return new Promise(e=>{let a=r.get(s);a.onsuccess=()=>{let r=a.result;return r?Date.now()>r.expiresAt?(t.transaction([at],"readwrite").objectStore(at).delete(s),e(null)):void e({title:r.title,textContent:r.textContent}):e(null)},a.onerror=()=>e(null)})}catch{return null}}async function ao(e,t,r){try{let s=(await as()).transaction([at],"readwrite").objectStore(at),a={id:ar(e),url:e,title:t,textContent:r,createdAt:Date.now(),expiresAt:Date.now()+6048e5};s.put(a)}catch{}}function an({children:e}){let t,r,s,o,n,i,l,c,[d,u]=(0,p.useReducer)(s9,s7),{getCachedAudio:m,cacheAudio:h}=(t=(0,p.useRef)(void 0),(0,p.useEffect)(()=>(t.current=setInterval(()=>{sZ()},12e4),()=>{t.current&&clearInterval(t.current)}),[]),r=(0,p.useCallback)(e=>{let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t).toString(36)},[]),s=(0,p.useCallback)((e,t)=>{let s=r(t);return`${e}_${s}`},[r]),o=(0,p.useCallback)(()=>new Promise((e,t)=>{let r=indexedDB.open("blogsareback-audio-cache",1);r.onerror=()=>t(r.error),r.onsuccess=()=>e(r.result),r.onupgradeneeded=e=>{let t=e.target.result;if(!t.objectStoreNames.contains(sQ)){let e=t.createObjectStore(sQ,{keyPath:"id"});e.createIndex("voiceId","voiceId",{unique:!1}),e.createIndex("expiresAt","expiresAt",{unique:!1})}}}),[]),n=(0,p.useCallback)(async(e,t)=>{try{let r=await o(),a=r.transaction([sQ],"readonly").objectStore(sQ),n=s(e,t);return new Promise(e=>{let t=a.get(n);t.onsuccess=()=>{let s=t.result;if(!s)return void e(null);if(Date.now()>s.expiresAt){r.transaction([sQ],"readwrite").objectStore(sQ).delete(n),e(null);return}try{let t=sJ(n,s.audioBlob);e(t)}catch(t){console.warn("Failed to create blob URL from cached audio:",t),r.transaction([sQ],"readwrite").objectStore(sQ).delete(n),e(null)}},t.onerror=()=>{console.warn("Failed to retrieve cached audio:",t.error),e(null)}})}catch(e){return console.warn("Audio cache retrieval failed:",e),null}},[o,s]),i=(0,p.useCallback)(async(e,t,a)=>{let n=s(e,t),i=sJ(n,a);try{let s=(await o()).transaction([sQ],"readwrite").objectStore(sQ),l=r(t),c={id:n,voiceId:e,textHash:l,audioBlob:a,createdAt:Date.now(),expiresAt:Date.now()+6048e5};return new Promise(e=>{let t=s.put(c);t.onsuccess=()=>{e(i)},t.onerror=()=>{console.warn("Failed to cache audio:",t.error),e(i)}})}catch(e){return console.warn("Audio caching failed:",e),i}},[o,s,r]),l=(0,p.useCallback)(async()=>{try{let e=(await o()).transaction([sQ],"readwrite").objectStore(sQ).index("expiresAt"),t=Date.now(),r=e.openCursor(IDBKeyRange.upperBound(t));r.onsuccess=e=>{let t=e.target.result;t&&(t.delete(),t.continue())},r.onerror=()=>{console.warn("Failed to cleanup expired cache:",r.error)}}catch(e){console.warn("Cache cleanup failed:",e)}},[o]),c=(0,p.useCallback)(async()=>{try{let e=(await o()).transaction([sQ],"readonly").objectStore(sQ),t=Date.now();return new Promise(r=>{let s=e.getAll();s.onsuccess=()=>{let e=s.result,a=e.filter(e=>e.expiresAt<=t).length,o=e.reduce((e,t)=>
14e+t.audioBlob.size,0);r({total:e.length,expired:a,size:o})},s.onerror=()=>{r({total:0,expired:0,size:0})}})}catch(e){return console.warn("Failed to get cache stats:",e),{total:0,expired:0,size:0}}},[o]),{getCachedAudio:n,cacheAudio:i,cleanupExpiredCache:l,getCacheStats:c,clearCache:(0,p.useCallback)(async()=>{try{(await o()).transaction([sQ],"readwrite").objectStore(sQ).clear()}catch(e){console.warn("Failed to clear cache:",e)}},[o]),getBlobUrlCacheStats:(0,p.useCallback)(()=>{let e=Date.now(),t=Array.from(sX.values()),r=t.reduce((e,t)=>e+t.size,0),s=t.filter(t=>e-t.lastAccessedAt>6e5);return{count:sX.size,maxCount:20,totalSize:r,maxSize:0x6400000,oldEntries:s.length,entries:t.map(t=>({cacheKey:t.cacheKey,size:t.size,ageSeconds:Math.round((e-t.createdAt)/1e3),idleSeconds:Math.round((e-t.lastAccessedAt)/1e3)}))}},[])}),f=(0,p.useRef)(null),g=(0,p.useRef)(void 0),x=(0,p.useCallback)(()=>{f.current&&f.current.abortController.abort()},[]),b=(0,p.useCallback)(e=>{u({type:"SET_MODE",mode:e})},[]),y=(0,p.useCallback)(e=>{g.current=e},[]),v=(0,p.useCallback)(async(e,t)=>{let r=await aa(e);if(t.aborted)throw ac();if(r?.textContent)return{title:r.title,textContent:r.textContent};let s=await s4(e);if(t.aborted)throw ac();if(!s.success||!s.content?.textContent){let e=Error(s.error||"No readable content");throw e.code="EXTRACTION",e}return await ao(e,s.content.title,s.content.textContent),{title:s.content.title,textContent:s.content.textContent}},[]),j=(0,p.useCallback)(async(e,t)=>{if(t.aborted)throw ac();return e.trim()?(function(e){let t=e.trim();if(t.length<=1500)return[t];let r=[],s=0;for(;s<t.length;){let e=s+1500;if(e>=t.length){r.push(t.slice(s));break}let a=function(e,t,r){let s=e.slice(t,r),a=-1;for(let e of[". ","! ","? ",".\n","!\n","?\n"]){let r=s.lastIndexOf(e);if(-1!==r){let s=t+r+e.length;s>a&&(a=s)}}return a}(t,s,e);-1===a&&(a=function(e,t,r){let s=e.slice(t,r);for(let e of["\n\n","\n",", ","; "," - "," — "]){let r=s.lastIndexOf(e);if(-1!==r&&r>.5*s.length)return t+r+e.length}let a=s.lastIndexOf(" ");return -1!==a&&a>.7*s.length?t+a+1:-1}(t,s,e)),-1===a&&(a=e);let o=t.slice(s,a).trim();o.length>0&&r.push(o),s=a}return r.filter(e=>e.length>0)})(e).map((e,t)=>({text:e,index:t,estimatedDuration:Math.ceil(e.trim().split(/\s+/).filter(e=>e.length>0).length/150)})):[]},[]),w=(0,p.useCallback)(async(e,t,r,s,a)=>{let o=e.length,n=[];for(let i=0;i<o;i++){if(r.aborted)throw ac();let l=e[i];s(i,o,l.text);let c=0;for(;c<=3;)try{let e,{speed:c=100,pitch:d=0}=t,u={};
14if(100!==c){let e=(c-100)/100;u.rate=e>=0?`+${Math.round(100*e)}%`:`${Math.round(100*e)}%`}if(0!==d&&(u.pitch=d>0?`+${d}Hz`:`${d}Hz`),(0,s8.isDesktopApp)()&&window.electronBridge){if(r.aborted)throw ac();let s=await window.electronBridge.invoke("TTS_SYNTHESIZE_CHUNK",{text:l.text,voice:t.voiceShortName,...u.rate&&{rate:u.rate},...u.pitch&&{pitch:u.pitch}});if(r.aborted)throw ac();if(!s.success||!s.data?.audioBase64){let e=Error(s.error||`No audio for chunk ${i+1}`);throw e.code="GENERATION",e}let a=atob(s.data.audioBase64),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);e=new Blob([o],{type:"audio/mpeg"})}else{let s=new sY(l.text,t.voiceShortName,u);if(r.aborted)throw ac();let a=await s.synthesize();if(r.aborted)throw ac();if(!a.audio){let e=Error(`No audio for chunk ${i+1}`);throw e.code="GENERATION",e}e=new Blob([await a.audio.arrayBuffer()],{type:"audio/mpeg"})}n.push(e),a&&a(e,i,o),s(i+1,o),i<o-1&&await al(1e3,r);break}catch(t){if(++c>3){let e=Error(`Failed chunk ${i+1} after 3 retries: ${ad(t)}`);throw e.code="GENERATION",e}let e=Math.min(1e3*Math.pow(2,c-1),5e3);s(i,o,`Retrying chunk ${i+1} (attempt ${c+1})…`),await al(e,r)}}return au(n)},[]),N=(0,p.useCallback)(async e=>{if(f.current)return{success:!1,error:"busy",errorMessage:"Already processing"};let t=e.voiceShortName??"en-US-JennyNeural",r=e.speed??100,s=e.pitch??0;u({type:"RESET"}),u({type:"START",status:"Extracting readable text…"}),u({type:"SET_LAST_REQUEST",request:e});let a=new AbortController,{signal:o}=a;f.current={abortController:a};try{let{textContent:a}=await v(e.postUrl,o);u({type:"STEP",step:"chunking",status:"Chunking text…"});let n=await j(a,o);if(u({type:"PROGRESS",currentChunk:0,totalChunks:n.length,progress:100*(0===n.length),status:n.length?"Generating audio…":"No content to narrate"}),u({type:"STEP",step:"generating"}),0===n.length)return u({type:"SUCCESS",audioUrl:void 0,status:"Nothing to narrate"}),f.current=null,{success:!0,audioUrl:void 0};let i=await m(t,a);if(i)return u({type:"PROGRESS",currentChunk:n.length,totalChunks:n.length,progress:100,status:"Loaded audio from cache"}),u({type:"SUCCESS",audioUrl:i,status:"Narration ready"}),f.current=null,{success:!0,audioUrl:i};let l=await w(n.map(e=>({text:e.text})),{voiceShortName:t,speed:r,pitch:s},o,(e,t,r)=>{let s=0===t?100:Math.round(e/t*80)+10;u({type:"PROGRESS",currentChunk:e,totalChunks:t,progress:Math.min(99,s),status:r??`Generating audio… ${e}/${t}`})},g.current);u({type:"PROGRESS",currentChunk:n.length,totalChunks:n.length,progress:95,status:"Caching audio…"});let c=await h(t,a,l);return u({type:"SUCCESS",audioUrl:c,status:"Audio ready!"}),f.current=null,{success:!0,audioUrl:c}}catch(r){var n;let e;if(function(e){if(!e)return!1;if(e?.code==="ABORT_ERR")return!0;if(e instanceof Error){let t=e.message?.toLowerCase()||"";return t.includes("abort")||"aborted"===t}return!1}(r))return u({type:"RESET"}),f.current=null,{success:!1,error:"cancelled",errorMessage:"Generation cancelled"};let t=ad(r);return u({type:"FAIL",error:t,status:"Narration failed"}),f.current=null,{success:!1,error:(e=ad(n=r).toLowerCase()).includes("extract")?"extraction":e.includes("chunk")?"chunking":e.includes("generat")||e.includes("tts")?"generation":n?.code==="EXTRACTION"?"extraction":n?.code==="GENERATION"?"generation":"unknown",errorMessage:t}}},[m,h,v,j,w]),k=(0,p.useCallback)(async e=>"ready"!==d.state?{success:!1,error:"Narration orchestrator is not ready"}:N(e),[d.state,N]),C=(0,p.useMemo)(()=>({...d,sendNarrationRequest:k,cancel:x,setMode:b,setOnChunkReady:y}),[d,k,x,b,y]);return(0,a.jsx)(ae.Provider,{value:C,children:e})}function ai(){let e=(0,p.useContext)(ae);if(!e)throw Error("useNarrationOrchestrator must be used within a NarrationOrchestratorProvider");return e}function al(e,t){return new Promise((r,s)=>{let a=setTimeout(()=>r(),e);t&&(t.aborted?(clearTimeout(a),s(ac())):t.addEventListener("abort",()=>{clearTimeout(a),s(ac())},{once:!0}))})}function ac(){let e=Error("aborted");return e.code="ABORT_ERR",e}function ad(e){if(!e)return"unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message||"error";try{return JSON.stringify(e)}catch{return"error"}}async function au(e){if(1===e.length)return e[0];let t=await Promise.all(e.map(e=>
14e.arrayBuffer())),r=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),s=0;for(let e of t)r.set(new Uint8Array(e),s),s+=e.byteLength;return new Blob([r],{type:"audio/mpeg"})}var am=e.i(282284),ah=e.i(948860);let af=0;function ap(){var e;let[t,r]=(0,n.useAtom)(am.ttsServiceStatusAtom),[,s]=(0,n.useAtom)(am.ttsServiceUnavailableModalOpenAtom),a=(0,p.useRef)(!1),o=(0,p.useCallback)(async(e=!1)=>{let s=Date.now();if(!e&&t&&s-af<9e5||a.current)return t;a.current=!0;try{let e=await fetch(tK.TTS_STATUS_API_URL,{method:"GET",headers:{Accept:"application/json"},credentials:"omit"});if(!e.ok){let e={status:"unknown",last_checked:null,message:"Unable to determine service status"};return r(e),af=s,e}let t=await e.json();return r(t),af=s,t}catch(t){let e={status:"unknown",last_checked:null,message:"Unable to check service status"};return r(e),af=s,e}finally{a.current=!1}},[t,r]),i=(0,p.useCallback)(async()=>{if((0,s8.isDesktopApp)()||(0,ah.isEdgeBrowser)())return!0;let e=await o();return"down"!==e?.status||(s(!0),!1)},[o,s]),l=(0,p.useCallback)(()=>{s(!0)},[s]);return{status:t?.status??null,statusResponse:t,lastChecked:t?.last_checked??null,message:t?.message??null,isDown:"down"===t?.status,hasIssues:"down"===(e=t?.status)||"degraded"===e,fetchStatus:o,checkBeforeNarration:i,showUnavailableModal:l}}function ag(){let{sendNarrationRequest:e,state:t,step:r,progress:s,statusText:a,error:o,result:i}=ai(),[l]=(0,n.useAtom)(am.selectedVoiceAtom),{checkBeforeNarration:c}=ap(),d="ready"!==t,u=(0,p.useCallback)(async r=>{if(!await c())return;let s=r.voiceShortName??l?.ShortName??l?.Name??"en-US-AvaNeural",a=r.speed??100,o=r.pitch??0;"ready"===t&&await e({postUrl:r.postUrl,postTitle:r.postTitle,postGuid:r.postGuid,blogId:r.blogId,voiceShortName:s,speed:a,pitch:o})},[e,l,100,0,t,c]);return(0,p.useMemo)(()=>({narrate:u,isBusy:d,progress:s,step:r,statusText:a,error:o,result:i}),[u,d,s,r,a,o,i])}var ax=e.i(177058);function ab({proxiedHtml:e}){let t=(0,n.useAtomValue)(er.selectedPostAtom),r=(0,n.useAtomValue)(er.postsAtom),[s,o]=(0,n.useAtom)(er.selectedPostIdAtom),i=(0,n.useAtomValue)(er.readPostGuidsAtom),l=(0,n.useAtomValue)(er.starredPostGuidsAtom),c=(0,n.useAtomValue)(er.readLaterPostGuidsAtom),d=(0,tf.useMarkAsRead)(),m=(0,tf.useMarkAsUnread)(),h=(0,tf.useToggleStar)(),f=(0,tf.useToggleReadLater)(),{narrate:g,isBusy:x}=ag(),{togglePreference:y}=sE(),j=(0,ex.default)(),w=(0,n.useSetAtom)(b.mobileViewAtom),[N,k]=(0,n.useAtom)(b.readingFocusModeAtom),[C,S]=(0,n.useAtom)(b.compactReaderHeaderAtom),[T,E]=(0,n.useAtom)(b.viewModeAtom),{isAvailable:M,savePost:z,deletePost:R}=(0,sh.useSavePostOffline)(),P=(0,n.useAtomValue)(er.savedOfflinePostGuidsAtom),I=!!(t?.guid&&P.has(t.guid)),[L,D]=p.useState(!1),F=function(e,t=350){let[r,s]=(0,p.useState)(!1),a=(0,p.useRef)(e);return(0,p.useEffect)(()=>{if(a.current!==e){s(!0);let r=setTimeout(()=>s(!1),t);return a.current=e,()=>clearTimeout(r)}},[e,t]),r}(I),O=t?.blogId===ax.SAVED_POSTS_BLOG_ID,B=t?.guid&&(0,er.isGuidInSet)(t.guid,i,t.guidHash),$=t?.guid&&l.has(t.guid),U=t?.guid&&c.has(t.guid),V=p.useMemo(()=>s?r.findIndex(e=>e.guid===s):-1,[s,r]),q=V>0,G=V<r.length-1,W=()=>{t?.guid&&t?.blogId&&t?.blogTitle&&(h(t,t.blogId,t.blogTitle,!!$),th.toast.loading($?"Removing from starred...":"Adding to starred...",{id:rz.STAR_TOAST_ID}))},K=()=>{t?.guid&&t?.blogId&&t?.blogTitle&&(f(t,t.blogId,t.blogTitle,!!U),th.toast.loading(U?"Removing from Read Later...":"Adding to Read Later...",{id:rz.READ_LATER_TOAST_ID}))},Y=async()=>{if(t)try{await navigator.share({title:t.title,url:t.link})}catch(e){if(navigator.clipboard)try{await navigator.clipboard.writeText(t.link),th.toast.success("Link copied to clipboard")}catch{th.toast.error("Failed to copy link")}else th.toast.error("Sharing not supported")}},Q=async()=>{if(t?.guid){D(!0);try{if(I)await R(t.guid)&&(th.toast.success("Removed from saved"),O&&o(null));else{let e=await z(t);e.alreadySaved?th.toast.info("Already saved"):e.success?((0,ey.trackPostSavedOffline)("manual"),th.toast.success("Saved for offline reading")):th.toast.error("Failed to save post")}}finally{D(!1)}}};return t?C?(0,a.jsx)("div",{className:"border-b bg-card px-4 py-2",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground truncate font-medium",children:t.blogTitle}
14),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground/60",children:[V+1,"/",r.length]})]}),(0,a.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,a.jsxs)(v.TooltipProvider,{children:[(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5",children:[!O&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-7 rounded",onClick:W,children:(0,a.jsx)(el.Star,{className:(0,A.cn)("size-3.5 transition-all",$?"fill-amber-500 text-amber-500":"text-muted-foreground")})})}),(0,a.jsx)(v.TooltipContent,{children:$?"Unstar":"Star"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-7 rounded",onClick:K,children:(0,a.jsx)(ec.Bookmark,{className:(0,A.cn)("size-3.5 transition-all",U?"fill-blue-500 text-blue-500":"text-muted-foreground")})})}),(0,a.jsx)(v.TooltipContent,{children:U?"Remove from Read Later":"Read Later"})]})]}),M&&(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-7 rounded",onClick:Q,disabled:L,children:L?(0,a.jsx)(H.Loader2,{className:"size-3.5 animate-spin"}):I?(0,a.jsx)(rK.HardDrive,{className:(0,A.cn)("size-3.5 text-primary",F&&"post-save-active")}):(0,a.jsx)(rW,{className:"size-3.5 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:I?"Remove from saved":"Save offline"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-7 rounded",asChild:!0,children:(0,a.jsx)("a",{href:t.link,target:"_blank",rel:"noopener",children:(0,a.jsx)(ez.ExternalLink,{className:"size-3.5 text-muted-foreground"})})})}),(0,a.jsx)(v.TooltipContent,{children:"Open original"})]})]}),(0,a.jsx)(rN.Separator,{orientation:"vertical",className:"mx-1.5 h-4 bg-border/50"}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-7 rounded text-muted-foreground hover:text-foreground",onClick:()=>S(!1),children:(0,a.jsx)(ee.ChevronDown,{className:"size-3.5"})})}),(0,a.jsx)(v.TooltipContent,{children:"Expand header"})]})]})})]})}):(0,a.jsxs)("div",{className:"border-b p-4 bg-card",children:[j&&(0,a.jsx)("div",{className:"mb-3",children:(0,a.jsxs)(u.Button,{variant:"ghost",size:"sm",onClick:()=>{w("list")},className:"-ml-2 text-muted-foreground hover:text-foreground",children:[(0,a.jsx)(sk.ArrowLeft,{className:"mr-2 size-4"}),"Back to list"]})}),(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3 mobile:flex-col @max-2xl/postreader:flex-col",children:[(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsx)(rS.motion.h1,{initial:{opacity:0}
14,animate:{opacity:1},transition:{delay:.1},className:"text-xl font-semibold leading-snug tracking-tight text-foreground",children:t.title})}),(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap-reverse",children:[(0,a.jsx)("div",{className:"flex items-center gap-0.5 rounded-lg bg-muted/50 p-0.5",children:!O&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:()=>{t?.guid&&t?.blogId&&(B?(m(t.guid,t.blogId),th.toast.success("Marked as unread")):(d(t.guid,t.blogId),th.toast.success("Marked as read")))},children:B?(0,a.jsx)(sw.EyeOff,{className:"size-4 text-muted-foreground"}):(0,a.jsx)(sj.Eye,{className:"size-4"})})}),(0,a.jsx)(v.TooltipContent,{children:B?"Mark as unread":"Mark as read"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:W,children:(0,a.jsx)(el.Star,{className:(0,A.cn)("size-4 transition-all",$?"fill-amber-500 text-amber-500 drop-shadow-sm":"text-muted-foreground")})})}),(0,a.jsx)(v.TooltipContent,{children:$?"Unstar":"Star"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:K,children:(0,a.jsx)(ec.Bookmark,{className:(0,A.cn)("size-4 transition-all",U?"fill-blue-500 text-blue-500":"text-muted-foreground")})})}),(0,a.jsx)(v.TooltipContent,{children:U?"Remove from Read Later":"Add to Read Later"})]})]})}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-lg bg-muted/50 p-0.5",children:[(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:()=>g({postUrl:t.link,postTitle:t.title,postGuid:t.guid,blogId:t.blogId}),disabled:!t?.guid||!t?.blogId||!t?.link||!t?.title||x,children:x?(0,a.jsx)(H.Loader2,{className:"size-4 animate-spin"}):(0,a.jsx)(sT.AudioLines,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:"Text to Speech"})]}),M&&(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:Q,disabled:L,children:L?(0,a.jsx)(H.Loader2,{className:"size-4 animate-spin"}):I?(0,a.jsx)(rK.HardDrive,{className:(0,A.cn)("size-4 text-primary",F&&"post-save-active")}):(0,a.jsx)(rW,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:I?"Remove from saved":"Save offline"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:Y,children:(0,a.jsx)(rq.Share2,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:"Share"})]})]}),e&&"iframe"===T&&(0,a.jsxs)("div",{className:"proxied-badge-editorial flex items-center gap-1.5 rounded-full bg-blue-500/10 px-2.5 py-1 text-[10px] font-medium uppercase tracking-wide text-blue-600 dark:text-blue-400 border border-blue-500/20",children:[(0,a.jsx)("span",{className:"proxied-dot size-1.5 rounded-full bg-blue-500",style:{animation:"ribbon-pulse 2s ease-in-out infinite"}}),"Proxied"]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 rounded-lg bg-muted/50 p-0.5",children:[(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:()=>{if(t?.blogId){let e=y(t.blogId,T);E(e),th.toast.success(`Switched to ${"content"===e?"in-house":"iframe"} view`,{description:"Your preference has been saved for this blog."})}},children:"iframe"===T?(0,a.jsx)(sC.FileCode,{className:"size-4 text-muted-foreground"}):(0,a.jsx)(_.Monitor,{className:"size-4 text-muted-foreground"})})}
14),(0,a.jsx)(v.TooltipContent,{children:"iframe"===T?"Show in-house content":"Show iframe"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:()=>k(!N),children:N?(0,a.jsx)(sS.Minimize2,{className:"size-4 text-muted-foreground"}):(0,a.jsx)(sA.Maximize2,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:N?"Exit focus mode":"Enter focus mode"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",asChild:!0,children:(0,a.jsx)("a",{href:t.link,target:"_blank",rel:"noopener",children:(0,a.jsx)(ez.ExternalLink,{className:"size-4 text-muted-foreground"})})})}),(0,a.jsx)(v.TooltipContent,{children:"Open original"})]}),(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"size-8 rounded-md",onClick:()=>S(!0),children:(0,a.jsx)(sx.ChevronUp,{className:"size-4 text-muted-foreground"})})}),(0,a.jsx)(v.TooltipContent,{children:"Compact header"})]})]})]})})]}),(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-1.5 text-sm text-muted-foreground/80",children:[t.author&&(0,a.jsx)("span",{className:"font-medium",children:t.author}),t.author&&(t.blogTitle||t.pubDate)&&(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),t.blogTitle&&(0,a.jsx)("span",{children:t.blogTitle}),t.blogTitle&&t.pubDate&&(0,a.jsx)("span",{className:"text-muted-foreground/40",children:"·"}),t.pubDate&&(0,a.jsx)("span",{className:"tabular-nums",children:(0,sv.format)(new Date(t.pubDate),"MMM d, yyyy")})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,a.jsxs)("div",{className:"flex gap-1",children:[(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",onClick:()=>{if(q){let e=r[V-1];e.guid&&o(e.guid)}},disabled:!q,children:[(0,a.jsx)(sN.ChevronLeft,{className:"mr-1 size-4"}),"Previous"]}),(0,a.jsxs)(u.Button,{variant:"outline",size:"sm",onClick:()=>{if(G){let e=r[V+1];e.guid&&o(e.guid)}},disabled:!G,children:["Next",(0,a.jsx)(eT.ChevronRight,{className:"ml-1 size-4"})]})]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[V+1," of ",r.length]})]})]}):null}let{entries:ay,setPrototypeOf:av,isFrozen:aj,getPrototypeOf:aw,getOwnPropertyDescriptor:aN}=Object,{freeze:ak,seal:aC,create:aA}=Object,{apply:aS,construct:aT}="u">typeof Reflect&&Reflect;ak||(ak=function(e){return e}),aC||(aC=function(e){return e}),aS||(aS=function(e,t){for(var r=arguments.length,s=Array(r>2?r-2:0),a=2;a<r;a++)s[a-2]=arguments[a];return e.apply(t,s)}),aT||(aT=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];return new e(...r)});let aE=aV(Array.prototype.forEach),aM=aV(Array.prototype.lastIndexOf),a_=aV(Array.prototype.pop),az=aV(Array.prototype.push),aR=aV(Array.prototype.splice),aP=aV(String.prototype.toLowerCase),aI=aV(String.prototype.toString),aL=aV(String.prototype.match),aD=aV(String.prototype.replace),aF=aV(String.prototype.indexOf),aO=aV(String.prototype.trim),aB=aV(Object.prototype.hasOwnProperty),a$=aV(RegExp.prototype.test),aU=(s=TypeError,function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return aT(s,t)});function aV(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,s=Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];return aS(e,t,s)}}function aq(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:aP;av&&av(e,null);let s=t.length;for(;s--;){let a=t[s];if("string"==typeof a){let e=r(a);e!==a&&(aj(t)||(t[s]=e),a=e)}e[a]=!0}return e}function aH(e){let t=aA(null);for(let[r,s]of ay(e))aB(e,r)&&(Array.isArray(s)?t[r]=function(e){for(let t=0;t<e.length;t++)aB(e,t)||(e[t]=null);return e}(s):s&&"object"==typeof s&&s.constructor===Object?t[r]=aH(s):t[r]=s);return t}function aG(e,t){for(;null!==e;){let r=aN(e,t);if(r){if(r.get)return aV(r.get);if("function"==typeof r.value)return aV(r.value)}e=aw(e)}return function(){return null}}let aW=ak(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),aK=ak(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),aY=ak(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),aQ=ak(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),aX=ak(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),aZ=ak(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),aJ=ak(["#text"]),a0=ak(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","
14spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),a1=ak(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),a2=ak(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),a5=ak(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),a3=aC(/\{\{[\w\W]*|[\w\W]*\}\}/gm),a4=aC(/<%[\w\W]*|[\w\W]*%>/gm),a6=aC(/\$\{[\w\W]*/gm),a8=aC(/^data-[\-\w.\u00B7-\uFFFF]+$/),a7=aC(/^aria-[\-\w]+$/),a9=aC(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),oe=aC(/^(?:\w+script|data):/i),ot=aC(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),or=aC(/^html$/i);var os=Object.freeze({__proto__:null,ARIA_ATTR:a7,ATTR_WHITESPACE:ot,CUSTOM_ELEMENT:aC(/^[a-z][.\w]*(-[.\w]+)+$/i),DATA_ATTR:a8,DOCTYPE_NAME:or,ERB_EXPR:a4,IS_ALLOWED_URI:a9,IS_SCRIPT_OR_DATA:oe,MUSTACHE_EXPR:a3,TMPLIT_EXPR:a6});let oa=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null,s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(r=t.getAttribute(s));let a="dompurify"+(r?"#"+r:"");try{return e.createPolicy(a,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+a+" could not be created."),null}},oo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};var on=function e(){let t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"u"<typeof window?null:window,s=t=>e(t);if(s.version="3.3.1",s.removed=[],!r||!r.document||9!==r.document.nodeType||!r.Element)return s.isSupported=!1,s;let{document:a}=r,o=a,n=o.currentScript,{DocumentFragment:i,HTMLTemplateElement:l,Node:c,Element:d,NodeFilter:u,NamedNodeMap:m=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:h,DOMParser:f,trustedTypes:p}=r,g=d.prototype,x=aG(g,"cloneNode"),b=aG(g,"remove"),y=aG(g,"nextSibling"),v=aG(g,"childNodes"),j=aG(g,"parentNode");if("function"==typeof l){let e=a.createElement("template");e.content&&e.content.ownerDocument&&(a=e.content.ownerDocument)}let w="",{implementation:N,createNodeIterator:k,createDocumentFragment:C,getElementsByTagName:A}=a,{importNode:S}=o,T=oo();s.isSupported="function"==typeof ay&&"function"==typeof j&&N&&void 0!==N.createHTMLDocument;let{MUSTACHE_EXPR:E,ERB_EXPR:M,TMPLIT_EXPR:_,DATA_ATTR:z,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:P,ATTR_WHITESPACE:I,CUSTOM_ELEMENT:L}=os,{IS_ALLOWED_URI:D}=os,F=null,O=aq({},[...aW,...aK,...aY,...aX,...aJ]),B=null,$=aq({}
vendor: 4,245 bytes, line 14
14,[...a0,...a1,...a2,...a5]),U=Object.seal(aA(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,q=null,H=Object.seal(aA(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),G=!0,W=!0,K=!1,Y=!0,Q=!1,X=!0,Z=!1,J=!1,ee=!1,et=!1,er=!1,es=!1,ea=!0,eo=!1,en=!0,ei=!1,el={},ec=null,ed=aq({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),eu=null,em=aq({},["audio","video","img","source","image","track"]),eh=null,ef=aq({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ep="http://www.w3.org/1998/Math/MathML",eg="http://www.w3.org/2000/svg",ex="http://www.w3.org/1999/xhtml",eb=ex,ey=!1,ev=null,ej=aq({},[ep,eg,ex],aI),ew=aq({},["mi","mo","mn","ms","mtext"]),eN=aq({},["annotation-xml"]),ek=aq({},["title","style","font","a","script"]),eC=null,eA=["application/xhtml+xml","text/html"],eS=null,eT=null,eE=a.createElement("form"),eM=function(e){return e instanceof RegExp||e instanceof Function},e_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!eT||eT!==e){if(e&&"object"==typeof e||(e={}),e=aH(e),eS="application/xhtml+xml"===(eC=-1===eA.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE)?aI:aP,F=aB(e,"ALLOWED_TAGS")?aq({},e.ALLOWED_TAGS,eS):O,B=aB(e,"ALLOWED_ATTR")?aq({},e.ALLOWED_ATTR,eS):$,ev=aB(e,"ALLOWED_NAMESPACES")?aq({},e.ALLOWED_NAMESPACES,aI):ej,eh=aB(e,"ADD_URI_SAFE_ATTR")?aq(aH(ef),e.ADD_URI_SAFE_ATTR,eS):ef,eu=aB(e,"ADD_DATA_URI_TAGS")?aq(aH(em),e.ADD_DATA_URI_TAGS,eS):em,ec=aB(e,"FORBID_CONTENTS")?aq({},e.FORBID_CONTENTS,eS):ed,V=aB(e,"FORBID_TAGS")?aq({},e.FORBID_TAGS,eS):aH({}),q=aB(e,"FORBID_ATTR")?aq({},e.FORBID_ATTR,eS):aH({}),el=!!aB(e,"USE_PROFILES")&&e.USE_PROFILES,G=!1!==e.ALLOW_ARIA_ATTR,W=!1!==e.ALLOW_DATA_ATTR,K=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Y=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Q=e.SAFE_FOR_TEMPLATES||!1,X=!1!==e.SAFE_FOR_XML,Z=e.WHOLE_DOCUMENT||!1,et=e.RETURN_DOM||!1,er=e.RETURN_DOM_FRAGMENT||!1,es=e.RETURN_TRUSTED_TYPE||!1,ee=e.FORCE_BODY||!1,ea=!1!==e.SANITIZE_DOM,eo=e.SANITIZE_NAMED_PROPS||!1,en=!1!==e.KEEP_CONTENT,ei=e.IN_PLACE||!1,D=e.ALLOWED_URI_REGEXP||a9,eb=e.NAMESPACE||ex,ew=e.MATHML_TEXT_INTEGRATION_POINTS||ew,eN=e.HTML_INTEGRATION_POINTS||eN,U=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&eM(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(U.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&eM(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(U.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(U.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Q&&(W=!1),er&&(et=!0),el&&(F=aq({},aJ),B=[],!0===el.html&&(aq(F,aW),aq(B,a0)),!0===el.svg&&(aq(F,aK),aq(B,a1),aq(B,a5)),!0===el.svgFilters&&(aq(F,aY),aq(B,a1),aq(B,a5)),!0===el.mathMl&&(aq(F,aX),aq(B,a2),aq(B,a5))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?H.tagCheck=e.ADD_TAGS:(F===O&&(F=aH(F)),aq(F,e.ADD_TAGS,eS))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?H.attributeCheck=e.ADD_ATTR:(B===$&&(B=aH(B)),aq(B,e.ADD_ATTR,eS))),e.ADD_URI_SAFE_ATTR&&aq(eh,e.ADD_URI_SAFE_ATTR,eS),e.FORBID_CONTENTS&&(ec===ed&&(ec=aH(ec)),aq(ec,e.FORBID_CONTENTS,eS)),e.ADD_FORBID_CONTENTS&&(ec===ed&&(ec=aH(ec)),aq(ec,e.ADD_FORBID_CONTENTS,eS)),en&&(F["#text"]=!0),Z&&aq(F,["html","head","body"]),F.table&&(aq(F,["tbody"]),delete V.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw aU('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw aU('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=(t=e.TRUSTED_TYPES_POLICY).createHTML("")}
14else void 0===t&&(t=oa(p,n)),null!==t&&"string"==typeof w&&(w=t.createHTML(""));ak&&ak(e),eT=e}},ez=aq({},[...aK,...aY,...aQ]),eR=aq({},[...aX,...aZ]),eP=function(e){let t=j(e);t&&t.tagName||(t={namespaceURI:eb,tagName:"template"});let r=aP(e.tagName),s=aP(t.tagName);return!!ev[e.namespaceURI]&&(e.namespaceURI===eg?t.namespaceURI===ex?"svg"===r:t.namespaceURI===ep?"svg"===r&&("annotation-xml"===s||ew[s]):!!ez[r]:e.namespaceURI===ep?t.namespaceURI===ex?"math"===r:t.namespaceURI===eg?"math"===r&&eN[s]:!!eR[r]:e.namespaceURI===ex?(t.namespaceURI!==eg||!!eN[s])&&(t.namespaceURI!==ep||!!ew[s])&&!eR[r]&&(ek[r]||!ez[r]):"application/xhtml+xml"===eC&&!!ev[e.namespaceURI])},eI=function(e){az(s.removed,{element:e});try{j(e).removeChild(e)}catch(t){b(e)}},eL=function(e,t){try{az(s.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){az(s.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(et||er)try{eI(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},eD=function(e){let r=null,s=null;if(ee)e="<remove></remove>"+e;else{let t=aL(e,/^[\r\n\t ]+/);s=t&&t[0]}"application/xhtml+xml"===eC&&eb===ex&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");let o=t?t.createHTML(e):e;if(eb===ex)try{r=new f().parseFromString(o,eC)}catch(e){}if(!r||!r.documentElement){r=N.createDocument(eb,"template",null);try{r.documentElement.innerHTML=ey?w:o}catch(e){}}let n=r.body||r.documentElement;return(e&&s&&n.insertBefore(a.createTextNode(s),n.childNodes[0]||null),eb===ex)?A.call(r,Z?"html":"body")[0]:Z?r.documentElement:n},eF=function(e){return k.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},eO=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof m)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},eB=function(e){return"function"==typeof c&&e instanceof c};function e$(e,t,r){aE(e,e=>{e.call(s,t,r,eT)})}let eU=function(e){let t=null;if(e$(T.beforeSanitizeElements,e,null),eO(e))return eI(e),!0;let r=eS(e.nodeName);if(e$(T.uponSanitizeElement,e,{tagName:r,allowedTags:F}),X&&e.hasChildNodes()&&!eB(e.firstElementChild)&&a$(/<[/\w!]/g,e.innerHTML)&&a$(/<[/\w!]/g,e.textContent)||7===e.nodeType||X&&8===e.nodeType&&a$(/<[/\w]/g,e.data))return eI(e),!0;if(!(H.tagCheck instanceof Function&&H.tagCheck(r))&&(!F[r]||V[r])){if
14(!V[r]&&eq(r)&&(U.tagNameCheck instanceof RegExp&&a$(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r)))return!1;if(en&&!ec[r]){let t=j(e)||e.parentNode,r=v(e)||e.childNodes;if(r&&t){let s=r.length;for(let a=s-1;a>=0;--a){let s=x(r[a],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,y(e))}}}return eI(e),!0}return e instanceof d&&!eP(e)||("noscript"===r||"noembed"===r||"noframes"===r)&&a$(/<\/no(script|embed|frames)/i,e.innerHTML)?(eI(e),!0):(Q&&3===e.nodeType&&(t=e.textContent,aE([E,M,_],e=>{t=aD(t,e," ")}),e.textContent!==t&&(az(s.removed,{element:e.cloneNode()}),e.textContent=t)),e$(T.afterSanitizeElements,e,null),!1)},eV=function(e,t,r){if(ea&&("id"===t||"name"===t)&&(r in a||r in eE))return!1;if(W&&!q[t]&&a$(z,t));else if(G&&a$(R,t));else if(H.attributeCheck instanceof Function&&H.attributeCheck(t,e));else if(!B[t]||q[t]){if(!(eq(e)&&(U.tagNameCheck instanceof RegExp&&a$(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&a$(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t,e))||"is"===t&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&a$(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r))))return!1}else if(eh[t]);else if(a$(D,aD(r,I,"")));else if(("src"===t||"xlink:href"===t||"href"===t)&&"script"!==e&&0===aF(r,"data:")&&eu[e]);else if(K&&!a$(P,aD(r,I,"")));else if(r)return!1;return!0},eq=function(e){return"annotation-xml"!==e&&aL(e,L)},eH=function(e){e$(T.beforeSanitizeAttributes,e,null);let{attributes:r}=e;if(!r||eO(e))return;let a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0},o=r.length;for(;o--;){let{name:n,namespaceURI:i,value:l}=r[o],c=eS(n),d="value"===n?l:aO(l);if(a.attrName=c,a.attrValue=d,a.keepAttr=!0,a.forceKeepAttr=void 0,e$(T.uponSanitizeAttribute,e,a),d=a.attrValue,eo&&("id"===c||"name"===c)&&(eL(n,e),d="user-content-"+d),X&&a$(/((--!?|])>)|<\/(style|title|textarea)/i,d)||"attributename"===c&&aL(d,"href")){eL(n,e);continue}if(a.forceKeepAttr)continue;if(!a.keepAttr||!Y&&a$(/\/>/i,d)){eL(n,e);continue}Q&&aE([E,M,_],e=>{d=aD(d,e," ")});let u=eS(e.nodeName);if(!eV(u,c,d)){eL(n,e);continue}if(t&&"object"==typeof p&&"function"==typeof p.getAttributeType)if(i);else switch(p.getAttributeType(u,c)){case"TrustedHTML":d=t.createHTML(d);break;case"TrustedScriptURL":d=t.createScriptURL(d)}if(d!==l)try{i?e.setAttributeNS(i,n,d):e.setAttribute(n,d),eO(e)?eI(e):a_(s.removed)}catch(t){eL(n,e)}}e$(T.afterSanitizeAttributes,e,null)},eG=function e(t){let r=null,s=eF(t);for(e$(T.beforeSanitizeShadowDOM,t,null);r=s.nextNode();)e$(T.uponSanitizeShadowNode,r,null),eU(r),eH(r),r.content instanceof i&&e(r.content);e$(T.afterSanitizeShadowDOM,t,null)};return s.sanitize=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=null,n=null,l=null,d=null;if((ey=!e)&&(e="<!-->"),"string"!=typeof e&&!eB(e))if("function"==typeof e.toString){if("string"!=typeof(e=e.toString()))throw aU("dirty is not a string, aborting")}else throw aU("toString is not a function");if(!s.isSupported)return e;if(J||e_(r),s.removed=[],"string"==typeof e&&(ei=!1),ei){if(e.nodeName){let t=eS(e.nodeName);if(!F[t]||V[t])throw aU("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)1===(n=(a=eD("<!---->")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===n.nodeName||"HTML"===n.nodeName?a=n:a.appendChild(n);else{if(!et&&!Q&&!Z&&-1===e.indexOf("<"))return t&&es?t.createHTML(e):e;if(!(a=eD(e)))return et?null:es?w:""}a&&ee&&eI(a.firstChild);let u=eF(ei?e:a);for(;l=u.nextNode();)eU(l),eH(l),l.content instanceof i&&eG(l.content);if(ei)return e;if(et){if(er)for(d=C.call(a.ownerDocument);a.firstChild;)d.appendChild(a.firstChild);else d=a;return(B.shadowroot||B.shadowrootmode)&&(d=S.call(o,d,!0)),d}let m=Z?a.outerHTML:a.innerHTML;return Z&&F["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&a$(or,a.ownerDocument.doctype.name)&&(m="<!DOCTYPE "+a.ownerDocument.doctype.name+">\n"+m),Q&&aE([E,M,_],e=>{m=aD(m,e," ")}),t&&es?t.createHTML(m):m},s.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e_(e),J=!0},s.clearConfig=function(){eT=null,J=!1},s.isValidAttribute=function(e,t,r){return eT||e_({}),eV(eS(e),eS(t),r)},s.addHook=function(e,t){"function"==typeof t&&az(T[e],t)},s.removeHook=function(e,t){if(void 0!==t){let r=aM(T[e],t);return -1===r?void 0:aR(T[e],r,1)[0]}return a_(T[e])},s.removeHooks=function(e){T[e]=[]},s.removeAllHooks=function(){T=oo()},s}(),oi=e.i(677855),ol=e.i(650700);let oc="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js",od=null,ou=null;async function om(){return od||ou||(ou=new Promise(e=>{let t=window.hljs;if(t){od=t,e(t);return}let r=document.createElement("script");r.src=oc,r.async=!0,r.onload=()=>{e(od=window.hljs)},r.onerror=()=>{console.warn("Failed to load highlight.js from CDN (offline?), skipping syntax highlighting"),ou=null,e(null)},document.head.appendChild(r)}))}async function oh(e,t){if(!t.enabled)return e;let r=await om();if(!r)return e;let s=new DOMParser().parseFromString(e,"text/html");
14return s.querySelectorAll("pre code").forEach(e=>{let s=e.parentElement;e.setAttribute("data-highlighted","true"),s?.tagName==="PRE"&&s.setAttribute("data-highlighted","true");let a=e.className.match(/language-(\w+)/),o=a?a[1]:null;try{if(o&&r.getLanguage(o)){let t=r.highlight(e.textContent||"",{language:o});e.innerHTML=t.value,e.classList.add("hljs"),s?.tagName==="PRE"&&s.classList.add("hljs")}else if(t.autoDetect){let t=r.highlightAuto(e.textContent||"");e.innerHTML=t.value,e.classList.add("hljs"),s?.tagName==="PRE"&&s.classList.add("hljs"),t.language&&e.classList.add(`language-${t.language}`)}else e.classList.add("hljs"),s?.tagName==="PRE"&&s.classList.add("hljs")}catch(t){console.error("Error highlighting code block:",t),e.classList.add("hljs")}}),s.body.innerHTML}e.i(422793);var of=e.i(296274),op=e.i(363271);let og={ALLOWED_TAGS:["p","br","strong","em","u","i","b","a","ul","ol","li","blockquote","code","pre","h1","h2","h3","h4","h5","h6","img","figure","figcaption","table","thead","tbody","tr","th","td","div","span","hr","del","ins","sub","sup","dl","dt","dd","tfoot","caption","colgroup","col","mark","kbd","samp","var","q","cite","small","time","abbr","details","summary","ruby","rt","rp"],ALLOWED_ATTR:["href","src","alt","title","class","target","rel","width","height","align","datetime","open","colspan","rowspan","span"],ADD_ATTR:["target","rel"],ALLOW_DATA_ATTR:!1};function ox({post:e,extractedContent:t,isLoadingExtraction:r}){let{customization:s}=(0,oi.useReaderCustomization)(),o=(0,p.useRef)(null),{content:i,isLoading:l}=function(e){let[t,r]=(0,p.useState)(null),[s,a]=(0,p.useState)(!!e),o=(0,p.useRef)(e);return o.current!==e&&(o.current=e,e?a(!0):a(!1),r(null)),(0,p.useEffect)(()=>{if(!e){r(null),a(!1);return}let t=!1;return a(!0),(0,tS.getPostContent)(e).then(e=>{t||(r(e),a(!1))}),()=>{t=!0}},[e]),{content:t,isLoading:s}}(e.guidHash),c="content"in e?e.content:void 0,d=t||i||c,m=(0,n.useAtomValue)(op.syntaxHighlightingAtom);!function(e,t,r){let{resolvedTheme:s}=(0,rr.useTheme)(),a=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!e){a.current&&(a.current.remove(),a.current=null);return}let o=(0,ol.getThemeForMode)("dark"===s?"dark":"light",t,r);a.current&&a.current.remove();let n=document.createElement("link");return n.rel="stylesheet",n.href=o.cdnUrl||`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/${o.cssFile}`,n.id="syntax-theme",document.head.appendChild(n),a.current=n,()=>{a.current&&(a.current.remove(),a.current=null)}},[e,t,r,s])}(m.enabled,m.lightTheme,m.darkTheme);let h=s.typographicScale||1.15,f=s.fontSize||1,g=(0,p.useMemo)(()=>({h1:f*Math.pow(h,1.8),h2:f*Math.pow(h,1.5),h3:f*Math.pow(h,1.2),h4:f*Math.pow(h,1),h5:f*Math.pow(h,.5),h6:f*Math.pow(h,.5)}),[f,h]),[x,b]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!d)return void b(null);let t=on.sanitize(d,og),r=e.link?(0,s5.resolveRelativeUrls)(t,e.link):t;m.enabled?oh(r,{enabled:m.enabled,autoDetect:m.autoDetectLanguage}).then(b,()=>{b(r)}):b(r)},[d,e.link,m.enabled,m.autoDetectLanguage]),(0,p.useEffect)(()=>{o.current&&x&&o.current.querySelectorAll('a[href^="http"]').forEach(e=>{e.setAttribute("target","_blank"),e.setAttribute("rel","noopener")})},[x]),(0,p.useEffect)(()=>{o.current&&x&&o.current.querySelectorAll("img[width][height]").forEach(e=>{let t=e.getAttribute("width"),r=e.getAttribute("height");if(t&&r){let s=parseFloat(t),a=parseFloat(r);s>0&&a>0&&(e.style.aspectRatio=`${s} / ${a}`)}})},[x]),(0,p.useEffect)(()=>{if(!o.current||!x)return;let e=o.current.querySelectorAll("img"),t=new Map;return e.forEach(e=>{let r=()=>{if(e.dataset.brokenHandled)return;e.dataset.brokenHandled="true";let t=document.createElement("div");t.className="prose-broken-image",t.setAttribute("role","img"),t.setAttribute("aria-label",e.alt||"Image unavailable"),e.width&&e.height&&e.width>0&&(t.style.aspectRatio=`${e.width} / ${e.height}`),t.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',e.replaceWith(t)};
14e.complete&&0===e.naturalWidth&&e.src?r():(e.addEventListener("error",r,{once:!0}),t.set(e,r))}),()=>{t.forEach((e,t)=>{t.removeEventListener("error",e)})}},[x]);let y=(0,p.useMemo)(()=>({fontFamily:s.fontFamily,fontSize:`${s.fontSize}rem`,lineHeight:s.lineHeight,color:s.textColor,maxWidth:`${s.contentWidth}ch`,letterSpacing:`${s.letterSpacing}em`,textAlign:s.textAlign,"--paragraph-spacing":`${s.paragraphSpacing}em`,"--custom-background-color":s.backgroundColor,"--base-font-size":`${f}rem`,"--scale-ratio":h,"--font-size-h1":`${g.h1}rem`,"--font-size-h2":`${g.h2}rem`,"--font-size-h3":`${g.h3}rem`,"--font-size-h4":`${g.h4}rem`,"--font-size-h5":`${g.h5}rem`,"--font-size-h6":`${g.h6}rem`}),[s,f,h,g]);return(0,a.jsx)("div",{className:"flex-1 max-h-full overflow-auto",style:{backgroundColor:s.backgroundColor},children:(0,a.jsxs)("div",{className:"mx-auto max-w-4xl p-2 md:p-4 lg:p-6",children:[r&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 gap-4",children:[(0,a.jsx)("div",{className:"size-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Extracting full article content..."})]}),!r&&(0,a.jsx)(a.Fragment,{children:x?(0,a.jsx)("article",{ref:o,className:`${of.merriweather.variable} prose mx-auto`,style:{...y},dangerouslySetInnerHTML:{__html:x}}):l?null:e.description?(0,a.jsx)("article",{className:`${of.merriweather.variable} prose mx-auto`,style:{...y},children:(0,a.jsx)("p",{children:e.description})}):(0,a.jsxs)("div",{className:"py-12 text-center text-muted-foreground",children:[(0,a.jsx)("p",{className:"mb-4",children:"No content available for this post."}),(0,a.jsx)(u.Button,{asChild:!0,children:(0,a.jsxs)("a",{href:e.link,target:"_blank",rel:"noopener",children:[(0,a.jsx)(ez.ExternalLink,{className:"mr-2 size-4"}),"Read on original site"]})})]})})]})})}var ob=e.i(98919),oy=e.i(506231),ov=e.i(735025),oj=e.i(661546);let ow=[{icon:E.Zap,title:"Faster reading",description:"Zero server dependency for feed fetching"},{icon:ob.Shield,title:"Enhanced privacy",description:"Fetch feeds and content directly from your browser"},{icon:tq.Globe,title:"Universal access",description:"Read any blog, regardless of CORS restrictions"}];function oN({className:e,forceShow:t=!1}){let r=(0,n.useAtomValue)(T.extensionAvailableAtom),s=(0,n.useAtomValue)(P.hasCustomProxyAtom);(0,n.useSetAtom)(b.settingsDialogOpenAtom),(0,n.useSetAtom)(b.settingsTabSelectionAtom);let{data:o}=(0,rO.useServerCapabilities)(),i=o?.can.fetchPostContentWithoutExtension??!1;return(r||s||i)&&!t?null:(0,a.jsx)("div",{className:(0,A.cn)("h-dvh flex flex-col min-h-0 flex-1 items-center justify-center",e),children:(0,a.jsx)("div",{className:"max-h-full max-w-xl overflow-y-auto thin-scrollbars",children:(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-auto gap-4 text-center",children:[(0,a.jsx)("div",{className:"flex justify-center items-center mt-10 mb-6",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute inset-0 animate-pulse rounded-full dark:bg-primary/20 bg-primary/40 blur-xl"}),(0,a.jsx)("div",{className:"relative rounded-full bg-gradient-to-br to-primary/20 from-primary/5 p-6 ring-1 ring-primary/10 dark:from-primary/20 dark:to-primary/5",children:(0,a.jsx)(oj.default,{className:"size-10 text-primary -mt-0.5 -mr-0.5",fill:"currentColor"})})]})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h2",{className:"text-2xl font-semibold tracking-tight",children:"Unlock the full experience"}),(0,a.jsxs)("p",{className:"text-muted-foreground leading-relaxed",children:["Install the browser extension for the best reading experience.",(0,a.jsx)("br",{}),"It's free,"," ",(0,a.jsx)("a",{href:tK.EXTENSION_URLS.SOURCE,target:"_blank",className:"underline hover:text-foreground duration-200",children:"open source"}),", lightweight, and needed to pull feeds and content."]})]}),(0,a.jsx)("div",{className:"grid gap-4 text-left",children:ow.map(e=>
14(0,a.jsxs)("div",{className:"flex items-start gap-4 rounded-lg border bg-card p-4",children:[(0,a.jsx)("div",{className:"rounded-full bg-primary/10 p-2.5",children:(0,a.jsx)(e.icon,{className:"size-5 text-primary"})}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("p",{className:"font-medium",children:e.title}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]})]},e.title))}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:justify-center",children:[(0,a.jsxs)(u.Button,{size:"lg",className:"gap-2",onClick:()=>window.open(tK.EXTENSION_URLS.CHROME,"_blank","noopener,noreferrer"),children:[(0,a.jsx)(ov.default,{fill:"currentColor",className:"size-5"}),"Add to Chrome",(0,a.jsx)(eT.ChevronRight,{className:"size-4 opacity-50"})]}),(0,a.jsxs)(u.Button,{size:"lg",variant:"outline",className:"gap-2",onClick:()=>window.open(tK.EXTENSION_URLS.FIREFOX,"_blank","noopener,noreferrer"),children:[(0,a.jsx)(oy.default,{fill:"currentColor",className:"size-5"}),"Add to Firefox"]})]}),(0,a.jsxs)("div",{className:"text-xs text-muted-foreground flex flex-row items-center gap-1 mx-auto justify-center opacity-70",children:[(0,a.jsxs)("div",{children:["Power user?"," ","Tech savvy?"," "]}),(0,a.jsx)("a",{href:"/guides/self-hosted-proxy",target:"_blank",rel:"noopener noreferrer",className:"text-xs underline hover:text-foreground duration-200",children:"Setup a custom proxy"})]})]})]})})})}var ok=e.i(840047);let oC="accelerometer 'none'; autoplay 'none'; camera 'none'; display-capture 'none'; encrypted-media 'none'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; publickey-credentials-get 'none'; usb 'none'; xr-spatial-tracking 'none'; fullscreen";function oA(e){let t=e.htmlContent||e.content;return t?t:e.textContent&&e.textContent.split(/\n\n+/).map(e=>e.trim()).filter(e=>e.length>0).map(e=>`<p>${e.replace(/\n/g,"<br>")}</p>`).join("\n")||null}function oS(){var e,t;let r,s,o,i,l,c=(0,n.useAtomValue)(er.selectedPostAtom),d=(0,n.useAtomValue)(er.blogsAtom),u=(0,n.useSetAtom)(er.unreadExemptionAtom),m=(0,n.useAtomValue)(er.hasNoBlogsAtom),h=(0,n.useAtomValue)(er.blogsLoadingAtom),f=(0,ru.useMounted)(),{getPreference:g,preferences:x,togglePreference:y}=sE(),v=(0,n.useAtomValue)(b.readerViewModesAtom);(0,n.useSetAtom)(b.readerViewModesAtom);let j=(0,n.useAtomValue)(b.readingFocusModeAtom),w=(0,n.useSetAtom)(b.readingFocusModeAtom),N=(0,n.useAtomValue)(b.viewModeAtom),k=(0,n.useSetAtom)(b.viewModeAtom),C=(0,ex.default)(),A=(0,n.useAtomValue)(er.savedOfflinePostGuidsAtom),S=c?.blogId===ax.SAVED_POSTS_BLOG_ID||!!(c?.guid&&A.has(c.guid)),E=(0,n.useAtomValue)(P.customProxyConfigStoredAtom),M=E?.useForDirectoryBlogs??!1,_=(0,ok.useCanCustomProxyParse)(),z=(0,n.useAtomValue)(T.extensionAvailableAtom),R=(0,n.useAtomValue)(P.hasCustomProxyAtom),{data:I}=(0,rO.useServerCapabilities)(),L=I?.can.fetchPostContentWithoutExtension??!1,D=(0,p.useMemo)(()=>c?.blogId?(0,tR.findBlogByPostBlogId)(d,c.blogId):null,[c?.blogId,d]),F=(0,p.useMemo)(()=>c?.blogId&&D?g(c.blogId,D.has_full_content):"content",[c?.blogId,D,g]),[O,$]=(0,p.useState)(null),[U,V]=(0,p.useState)(null),[q,H]=(0,p.useState)(null),[G,W]=(0,p.useState)(!1),[K,Y]=(0,p.useState)(!1),[Q,X]=(0,p.useState)(!1),[Z,J]=(0,p.useState)(null),[ee,et]=(0,p.useState)(!1),[es,ea]=(0,p.useState)(null);(0,p.useEffect)(()=>{if(!S||!c?.guid)return;J(null),et(!0),ea(null),k("content");let e=!1;return(0,s0.getSavedPostContentViaExtension)(c.guid).then(t=>{e||(t?J(t):ea("Saved post content not found"),et(!1))}).catch(()=>{e||(ea("Failed to load saved post"),et(!1))}),()=>{e=!0}},[S,c?.guid,k]);let eo=(0,p.useRef)(null),[en,ei]=(0,p.useState)(0),el=(0,p.useRef)(void 0);(0,p.useEffect)(()=>{let e=c?.blogId,t=e&&e!==el.current;f&&e&&t&&(C?k(v[e]||F):k(F),el.current=e)},[c?.blogId,F,k,v,C,f]),(0,p.useEffect)(()=>{ei(0)},[c?.guid]),(0,p.useEffect)(()=>{u(null)},[c?.guid,u]),(0,p.useEffect)(()=>{let e=e=>{"Escape"===e.key&&j&&(w(!1),th.toast.success("Exited focus mode"))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[j,w]);let ec=(0,p.useCallback)(e=>{try{let t=new URL(e).hostname.toLowerCase();return["substack.com","medium.com","twitter.com","x.com","facebook.com","instagram.com","linkedin.com","youtube.com","reddit.com","github.com"].some(e=>t===e||t.endsWith(`.${e}`))}catch{return!1}},[]),ed=(0,p.useCallback)(async e=>{if(W(!0),$(null),(0,s0.shouldUseExtension)())try{console.log(`[PostReader][Extension] Attempting to fetch page via browser extension: ${e}`);let t=await (0,s0.fetchPageViaExtension)(e);H(t),console.log("[PostReader][Extension] Successfully fetched page via extension"),th.toast.success("Loaded via extension",{description:"Content loaded using browser extension."}),U&&(clearTimeout(U),V(null)),W(!1);return}catch(t){(0,s0.isExtensionError)(t)?console.log(`[PostReader][Extension] Extension fetch failed for ${e}: ${t.message}`):console.warn(`[PostReader][Extension] Unexpected extension error for ${e}:`,t)}try{console.log(`[PostReader] Fetching HTML via server proxy for: ${e}`);let t=await fetch("/api/proxy/feed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})});if(!t.ok){if(503===t.status){let e=await t.json().catch(()=>({}));if("PROXY_DISABLED"===e.code){$("Feed proxy is temporarily disabled. Install the browser extension for uninterrupted access."),k("content"),th.toast.error("Proxy temporarily disabled",{description:"High server load. Install the browser extension to continue.",duration:8e3});return}}throw Error(`Proxy request failed: ${t.status}`)}let r=await t.text();H(r),console.log("[PostReader] Successfully fetched proxied HTML"),th.toast.success("Loaded via proxy",{description:"Content loaded through server proxy to bypass embedding restrictions."})}catch(e){console.error("[PostReader] Failed to fetch proxied HTML:",e),$("Failed to load content via proxy. Showing sanitized content instead."),k("content"),th.toast.error("Failed to load via proxy",{description:"Showing sanitized content instead."})}finally{W(!1),U&&(clearTimeout(U),V(null))}},[U,k]),eu=(0,p.useCallback)(e=>{console.log(`[PostReader] Iframe failed to load (${e}), attempting to load via proxy`),U&&(clearTimeout(U),V(null)),Y(!1),X(!1),("csp"===e||"blocked"===e)&&c?.link?ed(c.link):($("Failed to load iframe. Showing sanitized content instead."),k("content"),th.toast.info("Switched to content view",{description:"Failed to load iframe."}))},[U,c?.link,ed]),em=(0,p.useCallback)(()=>{U&&(clearTimeout(U),V(null)),Y(!1),X(!1)},[U]);if((0,p.useEffect)(()=>{let e=e=>{("frame-ancestors"===e.violatedDirective||"frame-ancestors"===e.effectiveDirective||e.blockedURI?.includes(c?.link||""))&&(console.log("[PostReader] CSP frame-ancestors violation detected:",e.violatedDirective),eu("csp"))};return window.addEventListener("securitypolicyviolation",e),()=>{window.removeEventListener("securitypolicyviolation",e)}},[c?.link,eu]),(0,p.useEffect)(()=>{S||(J(null),et(!1),ea(null),!c?.link||"content"!==N||D?.has_full_content||(async()=>{let e=D?(0,tR.getEffectiveBlogId)(D):c.blogId;try{let e=await (0,s3.getCachedContent)(c.link);if(e&&e.htmlContent){console.log(`[PostReader][Cache] Cache hit for: ${c.link} (source: ${e.source})`),J(e.htmlContent);return}}catch(e){console.warn("[PostReader][Cache] Cache lookup failed, proceeding with extraction:",e)}et(!0),ea(null);try{console.log(`[PostReader] Extracting full HTML content for post without full feed content: ${c.link}`);let n=D&&("directory"===D.source||"community"===D.source),i=D?.directory_blog_id||D?.community_blog_id;if(!(0,s0.shouldUseExtension)()&&n&&i&&!M){let t=D.source;console.log(`[PostReader] Using catalog post endpoint for extraction (catalog=${t})`);let r=await fetch(`/api/catalog/post?url=${encodeURIComponent(c.link)}&blogId=${i}&catalog=${t}&format=html`,{credentials:"include"});if(!r.ok){let e=await r.json().catch(()=>({error:"Unknown error"}));if(503===r.status&&"PARSE_DISABLED"===e.code)throw Error("Content parsing temporarily disabled. Please try again later.");throw Error(e.error||`Failed to parse content: ${r.status}`)}let s=await r.json(),a=oA(s);if(a){J(a),console.log(`[PostReader] Successfully extracted content via catalog endpoint (catalog=${t})`),(0,s3.setCachedContent)(c.link,{htmlContent:a,textContent:s.textContent,title:s.title,excerpt:s.excerpt,byline:s.byline,image:s.image,length:s.length},t,{guid:c.guid,blogId:e}).catch(e=>console.warn("[PostReader] Failed to cache content:",e)),th.toast.success("Full content loaded",{description:"Extracted readable content from the article."});return}throw Error("No content returned from parser")}if(!(0,s0.shouldUseExtension)()&&n&&i&&M){console.log("[PostReader] Using custom proxy /parse endpoint for extraction");let n=await (0,s2.parseViaCustomProxy)(c.link,E?.proxyUrl??"",E?.apiKey??null,"html");if(n.success){let t=n?.htmlContent||n?.content||"",r=oA({htmlContent:t,textContent:n.textContent});if(r)J(r),console.log("[PostReader] Successfully extracted content via custom proxy /parse"),(0,s3.setCachedContent)(c.link,{htmlContent:r,textContent:n.textContent,title:n.title,excerpt:n.excerpt??void 0,byline:n.byline??void 0,length:n.length},"custom-proxy",{guid:c.guid,blogId:e}).catch(e=>console.warn("[PostReader] Failed to cache content:",e)),th.toast.success("Full content loaded",{description:"Extracted readable content via custom proxy."});else throw Error("No content returned from custom proxy parser")}else{var t,r,s,o;throw n.error&&(t=n.error,r=c.link,s=function(e){switch(e){case"CONTENT_TOO_LARGE":return"Content too large to process";case"TIMEOUT":return"Request timed out";case"FETCH_FAILED":return"Failed to fetch content";case"INVALID_URL":return"Invalid URL";case"INVALID_CONTENT_TYPE":return"Unsupported content type";case"UNAUTHORIZED":return"Proxy authentication failed";
14case"NETWORK_ERROR":return"Network connection error";case"PROXY_ERROR":return"Proxy server error";default:return"An error occurred"}}(t.code),o={code:t.code,message:t.message,context:r},th.toast.custom(e=>(0,a.jsx)(sb,{id:e,title:s,details:{...o,timestamp:o.timestamp??new Date}}),{duration:1/0,position:"top-center",className:"persistent-error-toast"})),Error(n.error?.message||"Failed to parse content")}return}if(!(0,s0.shouldUseExtension)()&&!_&&!L){D&&c.blogId&&(y(c.blogId,"iframe"),k("iframe"),th.toast.error("Extension required for full content extraction",{description:"Switching back to iframe view.",duration:5e3}));return}let l=await s6(c.link,{guid:c.guid,blogId:e});if(l.success&&l.content){let e=oA(l.content);if(e)J(e),console.log("[PostReader] Successfully extracted full HTML content"),l.content.fromCache||th.toast.success("Full content loaded",{description:"Extracted readable content from the article."});else throw Error("No readable content found")}else throw Error(l.error||"Failed to extract content")}catch(t){console.error("[PostReader] Failed to extract content:",t);let e=t instanceof Error?t.message:"Failed to extract content";ea(e),["CONTENT_TOO_LARGE","TIMEOUT","FETCH_FAILED","INVALID_URL","INVALID_CONTENT_TYPE","UNAUTHORIZED","NETWORK_ERROR","PROXY_ERROR"].some(t=>e.includes(t))||th.toast.error("Failed to extract content",{description:"Showing feed excerpt instead. Try switching to iframe view."})}finally{et(!1)}})())},[c?.guid,c?.link,N,D]),(0,p.useEffect)(()=>{if($(null),H(null),W(!1),Y(!1),X(!1),U&&(clearTimeout(U),V(null)),"iframe"===N&&c?.link){if(D?.blocks_iframe===!0){console.log("[PostReader] Blog blocks_iframe=true, fetching via proxy immediately:",c.link),ed(c.link);return}if((D?.blocks_iframe===null||D?.blocks_iframe===void 0)&&ec(c.link)){console.log("[PostReader] Known blocked domain detected, fetching via proxy immediately:",c.link),ed(c.link);return}if(D?.blocks_iframe===!1){console.log("[PostReader] Blog blocks_iframe=false, using direct iframe without timeout"),Y(!0);return}return q||(Y(!0),V(setTimeout(()=>{Y(!1),X(!0);let e=eo.current;if(e&&e.src)try{let t=e.contentWindow;t&&t.location?X(!1):(X(!1),eu("blocked"))}catch(e){X(!1),eu("blocked")}},5e3))),()=>{U&&clearTimeout(U)}}},[c?.guid,N]),!C&&!c&&!h&&m)return(0,a.jsx)(rw,{});if(!c)return C||z||R?(0,a.jsx)(ra,{icon:B.FileText,title:"No post selected",description:"Select a post from the list to read it here, or use j/k keys to navigate.",className:"bg-muted/10"}):(0,a.jsx)(oN,{className:"bg-muted/10"});return(0,a.jsx)(rT.AnimatePresence,{mode:"wait",children:(0,a.jsxs)(rS.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2},className:"flex h-full flex-col @container/postreader",children:[(0,a.jsx)(sy.Progress,{value:en,className:"h-1 rounded-none"}),!C&&(0,a.jsx)(ab,{proxiedHtml:q}),"iframe"===N?(0,a.jsxs)("div",{className:"relative flex-1 bg-background",children:[(K||G||Q)&&(0,a.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/90 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"flex flex-col items-center gap-4 max-w-xs text-center",children:[(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)("div",{className:"size-10 animate-spin rounded-full border-4 border-muted border-t-primary"})}),K&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Loading article..."}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Connecting to ",c?.link?new URL(c.link).hostname:"site"]})]}),Q&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Checking access..."}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Some sites block embedding. We'll try an alternative if needed."})]}),G&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Loading via proxy..."}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"This site blocks direct embedding. Fetching content securely."})]})]})}),q?(0,a.jsx)("iframe",{ref:eo,srcDoc:(e=q,t=c.link,r=e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<noscript\b[^<]*(?:(?!<\/noscript>)<[^<]*)*<\/noscript>
14/gi,"").replace(/\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*)/gi,"").replace(/(\s(?:href|src|action)\s*=\s*["']?)javascript:[^"'\s>]*/gi,"$1#").replace(/(\ssrc\s*=\s*["']?)data:(?!image\/)[^"'\s>]*/gi,"$1#").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/<iframe\b[^>]*\/?>/gi,"").replace(/<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi,"").replace(/<embed\b[^>]*\/?>/gi,"").replace(/<form\b[^>]*>/gi,'<div class="bab-form-placeholder">').replace(/<\/form>/gi,"</div>"),s=function(e){let t="'none'";try{t=new URL(e).origin}catch{}return`default-src 'none'; img-src ${t} data: https:; style-src 'unsafe-inline' ${t} https:; font-src ${t} https://fonts.gstatic.com https://fonts.googleapis.com data:; script-src 'none'; frame-src 'none'; object-src 'none'; media-src ${t} https:; connect-src 'none'; form-action 'self'; base-uri 'self'`}(t),o=`<meta http-equiv="Content-Security-Policy" content="${s}">`,i=`<base href="${t}" target="_blank">`,l=`${o}
15    ${i}
16    <meta name="referrer" content="no-referrer">`,r.toLowerCase().includes("<head>")?r.replace(/<head>/i,`<head>
17    ${l}`):r.toLowerCase().includes("<html>")?r.replace(/<html[^>]*>/i,`$&
18  <head>
19    ${l}
20  </head>`):`<!DOCTYPE html>
21<html>
22  <head>
23    ${l}
24  </head>
25  <body>
26${r}
27  </body>
28</html>`),className:"size-full border-0",title:c.title,sandbox:"allow-scripts allow-popups allow-popups-to-escape-sandbox",allow:oC,referrerPolicy:"no-referrer",onLoad:em}):(0,a.jsx)("iframe",{ref:eo,src:c.link,className:"size-full border-0",title:c.title,sandbox:"allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox",allow:oC,referrerPolicy:"no-referrer",loading:"lazy",onLoad:em,onError:()=>eu("error")})]}):(0,a.jsx)(ox,{post:c,extractedContent:Z,isLoadingExtraction:ee})]},c.guid)})}function oT({groupSize:e,panelElement:t,styleProp:r}){let s,[a,o]=function(e){switch(typeof e){case"number":return[e,"px"];case"string":{let t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}(r);switch(o){case"%":s=a/100*e;break;case"px":s=a;break;case"rem":s=a*parseFloat(getComputedStyle(t.ownerDocument.body).fontSize);break;case"em":s=a*parseFloat(getComputedStyle(t).fontSize);break;case"vh":s=a/100*window.innerHeight;break;case"vw":s=a/100*window.innerWidth}return s}function oE(e){return parseFloat(e.toFixed(3))}function oM({group:e}){let{orientation:t,panels:r}=e;return r.reduce((e,r)=>e+="horizontal"===t?r.element.offsetWidth:r.element.offsetHeight,0)}function o_(e){let{panels:t}=e,r=oM({group:e});return 0===r?t.map(e=>({groupResizeBehavior:e.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:!0===e.panelConstraints.collapsible,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let t,{element:s,panelConstraints:a}=e,o=0;void 0!==a.collapsedSize&&(o=oE(oT({groupSize:r,panelElement:s,styleProp:a.collapsedSize})/r*100)),void 0!==a.defaultSize&&(t=oE(oT({groupSize:r,panelElement:s,styleProp:a.defaultSize})/r*100));let n=0;void 0!==a.minSize&&(n=oE(oT({groupSize:r,panelElement:s,styleProp:a.minSize})/r*100));let i=100;return void 0!==a.maxSize&&(i=oE(oT({groupSize:r,panelElement:s,styleProp:a.maxSize})/r*100)),{groupResizeBehavior:a.groupResizeBehavior,collapsedSize:o,collapsible:!0===a.collapsible,defaultSize:t,disabled:a.disabled,minSize:n,maxSize:i,panelId:e.id}})}function oz(e,t="Assertion error"){if(!e)throw Error(t)}function oR(e,t){return Array.from(t).sort("horizontal"===e?oP:oI)}function oP(e,t){let r=e.element.offsetLeft-t.element.offsetLeft;return 0!==r?r:e.element.offsetWidth-t.element.offsetWidth}function oI(e,t){let r=e.element.offsetTop-t.element.offsetTop;return 0!==r?r:e.element.offsetHeight-t.element.offsetHeight}function oL(e){return null!==e&&"object"==typeof e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function oD(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function oF(e){let{element:r,orientation:s,panels:a,separators:o}=e,n=oR(s,Array.from(r.children).filter(oL).map(e=>({element:e}))).map(({element:e})=>e),i=[],l=!1,c=!1,d=-1,u=-1,m=0,h,f=[];{let e=-1;for(let t of n)t.hasAttribute("data-panel")&&(e++,null===t.ariaDisabled&&(m++,-1===d&&(d=e),u=e))}if(m>1){let r=-1;for(let m of n)if(m.hasAttribute("data-panel")){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a,n=h.element.getBoundingClientRect(),p=m.getBoundingClientRect();if(c){let e="horizontal"===s?new DOMRect(n.right,n.top,0,n.height):new DOMRect(n.left,n.bottom,n.width,0),t="horizontal"===s?new DOMRect(p.left,p.top,0,p.height):new DOMRect(p.left,p.top,p.width,0);switch(f.length){case 0:a=[e,t];break;case 1:{let r=f[0],o=function({orientation:e,rects:t,targetRect:r}){let s={x:r.x+r.width/2,y:r.y+r.height/2},a,o=Number.MAX_VALUE;for(let r of t){let{x:t,y:n}=oD(s,r),i="horizontal"===e?t:n;i<o&&(o=i,a=r)}return oz(a,"No rect found"),a}({orientation:s,rects:[n,p],targetRect:r.element.getBoundingClientRect()});a=[r,o===n?t:e];break}default:a=f}}else a=f.length?f:["horizontal"===s?new DOMRect(n.right,p.top,p.left-n.r
28ight,p.height):new DOMRect(p.left,n.bottom,p.width,p.top-n.bottom)];for(let s of a){let a="width"in s?s:s.element.getBoundingClientRect(),n=(void 0===t&&(t="function"==typeof matchMedia&&!!matchMedia("(pointer:coarse)").matches),t)?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(a.width<n){let e=n-a.width;a=new DOMRect(a.x-e/2,a.y,a.width+e,a.height)}if(a.height<n){let e=n-a.height;a=new DOMRect(a.x,a.y-e/2,a.width,a.height+e)}let c=r<=d||r>u;l||c||i.push({group:e,groupSize:oM({group:e}),panels:[h,o],separator:"width"in s?void 0:s,rect:a}),l=!1}}c=!1,h=o,f=[]}}else if(m.hasAttribute("data-separator")){null!==m.ariaDisabled&&(l=!0);let e=o.find(e=>e.element===m);e?f.push(e):(h=void 0,f=[])}else c=!0}return i}class oO{#e={};addListener(e,t){let r=this.#e[e];return void 0===r?this.#e[e]=[t]:r.includes(t)||r.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let r=this.#e[e];if(void 0!==r)if(1===r.length)r[0].call(null,t);else{let e=!1,s=null,a=Array.from(r);for(let r=0;r<a.length;r++){let o=a[r];try{o.call(null,t)}catch(t){null===s&&(e=!0,s=t)}}if(e)throw s}}removeAllListeners(){this.#e={}}removeListener(e,t){let r=this.#e[e];if(void 0!==r){let e=r.indexOf(t);e>=0&&r.splice(e,1)}}}let oB=new Map,o$=new oO;function oU(e,t){for(let[t]of oB)if(t.id===e)return t}function oV(e,t){for(let[t,r]of oB)if(t.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function oq(e,t){return o$.addListener("groupChange",r=>{r.group.id===e&&t(r)})}function oH(e,t){let r=oB.get(e);(oB=new Map(oB)).set(e,t),o$.emit("groupChange",{group:e,prev:r,next:t})}let oG=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function oW(e){let t=e.length;for(;t--;){let r=e[t];if(oz(r,"Missing node"),function(e){let t,r=getComputedStyle(e);return!!("fixed"===r.position||"auto"!==r.zIndex&&("static"!==r.position||"flex"===(t=getComputedStyle(oQ(e)??e).display)||"inline-flex"===t)||1>+r.opacity||"transform"in r&&"none"!==r.transform||"webkitTransform"in r&&"none"!==r.webkitTransform||"mixBlendMode"in r&&"normal"!==r.mixBlendMode||"filter"in r&&"none"!==r.filter||"webkitFilter"in r&&"none"!==r.webkitFilter||"isolation"in r&&"isolate"===r.isolation||oG.test(r.willChange)||"touch"===r.webkitOverflowScrolling)}(r))return r}return null}function oK(e){return e&&Number(getComputedStyle(e).zIndex)||0}function oY(e){let t=[];for(;e;)t.push(e),e=oQ(e);return t}function oQ(e){let{parentNode:t}=e;return null!==t&&"object"==typeof t&&"nodeType"in t&&t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?t.host:t}function oX(e,t){let r=[];return t.forEach((t,s)=>{if(s.disabled)return;let a=oF(s),o=function(e,t,r){let s,a={x:1/0,y:1/0};for(let o of t){let t=oD(r,o.rect);switch(e){case"horizontal":t.x<=a.x&&(s=o,a=t);break;case"vertical":t.y<=a.y&&(s=o,a=t)}}return s?{distance:a,hitRegion:s}:void 0}(s.orientation,a,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&function({groupElement:e,hitRegion:t,pointerEventTarget:r}){if(!oL(r)||r.contains(e)||e.contains(r))return!0;if(function(e,t){let r;if(e===t)throw Error("Cannot compare node with itself");let s={a:oY(e),b:oY(t)};for(;s.a.at(-1)===s.b.at(-1);)r=s.a.pop(),s.b.pop();oz(r,"Stacking order can only be calculated for elements with a common ancestor");let a={a:oK(oW(s.a)),b:oK(oW(s.b))};if(a.a===a.b){let e=r.childNodes,t={a:s.a.at(-1),b:s.b.at(-1)},a=e.length;for(;a--;){let r=e[a];if(r===t.a)return 1;if(r===t.b)return -1}}return Math.sign(a.a-a.b)}(r,e)>0){let a=r;for(;a;){var s;if(a.contains(e))break;if(s=a.getBoundingClientRect(),s.x<t.x+t.width&&s.x+s.width>t.x&&s.y<t.y+t.height&&s.y+s.height>t.y)return!1;a=a.parentElement}}return!0}({groupElement:s.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&r.push(o.hitRegion)}),r}function oZ(e,t,r=0){return Math.abs(oE(e)-oE(t))<=r}function oJ(e,t){return oZ(e,t)?0:e>t?1:-1}function o0({overrideDisabledPanels:e,panelConstraints:t,prevSize:r,size:s}){let{collapsedSize:a=0,collapsible:o,disabled:n,maxSize:i=100,minSize:l=0}=t;return n&&!e?r:(0>oJ(s,l)&&(s=o&&0>oJ(s,(a+l)/2)?a:l),oE(s=Math.min(i,s)))}function o1({delta:e,initialLayout:t,panelConstraints:r,pivotIndices:s,prevLayout:a,trigger:o}){if(oZ(e,0))return t;let n="imperative-api"===o,i=Object.values(t),l=Object.values(a),c=[...i],[d,u]=s;oz(null!=d,"Invalid first pivot index"),oz(null!=u,"Invalid second pivot index");let m=0;if("keyboard"===o){{let t=e<0?u:d,s=r[t];oz(s,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:o,minSize:n=0}=s;if(o){let r=i[t];if(oz(null!=r,`Previous layout not found for panel index ${t}`),oZ(r,a)){let t=n-r;oJ(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?d:u,s=r[t];
28oz(s,`No panel constraints found for index ${t}`);let{collapsedSize:a=0,collapsible:o,minSize:n=0}=s;if(o){let r=i[t];if(oz(null!=r,`Previous layout not found for panel index ${t}`),oZ(r,n)){let t=r-a;oJ(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}else{let t=e<0?u:d,s=r[t];oz(s,`Panel constraints not found for index ${t}`);let a=i[t],{collapsible:o,collapsedSize:n,minSize:l}=s;if(o&&0>oJ(a,l))if(e>0){let t=l-n;0>oJ(a+e,l)&&(e=0>=oJ(e,t/2)?0:t)}else{let t=l-n;0>oJ(a-e,l)&&(e=oJ(100+e,100-t/2)>0?0:-t)}}{let t=e<0?1:-1,s=e<0?u:d,a=0;for(;;){let e=i[s];if(oz(null!=e,`Previous layout not found for panel index ${s}`),a+=o0({overrideDisabledPanels:n,panelConstraints:r[s],prevSize:e,size:100})-e,(s+=t)<0||s>=r.length)break}let o=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-o:o}{let t=e<0?d:u;for(;t>=0&&t<r.length;){let s=Math.abs(e)-Math.abs(m),a=i[t];oz(null!=a,`Previous layout not found for panel index ${t}`);let o=a-s,l=o0({overrideDisabledPanels:n,panelConstraints:r[t],prevSize:a,size:o});if(!oZ(a,l)&&(m+=a-l,c[t]=l,m.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!=t[r])return!1;return!0}(l,c))return a;{let t=e<0?u:d,s=i[t];oz(null!=s,`Previous layout not found for panel index ${t}`);let a=s+m,o=o0({overrideDisabledPanels:n,panelConstraints:r[t],prevSize:s,size:a});if(c[t]=o,!oZ(o,a)){let t=a-o,s=e<0?u:d;for(;s>=0&&s<r.length;){let a=c[s];oz(null!=a,`Previous layout not found for panel index ${s}`);let o=a+t,i=o0({overrideDisabledPanels:n,panelConstraints:r[s],prevSize:a,size:o});if(oZ(a,i)||(t-=i-a,c[s]=i),oZ(t,0))break;e>0?s--:s++}}}if(!oZ(Object.values(c).reduce((e,t)=>t+e,0),100,.1))return a;let h=Object.keys(a);return c.reduce((e,t,r)=>(e[h[r]]=t,e),{})}function o2(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(void 0===t[r]||0!==oJ(e[r],t[r]))return!1;return!0}function o5({layout:e,panelConstraints:t}){let r=Object.values(e),s=[...r],a=s.reduce((e,t)=>e+t,0);if(s.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${s.map(e=>`${e}%`).join(", ")}`);if(!oZ(a,100)&&s.length>0)for(let e=0;e<t.length;e++){let t=s[e];oz(null!=t,`No layout data found for index ${e}`);let r=100/a*t;s[e]=r}let o=0;for(let e=0;e<t.length;e++){let a=r[e];oz(null!=a,`No layout data found for index ${e}`);let n=s[e];oz(null!=n,`No layout data found for index ${e}`);let i=o0({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:a,size:n});n!=i&&(o+=n-i,s[e]=i)}if(!oZ(o,0))for(let e=0;e<t.length;e++){let r=s[e];oz(null!=r,`No layout data found for index ${e}`);let a=r+o,n=o0({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:r,size:a});if(r!==n&&(o-=n-r,s[e]=n,oZ(o,0)))break}let n=Object.keys(e);return s.reduce((e,t,r)=>(e[n[r]]=t,e),{})}function o3({groupId:e,panelId:t}){let r=()=>{for(let[t,{defaultLayoutDeferred:r,derivedPanelConstraints:s,layout:a,groupSize:o,separatorToPanels:n}]of oB)if(t.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:s,group:t,groupSize:o,layout:a,separatorToPanels:n};throw Error(`Group ${e} not found`)},s=()=>{let e=r().derivedPanelConstraints.find(e=>e.panelId===t);if(void 0!==e)return e;throw Error(`Panel constraints not found for Panel ${t}`)},a=()=>{let e=r().group.panels.find(e=>e.id===t);if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},o=()=>{let e=r().layout[t];if(void 0!==e)return e;throw Error(`Layout not found for Panel ${t}`)},n=e=>{let s=o();if(e===s)return;let{defaultLayoutDeferred:a,derivedPanelConstraints:n,group:i,groupSize:l,layout:c,separatorToPanels:d}=r(),u=i.panels.findIndex(e=>e.id===t),m=u===i.panels.length-1,h=o5({layout:o1({delta:m?s-e:e-s,initialLayout:c,panelConstraints:n,pivotIndices:m?[u-1,u]:[u,u+1],prevLayout:c,trigger:"imperative-api"}),panelConstraints:n});o2(c,h)||oH(i,{defaultLayoutDeferred:a,derivedPanelConstraints:n,groupSize:l,layout:h,separatorToPanels:d})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=s(),{mutableValues:r}=a(),i=o();e&&i!==t&&(r.expandToSize=i,n(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:r}=s(),{mutableValues:i}=a(),l=o();
28if(e&&l===t){let e=i.expandToSize??r;0===e&&(e=1),n(e)}},getSize:()=>{let{group:e}=r(),t=o(),{element:s}=a();return{asPercentage:t,inPixels:"horizontal"===e.orientation?s.offsetWidth:s.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=s(),r=o();return e&&oZ(t,r)},resize:e=>{if(o()!==e){let t;switch(typeof e){case"number":{let{group:s}=r();t=oE(e/oM({group:s})*100);break}case"string":t=parseFloat(e)}n(t)}}}}function o4(e){e.defaultPrevented||oX(e,oB).forEach(t=>{if(t.separator){let r=t.panels.find(e=>void 0!==e.panelConstraints.defaultSize);if(r){let s=r.panelConstraints.defaultSize,a=o3({groupId:t.group.id,panelId:r.id});a&&void 0!==s&&(a.resize(s),e.preventDefault())}}})}function o6(e){for(let[t]of oB)if(t.separators.some(t=>t.element===e))return t;throw Error("Could not find parent Group for separator element")}function o8({groupId:e}){let t=()=>{for(let[t,r]of oB)if(t.id===e)return{group:t,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:r}=t();return e?{}:r},setLayout(e){let{defaultLayoutDeferred:r,derivedPanelConstraints:s,group:a,groupSize:o,layout:n,separatorToPanels:i}=t(),l=o5({layout:e,panelConstraints:s});return r?n:(o2(n,l)||oH(a,{defaultLayoutDeferred:r,derivedPanelConstraints:s,groupSize:o,layout:l,separatorToPanels:i}),l)}}}function o7(e,t){let r=o6(e),s=oV(r.id,!0),a=r.separators.find(t=>t.element===e);oz(a,"Matching separator not found");let o=s.separatorToPanels.get(a);oz(o,"Matching panels not found");let n=o.map(e=>r.panels.indexOf(e)),i=o8({groupId:r.id}).getLayout(),l=o5({layout:o1({delta:t,initialLayout:i,panelConstraints:s.derivedPanelConstraints,pivotIndices:n,prevLayout:i,trigger:"keyboard"}),panelConstraints:s.derivedPanelConstraints});o2(i,l)||oH(r,{defaultLayoutDeferred:s.defaultLayoutDeferred,derivedPanelConstraints:s.derivedPanelConstraints,groupSize:s.groupSize,layout:l,separatorToPanels:s.separatorToPanels})}function o9(e){if(e.defaultPrevented)return;let t=e.currentTarget,r=o6(t);if(!r.disabled)switch(e.key){case"ArrowDown":e.preventDefault(),"vertical"===r.orientation&&o7(t,5);break;case"ArrowLeft":e.preventDefault(),"horizontal"===r.orientation&&o7(t,-5);break;case"ArrowRight":e.preventDefault(),"horizontal"===r.orientation&&o7(t,5);break;case"ArrowUp":e.preventDefault(),"vertical"===r.orientation&&o7(t,-5);break;case"End":e.preventDefault(),o7(t,100);break;case"Enter":{e.preventDefault();let r=o6(t),{derivedPanelConstraints:s,layout:a,separatorToPanels:o}=oV(r.id,!0),n=r.separators.find(e=>e.element===t);oz(n,"Matching separator not found");let i=o.get(n);oz(i,"Matching panels not found");let l=i[0],c=s.find(e=>e.panelId===l.id);if(oz(c,"Panel metadata not found"),c.collapsible){let e=a[l.id];o7(t,(c.collapsedSize===e?r.mutableState.expandedPanelSizes[l.id]??c.minSize:c.collapsedSize)-e)}break}case"F6":{e.preventDefault();let r=o6(t).separators.map(e=>e.element),s=Array.from(r).findIndex(t=>t===e.currentTarget);oz(null!==s,"Index not found");let a=e.shiftKey?s>0?s-1:r.length-1:s+1<r.length?s+1:0;r[a].focus();break}case"Home":e.preventDefault(),o7(t,-100)}}let ne={cursorFlags:0,state:"inactive"},nt=new oO;function nr(e){let t=ne;ne=e,nt.emit("change",{prev:t,next:e})}function ns(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=oB,r=oX(e,t),s=new Map,a=!1;r.forEach(e=>{e.separator&&(a||(a=!0,e.separator.element.focus()));let r=t.get(e.group);r&&s.set(e.group,r.layout)}),nr({cursorFlags:0,hitRegions:r,initialLayoutMap:s,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),r.length&&e.preventDefault()}let na=e=>e,no=()=>{};function nn(){return void 0===r&&(r=!1,(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(r=!0)),r}let ni=new WeakMap;function nl(e){if(null===e.defaultView||void 0===e.defaultView)return;let{prevStyle:t,styleSheet:r}=ni.get(e)??{};void 0===r&&(r=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(r));let s=ne;switch(s.state){case"active":case"hover":{let e=function({cursorFlags:e,groups:t,state:r}){let s=0,a=0;
28switch(r){case"active":case"hover":t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case"horizontal":s++;break;case"vertical":a++}})}if(0!==s||0!==a){if("active"===r&&e&&nn()){let t=(4&e)!=0,r=(8&e)!=0;if((1&e)!=0)return t?"se-resize":r?"ne-resize":"e-resize";if((2&e)!=0)return t?"sw-resize":r?"nw-resize":"w-resize";if(t)return"s-resize";if(r)return"n-resize"}return nn()?s>0&&a>0?"move":s>0?"ew-resize":"ns-resize":s>0&&a>0?"grab":s>0?"col-resize":"row-resize"}}({cursorFlags:s.cursorFlags,groups:s.hitRegions.map(e=>e.group),state:s.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?0===r.cssRules.length?r.insertRule(a):r.replaceSync(a):1===r.cssRules.length&&r.deleteRule(0);break}case"inactive":t=void 0,1===r.cssRules.length&&r.deleteRule(0)}ni.set(e,{prevStyle:t,styleSheet:r})}function nc({document:e,event:t,hitRegions:r,initialLayoutMap:s,mountedGroups:a,pointerDownAtPoint:o,prevCursorFlags:n}){var i;let l,c,d=0;r.forEach(e=>{let{group:r,groupSize:n}=e,{orientation:i,panels:l}=r,{disableCursor:c}=r.mutableState,u=0;u=o?"horizontal"===i?(t.clientX-o.x)/n*100:(t.clientY-o.y)/n*100:"horizontal"===i?t.clientX<0?-100:100:t.clientY<0?-100:100;let m=s.get(r),h=a.get(r);if(!m||!h)return;let{defaultLayoutDeferred:f,derivedPanelConstraints:p,groupSize:g,layout:x,separatorToPanels:b}=h;if(p&&x&&b){let t=o1({delta:u,initialLayout:m,panelConstraints:p,pivotIndices:e.panels.map(e=>l.indexOf(e)),prevLayout:x,trigger:"mouse-or-touch"});if(o2(t,x)){if(0!==u&&!c)switch(i){case"horizontal":d|=u<0?1:2;break;case"vertical":d|=u<0?4:8}}else oH(e.group,{defaultLayoutDeferred:f,derivedPanelConstraints:p,groupSize:g,layout:t,separatorToPanels:b})}});let u=0;0===t.movementX?u|=3&n:u|=3&d,0===t.movementY?u|=12&n:u|=12&d,i=u,l=ne,(c={...ne}).cursorFlags=i,ne=c,nt.emit("change",{prev:l,next:c}),nl(e)}function nd(e){let t=oB,r=ne;"active"===r.state&&nc({document:e.currentTarget,event:e,hitRegions:r.hitRegions,initialLayoutMap:r.initialLayoutMap,mountedGroups:t,prevCursorFlags:r.cursorFlags})}function nu(e){if(e.defaultPrevented)return;let t=ne,r=oB;if("active"===t.state){if(0===e.buttons){nr({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(e=>{let t=oV(e.group.id,!0);oH(e.group,t)});return}nc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags})}else{let s=oX(e,r);0===s.length?"inactive"!==t.state&&nr({cursorFlags:0,state:"inactive"}):nr({cursorFlags:0,hitRegions:s,state:"hover"}),nl(e.currentTarget)}}function nm(e){e.relatedTarget instanceof HTMLIFrameElement&&"hover"===ne.state&&nr({cursorFlags:0,state:"inactive"})}function nh(e){if(e.defaultPrevented||"mouse"===e.pointerType&&e.button>0)return;let t=ne;"active"===t.state&&(nr({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(nl(e.currentTarget),t.hitRegions.forEach(e=>{let t=oV(e.group.id,!0);oH(e.group,t)}),e.preventDefault()))}function nf(e){let t=0,r=0,s={};for(let a of e)if(void 0!==a.defaultSize){t++;let e=oE(a.defaultSize);r+=e,s[a.panelId]=e}else s[a.panelId]=void 0;let a=e.length-t;if(0!==a){let t=oE((100-r)/a);for(let r of e)void 0===r.defaultSize&&(s[r.panelId]=t)}return s}let np=new Map;function ng(e){let t=(0,p.useId)();return`${e??t}`}let nx=p.useLayoutEffect;function nb(e){let t=(0,p.useRef)(e);return nx(()=>{t.current=e},[e]),(0,p.useCallback)((...e)=>t.current?.(...e),[t])}function ny(...e){return nb(t=>{e.forEach(e=>{if(e)switch(typeof e){case"function":e(t);break;case"object":e.current=t}})})}function nv(e){let t=(0,p.useRef)({...e});return nx(()=>{for(let r in e)t.current[r]=e[r]},[e]),t.current}let nj=(0,p.createContext)(null);function nw({children:e,className:t,defaultLayout:r,disableCursor:s,disabled:o,elementRef:n,groupRef:i,id:l,onLayoutChange:c,onLayoutChanged:d,orientation:u="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:h,...f}){let g,x=(0,p.useRef)({onLayoutChange:{},onLayoutChanged:{}}),b=nb(e=>{o2(x.current.onLayoutChange,e)||(x.current.onLayoutChange=e,c?.(e))}),y=nb(e=>{o2(x.current.onLayoutChanged,e)||(x.current.onLayoutChanged=e,d?.(e))}),v=ng(l),j=(0,p.useRef)(null),[w,N]=function(){let[e,t]=(0,p.useState)({});return[e,(0,p.useCallback)(()=>t({}),[])]}(),k=(0,p.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),C=ny(j,n);g=(0,p.useRef)({getLayout:()=>({}),setLayout:na}),(0,p.useImperativeHandle)(i,()=>g.current,[]),nx(()=>{Object.assign(g.current,o8({groupId:v}))});let A=nb((e,t)=>{let s=ne,a=oU(e),o=oV(e);if(o){let e=!1;return"active"===s.state&&(e=s.hitRegions.some(e=>e.group===a)),{flexGrow:o.layout[t]??1,pointerEvents:e?"none":void 0}}return{flexGrow:r?.[t]??1}}),S=nv({defaultLayout:r,disableCursor:s}),T=(0,p.useMemo)(()=>
28({get disableCursor(){return!!S.disableCursor},getPanelStyles:A,id:v,orientation:u,registerPanel:e=>{let t=k.current;return t.panels=oR(u,[...t.panels,e]),N(),()=>{t.panels=t.panels.filter(t=>t!==e),N()}},registerSeparator:e=>{let t=k.current;return t.separators=oR(u,[...t.separators,e]),N(),()=>{t.separators=t.separators.filter(t=>t!==e),N()}},togglePanelDisabled:(e,t)=>{let r=k.current.panels.find(t=>t.id===e);r&&(r.panelConstraints.disabled=t);let s=oU(v),a=oV(v);s&&a&&oH(s,{...a,derivedPanelConstraints:o_(s)})},toggleSeparatorDisabled:(e,t)=>{let r=k.current.separators.find(t=>t.id===e);r&&(r.disabled=t)}}),[A,v,N,u,S]),E=(0,p.useRef)(null);return nx(()=>{let e,t,r,s,a,n,i,l,c,d,m,h,f,p=j.current;if(null===p)return;let g=k.current;if(void 0!==S.defaultLayout&&Object.keys(S.defaultLayout).length===g.panels.length)for(let t of(e={},g.panels)){let r=S.defaultLayout[t.id];void 0!==r&&(e[t.id]=r)}let x={disabled:!!o,element:p,id:v,mutableState:{defaultLayout:e,disableCursor:!!S.disableCursor,expandedPanelSizes:k.current.lastExpandedPanelSizes,layouts:k.current.layouts},orientation:u,panels:g.panels,resizeTargetMinimumSize:g.resizeTargetMinimumSize,separators:g.separators};E.current=x;let w=(t=!0,oz(x.element.ownerDocument.defaultView,"Cannot register an unmounted Group"),r=x.element.ownerDocument.defaultView.ResizeObserver,s=new Set,a=new Set,(n=new r(e=>{for(let r of e){let{borderBoxSize:e,target:s}=r;if(s===x.element){if(t){let e=oM({group:x});if(0===e)return;let t=oV(x.id);if(!t)return;let r=o_(x),s=t.defaultLayoutDeferred?nf(r):t.layout,a=o5({layout:function({group:e,nextGroupSize:t,prevGroupSize:r,prevLayout:s}){if(r<=0||t<=0||r===t)return s;let a=0,o=0,n=!1,i=new Map,l=[];for(let c of e.panels){let e=s[c.id]??0;if("preserve-pixel-size"===c.panelConstraints.groupResizeBehavior){n=!0;let s=oE(e/100*r/t*100);i.set(c.id,s),a+=s}else l.push(c.id),o+=e}if(!n||0===l.length)return s;let c=100-a,d={...s};if(i.forEach((e,t)=>{d[t]=e}),o>0)for(let e of l){let t=s[e]??0;d[e]=oE(t/o*c)}else{let e=oE(c/l.length);for(let t of l)d[t]=e}return d}({group:x,nextGroupSize:e,prevGroupSize:t.groupSize,prevLayout:s}),panelConstraints:r});if(!t.defaultLayoutDeferred&&o2(t.layout,a)&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}(t.derivedPanelConstraints,r)&&t.groupSize===e)return;oH(x,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,groupSize:e,layout:a,separatorToPanels:t.separatorToPanels})}}else!function(e,t,r){if(!r[0])return;let s=e.panels.find(e=>e.element===t);if(!s||!s.onResize)return;let a=oM({group:e}),o="horizontal"===e.orientation?s.element.offsetWidth:s.element.offsetHeight,n=s.mutableValues.prevSize,i={asPercentage:oE(o/a*100),inPixels:o};s.mutableValues.prevSize=i,s.onResize(i,s.id,n)}(x,s,e)}})).observe(x.element),x.panels.forEach(e=>{oz(!s.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),s.add(e.id),e.onResize&&n.observe(e.element)}),i=oM({group:x}),l=o_(x),c=x.panels.map(({id:e})=>e).join(","),(d=x.mutableState.defaultLayout)&&(function(e,t){let r=e.map(e=>e.id),s=Object.keys(t);if(r.length!==s.length)return!1;for(let e of r)if(!s.includes(e))return!1;return!0}(x.panels,d)||(d=void 0)),m=o5({layout:x.mutableState.layouts[c]??d??nf(l),panelConstraints:l}),h=x.element.ownerDocument,np.set(h,(np.get(h)??0)+1),f=new Map,oF(x).forEach(e=>{e.separator&&f.set(e.separator,e.panels)}),oH(x,{defaultLayoutDeferred:0===i,derivedPanelConstraints:l,groupSize:i,layout:m,separatorToPanels:f}),x.separators.forEach(e=>{oz(!a.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),a.add(e.id),e.element.addEventListener("keydown",o9)}),1===np.get(h)&&(h.addEventListener("dblclick",o4,!0),h.addEventListener("pointerdown",ns,!0),h.addEventListener("pointerleave",nd),h.addEventListener("pointermove",nu),h.addEventListener("pointerout",nm),h.addEventListener("pointerup",nh,!0)),function(){t=!1,np.set(h,Math.max(0,(np.get(h)??0)-1)),(oB=new Map(oB)).delete(x),x.separators.forEach(e=>{e.element.removeEventListener("keydown",o9)}),np.get(h)||(h.removeEventListener("dblclick",o4,!0),h.removeEventListener("pointerdown",ns,!0),h.removeEventListener("pointerleave",nd),h.removeEventListener("pointermove",nu),h.removeEventListener("pointerout",nm),h.removeEventListener("pointerup",nh,!0)),n.disconnect()}),{defaultLayoutDeferred:N,derivedPanelConstraints:C,layout:A}=oV(x.id,!0);!N&&C.length>0&&(b(A),y(A));let T=oq(v,e=>{let{defaultLayoutDeferred:t,derivedPanelConstraints:r,layout:s}=e.next;if(t||0===r.length)return;let a=x.panels.map(({id:e})=>e).join(",");x.mutableState.layouts[a]=s,r.forEach(t=>{if(t.collapsible){let{layout:r}=e.prev??{};if(r){let e=oZ(t.collapsedSize,s[t.panelId]),a=oZ(t.collapsedSize,r[t.panelId]);e&&!a&&(x.mutableState.expandedPanelSizes[t.panelId]=r[t.panelId])}}});let o="active"!==ne.state;b(s),o&&y(s)});return()=>{E.current=null,w(),T()}},[o,v,y,b,u,w,S]),(0,p.useEffect)(()=>{let e=E.current;e&&(e.mutableState.defaultLayout=r,e.mutableState.disableCursor=!!s)}),(0,a.jsx)(nj.Provider,{value:T,children:(0,a.jsx)("div",{...f,className:t,"data-group":!0,"data-testid":v,id:v,ref:C,style:{height:"100%",width:"100%",overflow:"hidden",...h,display:"flex",flexDirection:"horizontal"===u?"row":"column",flexWrap:"nowrap",touchAction:"horizontal"===u?"pan-y":"pan-x"},children:e})})}function nN(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function nk({debounceSaveMs:e=100,panelIds:t,storage:r=localStorage,...s}){let a=void 0!==t,o="id"in s?s.id:s.groupId,n=nN(o,t??[]),i=(0,p.useSyncExternalStore)(nC,()=>r.getItem(n),()=>r.getItem(n)),l=(0,p.useMemo)(()=>i?JSON.parse(i):void 0,[i]),c=(0,p.useRef)(null),d=(0,p.useCallback)(()=>
28{let e=c.current;e&&(c.current=null,clearTimeout(e))},[]);(0,p.useLayoutEffect)(()=>()=>{d()},[d]);let u=(0,p.useCallback)(e=>{let t;d(),t=a?nN(o,Object.keys(e)):nN(o,[]);try{r.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[d,a,o,r]);return{defaultLayout:l,onLayoutChange:(0,p.useCallback)(t=>{d(),0===e?u(t):c.current=setTimeout(()=>{u(t)},e)},[d,e,u]),onLayoutChanged:u}}function nC(){return function(){}}function nA(){let e=(0,p.useContext)(nj);return oz(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function nS({children:e,className:t,collapsedSize:r="0%",collapsible:s=!1,defaultSize:o,disabled:n,elementRef:i,groupResizeBehavior:l="preserve-relative-size",id:c,maxSize:d="100%",minSize:u="0%",onResize:m,panelRef:h,style:f,...g}){let x=!!c,b=ng(c),y=nv({disabled:n}),v=(0,p.useRef)(null),j=ny(v,i),{getPanelStyles:w,id:N,orientation:k,registerPanel:C,togglePanelDisabled:A}=nA(),S=null!==m,T=nb((e,t,r)=>{m?.(e,c,r)});nx(()=>{let e=v.current;if(null!==e)return C({element:e,id:b,idIsStable:x,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:S?T:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:r,collapsible:s,defaultSize:o,disabled:y.disabled,maxSize:d,minSize:u}})},[l,r,s,o,S,b,x,d,u,T,C,y]),(0,p.useEffect)(()=>{A(b,!!n)},[n,b,A]),function(e,t){let{id:r}=nA(),s=(0,p.useRef)({collapse:no,expand:no,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:no});(0,p.useImperativeHandle)(t,()=>s.current,[]),nx(()=>{Object.assign(s.current,o3({groupId:r,panelId:e}))})}(b,h);let E=(0,p.useSyncExternalStore)(e=>oq(N,e),()=>JSON.stringify(w(N,b)),()=>JSON.stringify(w(N,b)));return(0,a.jsx)("div",{...g,"aria-disabled":n||void 0,"data-panel":!0,"data-testid":b,id:b,ref:j,style:{...nT,display:"flex",flexBasis:0,flexShrink:1,overflow:"hidden",...JSON.parse(E)},children:(0,a.jsx)("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,...f,touchAction:"horizontal"===k?"pan-y":"pan-x"},children:e})})}nw.displayName="Group",nS.displayName="Panel";let nT={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function nE({children:e,className:t,disabled:r,elementRef:s,id:o,style:n,...i}){let l,c=ng(o),d=nv({disabled:r}),[u,m]=(0,p.useState)({}),[h,f]=(0,p.useState)("inactive"),g=(0,p.useRef)(null),x=ny(g,s),{disableCursor:b,id:y,orientation:v,registerSeparator:j,toggleSeparatorDisabled:w}=nA();return nx(()=>{let e=g.current;if(null!==e){var t;let r={disabled:d.disabled,element:e,id:c},s=j(r),a=(t=e=>{f("inactive"!==e.next.state&&e.next.hitRegions.some(e=>e.separator===r)?e.next.state:"inactive")},nt.addListener("change",t)),o=oq(y,e=>{let{derivedPanelConstraints:t,layout:s,separatorToPanels:a}=e.next,o=a.get(r);if(o){let e=o[0],r=o.indexOf(e);m(function({layout:e,panelConstraints:t,panelId:r,panelIndex:s}){let a,o,n=e[r],i=t.find(e=>e.panelId===r);if(i){let l=i.maxSize,c=i.collapsible?i.collapsedSize:i.minSize,d=[s,s+1];o=o5({layout:o1({delta:c-n,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[r],a=o5({layout:o1({delta:l-n,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[r]}return{valueControls:r,valueMax:a,valueMin:o,valueNow:n}}({layout:s,panelConstraints:t,panelId:e.id,panelIndex:r}))}});return()=>{a(),o(),s()}}},[y,c,j,d]),(0,p.useEffect)(()=>{w(c,!!r)},[r,c,w]),r&&!b&&(l="not-allowed"),(0,a.jsx)("div",{...i,"aria-controls":u.valueControls,"aria-disabled":r||void 0,"aria-orientation":"horizontal"===v?"vertical":"horizontal","aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":r?"disabled":h,"data-testid":c,id:c,ref:x,role:"separator",style:{flexBasis:"auto",cursor:l,...n,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:r?void 0:0})}function nM({className:e,...t}){return(0,a.jsx)(nw,{"data-slot":"resizable-panel-group",className:(0,A.cn)("flex h-full w-full aria-[orientation=vertical]:flex-col",e),...t})}function n_({...e}){return(0,a.jsx)(nS,{"data-slot":"resizable-panel",...e})}function nz({withHandle:e,className:t,...r}){return(0,a.jsx)(nE,{"data-slot":"resizable-handle",className:(0,A.cn)("bg-border focus-visible:ring-ring ring-offset-background relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",t),...r,children:e&&(0,a.jsx)("div",{className:"bg-border z-10 flex h-6 w-1 shrink-0 rounded-lg"})})}nE.displayName="Separator";var nR=e.i(708251);let nP=(0,rF.atom)(null),nI=(0,rF.atom)(null),nL=(0,rF.atom)(!1),nD=(0,rF.atom)(null);var nF=e.i(920755);
28function nO(){let e=(0,n.useAtomValue)(rg),t=(0,n.useSetAtom)(rg),r=(0,n.useAtomValue)(er.blogsAtom);return(0,p.useEffect)(()=>{if(!e)return;let{data:{subscription:r}}=(0,nF.createClient)().auth.onAuthStateChange(e=>{"SIGNED_IN"===e&&console.log("[OnboardingAuthHandler] User authenticated, onboarding will resume"),"SIGNED_OUT"===e&&(console.log("[OnboardingAuthHandler] User signed out, clearing in-progress flag"),t(!1))});return()=>{r.unsubscribe()}},[e,t]),(0,p.useEffect)(()=>{e&&r.length>0&&(console.log("[OnboardingAuthHandler] User has blogs, clearing in-progress flag"),t(!1))},[e,r.length,t]),null}function nB(){let e=(0,n.useAtomValue)(b.feedsLoadingAtom),t=(0,n.useAtomValue)(b.feedLoadingProgressAtom),[r,s]=(0,p.useState)(0);return(0,p.useEffect)(()=>{if(e)if(t)s(t.loaded/t.total*100);else{let e=setInterval(()=>{s(e=>e<70?e+10*Math.random():e<90?e+2*Math.random():e+.5*Math.random())},200);return()=>clearInterval(e)}else{s(100);let e=setTimeout(()=>{s(0)},400);return()=>clearTimeout(e)}},[e,t]),(0,a.jsx)(rT.AnimatePresence,{children:(e||r>0)&&(0,a.jsx)(rS.motion.div,{initial:{opacity:0}
28,animate:{opacity:1},exit:{opacity:0},className:"fixed top-0 left-0 right-0 z-50 h-1",children:(0,a.jsx)(rS.motion.div,{className:"h-full bg-primary",initial:{width:"0%"},animate:{width:`${Math.min(r,100)}%`},transition:{duration:.2,ease:"easeOut"},style:{boxShadow:r<100?"0 0 10px rgba(var(--primary), 0.6)":"none"}})})})}function n$(){let e=(0,n.useAtomValue)(er.unreadCountAtom),t=(0,n.useAtomValue)(b.showUnreadCountInTitleAtom);return(0,p.useEffect)(()=>(t&&e>0?document.title=`(${e}) ${tK.APP_NAME}`:document.title=tK.APP_NAME,()=>{document.title=tK.APP_NAME}),[e,t]),null}function nU({className:e,variant:t="full"}){let r=(0,n.useAtomValue)(er.proxyDisabledCountAtom),s=(0,n.useAtomValue)(er.proxyDisabledFeedsAtom),o=(0,n.useAtomValue)(T.extensionAvailableAtom),[i,l]=(0,n.useAtom)(b.proxyBannerDismissedAtom);if(0===r||o||i)return null;let c=()=>{window.open(tK.EXTENSION_URLS.LANDING,"_blank","noopener,noreferrer")},d=()=>{l(!0)},m=s.slice(0,5).map(e=>e.blogTitle).join(", "),h=s.length>5;return"compact"===t?(0,a.jsxs)("div",{className:(0,A.cn)("flex items-center gap-2 px-3 py-2 bg-amber-500/10 border-b border-amber-500/20",e),children:[(0,a.jsx)(eR.AlertTriangle,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,a.jsxs)("span",{className:"text-xs text-amber-700 dark:text-amber-300 flex-1 truncate",children:[r," feed",1!==r?"s":""," unavailable"]}),(0,a.jsxs)(u.Button,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-amber-700 dark:text-amber-300 hover:bg-amber-500/20",onClick:c,children:[(0,a.jsx)(r0.Download,{className:"size-3 mr-1"}),"Extension"]}),(0,a.jsx)("button",{onClick:d,className:"p-1 rounded hover:bg-amber-500/20 text-amber-600 dark:text-amber-400","aria-label":"Dismiss",children:(0,a.jsx)(F.X,{className:"size-3"})})]}):(0,a.jsx)("div",{className:(0,A.cn)("relative px-4 py-3 bg-gradient-to-r from-amber-500/10 via-orange-500/10 to-amber-500/10","border-b border-amber-500/20",e),children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"p-2 rounded-full bg-amber-500/20 shrink-0",children:(0,a.jsx)(E.Zap,{className:"size-4 text-amber-600 dark:text-amber-400"})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("h4",{className:"font-medium text-sm text-amber-700 dark:text-amber-300",children:[r," feed",1!==r?"s":""," couldn't load"]}),(0,a.jsx)("p",{className:"text-xs text-amber-600/80 dark:text-amber-400/80",children:"The server proxy is temporarily disabled due to high load. Install the browser extension to read feeds directly."}),(0,a.jsxs)("p",{className:"text-xs text-amber-600/60 dark:text-amber-400/60 truncate",children:["Affected: ",m,h&&` +${s.length-5} more`]})]}),(0,a.jsx)("div",{className:"flex items-center gap-2 shrink-0",children:(0,a.jsxs)(u.Button,{size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white",onClick:c,children:[(0,a.jsx)(r0.Download,{className:"size-4 mr-2"}
28),"Install Extension",(0,a.jsx)(ez.ExternalLink,{className:"size-3 ml-1.5 opacity-60"})]})})]})}),(0,a.jsx)("button",{onClick:d,className:"p-1.5 rounded-full hover:bg-amber-500/20 text-amber-600 dark:text-amber-400 shrink-0","aria-label":"Dismiss banner",children:(0,a.jsx)(F.X,{className:"size-4"})})]})})}function nV({className:e,variant:t="full"}){let{isOnline:r}=(0,x.useNetworkStatus)(),[s,o]=(0,p.useState)(!1);return((0,p.useEffect)(()=>{r&&o(!1)},[r]),r||s)?null:(0,a.jsxs)("div",{className:(0,A.cn)("flex items-center gap-2 px-3 py-1.5 bg-amber-500/10 border-b border-amber-500/20",e),children:[(0,a.jsx)(k.WifiOff,{className:"size-3.5 text-amber-600 dark:text-amber-400 shrink-0"}),(0,a.jsx)("span",{className:(0,A.cn)("flex-1 text-amber-700 dark:text-amber-300","compact"===t?"text-xs truncate":"text-xs"),children:"compact"===t?"Offline — posts still available":"You're offline — everything still works, new posts will load when you reconnect"}),(0,a.jsx)("button",{onClick:()=>o(!0),className:"p-1 rounded hover:bg-amber-500/20 text-amber-600 dark:text-amber-400 shrink-0","aria-label":"Dismiss offline banner",children:(0,a.jsx)(F.X,{className:"size-3"})})]})}var nq=e.i(839428),nH=e.i(266027);class nG{value;next;constructor(e){this.value=e}}class nW{#t;#r;#s;constructor(){this.clear()}enqueue(e){let t=new nG(e);this.#t?this.#r.next=t:this.#t=t,this.#r=t,this.#s++}dequeue(){let e=this.#t;if(e)return this.#t=this.#t.next,this.#s--,this.#t||(this.#r=void 0),e.value}peek(){if(this.#t)return this.#t.value}clear(){this.#t=void 0,this.#r=void 0,this.#s=0}get size(){return this.#s}*[Symbol.iterator](){let e=this.#t;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#t;)yield this.dequeue()}}function nK(e){if(!((Number.isInteger(e)||e===1/0)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up")}async function nY(e,t){let r;r="object"==typeof t&&null!==t?t:{requiresProxy:t};let s=await (0,tS.getCachedFeedWithHeaders)(e),a={requiresProxy:r.requiresProxy,source:r.source,catalogBlogId:r.catalogBlogId||null,conditionalHeaders:s?.etag||s?.lastModified?{etag:s.etag,lastModified:s.lastModified}:void 0},o=await (0,tA.parseFeed)(e,a);return o.notModified&&s?(console.log(`[Feed Refresh] Using cached data (304 Not Modified): ${e}`),{feed:{metadata:s.metadata,posts:s.posts},wasModified:!1,usedProxy:o.usedProxy||!1,cacheHit:!0}):(await (0,tS.setCachedFeed)(e,{metadata:o.metadata,posts:o.posts},o.etag,o.lastModified),{feed:{metadata:o.metadata,posts:o.posts},wasModified:!0,usedProxy:o.usedProxy||!1,cacheHit:!1})}let nQ="blogs-are-back-last-visit",nX="catalog-metadata-checked-at",nZ="catalog-metadata-versions";function nJ(e){try{localStorage.setItem(nX,String(e))}catch{}}async function n0(e,t,r){let s,a={checkedCount:0,refreshedCount:0,refreshedBlogIds:[]},o=function(){try{let e=localStorage.getItem(nX);return e?parseInt(e,10):null}catch{return null}}();if(o&&Date.now()-o<216e5)return a;let n=e.filter(e=>"directory"===e.source||"community"===e.source);if(0===n.length)return nJ(Date.now()),a;let i=function(){try{let e=localStorage.getItem(nZ);if(!e)return null;let t=JSON.parse(e);if(Date.now()-t.cachedAt>216e5)return null;return t}catch{return null}}();if(i)s=i.data;else try{let e=await fetch("/api/catalog/metadata-versions",{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw Error(`HTTP ${e.status}`);var l=s=await e.json();try{let e={data:l,cachedAt:Date.now()};localStorage.setItem(nZ,JSON.stringify(e))}catch{}}catch(t){let e=function(){try{let e=localStorage.getItem(nZ);if(!e)return null;let t=JSON.parse(e);if(Date.now()-t.cachedAt>864e5)return null;return t}catch{return null}}();if(!e)return console.log("[CatalogMetadata] Failed to fetch versions, skipping:",t),a;console.log("[CatalogMetadata] Using stale versions cache (offline/error fallback)"),s=e.data}let c=o||0,d=[],u=[];for(let e of n)if("directory"===e.source&&e.directory_blog_id){let t=s.directory[e.directory_blog_id];t&&new Date(t).getTime()>c&&d.push(e.directory_blog_id)}else if("community"===e.source&&e.community_blog_id){let t=s.community[e.community_blog_id];t&&new Date(t).getTime()>c&&u.push(e.community_blog_id)}let m=d.length+u.length;if(console.log(`[CatalogMetadata] Checked ${n.length} catalog blogs, ${m}
28 have updated metadata`),0===m)return nJ(Date.now()),{checkedCount:n.length,refreshedCount:0,refreshedBlogIds:[]};try{let e=await fetch("/api/blogs/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory_ids:d,community_ids:u})});if(!e.ok)throw Error(`HTTP ${e.status}`);let{blogs:s}=await e.json(),a=[],o=new Map(s.map(e=>[`${e.source}:${e.id}`,e]));for(let e of n){let s="directory"===e.source?e.directory_blog_id:e.community_blog_id;if(!s)continue;let n=o.get(`${e.source}:${s}`);n&&t.updateBlogStatusValues&&(await t.updateBlogStatusValues(r,e.id,e.source,{title:n.title,url:n.url,feed_url:n.feed_url,description:n.description,site_icon:n.site_icon,has_full_content:n.has_full_content,blocks_iframe:n.blocks_iframe,requires_proxy:n.requires_proxy,posts_require_proxy:n.posts_require_proxy,has_partial_archive:n.has_partial_archive,category:n.category,languages:n.languages}),a.push(e.id))}return console.log(`[CatalogMetadata] Refreshed metadata for ${a.length} blogs:`,a),nJ(Date.now()),{checkedCount:n.length,refreshedCount:a.length,refreshedBlogIds:a}}catch(e){return console.log("[CatalogMetadata] Failed to refresh stale metadata:",e),a}}var n1=e.i(215815),n2=e.i(964586),n5=e.i(39639),n3=e.i(483476),n4=e.i(378746);let{LOG_PREFIX:n6,STALE_RECORD_DAYS:n8,MAX_HASHES_PER_BLOG:n7}=n4.READ_STATUS_RETENTION_CONFIG;async function n9(e,t){let r=await (0,n3.openLocalStorageDB)(),s=await r.getAllFromIndex("read_status","by-u
28serId",e),a=Date.now()-24*n8*36e5,o=0;for(let e of s){let s=t.has(e.blog_id),n=e.updated_at<a;!s&&n&&(await r.delete("read_status",e.id),o++)}return o>0&&console.log(`${n6} Removed ${o} stale records`),o}let ie=[];function it({children:e}){let t,r,s,o,i,l,c;t=(0,f.useStorage)(),r=(0,f.useUserId)(),s=(0,n.useSetAtom)(tE.userSettingsAtom),o=(0,n.useSetAtom)(tE.settingsLoadingAtom),i=(0,n.useSetAtom)(ea.preferredLanguagesAtom),l=(0,n.useSetAtom)(ea.enableLanguageFilterSidebarAtom),(0,p.useEffect)(()=>{c()},[]),c=async()=>{o(!0);try{let e=await (0,tT.getUserSettings)(t,r);e&&(s(e),e.preferred_languages&&e.preferred_languages.length>0&&i(e.preferred_languages),void 0!==e.enable_language_filter_sidebar&&l(e.enable_language_filter_sidebar))}catch(e){console.error("Error loading user settings:",e)}finally{o(!1)}};let{data:d=ie,isLoading:u}=(0,nq.useFollowedBlogs)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ir,{}),(0,a.jsx)(is,{blogs:d,blogsLoading:u}),(0,a.jsx)(ia,{blogs:d,blogsLoading:u}),(0,a.jsx)(io,{}),(0,a.jsx)(ii,{blogs:d}),(0,a.jsx)(il,{blogs:d,blogsLoading:u}),(0,a.jsx)(ic,{blogs:d,blogsLoading:u}),(0,a.jsx)(iu,{}),e]})}function ir(){let e=(0,tg.useQueryClient)();return(0,p.useEffect)(()=>{let t=()=>{console.log("[DataProvider] Sync pull complete, invalidating queries..."),e.invalidateQueries({queryKey:["read-status"]}),e.invalidateQueries({queryKey:["favorites"]}),e.invalidateQueries({queryKey:["read-later"]}),e.invalidateQueries({queryKey:["blogs","followed"]})};return window.addEventListener("sync-pull-complete",t),()=>window.removeEventListener("sync-pull-complete",t)},[e]),null}function is({blogs:e,blogsLoading:t}){let r=(0,n.useSetAtom)(er.blogsAtom),s=(0,n.useSetAtom)(er.hasNoBlogsAtom),a=(0,n.useSetAtom)(er.blogsLoadingAtom),o=(0,n.useSetAtom)(b.feedsLoadingAtom);return(0,p.useEffect)(()=>{e&&(r(e),s(0===e.length))},[e,r,s]),(0,p.useEffect)(()=>{t?o(!0):0===e.length&&o(!1),a(t)},[t,e.length,a,o]),null}function ia({blogs:e,blogsLoading:t}){let r=(0,n.useSetAtom)(b.timelineRefetchAtom),s=(0,n.useSetAtom)(er.cleanupPostsAtom),{data:o=[],refetch:i,loadingPhase:l}=function(e){let t,r,s,a=(0,n.useSetAtom)(er.postsAtom),o=(0,n.useSetAtom)(b.feedsLoadingAtom),i=(0,n.useSetAtom)(b.isNetworkRefreshingAtom),l=(0,n.useSetAtom)(b.loadingPhaseAtom),{isOnline:c}=(0,x.useNetworkStatus)(),d=(0,p.useRef)(!1),u=(0,p.useRef)(!1),{data:m,isLoading:h,dataUpdatedAt:g}=(t=(0,f.useUserId)(),r=(0,n.useAtomValue)(tE.historyLimitsAtom),s=(0,p.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),(0,nH.useQuery)({queryKey:["cached-timeline",t,s,r.max_posts_per_feed,r.max_days_back,r.min_posts_per_feed],queryFn:async()=>{if(0===e.length)return[];let t=e.map(async e=>{try{let t=await (0,tS.getCachedFeed)(e.feed_url);if(!t)return null;return(0,tT.applyHistoryLimits)(t.posts,r).map(t=>{let{content:r,...s}=t;return{...s,blogTitle:e.title,blogId:"directory"===e.source&&e.directory_blog_id?e.directory_blog_id:"community"===e.source&&e.community_blog_id?e.community_blog_id:e.id,blogIcon:e.site_icon}})}catch(t){return console.log(`[Cache] Failed to load cache for ${e.title}:`,t),null}}),s=await Promise.all(t),a=s.filter(e=>null!==e).flat();return console.log(`[Cache] Loaded ${a.length} posts from ${s.filter(Boolean).length}/${e.length} cached blogs`),a},enabled:e.length>0,networkMode:"always",staleTime:1/0,gcTime:6e4,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1})),{data:y,isLoading:v,isFetching:j,dataUpdatedAt:w,refetch:N,isBackgroundRefreshing:k}=function(e){let t=(0,f.useStorage)(),r=(0,f.useUserId)(),s=(0,tg.useQueryClient)(),a=(0,n.useAtomValue)(tE.historyLimitsAtom),o=(0,n.useSetAtom)(er.failedFeedsAtom),i=(0,n.useSetAtom)(er.postsAtom),l=(0,n.useSetAtom)(sr),c=(0,n.useSetAtom)(b.feedLoadingProgressAtom),d=(0,n.useAtomValue)(b.isManualRefreshAtom),u=(0,p.useRef)(!1);u.current=d;let{data:m}=(0,eg.useUserSettings)(),h=(0,p.useRef)([]),g=(0,p.useRef)(0),x=(0,p.useRef)(0),y=(0,p.useRef)({loaded:0,total:0,pending:0,generation:0}),v=(0,p.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),j=(0,nH.useQuery)({queryKey:["timeline",r,v,a.max_posts_per_feed,a.max_days_back,a.min_posts_per_feed],queryFn:async()=>{try{let n;if(h.current=[],0===e.length)return c(null),[];let i=[],d=m?.use_directory_updates??!0,f=e.filter(e=>"directory"===e.source&&e.directory_blog_id).map(e=>({id:e.directory_blog_id,title:e.title})),p=f.map(e=>e.id),g=e.filter(e=>"community"===e.source&&e.community_blog_id).map(e=>({id:e.community_blog_id,title:e.title})),b=g.map(e=>e.id),v={success:!1,catalog:"directory",updatedBlogIds:new Set},j={success:!1,catalog:"community",updatedBlogIds:new Set},w=(e,t,r)=>{if(!e.success)return{status:"error",updatedCount:0,followedCount:t,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:e.error||"Unable to reach the catalog updates service"};{let s=r.filter(t=>e.updatedBlogIds.has(t)).length;return{status:"success",updatedCount:s,followedCount:t,totalBlogs:e.metadata?.totalBlogs??null,lastCheckedAt:e.metadata?.lastCheckedAt??null,nextCheckAt:e.metadata?.nextCheckAt??null,sinceTimestamp:e.metadata?.sinceTimestamp??null,error:void 0}}};if(d){l(e=>ss(e,{isEnabled:!0,directory:{status:"checking",updatedCount:0,followedCount:p.length,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:void 0},community:{status:"checking",updatedCount:0,followedCount:b.length,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:void 0}}));let t=function(){let e=localStorage.getItem(nQ);if(!e)return null;try{let t=parseInt(e,10);if(isNaN(t))return null;return new Date(t)}catch{return null}}();console.log("[Timeline] Checking catalog updates since:",t?.toISOString()||"all time");let r=e.filter(e=>"custom"===e.source).map(e=>({feedUrl:e.feed_url,title:e.title,lastPostDate:null})),s=e.map(e=>e.feed_url);(0,s0.syncAllBlogsToExtension)(f,g,r,s,t);let a=p.length>0,o=b.length>0,n=a||o?await (0,r8.checkCatalogSnapshot)(t||void 0,{directory:p,community:b}):null,i=n?.directory??{success:!0,catalog:"directory",updatedBlogIds:new Set},c=n?.community??{success:!0,catalog:"community",updatedBlogIds:new Set};v=i,j=c,v.success?console.log(`[Timeline] Directory updates: ${v.updatedBlogIds.size} blogs with new content`):console.warn("[Timeline] Directory updates check failed:",v.error),j.success?console.log(`[Timeline] Community updates: ${j.updatedBlogIds.size} blogs with new content`):console.warn("[Timeline] Community updates check failed:",j.error),l(e=>ss(e,{isEnabled:!0,directory:w(v,p.length,p),community:w(j,b.length,b)}))}else console.log("[Timeline] Catalog updates disabled in user settings - fetching all feeds"),l(e=>ss(e,{isEnabled:!1,directory:{status:"disabled",updatedCount:0,followedCount:p.length,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:void 0},community:{status:"disabled",updatedCount:0,followedCount:b.length,totalBlogs:null,lastCheckedAt:null,nextCheckAt:null,sinceTimestamp:void 0,error:void 0}}));let N=e.filter(e=>"directory"===e.source||"community"===e.source);N.length>0&&n0(N,t,r).then(e=>{e.refreshedCount>0&&s.invalidateQueries({queryKey:["blogs","followed",r]})}).catch(()=>{});let k=new Map;if(d){let t=e.filter(e=>"directory"===e.source&&e.directory_blog_id).filter(e=>!e.category||"indie"===e.category||"unknown"===e.category),r=e.filter(e=>"community"===e.source&&e.community_blog_id),s=[...t,...r];await Promise.all(s.map(async e=>{let t=await (0,tS.getLastFetchedTimestamp)(e.feed_url);k.set(e.feed_url,null!==t)})),console.log(`[Timeline] Checked cache existence for ${s.length} catalog blogs`)}let C=new Set;if(d){for(let t of e)"directory"===t.source&&t.directory_blog_id&&(t.category&&"indie"!==t.category&&"unknown"!==t.category||!v.success||v.updatedBlogIds.has(t.directory_blog_id)||C.add(t.feed_url)),"community"===t.source&&t.community_blog_id&&j.success&&!j.updatedBlogIds.has(t.community_blog_id)&&C.add(t.feed_url);C.size>
280&&console.log(`[Timeline] ${C.size} catalog blog(s) confirmed no new content — skipping background refresh`)}let A=[...e.filter(e=>{var t;let r;if(r=(t=e).feed_status||"active","disabled"===r||"paused"===r&&t.feed_paused_until&&new Date(t.feed_paused_until)>new Date||0)return console.log(`[Timeline] Skipping ${e.title} (status: ${e.feed_status})`),!1;if((e.feed_error_count||0)>0&&!function(e){if(!e.feed_last_error_at||!e.feed_error_count)return!0;let t=new Date(e.feed_last_error_at).getTime(),r=function(e){if(0===e)return 0;let t=[6e4,3e5,18e5,72e5,216e5],r=Math.min(e-1,t.length-1);return t[r]}(e.feed_error_count);return Date.now()-t>=r}(e))return console.log(`[Timeline] Skipping ${e.title} (in backoff period)`),!1;if("directory"===e.source&&e.directory_blog_id){if(!e.category||"indie"===e.category||"unknown"===e.category){let t=k.get(e.feed_url);return!0===t?(console.log(`[Timeline] Including ${e.title} (cache exists, will check if refresh needed)`),!0):!1===t?e.last_fetched_at?(0,r8.shouldFetchCatalogBlog)(e.directory_blog_id,v.updatedBlogIds,!v.success)?(console.log(`[Timeline] Fetching ${e.title} (no cache, server indicates updates)`),!0):(console.log(`[Timeline] Skipping ${e.title} (no cache, no server updates)`),!1):(console.log(`[Timeline] Fetching ${e.title} (newly followed, never fetched before)`),!0):(console.log(`[Timeline] Including ${e.title} (cache state unknown)`),!0)}console.log(`[Timeline] Fetching ${e.title} (${e.category} blog, bypassing server optimization)`)}if("community"===e.source&&e.community_blog_id){let t=k.get(e.feed_url);if(!0===t)return console.log(`[Timeline] Including ${e.title} (cache exists, will check if refresh needed)`),!0;if(!1===t)return e.last_fetched_at?(0,r8.shouldFetchCatalogBlog)(e.community_blog_id,j.updatedBlogIds,!j.success)?(console.log(`[Timeline] Fetching ${e.title} (no cache, server indicates updates)`),!0):(console.log(`[Timeline] Skipping ${e.title} (no cache, no server updates)`),!1):(console.log(`[Timeline] Fetching ${e.title} (newly followed, never fetched before)`),!0);console.log(`[Timeline] Including ${e.title} (cache state unknown)`)}return!0})].sort((e,t)=>{let r=!1===k.get(e.feed_url),s=!1===k.get(t.feed_url);if(r&&!s)return -1;if(!r&&s)return 1;if("custom"===e.source&&"custom"!==t.source)return -1;if("custom"!==e.source&&"custom"===t.source)return 1;let a=(e.feed_error_count||0)>0,o=(t.feed_error_count||0)>0;return a&&!o?1:!a&&o?-1:0}),S=A.length;x.current=0;let T=++y.current.generation;y.current={loaded:0,total:S,pending:0,generation:T},c({loaded:0,total:S});let E=()=>{if(y.current.generation!==T)return;y.current.loaded++,y.current.pending--;let{loaded:e,total:t,pending:r}=y.current;c({loaded:e,total:t}),0===r&&setTimeout(()=>{y.current.generation===T&&c(null)},800)},M=window.innerWidth<768?tK.FEED_FETCH_CONFIG.MAX_CONCURRENT_REQUESTS_MOBILE:tK.FEED_FETCH_CONFIG.MAX_CONCURRENT_REQUESTS,_=function(e){let t=!1;if("object"==typeof e&&({concurrency:e,rejectOnClear:t=!1}=e),nK(e),"boolean"!=typeof t)throw TypeError("Expected `rejectOnClear` to be a boolean");let r=new nW,s=0,a=()=>{s<e&&r.size>0&&(s++,r.dequeue().run())},o=async(e,t,r)=>{let o=(async()=>e(...r))();t(o);try{await o}catch{}s--,a()},n=(t,...n)=>new Promise((i,l)=>{let c;c={reject:l},new Promise(e=>{c.run=e,r.enqueue(c)}).then(o.bind(void 0,t,i,n)),s<e&&a()});return Object.defineProperties(n,{activeCount:{get:()=>s},pendingCount:{get:()=>r.size},clearQueue:{value(){if(!t)return void r.clear();let e=AbortSignal.abort().reason;for(;r.size>0;)r.dequeue().reject(e)}},concurrency:{get:()=>e,set(t){nK(t),e=t,queueMicrotask(()=>{for(;s<e&&r.size>0;)a()})}},map:{async value(e,t){return Promise.all(Array.from(e,(e,r)=>this(t,e,r)))}}}),n}(M);console.log(`[Timeline] Fetching ${S} feeds with max ${M} concurrent requests`);let z=await Promise.allSettled(A.map(e=>_(async()=>{try{let s,n=u.current,i=n?(0,tS.getManualRefreshThreshold)(e.requires_proxy):void 0,l=await (0,tS.getCachedFeedWithMeta)(e.feed_url,i);if(l){if((s=l.feed).posts=(0,tT.applyHistoryLimits)(s.posts,a),l.isStale&&(n||!C.has(e.feed_url))){y.current.generation===T&&y.current.pending++;let s={feedUrl:e.feed_url,blogId:(0,tR.getEffectiveBlogId)(e),blogTitle:e.title,blogIcon:e.site_icon},a=nY(e.feed_url,{requiresProxy:e.requires_proxy,source:e.source,catalogBlogId:e.directory_blog_id||e.community_blog_id||null}).then(async a=>(a.wasModified&&t.recordFeedSuccess&&await t.recordFeedSuccess(r,e),"custom"===e.source&&void 0!==a.usedProxy&&e.requires_proxy!==a.usedProxy&&t.updateBlogProxyStatus&&await t.updateBlogProxyStatus(r,e,a.usedProxy),E(),{wasModified:a.wasModified,blogInfo:a.wasModified?s:void 0})).catch(async s=>{let a=s instanceof Error?s.message:String(s);
28console.log(`[Feed] Background refresh failed for ${e.title}:`,a);let n=s instanceof tA.FeedParserError?s.httpStatus:void 0,i=tN(s instanceof Error?s:a,n);return t.recordFeedError&&await t.recordFeedError(r,e,i.message),o(t=>{let r=new Map(t),s=t.get(e.id);return r.set(e.id,{blogId:e.id,blogTitle:e.title,feedUrl:e.feed_url,error:i.message,errorType:i.type,httpStatus:i.httpStatus,isTransient:i.isTransient,suggestion:i.suggestion,timestamp:new Date,isBackgroundRefresh:!0,retryCount:(s?.retryCount||0)+1,extensionRequired:i.extensionRequired}),r}),E(),{wasModified:!1}});h.current.push(a)}}else{let o=await nY(e.feed_url,{requiresProxy:e.requires_proxy,source:e.source,catalogBlogId:e.directory_blog_id||e.community_blog_id||null});(s=o.feed).posts=(0,tT.applyHistoryLimits)(s.posts,a),o.wasModified&&t.recordFeedSuccess&&await t.recordFeedSuccess(r,e),"custom"===e.source&&void 0!==o.usedProxy&&e.requires_proxy!==o.usedProxy&&t.updateBlogProxyStatus&&await t.updateBlogProxyStatus(r,e,o.usedProxy)}if(o(t=>{if(t.has(e.id)){let r=new Map(t);return r.delete(e.id),r}return t}),y.current.generation===T){!l?.isStale&&y.current.loaded++;let{loaded:e,pending:t}=y.current,r=Math.floor(e/S*10),s=e+t===S;(r>x.current||s)&&(x.current=r,c({loaded:e,total:S}))}return s.posts.map(t=>{let{content:r,...s}=t;return{...s,blogTitle:e.title,blogId:(0,tR.getEffectiveBlogId)(e),blogIcon:e.site_icon}})}catch(d){let s=d instanceof Error?d.message:String(d);console.log(`[Feed] Failed to fetch ${e.title}:`,s);let a=d instanceof tA.FeedParserError?d.httpStatus:void 0,o=tN(d instanceof Error?d:s,a);t.recordFeedError&&t.recordFeedError(r,e,o.message).catch(e=>{console.log("[Feed] Failed to record feed error:",e.message)});let n=i.find(t=>t.blogId===e.id),l={blogId:e.id,blogTitle:e.title,feedUrl:e.feed_url,error:o.message,errorType:o.type,httpStatus:o.httpStatus,isTransient:o.isTransient,suggestion:o.suggestion,timestamp:new Date,isBackgroundRefresh:!1,retryCount:n?n.retryCount+1:1,extensionRequired:o.extensionRequired};if(i.push(l),y.current.generation===T){y.current.loaded++;let{loaded:e,pending:t}=y.current,r=Math.floor(e/S*10),s=e+t===S;(r>x.current||s)&&(x.current=r,c({loaded:e,total:S}))}return[]}})));if(y.current.generation===T&&0===y.current.pending&&c(null),i.length>0)if(o(e=>{let t=new Map(e);return i.forEach(e=>{t.set(e.blogId,e)}),t}),1===i.length){let e=i[0];th.toast.error(`Failed to load ${e.blogTitle}`,{description:e.suggestion||(e.error.length>100?e.error.substring(0,100)+"...":e.error),duration:5e3})}else th.toast.error(`Failed to load ${i.length} feeds`,{description:i.map(e=>e.blogTitle).join(", "),duration:5e3});let R=z.filter(e=>"fulfilled"===e.status).flatMap(e=>e.value);return n=Date.now(),localStorage.setItem(nQ,n.toString()),R}catch(e){return console.log("[Feed] Unexpected error in timeline fetch:",e instanceof Error?e.message:String(e)),[]}},enabled:e.length>0,refetchOnMount:!0,refetchOnWindowFocus:!1,staleTime:tK.CACHE_CONFIG.TIMELINE_STALE_TIME_MS,gcTime:6e4});(0,p.useEffect)(()=>{let e=h.current;if(0===e.length||j.dataUpdatedAt===g.current)return;g.current=j.dataUpdatedAt;let t=!1;return Promise.allSettled(e).then(async e=>{if(t)return;let r=[];for(let t of e)"fulfilled"===t.status&&t.value.wasModified&&t.value.blogInfo&&r.push(t.value.blogInfo);if(r.length>0){console.log(`[Timeline] Background refresh completed: ${r.length} feed(s) had new content, merging directly`);let e=r.map(async e=>{try{let t=await (0,tS.getCachedFeed)(e.feedUrl);if(!t)return[];return(0,tT.applyHistoryLimits)(t.posts,a).map(t=>{let{content:r,...s}=t;return{...s,blogTitle:e.blogTitle,blogId:e.blogId,blogIcon:e.blogIcon}})}catch(t){return console.log(`[Timeline] Failed to read cache for ${e.blogTitle}:`,t),[]}}),t=(await Promise.all(e)).flat();if(t.length>0){let e=new Set(r.map(e=>e.blogId));i(r=>{let s=r.filter(t=>!e.has(t.blogId||"")),a=new Set,o=[];for(let e of[...s,...t]){let t=e.guid||e.link;t&&!a.has(t)&&(a.add(t),o.push(e))}return o}),console.log(`[Timeline] Merged ${t.length} posts from ${r.length} updated feed(s)`)}}else e.length>
280&&console.log(`[Timeline] Background refresh completed: ${e.length} feed(s) checked, no new content`);h.current=[]}),()=>{t=!0}},[j.dataUpdatedAt,a,i]);let w=j.isFetching&&!j.isLoading;return{...j,isBackgroundRefreshing:w}}(e),C=(0,p.useMemo)(()=>0===e.length?"idle":h&&!d.current?"cache":c?j?"network":w>0?"complete":"idle":"complete",[e.length,h,j,c,w]);(0,p.useEffect)(()=>{l(C)},[C,l]),(0,p.useEffect)(()=>{m&&m.length>0&&!d.current&&(console.log(`[Progressive] Phase 1: Showing ${m.length} cached posts immediately`),a(m),d.current=!0)},[m,a]),(0,p.useEffect)(()=>{y&&y.length>0&&w>0&&(!d.current||w>g)&&(console.log(`[Progressive] Phase 2: Updating with ${y.length} posts from network`),a(y),u.current=!0)},[y,w,g,a]),(0,p.useEffect)(()=>{let t=!d.current&&("cache"===C||"network"===C),r=0===e.length&&h;o(t||r)},[C,e.length,h,o]),(0,p.useEffect)(()=>{i(c&&(j||k)&&d.current)},[c,j,k,i]);let A=(0,p.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]);return(0,p.useEffect)(()=>()=>{d.current=!1,u.current=!1},[A]),{data:(0,p.useMemo)(()=>y&&y.length>0?y:m&&m.length>0?m:[],[y,m]),isLoading:"cache"===C&&!d.current,isCacheLoading:h,isNetworkLoading:v,isNetworkFetching:j,isBackgroundRefreshing:k||j&&d.current,loadingPhase:C,cacheUpdatedAt:g,networkUpdatedAt:w,dataUpdatedAt:w>0?w:g,refetch:N,hasCachedData:d.current,hasNetworkData:w>0}}(e);(0,p.useEffect)(()=>{r(()=>i)},[i,r]);let c=(0,p.useRef)(!1),d=(0,p.useRef)(0);return(0,p.useEffect)(()=>{let e=o.length!==d.current;if(d.current=o.length,o.length>0&&e&&!c.current){c.current=!0;let e=setTimeout(()=>{s(),c.current=!1},1e3);return()=>{clearTimeout(e),c.current=!1}}},[o.length,s]),(0,p.useEffect)(()=>{let e=setInterval(()=>{s()},3e5);return()=>clearInterval(e)},[s]),(0,a.jsx)(id,{loadingPhase:l,timelinePostsLength:o.length,blogsLoading:t,blogsLength:e.length})}function io(){let e=(0,n.useSetAtom)(er.readPostGuidsAtom),t=(0,n.useSetAtom)(er.starredPostGuidsAtom),r=(0,n.useSetAtom)(er.readLaterPostGuidsAtom),{data:s}=(0,n1.useReadStatus)(),{data:a}=(0,n2.useFavoriteGuids)(),{data:o}=(0,n5.useReadLaterGuids)();return(0,p.useEffect)(()=>{s&&e(s)},[s,e]),(0,p.useEffect)(()=>{a&&t(a)},[a,t]),(0,p.useEffect)(()=>{o&&r(o)},[o,r]),null}function ii({blogs:e}){let t=(0,n.useSetAtom)(er.storedFavoritePostsAtom),r=(0,n.useSetAtom)(er.storedReadLaterPostsAtom),{data:s}=(0,n2.useFavoritePosts)(),{data:a}=(0,n5.useReadLaterPosts)(),o=(0,p.useRef)(new Map),i=(0,p.useMemo)(()=>{let t=new Map(e.map(e=>[(0,tR.getEffectiveBlogId)(e),e.site_icon])),r=o.current;if(r.size===t.size){let e=!0;for(let[s,a]of t)if(r.get(s)!==a){e=!1;break}if(e)return r}return o.current=t,t},[e]);return(0,p.useEffect)(()=>{if(!s)return;let e=!1;return(async()=>{let r=s.filter(e=>!i.has(e.blog_id)&&("directory"===e.blog_source||"community"===e.blog_source)).map(e=>({blogId:e.blog_id,blogSource:e.blog_source})),a=r.length>0?await (0,ax.ensureCatalogBlogsCached)(r):new Map;if(e)return;let o=await Promise.all(s.map(async e=>{let t=(0,ax.favoritePostToFeedPost)(e),r=i.get(e.blog_id);if(r)t.blogIcon=r;else{let r=a.get(e.blog_id);if(r?.site_icon)t.blogIcon=r.site_icon;else{let r=await (0,ax.getCachedBlogMeta)(e.blog_id);r?.site_icon&&(t.blogIcon=r.site_icon)}}return t}));e||t(o)})(),()=>{e=!0}},[s,i,t]),(0,p.useEffect)(()=>{if(!a)return;let e=!1;return(async()=>{let t=a.filter(e=>!i.has(e.blog_id)&&("directory"===e.blog_source||"community"===e.blog_source)).map(e=>({blogId:e.blog_id,blogSource:e.blog_source})),s=t.length>0?await (0,ax.ensureCatalogBlogsCached)(t):new Map;if(e)return;let o=await Promise.all(a.map(async e=>{let t=(0,ax.readLaterPostToFeedPost)(e),r=i.get(e.blog_id);if(r)t.blogIcon=r;else{let r=s.get(e.blog_id);if(r?.site_icon)t.blogIcon=r.site_icon;else{let r=await (0,ax.getCachedBlogMeta)(e.blog_id);r?.site_icon&&(t.blogIcon=r.site_icon)}}return t}));e||r(o)})(),()=>{e=!0}},[a,i,r]),null}function il({blogs:e,blogsLoading:t}){let r=(0,ef.usePathname)(),s=(0,n.useSetAtom)(b.viewFilterAtom),a=(0,n.useSetAtom)(b.exploreModeAtom),o=(0,n.useSetAtom)(b.searchModeAtom),i=(0,n.useAtomValue)(b.feedsLoadingAtom),l=(0,n.useSetAtom)(b.selectedBlogIdAtom),c=(0,n.use
28SetAtom)(b.selectedTagsAtom),d=(0,p.useRef)(!1),u=(0,p.useMemo)(()=>e.map(e=>(0,tR.getEffectiveBlogId)(e)).sort().join(","),[e]);return(0,p.useEffect)(()=>{d.current=!1},[u]),(0,p.useEffect)(()=>{let e=r.split("/")[2],t=(0,ep.pathToViewFilter)(e);t&&s(t)},[r,s]),(0,p.useEffect)(()=>{(0,ep.isExplorePath)(r)?a(!0):r.startsWith("/dashboard/")&&!(0,ep.isExplorePath)(r)&&a(!1)},[r,a]),(0,p.useEffect)(()=>{(0,ep.isSearchPath)(r)?o(!0):r.startsWith("/dashboard/")&&!(0,ep.isSearchPath)(r)&&o(!1)},[r,o]),(0,p.useEffect)(()=>{if(d.current||i||t||0===e.length)return;d.current=!0;let r=new Set,s=new Set;for(let t of e)if(s.add((0,tR.getEffectiveBlogId)(t)),t.tags)for(let e of t.tags)r.add(e);l(e=>e&&!s.has(e)?null:e),c(e=>{if(0===e.length)return e;let t=e.filter(e=>r.has(e));return t.length!==e.length?t:e})},[i,t,e,u,l,c]),null}function ic({blogs:e,blogsLoading:t}){let r=(0,p.useMemo)(()=>e.map(e=>(0,tR.getEffectiveBlogId)(e)).sort().join(","),[e]);return(0,p.useEffect)(()=>{(0,tS.cleanupExpiredCache)().then(e=>{e>0&&console.log(`Cleaned up ${e} expired cache entries`)}).catch(e=>{console.error("Cache cleanup failed:",e)});let e=setInterval(()=>{(0,tS.cleanupExpiredCache)().catch(e=>{console.error("Periodic cache cleanup failed:",e)})},18e5);return()=>clearInterval(e)},[]),(0,p.useEffect)(()=>{if(t||""===r)return;let e=localStorage.getItem("local-user-id");if(!e)return;let s=async()=>{try{let t=new Set(r.split(","));await n9(e,t)}catch(e){console.warn("[DataProvider] Read status cleanup failed:",e)}},a=setTimeout(s,n4.READ_STATUS_RETENTION_CONFIG.INITIAL_CLEANUP_DELAY_MS),o=setInterval(s,n4.READ_STATUS_RETENTION_CONFIG.CLEANUP_INTERVAL_MS);return()=>{clearTimeout(a),clearInterval(o)}},[t,r]),null}function id({loadingPhase:e,timelinePostsLength:t,blogsLoading:r,blogsLength:s}){let a=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{a.current||!("complete"===e||"network"===e&&t>0||!r&&0===s)||(0,s0.getExtensionAvailability)()&&(a.current=!0,(0,s0.acknowledgeUpdates)().then(e=>{e&&e.acknowledgedCount>0&&console.log(`[DataProvider] Acknowledged ${e.acknowledgedCount} extension updates`)}).catch(e=>{console.warn("[DataProvider] Failed to acknowledge extension updates:",e)}))},[e,t,r,s]),null}function iu(){(0,ev.useSavedPosts)();let e=(0,n.useSetAtom)(er.savedOfflinePostGuidsAtom),t=(0,p.useRef)(!1);return(0,p.useEffect)(()=>{t.current||(0,s0.getExtensionAvailability)()&&(t.current=!0,(0,s0.getAllSavedPostGuidsViaExtension)().then(t=>{t&&t.length>0&&e(new Set(t))}).catch(()=>{}))},[e]),null}function im(){let[e,t]=(0,n.useAtom)(b.mobileViewAtom),[r,s]=(0,n.useAtom)(b.exploreModeAtom),o=(0,n.useSetAtom)(b.settingsDialogOpenAtom),i=(0,n.useAtomValue)(er.unreadCountAtom),c=(0,n.useSetAtom)(b.mobileHasVisitedSelectedPostAtom),d=(0,n.useAtomValue)(b.showUnreadCountInSmartViewsAtom),u=[{id:"list",label:"Posts",icon:ek.List,badge:d&&i>0?i:null},{id:"reader",label:"Reader",icon:tB.BookOpen,badge:null},{id:"explore",label:"Explore",icon:em.Compass,badge:null},{id:"settings",label:"Settings",icon:l.Settings,badge:null}];return(0,a.jsx)("nav",{className:"fixed bottom-0 left-0 right-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",style:{paddingBottom:"env(safe-area-inset-bottom)"},children:(0,a.jsx)("div",{className:"flex h-16 items-center justify-around px-2",children:u.map(n=>{let i=n.icon,l=e===n.id;return(0,a.jsxs)("button",{onClick:()=>{var e;"settings"===(e=n.id)?o(!0):"explore"===e?(s(!r),t("explore")):(c(!0),s(!1),t(e))},className:(0,A.cn)("relative flex min-w-[4rem] flex-col items-center justify-center gap-1 rounded-md px-3 py-2 text-xs font-medium transition-colors","hover:bg-accent hover:text-accent-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",l?"text-primary":"text-muted-foreground"),"aria-label":n.label,"aria-current":l?"page":void 0,children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(i,{className:(0,A.cn)("size-5",l&&"fill-current")}),null!==n.badge&&(0,a.jsx)("span",{className:"absolute -right-2 -top-2 flex size-5 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground",children:n.badge>99?"99+":n.badge})]}),(0,a.jsx)("span",{className:(0,A.cn)("text-[11px]",l&&"font-semibold"),children:n.label})]},n.id)})})})}var rH=rH;function ih({onClick:e,visible:t=!0,className:r}){return(0,a.jsx)(rT.AnimatePresence,{children:t&&(0,a.jsx)(rS.motion.div,{initial:{scale:0,opacity:0}
28,animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{type:"spring",stiffness:300,damping:25},className:(0,A.cn)("fixed bottom-36 right-6 z-40",r),children:(0,a.jsx)(u.Button,{size:"lg",variant:"secondary",onClick:e,className:"size-14 rounded-full shadow-lg hover:shadow-xl","aria-label":"Open post actions",children:(0,a.jsx)(rH.default,{className:"size-6"})})})})}var ip=e.i(382373);(0,eC.default)("volume-x",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]),(0,eC.default)("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]);var ig=e.i(852917);function ix({open:e,onOpenChange:t,actions:r}){let s=r.filter(e=>"star"===e.id||"readLater"===e.id||"toggleRead"===e.id||"share"===e.id||"viewMode"===e.id||"themeMode"===e.id||"tts"===e.id),o=r.filter(e=>!s.find(t=>t.id===e.id));return(0,a.jsx)(ig.Sheet,{open:e,onOpenChange:t,children:(0,a.jsxs)(ig.SheetContent,{side:"bottom",className:"px-0 pb-8",children:[(0,a.jsxs)(ig.SheetHeader,{className:"px-4",children:[(0,a.jsx)(ig.SheetTitle,{children:"Post Actions"}),(0,a.jsx)(ig.SheetDescription,{children:"Choose an action for this post"})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsx)("div",{className:"grid grid-cols-4 gap-2 px-4",children:s.map(e=>(0,a.jsxs)("button",{onClick:()=>{e.onClick(),t(!1)},disabled:e.disabled,className:(0,A.cn)("flex flex-col items-center gap-2 rounded-lg border p-4","hover:bg-accent hover:border-accent-foreground/20","disabled:opacity-50 disabled:cursor-not-allowed",e.active&&"bg-accent border-accent-foreground/20"),children:[(0,a.jsx)("div",{className:(0,A.cn)("flex size-10 items-center justify-center rounded-full bg-muted",e.active&&"bg-primary/10 text-primary"),children:e.icon}),(0,a.jsx)("span",{className:"text-xs font-medium text-center",children:e.label})]},e.id))}),o.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(rN.Separator,{}),(0,a.jsx)("div",{className:"space-y-1 px-4",children:o.map(e=>(0,a.jsxs)(u.Button,{variant:"ghost",onClick:()=>{e.onClick(),t(!1)},disabled:e.disabled,className:(0,A.cn)("w-full justify-start gap-3 h-12",e.active&&"bg-accent"),children:[(0,a.jsx)("div",{className:"flex size-8 items-center justify-center rounded-full bg-muted",children:e.icon}),(0,a.jsxs)("div",{className:"flex flex-col items-start flex-1",children:[(0,a.jsx)("span",{className:"font-medium",children:e.label}),e.description&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]})]},e.id))})]})]})]})})}function ib({className:e}){let[t,r]=(0,n.useAtom)(er.selectedPostIdAtom),s=(0,n.useAtomValue)(er.selectedPostAtom),o=(0,n.useAtomValue)(er.displayedPostsAtom),i=(0,n.useAtomValue)(er.starredPostGuidsAtom),l=(0,n.useAtomValue)(er.readLaterPostGuidsAtom),c=(0,n.useAtomValue)(er.readPostGuidsAtom),{preferences:d,setPreference:u}=sE(),[m,h]=(0,n.useAtom)(b.viewModeAtom),{resolvedTheme:f,setTheme:g}=(0,rr.useTheme)(),x=(0,tf.useToggleStar)(),y=(0,tf.useToggleReadLater)(),v=(0,tf.useMarkAsRead)(),j=(0,tf.useMarkAsUnread)(),{narrate:w}=ag(),N=(0,p.useCallback)(e=>{let t="iframe"===(d[e]||"iframe")?"content":"iframe";u(e,t),h(t),th.toast.success(`Switched to ${"content"===t?"in-house":"iframe"} view`,{description:"Your preference has been saved for this blog."})},[d,u,h]),[k,C]=(0,p.useState)(!1),S=o.findIndex(e=>e.guid===t),T=s?.guid&&i.has(s.guid),E=s?.guid&&l.has(s.guid),M=s?.guid&&(0,er.isGuidInSet)(s.guid,c,s.guidHash),z=(0,p.useCallback)(()=>{if(S<o.length-1){let e=o[S+1];e?.guid&&r(e.guid)}},[S,o,r]),R=(0,p.useCallback)(()=>{if(S>0){let e=o[S-1];e?.guid&&r(e.guid)}},[S,o,r]);(0,p.useEffect)(()=>{let e=e=>{"ArrowLeft"===e.key||"h"===e.key?R():("ArrowRight"===e.key||"l"===e.key)&&z()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[z,R]);let P=S<o.length-1,I=S>0,L=(0,p.useMemo)(()=>s?[{id:"star",label:T?"Unstar":"Star",icon:(0,a.jsx)(el.Star,{className:(0,A.cn)("size-4",T&&"fill-yellow-500 text-yellow-500")}),onClick:()=>s.guid&&s.blogId&&x(s,s.blogId,s.blogTitle||"",T||!1),active:T||!1},{id:"readLater",label:E?"Remove from Read Later":"Read Later",icon:(0,a.jsx)(ec.Bookmark,{className:(0,A.cn)("size-4",E&&"fill-blue-500 text-blue-500")}),onClick:()=>s.guid&&s.blogId&&y(s,s.blogId,s.blogTitle||"",E||!1),active:E||!1},{id:"toggleRead",label:M?"Mark Unread":"Mark Read",icon:M?(0,a.jsx)(sw.EyeOff,{className:"size-4"}):(0,a.jsx)(sj.Eye,{className:"size-4"}),onClick:()=>{s.guid&&(M?j(s.guid||s.link,s.blogId||""):v(s.guid||s.link,s.blogId||""))},active:M||!1},{id:"share",label:"Share",icon:(0,a.jsx)(rq.Share2,{className:"size-4"}),onClick:async()=>
28{if(s.link)if(navigator.share)try{await navigator.share({title:s.title,url:s.link})}catch(e){"AbortError"!==e.name&&th.toast.error("Failed to share")}else await navigator.clipboard.writeText(s.link),th.toast.success("Link copied to clipboard")}},{id:"openBrowser",label:"Open in Browser",description:"Open the original post in your browser",icon:(0,a.jsx)(ez.ExternalLink,{className:"size-4"}),onClick:()=>{s.link&&window.open(s.link,"_blank","noopener,noreferrer")}},{id:"viewMode",label:"iframe"===m?"Show In-House":"Show Iframe",description:"iframe"===m?"Switch to in-house content view":"Switch to iframe view",icon:"iframe"===m?(0,a.jsx)(sC.FileCode,{className:"size-4"}):(0,a.jsx)(_.Monitor,{className:"size-4"}),onClick:()=>{s.blogId&&N(s.blogId)},active:"iframe"===m},{id:"themeMode",label:"dark"===f?"Switch to Light Mode":"Switch to Dark Mode",description:"dark"===f?"Switch to light mode":"Switch to dark mode",icon:"dark"===f?(0,a.jsx)(r4.Sun,{className:"size-4"}):(0,a.jsx)(r3.Moon,{className:"size-4"}),onClick:()=>{g("dark"===f?"light":"dark")},active:"dark"===f},{id:"tts",label:"Text to Speech",description:"Convert the post to audio",icon:(0,a.jsx)(sT.AudioLines,{className:"size-4"}),onClick:()=>{s&&w({postUrl:s.link,postTitle:s.title,postGuid:s.guid,blogId:s.blogId})}}]:[],[s,T,E,M,m,x,y,v,j,N,f,g,w]);return(0,a.jsxs)("div",{className:(0,A.cn)("relative h-full",e),children:[(0,a.jsx)(oS,{}),(I||P)&&(0,a.jsxs)("div",{className:"fixed bottom-20 left-0 right-0 flex justify-between px-4 pointer-events-none",children:[I&&(0,a.jsx)("button",{onClick:R,className:"pointer-events-auto rounded-full bg-background/80 backdrop-blur border px-3 py-1 text-xs text-muted-foreground hover:bg-accent",children:"← Previous"}),(0,a.jsx)("div",{className:"flex-1"}),P&&(0,a.jsx)("button",{onClick:z,className:"pointer-events-auto rounded-full bg-background/80 backdrop-blur border px-3 py-1 text-xs text-muted-foreground hover:bg-accent",children:"Next →"})]}),(0,a.jsx)(ih,{onClick:()=>C(!0),visible:!!s}),(0,a.jsx)(ix,{open:k,onOpenChange:C,actions:L})]})}sj.Eye,sw.EyeOff,el.Star,ec.Bookmark,rq.Share2,ez.ExternalLink,sC.FileCode,_.Monitor,sA.Maximize2,sS.Minimize2,ip.Volume2;var iy=e.i(838808),iv=tK,ij=e.i(756167);let iw=(0,rm.atomWithStorage)("audioVolume",1,void 0,{getOnInit:!1}),iN=(0,rm.atomWithStorage)("audioMuted",!1,void 0,{getOnInit:!1}),ik=(0,p.createContext)(null),iC=({children:e})=>{let t=(0,p.useRef)(null),[r,s]=(0,n.useAtom)(iw),[o,i]=(0,n.useAtom)(iN),l=(0,f.useStorage)(),c=(0,f.useUserId)(),d=(0,p.useRef)(!1),u=(0,p.useRef)(!1),m=(0,p.useRef)(!1),[h,g]=(0,p.useState)(null),[x,b]=(0,p.useState)(!1),[y,v]=(0,p.useState)(0),[j,w]=(0,p.useState)(0),[N,k]=(0,p.useState)(0),[C,A]=(0,p.useState)(!1),[S,T]=(0,p.useState)(null),[E,M]=(0,p.useState)(!1),[_,z]=(0,p.useState)([]),[R,P]=(0,p.useState)(0),[I,L]=(0,p.useState)(0),[D,F]=(0,p.useState)(0),O=(0,p.useRef)(!1);(0,p.useEffect)(()=>{m.current=E},[E]),(0,p.useEffect)(()=>{t.current&&(t.current.volume=o?0:r)},[r,o]);let B=(0,p.useCallback)(()=>{A(!0),T(null)},[]),$=(0,p.useCallback)(()=>{t.current&&(w(t.current.duration),A(!1))},[]),U=(0,p.useCallback)(()=>{t.current&&(v(t.current.currentTime),t.current.buffered.length>0&&k(t.current.buffered.end(t.current.buffered.length-1)))},[]),V=(0,p.useCallback)(async()=>{if(b(!0),h?.postGuid&&h?.blogId&&!d.current){d.current=!0;try{await (0,ij.markPostAsRead)(l,c,h.postGuid,h.blogId)}catch(e){console.error("Failed to mark post as read:",e)}}},[h,l,c]),q=(0,p.useCallback)(()=>{b(!1)},[]),H=(0,p.useCallback)(()=>{if(console.log(`[Audio Playback DEBUG] handleEnded fired - isTransitioning: ${O.current}, isStreaming: ${E}, chunkIndex: ${R}/${_.length}`),O.current)return void console.log("[Audio Playback] Ignoring ended event during transition");if(E){let e=R+1;if(console.log(`[Audio Playback DEBUG] Streaming mode - next chunk would be ${e}/${_.length}`),e<_.length){let r=_[e];if(t.current){let s=_[R];L(e=>e+(s?.duration||0)),console.log(`[Audio Playback DEBUG] Loading next chunk ${e}, URL: ${r.url.substring(0,50)}...`),t.current.src=r.url,t.current.load(),P(e),t.current.addEventListener("canplay",()=>{t.current&&(console.log(`[Audio Playback DEBUG] Chunk ${e} canplay - starting play`),t.current.play().catch(e=>{console.log("Failed to play next chunk:",e)}))},{once:!0})}}else console.log("[Audio Playback DEBUG] All chunks played, waiting for final audio"),b(!1),v(0)}else console.log("[Audio Playback DEBUG] Normal playback ended"),b(!1),v(0)},[E,R,_]),G=(0,p.useCallback)(e=>{if(u.current){u.current=!1;return}A(!1),b(!1),T("Failed to load audio"),console.error("Audio error:",e)},[]);(0,p.useEffect)(()=>{let e=t.current;if(e)return e.addEventListener("loadstart",B),e.addEventListener("loadeddata",$),e.addEventListener("timeupdate",U),e.addEventListener("play",V),e.addEventListener("pause",q),e.addEventListener("ended",H),e.addEventListener("error",G),()=>{e.removeEventListener("loadstart",B),e.removeEventListener("loadeddata",$),e.removeEventListener("timeupdate",U),e.removeEventListener("play",V),e.removeEventListener("pause",q),e.removeEventListener("ended",H),e.removeEventListener("error",G)}},[B,$,U,V,q,H,G]);let W=(0,p.useCallback)(e=>{M(!0),g(e),z([]),P(0),L(0),F(0),v(0),w(0),T(null),d.current=!1},[]),K=(0,p.useCallback)(async e=>new Promise(r=>{if(!m.current){console.log("[Audio Playback] Ignoring chunk - not in streaming mode"),r();return}let s=document.createElement("audio"),a=URL.createObjectURL(e);s.src=a,s.addEventListener("loadedmetadata",()=>{let o=s.duration,n={url:a,blob:e,duration:o};z(e=>{if(!m.current)return console.log("[Audio Playback] Ignoring chunk - streaming ended during processing"),URL.revokeObjectURL(a),e;let r=[...e,n];return console.log(`[Audio Playback DEBUG] Chunk ${r.length} appended, duration: ${o.toFixed(2)}s`),F(r.reduce((e,t)=>
28e+t.duration,0)),1===r.length&&t.current&&(console.log("[Audio Playback DEBUG] First chunk - starting playback"),t.current.src=n.url,t.current.load(),P(0),t.current.addEventListener("canplay",()=>{t.current&&(console.log("[Audio Playback DEBUG] First chunk canplay - starting play"),t.current.play().catch(e=>{console.log('"play()" failed:',e)}))},{once:!0})),r}),r()}),s.addEventListener("error",()=>{console.error("Failed to load chunk metadata"),URL.revokeObjectURL(a),r()})}),[]),Y=(0,p.useCallback)(async e=>{if(!t.current)return;console.log("[Audio Playback] Starting transition to full audio"),O.current=!0,_[R];let r=I+t.current.currentTime,s=_.map(e=>e.url);console.log(`[Audio Playback] Transitioning at ${r.toFixed(2)}s, wasPlaying: ${x}`),M(!1),z([]),P(0),L(0),F(0),t.current.pause(),t.current.src=e,t.current.load(),await new Promise(e=>{let s=!1,a=()=>{s||(s=!0,e())},o=setTimeout(()=>{console.warn("[Audio Playback] Timeout waiting for loadedmetadata, attempting playback anyway"),t.current&&x&&(t.current.currentTime=0,t.current.play().catch(e=>{console.error("[Audio Playback] Failed to play after timeout:",e)})),a()},1e4);t.current?(t.current.addEventListener("loadedmetadata",()=>{if(!t.current){clearTimeout(o),a();return}console.log(`[Audio Playback] Metadata loaded, duration: ${t.current.duration}s`);let e=Math.min(r,t.current.duration-.1);setTimeout(()=>{if(!t.current){clearTimeout(o),a();return}if(e>.5){let r=()=>{console.warn("[Audio Playback] Seek failed, playing from current position"),clearTimeout(o),t.current&&x&&t.current.play().catch(e=>{console.error("[Audio Playback] Failed to play after seek failure:",e)}),a()};t.current.addEventListener("seeked",()=>{clearTimeout(o),console.log(`[Audio Playback] Seeked to ${e.toFixed(2)}s`),t.current&&x&&t.current.play().catch(e=>{console.error("[Audio Playback] Failed to resume after transition:",e)}),a()},{once:!0}),t.current.addEventListener("error",r,{once:!0});try{t.current.currentTime=e}catch(e){console.error("[Audio Playback] Failed to set currentTime:",e),r()}}else clearTimeout(o),console.log("[Audio Playback] Starting from beginning (elapsed < 0.5s)"),x&&t.current.play().catch(e=>{console.error("[Audio Playback] Failed to resume after transition:",e)}),a()},100)},{once:!0}),t.current.addEventListener("error",e=>{console.error("[Audio Playback] Error loading final audio:",e),clearTimeout(o),a()},{once:!0})):(clearTimeout(o),a())}),O.current=!1,console.log(`[Audio Playback] Cleaning up ${s.length} chunk URLs`),s.forEach(e=>{try{URL.revokeObjectURL(e)}catch(e){console.warn("[Audio Playback] Failed to revoke blob URL:",e)}}),console.log("[Audio Playback] Transition complete")},[x,_,R,I]),Q=(0,p.useCallback)(()=>0===_.length?null:new Blob(_.map(e=>e.blob),{type:"audio/mpeg"}),[_]),X=(0,p.useCallback)(async()=>{if(t.current&&h)try{await t.current.play()}catch(e){console.log('"play()" failed:',e)}},[h]),Z=(0,p.useCallback)(()=>{t.current&&t.current.pause()},[]),J=(0,p.useCallback)(()=>{t.current&&(t.current.pause(),t.current.currentTime=0),b(!1),v(0)},[]),ee=(0,p.useCallback)(e=>{t.current&&(t.current.currentTime=Math.max(0,Math.min(e,j)))},[j]),et=(0,p.useCallback)((e=iv.AUDIO_SKIP_SECONDS)=>{ee(y+e)},[y,ee]),er=(0,p.useCallback)((e=iv.AUDIO_SKIP_SECONDS)=>{ee(y-e)},[y,ee]);(0,p.useEffect)(()=>{if(!("mediaSession"in navigator)||!h)return;navigator.mediaSession.metadata=new MediaMetadata({title:h.title||"Audio Narration",artist:"Blogs Are Back",album:"Generated Speech"});let e=[["play",()=>X()],["pause",()=>Z()],["seekbackward",()=>er()],["seekforward",()=>et()]];return e.forEach(([e,t])=>{try{navigator.mediaSession.setActionHandler(e,t)}catch(t){console.warn(`Media Session API: Action ${e} not supported`,t)}}),()=>{e.forEach(([e])=>{try{navigator.mediaSession.setActionHandler(e,null)}catch(e){}})}},[h,X,Z,er,et]),(0,p.useEffect)(()=>{"mediaSession"in navigator&&(navigator.mediaSession.playbackState=x?"playing":"paused")},[x]);let es=(0,p.useCallback)(e=>{t.current&&(h?.url&&h.url!==e.url&&URL.revokeObjectURL(h.url),E&&(console.log("[Audio Playback] Resetting streaming state (loadTrack called)"),M(!1),z([]),P(0),L(0),F(0)),t.current.src=e.url,t.current.load(),g(e),v(0),T(null),d.current=!1,u.current=!1)},[h,E]),ea=(0,p.useCallback)(()=>{t.current&&(u.current=!0,t.current.pause(),t.current.src="",h?.url&&URL.revokeObjectURL(h.url)),_.forEach(e
28=>{URL.revokeObjectURL(e.url)}),g(null),b(!1),v(0),w(0),k(0),T(null),d.current=!1,M(!1),z([]),P(0),L(0),F(0)},[h,_]),eo=(0,p.useCallback)(()=>{x?Z():X()},[x,X,Z]),en=(0,p.useCallback)(e=>{let t=Math.max(0,Math.min(1,e));s(t),o&&t>0&&i(!1)},[o,s,i]),ei=(0,p.useCallback)(()=>{i(!o)},[o,i]),el=(0,p.useCallback)(e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement))switch(e.key){case" ":e.preventDefault(),eo();break;case"ArrowLeft":e.preventDefault(),er();break;case"ArrowRight":e.preventDefault(),et();break;case"ArrowUp":e.preventDefault(),en(r+.1);break;case"ArrowDown":e.preventDefault(),en(r-.1);break;case"m":case"M":e.preventDefault(),ei()}},[eo,er,et,en,r,ei]);return(0,p.useEffect)(()=>(document.addEventListener("keydown",el),()=>document.removeEventListener("keydown",el)),[el]),(0,a.jsxs)(ik.Provider,{value:{audioRef:t,currentTrack:h,isPlaying:x,currentTime:y,duration:j,buffered:N,volume:r,isMuted:o,isLoading:C,error:S,isStreaming:E,streamingChunks:_,streamingChunkIndex:R,cumulativeStreamingTime:I,totalStreamingDuration:D,loadTrack:es,clearTrack:ea,play:X,pause:Z,stop:J,togglePlayPause:eo,seekTo:ee,skipForward:et,skipBackward:er,setVolume:en,toggleMute:ei,handleKeyDown:el,startStreaming:W,appendStreamingChunk:K,finishStreaming:Y,getPartialAudioBlob:Q},children:[e,(0,a.jsx)("audio",{ref:t,preload:"metadata",className:"hidden"})]})};var iA=e.i(431343);let iS=(0,eC.default)("skip-back",[["path",{d:"M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z",key:"15892j"}],["path",{d:"M3 20V4",key:"1ptbpl"}]]),iT=(0,eC.default)("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]),iE=(0,eC.default)("volume-off",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);var iM=e.i(90382);let i_=(0,eC.default)("arrow-down-to-line",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]),iz=(0,eC.default)("arrow-up-to-line",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]),iR=(0,eC.default)("arrow-down-left",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]),iP=(0,eC.default)("arrow-down-right",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]),iI=(0,eC.default)("arrow-up-left",[["path",{d:"M7 17V7h10",key:"11bw93"}],["path",{d:"M17 17 7 7",key:"2786uv"}]]),iL=(0,eC.default)("gamepad-directional",[["path",{d:"M11.146 15.854a1.207 1.207 0 0 1 1.708 0l1.56 1.56A2 2 0 0 1 15 18.828V21a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1v-2.172a2 2 0 0 1 .586-1.414z",key:"1re2og"}],["path",{d:"M18.828 15a2 2 0 0 1-1.414-.586l-1.56-1.56a1.207 1.207 0 0 1 0-1.708l1.56-1.56A2 2 0 0 1 18.828 9H21a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1z",key:"1pchrj"}],["path",{d:"M6.586 14.414A2 2 0 0 1 5.172 15H3a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2.172a2 2 0 0 1 1.414.586l1.56 1.56a1.207 1.207 0 0 1 0 1.708z",key:"16mt4c"}],["path",{d:"M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2.172a2 2 0 0 1-.586 1.414l-1.56 1.56a1.207 1.207 0 0 1-1.708 0l-1.56-1.56A2 2 0 0 1 9 5.172z",key:"19ox6c"}]]),iD=[{vertical:"bottom",horizontal:"center"},{vertical:"top",horizontal:"center"},{vertical:"bottom",horizontal:"right"},{vertical:"top",horizontal:"right"},{vertical:"bottom",horizontal:"left"},{vertical:"top",horizontal:"left"}],iF=[{vertical:"bottom",horizontal:"center"},{vertical:"top",horizontal:"center"}],iO=e=>{let{vertical:t,horizontal:r}=e;return"bottom"===t&&"center"===r?i_:"top"===t&&"center"===r?iz:"bottom"===t&&"left"===r?iR:"bottom"===t&&"right"===r?iP:"top"===t&&"left"===r?iI:"top"===t&&"right"===r?rG.ArrowUpRight:i_},iB=e=>{let{vertical:t,horizontal:r}=e;return`${"bottom"===t?"Bottom":"Top"} ${"center"===r?"Center":"left"===r?"Left":"Right"}`};function i$({positionAtom:e,className:t}){let[r,s]=(0,n.useAtom)(e),o=(0,ex.default)(),i=()=>{let e=o?iF:iD,t=(e.findIndex(e=>e.vertical===r.vertical&&e.horizontal===r.horizontal)+1)%e.length;return e[t]};if(o){let e,r=iO(i());
28return(0,a.jsx)(eN.TooltipWrapper,{content:(e=i(),`Move to ${iB(e)}`),children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:t,onClick:()=>{s(i())},children:(0,a.jsx)(r,{className:"h-3.5 w-3.5"})})})}return(0,a.jsxs)(tW.DropdownMenu,{children:[(0,a.jsx)(eN.TooltipWrapper,{content:"Change position",children:(0,a.jsx)(tW.DropdownMenuTrigger,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:t,children:(0,a.jsx)(iL,{className:"h-3.5 w-3.5"})})})}),(0,a.jsx)(tW.DropdownMenuContent,{align:"end",children:iD.map((e,t)=>{let o=iO(e),n=iB(e),i=e.vertical===r.vertical&&e.horizontal===r.horizontal;return(0,a.jsxs)(tW.DropdownMenuItem,{onClick:()=>s(e),className:"gap-2",children:[(0,a.jsx)(o,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:i?"font-medium":"",children:n})]},`${e.vertical}-${e.horizontal}`)})})]})}var iU=e.i(207670);let iV=(0,iU.default)("bg-background/50","backdrop-blur-lg border border-border","overflow-hidden"),iq=(0,iU.default)(iV,"rounded-lg shadow-2xl","transition-all duration-200"),iH=(0,iU.default)(iV,"rounded-md shadow-lg","px-3 py-1.5"),iG=(0,iU.default)("dark:bg-page-background/80! bg-white/50!","backdrop-blur!",""),iW=(0,iU.default)("main-content-glass","","");function iK({autoPlay:e=!0,className:t}){let{result:r,audioUrl:s,lastRequest:o,state:i,setOnChunkReady:l,cancel:c}=ai(),{loadTrack:d,play:m,currentTrack:h,isPlaying:f,currentTime:g,duration:x,buffered:y,volume:v,isMuted:j,isLoading:w,error:N,seekTo:k,skipForward:C,skipBackward:S,setVolume:T,toggleMute:E,togglePlayPause:M,clearTrack:_,audioRef:z,startStreaming:R,appendStreamingChunk:P,finishStreaming:I,getPartialAudioBlob:L,isStreaming:D,streamingChunks:O,cumulativeStreamingTime:B}=(()=>{let e=(0,p.useContext)(ik);if(!e)throw Error("useAudioPlayback must be used within AudioPlaybackProvider");return e})(),[$]=(0,n.useAtom)(b.audioPlayerPositionAtom),[U,V]=(0,n.useAtom)(b.audioPlayerExpandedAtom),[q,G]=(0,n.useAtom)(am.ttsPlayerVisibleAtom),W=(0,n.useSetAtom)(am.ttsProgressVisibleAtom),{currentChunk:K,totalChunks:Y}=ai(),[Q,X]=(0,p.useState)(!1);(0,p.useEffect)(()=>{!async function(){let e=!1;Y>0&&0===K&&(e=!0),X(e)}()},[K,Y]);let Z=(0,ex.default)(),J=(0,p.useRef)(!1),ee=(0,p.useRef)(null),et=(0,p.useRef)(i),[er,es]=(0,p.useState)(!1),ea=(0,p.useRef)(!0);(0,p.useEffect)(()=>(l(async(e,t,r)=>{ea.current?await P(e):console.log(`[Narration Bridge] Ignoring late chunk ${t+1}/${r}`)}),()=>{l(void 0)}),[l,P]),(0,p.useEffect)(()=>{"processing"===et.current&&"ready"===i&&"success"!==r&&J.current&&(G(!1),_(),J.current=!1,ee.current=null),et.current=i},[i,r,_,G]),(0,p.useEffect)(()=>{"processing"!==i||J.current||(J.current=!0,ea.current=!0,G(!0),R({url:"",title:o?.postTitle||"TTS Audio",postGuid:o?.postGuid,blogId:o?.blogId})),"processing"!==i&&(J.current=!1)},[i,o,R,G]),(0,p.useEffect)(()=>{"success"===r&&s&&s!==ee.current&&(async()=>{console.log(`[Narration Bridge] Generation complete, isStreaming: ${D}, streamingChunks: ${O.length}`);let t=o?.postTitle||"TTS Audio",r=o?.postGuid,a=o?.blogId;if(D){console.log("[Narration Bridge] Was streaming - loading full audio (iOS-friendly approach)");let e=B+g;console.log(`[Narration Bridge] Captured position: ${e.toFixed(2)}s, wasPlaying: ${f}`),ea.current=!1,l(void 0),console.log("[Narration Bridge] Stopped accepting chunks"),O.forEach(e=>{try{URL.revokeObjectURL(e.url)}catch(e){console.warn("Failed to revoke chunk URL:",e)}}),G(!0),d({url:s,title:t,postGuid:r,blogId:a}),setTimeout(()=>{if(z.current&&e>.5){let t=Math.min(e,z.current.duration-.1);console.log(`[Narration Bridge] Seeking to ${t.toFixed(2)}s`),z.current.currentTime=t}f&&z.current&&(console.log("[Narration Bridge] Resuming playback"),z.current.play().catch(e=>{console.log("Play failed:",e)}))},500)}else console.log("[Narration Bridge] Loading track directly (not streaming)"),G(!0),d({url:s,title:t,postGuid:r,blogId:a}),e&&queueMicrotask(()=>m());ee.current=s,console.log("[Narration Bridge] Transition handler complete")})()},[r,s,o,d,m,e,I,G]);let eo=x>0?y/x*100:0,en=e=>{if(!isFinite(e)||isNaN(e))return"0:00";let t=Math.floor(e/60),r=Math.floor(e%60);return`${t}:${r.toString().padStart(2,"0")}`},ei=(0,p.useCallback)(async()=>{let e=async e=>{let t=new Uint8Array(await e.arrayBuffer()),r="";for(let e=0;e<t.length;e++)r+=String.fromCharCode(t[e]);return btoa(r)},t=h?.title||"audio";if(D){let r=L();if(!r)return void th.toast.error("No audio available to download");if((0,s8.isDesktopApp)()&&window.electronBridge){let s=await e(r),a=await window.electronBridge.invoke("TTS_SAVE_AUDIO",{audioBase64:s,title:`${t}-partial`});a.data?.saved&&th.toast.success("Audio saved")}else{let e=URL.createObjectURL(r),s=document.createElement("a");s.href=e,s.download=`${t}-partial-${Date.now()}.mp3`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(e),th.toast.success("Partial audio download started")}}else{if(!h?.url)return;if((0,s8.isDesktopApp)()&&window.electronBridge)try{let r=await fetch(h.url),s=await r.blob(),a=await e(s),o=await window.electronBridge.invoke("TTS_SAVE_AUDIO",{audioBase64:a,title:t});o.data?.saved&&th.toast.success("Audio saved")}catch{th.toast.error("Failed to save audio")}else{let e=document.createElement("a");e.href=h.url,e.download=`${t}-${Date.now()}.mp3`,document.body.appendChild(e),e.click(),document.body.removeChild(e),th.toast.success("Audio download started")}}},[h,D,L]),el=(0,p.useCallback)(()=>{D?(G(!1),W(!1),c(),_(),th.toast.info("Generation cancelled",{duration:2e3})):(G(!1),_(),th.toast.info("Audio player closed",{duration:2e3}))},[_,D,c,G,W]);if(!h||!q)return null;let ec=()=>"bottom"===$.vertical?100:-100;return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(rT.AnimatePresence,{children:(0,a.jsx)(rS.motion.div,{initial:{y:ec(),opacity:0}
28,animate:{y:0,opacity:1},exit:{y:ec(),opacity:0},transition:{type:"spring",stiffness:400,damping:30},className:(0,A.cn)("fixed z-50","w-[calc(100%-2rem)] max-w-xl",(()=>{let{vertical:e,horizontal:t}=$;return`${"bottom"===e?"bottom-4 mobile:bottom-20":"top-4 mobile:top-4"} ${"center"===t?"left-1/2 -translate-x-1/2":"left"===t?"left-4":"right-4"}`})(),t),children:(0,a.jsxs)("div",{className:(0,A.cn)(iq),children:[N&&(0,a.jsx)("div",{className:"bg-destructive/10 text-destructive text-xs px-3 py-2 border-b border-border",children:N}),(0,a.jsx)("div",{className:(0,A.cn)("transition-all duration-200",U?"p-3 space-y-2":"px-3 py-2"),children:U?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)("div",{className:"flex-1 min-w-0",children:D?(0,a.jsxs)("div",{className:"space-y-0.5",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:h.title||"Audio Playing"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Generating... ",K,"/",Y," chunks"]})]}):(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:h.title||"Audio Playing"})}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(eN.TooltipWrapper,{content:"Collapse",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>V(!1),children:(0,a.jsx)(sS.Minimize2,{className:"h-4 w-4"})})}),(0,a.jsx)(i$,{positionAtom:b.audioPlayerPositionAtom,className:"h-7 w-7"}),(0,a.jsx)(eN.TooltipWrapper,{content:"Close player",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:el,children:(0,a.jsx)(F.X,{className:"h-4 w-4"})})})]})]}),D?(0,a.jsx)("div",{className:"space-y-1",children:(0,a.jsx)("div",{className:"flex items-center justify-center py-2",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("div",{className:"animate-pulse w-2 h-2 bg-primary rounded-full"}),(0,a.jsx)("span",{children:Q?"Generating audio...":f?"Playing stream":"Stream paused"})]})})}):(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(iM.Slider,{value:[x>0?g/x*100:0],onValueChange:e=>{k(e[0]/100*x)},max:100,step:.1,className:"w-full [&_[role=slider]]:dark:opacity-0","aria-label":"Seek"}),(0,a.jsx)("div",{className:"absolute top-1/2 left-0 h-1 bg-muted/50 rounded-full -translate-y-1/2 pointer-events-none z-52",style:{width:`${eo}%`}})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground font-mono",children:[(0,a.jsx)("span",{children:en(g)}),(0,a.jsx)("span",{children:en(x)})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 grow justify-center mx-auto",children:[!D&&(0,a.jsx)(eN.TooltipWrapper,{content:`Skip backward ${tK.AUDIO_SKIP_SECONDS}s`,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:()=>S(tK.AUDIO_SKIP_SECONDS),className:"h-8 w-8 rounded-full",children:(0,a.jsx)(iS,{className:"h-4 w-4"})})}),(0,a.jsx)(eN.TooltipWrapper,{content:Q?"Generating text-to-speech...":f?"Pause":"Play",children:(0,a.jsx)(u.Button,{variant:"default",size:"icon",onClick:M,disabled:w,className:(0,A.cn)("rounded-full",D?"h-10 w-10":"h-9 w-9",Q&&"opacity-50"),children:Q?(0,a.jsx)(H.Loader2,{className:"h-4 w-4 animate-spin"}):f?(0,a.jsx)(eP.Pause,{className:"h-4 w-4",fill:"currentColor",strokeWidth:0}):(0,a.jsx)(iA.Play,{className:"h-4 w-4 ml-0.5",fill:"currentColor",strokeWidth:0})})}),!D&&(0,a.jsx)(eN.TooltipWrapper,{content:`Skip forward ${tK.AUDIO_SKIP_SECONDS}s`,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:()=>C(tK.AUDIO_SKIP_SECONDS),className:"h-8 w-8 rounded-full",children:(0,a.jsx)(iT,{className:"h-4 w-4"})})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[!Z&&(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(eN.TooltipWrapper,{content:j?"Unmute":"Mute",side:"left",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:E,onMouseEnter:()=>es(!0),className:"h-8 w-8",children:j||0===v?(0,a.jsx)(iE,{className:"h-4 w-4"}):(0,a.jsx)(ip.Volume2,{className:"h-4 w-4"})})}),(0,a.jsx)(rT.AnimatePresence,{children:er&&(0,a.jsx)(rS.motion.div,{initial:{opacity:0,y:10}
28,animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.15},className:"absolute bottom-full left-1/2 -translate-x-1/2 mr-2 p-2 bg-popover border border-border rounded-lg shadow-lg z-[52]",onMouseEnter:()=>es(!0),onMouseLeave:()=>es(!1),children:(0,a.jsx)(iM.Slider,{orientation:"horizontal",value:[j?0:100*v],onValueChange:e=>T(e[0]/100),max:100,step:1,className:"h-full z-52 w-24","aria-label":"Volume"})})})]}),(0,a.jsx)(eN.TooltipWrapper,{content:"Download audio",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:ei,className:"h-8 w-8",children:(0,a.jsx)(r0.Download,{className:"h-4 w-4"})})})]})]})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eN.TooltipWrapper,{content:Q?"Generating text-to-speech...":f?"Pause":"Play",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",onClick:M,disabled:w,className:(0,A.cn)("h-8 w-8 shrink-0",Q&&"opacity-50"),children:Q?(0,a.jsx)(H.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,a.jsx)(a.Fragment,{children:f?(0,a.jsx)(eP.Pause,{className:"h-3.5 w-3.5",fill:"currentColor",strokeWidth:0}):(0,a.jsx)(iA.Play,{className:"h-3.5 w-3.5 ml-0.5",fill:"currentColor",strokeWidth:0})})})}),(0,a.jsx)("div",{className:"flex-1 min-w-0",children:D?(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("p",{className:"text-xs font-medium truncate",children:h.title||"Audio Playing"}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-mono shrink-0",children:[K,"/",Y]})]}):(0,a.jsx)("p",{className:"text-xs font-medium truncate",children:h.title||"Audio Playing"})}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[(0,a.jsx)(eN.TooltipWrapper,{content:"Expand",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>V(!0),children:(0,a.jsx)(sA.Maximize2,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(i$,{positionAtom:b.audioPlayerPositionAtom,className:"h-7 w-7"}),(0,a.jsx)(eN.TooltipWrapper,{content:"Close player",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:el,children:(0,a.jsx)(F.X,{className:"h-3.5 w-3.5"})})})]})]})})]})})})})}function iY({className:e}){let{state:t,step:r,progress:s,currentChunk:o,totalChunks:i,error:l,result:c,cancel:d,lastRequest:m}=ai(),[h]=(0,n.useAtom)(b.audioPlayerPositionAtom),[f]=(0,n.useAtom)(b.audioPlayerExpandedAtom),[g,x]=(0,n.useAtom)(am.ttsProgressVisibleAtom),y=(0,n.useSetAtom)(am.ttsPlayerVisibleAtom),v=(0,p.useRef)(!1),j=(0,p.useRef)(!1),w=(0,p.useRef)(t),N=(0,p.useRef)(!1);(0,p.useEffect)(()=>{"processing"!==t||"processing"===w.current||v.current||(x(!0),th.toast.info("Generating audio narration...",{description:m?.postTitle||"Processing your request",duration:3e3}),v.current=!0,j.current=!1,N.current=!1),"ready"===t&&"processing"===w.current&&(x(!1),v.current=!1,j.current=!1),"error"===t&&"error"!==w.current&&x(!1),w.current=t},[t,m,x]),(0,p.useEffect)(()=>{"success"!==c||j.current||(th.toast.success("Audio ready!",{description:"Your narration has been generated",duration:3e3}),j.current=!0)},[c]),(0,p.useEffect)(()=>{"error"===t&&l&&!N.current&&th.toast.error("Generation failed",{description:l,duration:5e3})},[t,l]);let k=(0,p.useCallback)(()=>{"processing"===t?(N.current=!0,x(!1),y(!1),d(),th.toast.info("Generation cancelled",{duration:2e3})):"error"===t&&x(!1)},[t,d,x,y]);if(!(("processing"===t||"error"===t)&&g))return null;let{vertical:C,horizontal:S}=h,T=()=>"bottom"===h.vertical?100:-100;return(0,a.jsx)(rT.AnimatePresence,{children:(0,a.jsx)(rS.motion.div,{initial:{y:T(),opacity:0},animate:{y:0,opacity:1},exit:{y:T(),opacity:0},transition:{type:"spring",stiffness:400,damping:30},className:(0,A.cn)("fixed z-50","w-[calc(100%-2rem)] max-w-xl","bottom"===C?f?"bottom-43 mobile:bottom-59":"bottom-20 mobile:bottom-34":f?"top-43 mobile:top-43":"top-20 mobile:top-18","center"===S?"left-1/2 -translate-x-1/2":"left"===S?"left-4":"right-4",e),children:(0,a.jsx)("div",{className:(0,A.cn)(iH,"error"===t?"border-destructive/50":"border-border"),children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:["processing"===t&&(0,a.jsx)(H.Loader2,{className:"h-3 w-3 text-primary animate-spin shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:"error"===t?"Failed":(()=>{switch(r){case"extracting":return"Extracting";case"chunking":default:return"Processing";case"generating":return"Generating"}})()}),"processing"===t&&i>0&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-mono bottom-20",children:[o,"/",i]}),"processing"===t&&(0,a.jsxs)("div",{className:"flex-1 flex items-center gap-2",children:[(0,a.jsx)(sy.Progress,{value:s,className:"h-1 flex-1"}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground font-mono tabular-nums",children:[Math.round(s),"%"]})]}),"error"===t&&l&&(0,a.jsx)("p",{className:"text-xs text-destructive truncate",children:l})]}
28),(0,a.jsx)(eN.TooltipWrapper,{content:"Cancel generation",children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0",onClick:k,children:(0,a.jsx)(F.X,{className:"h-3 w-3"})})})]})})})})}(0,iU.default)("main-content-glass","rounded-lg","");var iQ=e.i(326999),iX=e.i(826707),iZ=e.i(890538);let iJ=e=>(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e,children:[(0,a.jsx)("title",{children:"Microsoft Edge icon"}),(0,a.jsx)("path",{d:"M21.86 17.86q.14 0 .25.12.1.13.1.25t-.11.33l-.32.46-.43.53-.44.5q-.21.25-.38.42l-.22.23q-.58.53-1.34 1.04t-1.6.91q-.86.4-1.74.64t-1.67.24q-.9 0-1.69-.28-.8-.28-1.48-.78T9.57 21.3q-.53-.66-.92-1.44-.38-.77-.58-1.6t-.2-1.67q0-1 .32-1.96.33-.97.87-1.8.14.95.55 1.77t1.02 1.5q.6.68 1.38 1.21.78.54 1.64.9t1.77.56q.92.2 1.8.2 1.12 0 2.18-.24 1.06-.23 2.06-.72l.2-.1zm-15.5-1.27q0 1.1.27 2.15.27 1.06.78 2.03.51.96 1.24 1.77.74.82 1.66 1.4-1.47-.2-2.8-.74-1.33-.55-2.48-1.37-1.15-.83-2.08-1.9-.92-1.07-1.58-2.33T.36 14.94Q0 13.54 0 12.06q0-.81.32-1.49.31-.68.83-1.23.53-.55 1.2-.96.66-.4 1.35-.66.74-.27 1.5-.39.78-.12 1.55-.12.7 0 1.42.1.72.12 1.4.35t1.32.57q.63.35 1.16.83-.35 0-.7.07-.33.07-.65.23v-.02q-.63.28-1.2.74t-1.05 1.04-.87 1.26q-.38.67-.65 1.39-.27.71-.42 1.44-.15.72-.15 1.38M11.96.06q1.7 0 3.33.39 1.63.38 3.07 1.15 1.43.77 2.62 1.93 1.18 1.16 1.98 2.7.49.94.76 1.96.28 1 .28 2.08 0 .89-.23 1.7-.24.8-.69 1.48t-1.1 1.22q-.64.53-1.45.88-.54.24-1.11.36-.58.13-1.16.13-.42 0-.97-.03-.54-.03-1.1-.12-.55-.1-1.05-.28-.5-.19-.84-.5-.12-.09-.23-.24-.1-.16-.1-.33 0-.15.16-.35t.35-.5q.2-.28.36-.68t.16-.95q0-1.06-.4-1.96-.4-.91-1.06-1.64-.66-.74-1.52-1.28-.86-.55-1.79-.89-.84-.3-1.72-.44-.87-.14-1.76-.14-1.55 0-3.06.45T.94 7.55q.71-1.74 1.81-3.13 1.1-1.38 2.52-2.35Q6.68 1.1 8.37.58q1.7-.52 3.58-.52Z",fill:"currentColor"})]}),i0=({className:e})=>(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,"aria-hidden":"true",children:(0,a.jsx)("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),i1=({className:e})=>(0,a.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,"aria-hidden":"true",children:(0,a.jsx)("path",{d:"M3,20.5V3.5C3,2.91 3.34,2.39 3.84,2.15L13.69,12L3.84,21.85C3.34,21.6 3,21.09 3,20.5M16.81,15.12L6.05,21.34L14.54,12.85L16.81,15.12M20.16,10.81C20.5,11.08 20.75,11.5 20.75,12C20.75,12.5 20.53,12.9 20.18,13.18L17.89,14.5L15.39,12L17.89,9.5L20.16,10.81M6.05,2.66L16.81,8.88L14.54,11.15L6.05,2.66Z"})});function i2(){let[e,t]=(0,n.useAtom)(am.ttsServiceUnavailableModalOpenAtom),[,r]=(0,n.useAtom)(am.ttsServiceAnnouncementDismissedAtom),{message:s}=ap();return(0,a.jsx)(rT.AnimatePresence,{children:e&&(0,a.jsx)(iQ.Root,{open:e,onOpenChange:()=>{t(!1),r(!0)},children:(0,a.jsxs)(iQ.Portal,{forceMount:!0,children:[(0,a.jsx)(iQ.Overlay,{asChild:!0,forceMount:!0,children:(0,a.jsx)(rS.motion.div,{initial:{opacity:0}
28,animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:(0,A.cn)("fixed inset-0 z-50",iG)})}),(0,a.jsx)(iQ.Content,{asChild:!0,forceMount:!0,children:(0,a.jsxs)(rS.motion.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{duration:.3,ease:[.16,1,.3,1]},className:(0,A.cn)("fixed top-[50%] left-[50%] z-50 w-full max-w-[min(600px,calc(100%-2rem))] translate-x-[-50%] translate-y-[-50%]","rounded-2xl border p-0 shadow-2xl","max-h-[90vh] overflow-hidden flex flex-col","thin-scrollbars",iW),children:[(0,a.jsx)("div",{className:"h-1.5 w-full bg-gradient-to-r from-yellow-600 via-purple-500 to-indigo-400"}),(0,a.jsx)(iQ.Close,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 z-10 h-8 w-8 rounded-full opacity-70 hover:opacity-100 transition-opacity","aria-label":"Close announcement","data-umami-event":"Close Service Announcement",children:(0,a.jsx)(F.X,{className:"h-4 w-4"})})}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 sm:p-8",children:[(0,a.jsxs)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.1,duration:.4},className:"flex flex-col items-center text-center mb-6",children:[(0,a.jsx)("div",{className:"mb-4 p-3 rounded-full bg-yellow-600/20 dark:bg-yellow-600/20",children:(0,a.jsx)(eR.AlertTriangle,{className:"h-8 w-8 text-yellow-600 dark:text-yellow-500"})}),(0,a.jsx)(iQ.Title,{className:"text-2xl sm:text-3xl font-semibold tracking-tight text-foreground mb-2",children:"Narration Temporarily Unavailable"}),(0,a.jsx)(iQ.Description,{className:"text-base sm:text-lg text-muted-foreground max-w-md",children:s||"The text-to-speech service is currently unavailable."})]}),(0,a.jsx)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.2,duration:.4},className:"mb-6",children:(0,a.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground text-center mb-4",children:"Our narration service leverages Microsoft Edge's built-in TTS capabilities to provide free text-to-speech. We do this by emulating how the Edge browser makes requests so we can use it in any web browser. Unfortunately, Microsoft has tightened their requirements, so we're looking for a new solution."})}),(0,a.jsx)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.25,duration:.4},className:"mb-3",children:(0,a.jsx)("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/10 dark:bg-blue-500/5 p-4",children:(0,a.jsxs)("div",{className:"flex items-start justify-center gap-3",children:[(0,a.jsx)("div",{className:"p-1.5 rounded-md bg-blue-500/20 dark:bg-blue-500/15 shrink-0 self-center",children:(0,a.jsx)(iJ,{className:"size-7 text-blue-600 dark:text-blue-400"})}),(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("div",{className:"font-medium text-blue-700 dark:text-blue-300 mb-1 flex items-center gap-2",children:[(0,a.jsx)("div",{className:"text-[10px] font-semibold border-blue-500/30 bg-blue-500/20 dark:bg-blue-500/15 text-blue-700 dark:text-blue-300 uppercase px-1.5 py-0.5 border rounded-full",children:"New"}),(0,a.jsx)("div",{className:"",children:"Microsoft Edge workaround"})]}),(0,a.jsx)("p",{className:"text-blue-600/90 dark:text-blue-400/90",children:"Apparently, our narration service still works if you're using the Edge web browser (both desktop and mobile)."})]})]})})}),(0,a.jsx)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.3,duration:.4},className:"mb-3",children:(0,a.jsx)(iZ.Accordion,{type:"single",collapsible:!0,className:"w-full",children:(0,a.jsxs)(iZ.AccordionItem,{value:"technical",className:"border-none",children:[(0,a.jsx)(iZ.AccordionTrigger,{className:"py-3 text-sm text-muted-foreground hover:text-foreground hover:no-underline justify-center gap-2",children:(0,a.jsx)("span",{children:"Why is this happening?"})}),(0,a.jsx)(iZ.AccordionContent,{className:"pt-2 pb-4",children:(0,a.jsxs)("div",{className:"rounded-lg bg-muted/50 p-3 text-sm text-muted-foreground space-y-2",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{className:"text-foreground
28/90",children:"The issue:"})," ","Microsoft now requires custom headers on WebSocket connections to their TTS service. Web browsers don't allow setting custom headers on WebSockets for security reasons."]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{className:"text-foreground/90",children:"Why the app works:"})," ","Native mobile apps have full control over network requests and can set the required headers, so the connection works normally."]})]})})]})})}),(0,a.jsxs)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4,duration:.4},className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 justify-center text-sm text-muted-foreground",children:[(0,a.jsx)("div",{className:"h-px flex-1 bg-border"}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(iX.Smartphone,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Continue with our free mobile app"})]}),(0,a.jsx)("div",{className:"h-px flex-1 bg-border"})]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,a.jsx)(u.Button,{asChild:!0,size:"lg",className:"flex-1 h-12 text-base font-medium bg-gradient-to-r from-indigo-500 to-indigo-400 hover:from-indigo-500 hover:to-indigo-500 text-white shadow-lg shadow-indigo-600/20 transition-all duration-300 hover:shadow-xl hover:shadow-indigo-500/30 mobile:py-2 text-shadow-sm","data-umami-event":"Download iOS App from Announcement",children:(0,a.jsxs)("a",{href:tK.MOBILE_APP_LINKS.ios,target:"_blank",rel:"noopener noreferrer",children:[(0,a.jsx)(i0,{className:"h-5 w-5 mr-2"}),"App Store",(0,a.jsx)(ez.ExternalLink,{className:"h-3.5 w-3.5 ml-2 opacity-70"})]})}),(0,a.jsx)(u.Button,{asChild:!0,size:"lg",className:"flex-1 h-12 text-base font-medium bg-gradient-to-r from-green-600 to-green-500 hover:from-green-600 hover:to-green-600 text-white shadow-lg shadow-green-500/20 transition-all duration-300 hover:shadow-xl hover:shadow-green-500/30 mobile:py-2 text-shadow-sm","data-umami-event":"Download Android App from Announcement",children:(0,a.jsxs)("a",{href:tK.MOBILE_APP_LINKS.android,target:"_blank",rel:"noopener noreferrer",children:[(0,a.jsx)(i1,{className:"h-5 w-5 mr-2"}),"Google Play",(0,a.jsx)(ez.ExternalLink,{className:"h-3.5 w-3.5 ml-2 opacity-70"})]})})]}),(0,a.jsxs)("p",{className:"text-center text-xs text-muted-foreground",children:[(0,a.jsx)("strong",{className:"text-foreground/80",children:tK.MOBILE_APP_NAME})," — completely free, same great voices"]})]})]}),(0,a.jsx)(rS.motion.div,{initial:{opacity:0}
28,animate:{opacity:1},transition:{delay:.5,duration:.4},className:"border-t px-6 py-4 bg-muted/30",children:(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3",children:[(0,a.jsx)("p",{className:"text-xs text-muted-foreground text-center sm:text-left",children:"We appreciate your patience and support."}),(0,a.jsx)(iQ.Close,{asChild:!0,children:(0,a.jsx)(u.Button,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground","data-umami-event":"Dismiss Service Announcement",children:"I understand, close this"})})]})})]})})]})})})}function i5({children:e}){return(0,a.jsx)(iC,{children:(0,a.jsxs)(an,{children:[e,(0,a.jsx)(iK,{autoPlay:!0}),(0,a.jsx)(iY,{}),(0,a.jsx)(i2,{})]})})}var i3=e.i(491288),i4=e.i(16862),i6=e.i(461638),i8=e.i(402824);function i7({onNext:e,onBack:t,onSkip:r}){let{openAuthModal:s}=(0,i8.useAuthModal)(),{setOnboardingInProgress:o}=rv(),[n,i]=(0,p.useState)(!1),l=(0,ex.default)();return(0,p.useEffect)(()=>{(async()=>{let e=(0,nF.createClient)(),{data:{user:t}}=await e.auth.getUser();i(!!t)})();let{data:{subscription:e}}=(0,nF.createClient)().auth.onAuthStateChange((e,t)=>{i(!!t?.user)});return()=>{e.unsubscribe()}},[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-2",children:[(0,a.jsx)(i3.ModalTitle,{className:"text-2xl text-center",children:"Your Data Stays Private"}),(0,a.jsx)(i3.ModalDescription,{className:"text-base text-center",children:"Local-first storage with optional cloud backup"})]}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-4 mobile:px-2 mobile:py-2",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3 py-2 mobile:py-2 mobile:gap-2",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,a.jsx)("div",{className:"w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)(j.Database,{className:"h-7 w-7 text-primary"})}),(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:"Your Device"})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4",children:[(0,a.jsx)(rc.ArrowRight,{className:`h-5 w-5 transition-colors ${n?"text-primary":"text-muted-foreground opacity-50"}`}),(0,a.jsx)("span",{className:`text-xs transition-colors ${n?"text-green-600 dark:text-green-500 font-medium":"text-muted-foreground/70"}`,children:n?"active":"optional"})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,a.jsx)("div",{className:`w-14 h-14 rounded-full flex items-center justify-center border-2 transition-all ${n?"bg-primary/10 border-primary border-solid":"bg-muted/50 border-dashed border-muted-foreground/20"}`,children:(0,a.jsx)(w.Cloud,{className:`h-7 w-7 transition-colors ${n?"text-primary":"text-muted-foreground/50"}`})}),(0,a.jsx)("span",{className:`text-xs font-medium transition-colors ${n?"text-foreground":"text-muted-foreground/50"}`,children:"Cloud Backup"})]})]}),(0,a.jsx)("div",{className:"space-y-3 text-sm text-muted-foreground text-center max-w-md mx-auto",children:n?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 text-green-600 dark:text-green-500 font-medium mb-2",children:[(0,a.jsx)(D.Check,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-sm",children:"Cloud sync enabled!"})]}),(0,a.jsx)("p",{children:"Your reading data is now backed up to the cloud. You can access it from any device by signing in with your account."}),(0,a.jsx)("p",{className:"text-xs",children:"Data syncs automatically in the background. You can manage sync settings anytime."})]}):(0,a.jsxs)(a.Fragment,{children:[!l&&(0,a.jsx)("p",{children:"Blogs Are Back stores everything locally on your device. Your reading history and bookmarks never leave your browser unless you sign in to enable cloud sync."}),(0,a.jsx)("p",{className:"text-xs text-balance",children:"You can enable cloud backup anytime from settings to access your data across multiple devices."})]})}),!n&&(0,a.jsxs)("button",{onClick:()=>{o(!0),s()},className:"flex items-center justify-center gap-2 px-4 py-3 rounded-lg bg-muted/30 border border-dashed mx-auto hover:bg-muted/50 duration-200 transition-colors",children:[(0,a.jsx)(w.Cloud,{className:"h-4 w-4 text-primary"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:"Enable cloud sync / sign in here"})]})]})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col sm:flex-row gap-2",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:r,className:"w-full sm:w-auto",children:"Skip Tour"}),(0,a.jsxs)("div",{className:"flex gap-2 w-full sm:w-auto",children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:t,className:"flex-1 sm:flex-none",children:"Back"}),(0,a.jsx)(u.Button,{onClick:e,className:"flex-1 sm:flex-none",children:"Continue"})]})]})]})}function i9({onNext:e,onSkip:t}){return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-2",children:[(0,a.jsx)("div",{className:"flex justify-center mb-4",children:(0,a.jsx)("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:(0,a.jsx)(tB.BookOpen,{className:"h-8 w-8 text-primary"})})}),(0,a.jsxs)(i3.ModalTitle,{className:"text-2xl text-center",children:["Welcome to ",(0,a.jsx)("span",{className:"tracking-tighter",children:tK.APP_NAME}),"!"]}),(0,a.jsx)(i3.ModalDescription,{className:"text-base mt-3 text-center",children:"Your privacy-first RSS reader that keeps you focused on what matters"})]}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:"Blogs Are Back brings back the joy of reading blogs. No algorithms, no ads, no tracking—just you and the content you care about. Your feed, your way."}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2 px-4 py-3 rounded-lg bg-muted/50 border",children:[(0,a.jsx)(ob.Shield,{className:"h-4 w-4 text-primary"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:"Privacy First: Your data stays local by default"})]})]})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col sm:flex-row gap-2",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:t,className:"w-full sm:w-auto",children:"Skip Tour"}),(0,a.jsx)(u.Button,{onClick:e,className:"w-full sm:w-auto",children:"Get Started"})]})]})}let le=(0,eC.default)("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}
28],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]),lt=({src:e,alt:t,className:r="",showFallback:s=!1,fallbackText:o,...n})=>{let[i,l]=(0,p.useState)("loading"),c=`object-cover transition-opacity duration-300 ease-in-out ${r}`;return"error"===i?(0,a.jsxs)("div",{role:"img","aria-label":`Fallback for: ${t}`,className:`flex flex-col items-center justify-center overflow-hidden bg-zinc-100 dark:bg-zinc-800 text-zinc-400 dark:text-zinc-600 border border-zinc-200 dark:border-zinc-700 ${r}`,children:[(0,a.jsx)("div",{className:"absolute inset-0 opacity-20",style:{backgroundImage:"radial-gradient(currentColor 1px, transparent 1px)",backgroundSize:"12px 12px"}}),(0,a.jsx)("div",{className:"relative z-10 p-2",children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-1/3 h-1/3 min-w-6 min-h-6 mx-auto opacity-80",children:[(0,a.jsx)("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),(0,a.jsx)("circle",{cx:"9",cy:"9",r:"2"}),(0,a.jsx)("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),s&&(0,a.jsx)("span",{className:"relative z-10 text-xs font-medium mt-2 px-2 text-center truncate max-w-full hidden sm:block opacity-70",children:o||"Image unavailable"})]}):(0,a.jsxs)(a.Fragment,{children:["loading"===i&&(0,a.jsx)("div",{className:`animate-pulse bg-zinc-200 dark:bg-zinc-700 absolute inset-0 ${r}`}),(0,a.jsx)("img",{src:e,alt:t,onLoad:()=>l("success"),onError:()=>l("error"),className:`${c} ${"loading"===i?"opacity-0":"opacity-100"}`,...n})]})};function lr({blog:e,isSelected:t,onToggle:r}){return(0,a.jsxs)(rS.motion.div,{className:(0,A.cn)("relative flex flex-col rounded-lg border p-4 cursor-pointer",t&&"border-primary bg-primary/5","z-50"),onClick:r,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),r())},role:"button",tabIndex:0,"aria-pressed":t,"aria-label":`${t?"Deselect":"Select"}
28 ${e.title}`,whileHover:{scale:1.02},whileTap:{scale:.98},transition:{type:"spring",stiffness:400,damping:25},children:[(0,a.jsx)(rS.motion.div,{className:(0,A.cn)("absolute top-2 right-2 w-5 h-5 rounded-full border-2 flex items-center justify-center",t?"bg-primary border-primary":"border-muted-foreground/30"),animate:{scale:t?[1,1.2,1]:1},transition:{duration:.3},children:t&&(0,a.jsx)(rS.motion.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",stiffness:500,damping:25},children:(0,a.jsx)(D.Check,{className:"h-3 w-3 text-primary-foreground"})})}),(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-2",children:[e.site_icon?(0,a.jsx)(lt,{src:e.site_icon,alt:e.title,className:"w-10 h-10 rounded-md object-cover flex-shrink-0 relative"}):(0,a.jsx)("div",{className:"w-10 h-10 rounded-md bg-muted flex items-center justify-center flex-shrink-0",children:(0,a.jsx)("span",{className:"text-sm font-medium text-muted-foreground",children:e.title.charAt(0).toUpperCase()})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("h3",{className:"font-medium text-sm line-clamp-1 mb-1",children:e.title}),e.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})]}),e.tags&&e.tags.length>0&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[e.tags.slice(0,3).map(e=>(0,a.jsx)(J.TagBadge,{tag:e,className:"text-xs"},e)),e.tags.length>3&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",e.tags.length-3]})]})]})}var ls=e.i(648440);async function la(){let e=await fetch("/api/public/directory-blogs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({limit:30,offset:0,sortBy:"rank",freeAccessFilter:"full-content"})});if(!e.ok)throw Error("Failed to fetch directory blogs");return(await e.json()).blogs||[]}function lo({tag:e,active:t,onClick:r}){let s=(0,et.getTagColor)(e);return(0,a.jsx)("button",{onClick:r,className:(0,A.cn)("px-2.5 py-1 rounded-full text-xs font-medium transition-all whitespace-nowrap flex-shrink-0",s,t?"shadow-[inset_0_0_0_2px_currentColor] font-semibold":"opacity-70 hover:opacity-100"),"aria-pressed":t,children:e})}function ln({selectedBlogs:e,onToggleBlog:t,onFollow:r,onBack:s,onSkip:o}){let[i,l]=(0,p.useState)(!1),[c,d]=(0,p.useState)(""),[m,h]=(0,p.useState)([]),f=(0,ex.default)(),[g,x]=(0,n.useAtom)(ls.referralBlogAtom),b=(0,p.useRef)(!1),{data:y=[],isLoading:v}=(0,nH.useQuery)({queryKey:["onboarding-directory-blogs"],queryFn:la,staleTime:3e5});(0,p.useEffect)(()=>{g&&!b.current&&!v&&(b.current=!0,e.some(e=>e.id===g.id)||t({id:g.id,feed_url:g.feed_url,title:g.title,description:g.description,url:g.url,site_icon:g.site_icon??void 0,has_full_content:g.has_full_content,category:g.category,requires_proxy:g.requires_proxy,posts_require_proxy:g.posts_require_proxy,blocks_iframe:g.blocks_iframe}))},[g,v,e,t]);let j=(0,p.useMemo)(()=>{let e=new Map;return y.forEach(t=>{t.tags&&t.tags.length>0&&t.tags.forEach(t=>{e.set(t,(e.get(t)||0)+1)})}),Array.from(e.entries()).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e])=>e)},[y]),w=(0,p.useMemo)(()=>{let e=y;if(m.length>0&&(e=e.filter(e=>e.tags?.some(e=>m.includes(e)))),c.trim()){let t=c.toLowerCase();e=e.filter(e=>e.title.toLowerCase().includes(t)||e.description?.toLowerCase().includes(t))}return g&&(e=e.filter(e=>e.id!==g.id)),e},[y,m,c,g]),N=(0,p.useMemo)(()=>g?{id:g.id,feed_url:g.feed_url,url:g.url,title:g.title,description:g.description,site_icon:g.site_icon??void 0,has_full_content:g.has_full_content??!1,category:g.category??"unknown",requires_proxy:g.requires_proxy,posts_require_proxy:g.posts_require_proxy,blocks_iframe:g.blocks_iframe,rank:100,bucket:3,tags:[],hidden:!1,disabled:!1,has_partial_archive:g.has_partial_archive??void 0,submission_source:"manual",discovery_metadata:{},metadata:{},created_at:new Date().toISOString(),updated_at:new Date().toISOString()}:null,[g]),k=async()=>{l(!0);try{await r()}finally{l(!1)}},C=e.length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-2",children:[(0,a.jsx)(i3.ModalTitle,{className:"text-xl text-center",children:"Let's get you started"}),(0,a.jsx)(i3.ModalDescription,{className:"text-center",children:"Select a few blogs to follow from our curated directory"})]}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 px-2 py-4 flex flex-col overflow-hidden",children:[(0,a.jsx)("div",{className:"space-y-3 flex-shrink-0",children:j.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2 overflow-x-auto pb-1 -mx-2 px-2 thin-scrollbars",role:"group","aria-label":"Filter blogs by topic",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-muted-foreground whitespace-nowrap flex-shrink-0",children:"Topics:"}),j.map(e=>(0,a.jsx)(lo,{tag:e,active:m.includes(e),onClick:()=>{h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}},e)),m.length>0&&(0,a.jsx)("button",{onClick:()=>{h([])},className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 ml-1",children:"Clear"})]})}),(0,a.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto mt-3 thin-scrollbars",children:(0,a.jsx)("div",{className:"px-4 py-2",children:v?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsx)(H.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):0===w.length?(0,a.jsx)("div",{className:"text-center py-12 text-sm text-muted-foreground",children:c||m.length>0?"No blogs match your filters. Try adjusting your search or topics.":"No blogs available. You can add your own later!"}):(0,a.jsxs)("div",{className:"space-y-4 pb-3",children:[N&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[(0,a.jsx)(le,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"You came from this blog"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"absolute -inset-1 rounded-xl bg-gradient-to-r from-primary/20 via-primary/10 to-primary/20 blur-sm"}),(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)(lr,{blog:N,isSelected:e.some(e=>e.id===N.id),onToggle:()=>
28t({id:N.id,feed_url:N.feed_url,title:N.title,description:N.description??void 0,url:N.url,site_icon:N.site_icon??void 0,has_full_content:N.has_full_content,category:N.category,requires_proxy:N.requires_proxy,posts_require_proxy:N.posts_require_proxy,blocks_iframe:N.blocks_iframe})})})]})]}),w.length>0&&(0,a.jsxs)("div",{className:"space-y-2",children:[N&&(0,a.jsx)("div",{className:"text-sm font-medium text-muted-foreground pt-2",children:"More blogs to explore"}),(0,a.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:w.map(r=>(0,a.jsx)(lr,{blog:r,isSelected:e.some(e=>e.id===r.id),onToggle:()=>t({id:r.id,feed_url:r.feed_url,title:r.title,description:r.description,url:r.url,site_icon:r.site_icon,has_full_content:r.has_full_content,category:r.category,requires_proxy:r.requires_proxy,posts_require_proxy:r.posts_require_proxy,blocks_iframe:r.blocks_iframe})},r.id))})]})]})})})]}),(0,a.jsxs)(i3.ModalFooter,{className:f?"":"flex flex-col sm:flex-row gap-2",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:o,disabled:i,className:"w-full sm:w-auto",children:"Skip - I'll add my own later"}),(0,a.jsxs)("div",{className:"flex gap-2 w-full sm:w-auto",children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:s,disabled:i,className:"flex-1 sm:flex-none",children:"Back"}),(0,a.jsx)(u.Button,{onClick:k,disabled:i,className:"flex-1 sm:flex-none",children:i?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(H.Loader2,{className:"h-4 w-4 mr-2 animate-spin"}),"Following..."]}):C>0?`Follow ${C} Blog${C>1?"s":""}`:"Continue"})]})]})]})}var li=e.i(595468);function ll({blogsFollowedCount:e,onComplete:t}){let r=(0,ex.default)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-2",children:[(0,a.jsx)("div",{className:"flex justify-center mb-4",children:(0,a.jsx)(rS.motion.div,{className:"w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center",initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:200,damping:15,delay:.1},children:(0,a.jsx)(rS.motion.div,{initial:{scale:0,rotate:-180},animate:{scale:1,rotate:0},transition:{type:"spring",stiffness:200,damping:20,delay:.3},children:(0,a.jsx)(li.CheckCircle2,{className:"h-8 w-8 text-green-500"})})})}),(0,a.jsxs)(rS.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.4,duration:.3},children:[(0,a.jsx)(i3.ModalTitle,{className:"text-2xl text-center",children:"You're all set!"}),(0,a.jsx)(i3.ModalDescription,{className:"text-base mt-2 text-center",children:e>0?`Great choice! We've added ${e} blog${e>1?"s":""} to your feed.`:"You're ready to start reading!"})]})]}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-6",children:(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:e>0?"Start exploring or add more blogs from the directory anytime.":"Add blogs from the directory or paste your own RSS feed URLs to get started."}),!r&&(0,a.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg bg-primary/5 border border-primary/20 mobile:hidden",children:[(0,a.jsx)(rl.Sparkles,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h4",{className:"text-sm font-medium mb-1",children:"Pro Tip"}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Press"," ",(0,a.jsx)("kbd",{className:"px-1.5 py-0.5 text-xs font-semibold bg-muted rounded",children:"Cmd+K"})," ","(or"," ",(0,a.jsx)("kbd",{className:"px-1.5 py-0.5 text-xs font-semibold bg-muted rounded",children:"Ctrl+K"}),") to quickly search and navigate. Check out more keyboard shortcuts in the settings!"]})]})]})]})}),(0,a.jsx)(i3.ModalFooter,{children:(0,a.jsx)(u.Button,{onClick:t,className:"w-full",children:"Start Reading"})})]})}let lc=["Welcome","Storage","Extension","Get Started","Complete"],ld=lc.length,lu=[.4,0,.2,1];function lm({currentStep:e,totalSteps:t=ld,className:r,onGoToStep:s}){let o=Array.from({length:t},(e,r)=>r<t-1?"10px 1fr":"10px").join(" ");return(0,a.jsx)("div",{className:(0,A.cn)("flex flex-col items-center w-full",r),role:"progressbar","aria-valuenow":e+1,"aria-valuemin":1,"aria-valuemax":t,"aria-label":`Onboarding progress: Step ${e+1} of ${t}`,children:(0,a.jsxs)("div",{className:"w-full max-w-sm items-center",style:{display:"grid",gridTemplateColumns:o,rowGap:"6px"},children:[Array.from({length:t}).map((r,o)=>{let n=o<e,i=o===e;return(0,a.jsxs)(p.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:"flex items-center justify-center justify-self-center cursor-pointer",style:{gridRow:1},onClick:()=>s?.(o),"aria-label":`Go to step ${o+1}: ${lc[o]}`,children:(0,a.jsx)(rS.motion.div,{className:(0,A.cn)("rounded-full",n||i?"bg-primary":"bg-muted-foreground
28/25"),animate:{width:i?10:8,height:i?10:8},transition:{type:"spring",stiffness:400,damping:25}})}),o<t-1&&(0,a.jsx)("div",{className:"h-[2px] bg-muted-foreground/15 rounded-full overflow-hidden",style:{gridRow:1},children:(0,a.jsx)(rS.motion.div,{className:"h-full bg-primary rounded-full origin-left",initial:{scaleX:0},animate:{scaleX:+!!n},transition:{duration:.4,ease:lu}})})]},o)}),Array.from({length:t}).map((t,r)=>{let o=r<e,n=r===e;return(0,a.jsx)("button",{type:"button",className:"cursor-pointer justify-self-center",style:{gridRow:2,gridColumn:2*r+1},onClick:()=>s?.(r),children:(0,a.jsx)("span",{className:(0,A.cn)("text-[11px] leading-none whitespace-nowrap transition-colors",n?"text-primary font-medium":o?"text-muted-foreground":"text-muted-foreground/40"),children:lc[r]})},r)})]})})}let lh=e=>(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e,children:[(0,a.jsx)("title",{children:"Brave"}),(0,a.jsx)("path",{d:"m15.68 0 2.096 2.38s1.84-.512 2.709.358c.868.87 1.584 1.638 1.584 1.638l-.562 1.381.715 2.047s-2.104 7.98-2.35 8.955c-.486 1.919-.818 2.66-2.198 3.633a186.42 186.42 0 0 1-4.293 2.916c-.409.256-.92.692-1.38.692-.46 0-.97-.436-1.38-.692a185.796 185.796 0 0 1-4.293-2.916c-1.38-.973-1.712-1.714-2.197-3.633-.247-.975-2.351-8.955-2.351-8.955l.715-2.047-.562-1.381s.716-.768 1.585-1.638c.868-.87 2.708-.358 2.708-.358L8.321 0h7.36zm-3.679 14.936c-.14 0-1.038.317-1.758.69-.72.373-1.242.637-1.409.742-.167.104-.065.301.087.409.152.107 2.194 1.69 2.393 1.866.198.175.489.464.687.464.198 0 .49-.29.688-.464.198-.175 2.24-1.759 2.392-1.866.152-.108.254-.305.087-.41-.167-.104-.689-.368-1.41-.741-.72-.373-1.617-.69-1.757-.69zm0-11.278s-.409.001-1.022.206-1.278.46-1.584.46c-.307 0-2.581-.434-2.581-.434S4.119 7.152 4.119 7.849c0 .697.339.881.68 1.243l2.02 2.149c.192.203.59.511.356 1.066-.235.555-.58 1.26-.196 1.977.384.716 1.042 1.194 1.464 1.115.421-.08 1.412-.598 1.776-.834.364-.237 1.518-1.19 1.518-1.554 0-.365-1.193-1.02-1.413-1.168-.22-.15-1.226-.725-1.247-.95-.02-.227-.012-.293.284-.851.297-.559.831-1.304.742-1.8-.089-.495-.95-.753-1.565-.986-.615-.232-1.799-.671-1.947-.74-.148-.068-.11-.133.339-.175.448-.043 1.719-.212 2.292-.052.573.16 1.552.403 1.632.532.079.13.149.134.067.579-.081.445-.5 2.581-.541 2.96-.04.38-.12.63.288.724.409.094 1.097.256 1.333.256s.924-.162 1.333-.256c.408-.093.329-.344.288-.723-.04-.38-.46-2.516-.541-2.961-.082-.445-.012-.45.067-.579.08-.129 1.059-.372 1.632-.532.573-.16 1.845.009 2.292.052.449.042.487.107.339.175-.148.069-1.332.508-1.947.74-.615.233-1.476.49-1.565.986-.09.496.445 1.241.742 1.8.297.558.304.624.284.85-.02.226-1.026.802-1.247.95-.22.15-1.413.804-1.413 1.169 0 .364 1.154 1.317 1.518 1.554.364.236 1.355.755 1.776.834.422.079 1.08-.4 1.464-1.115.384-.716.039-1.422-.195-1.977-.235-.555.163-.863.355-1.066l2.02-2.149c.341-.362.68-.546.68-1.243 0-.697-2.695-3.96-2.695-3.96s-2.274.436-2.58.436c-.307 0-.972-.256-1.585-.461-.613-.205-1.022-.206-1.022-.206z",fill:"currentColor"})]}),lf=e=>(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e,children:[(0,a.jsx)("title",{children:"Arc"}),(0,a.jsx)("path",{d:"M23.937 8.509a2.951 2.951 0 0 0-.336-2.097 2.852 2.852 0 0 0-1.908-1.35 2.918 2.918 0 0 0-.562-.058h-.01c-1.377 0-2.533.988-2.807 2.338a6.956 6.956 0 0 1-.92 2.27.263.263 0 0 1-.236.12.263.263 0 0 1-.22-.146l-2.86-5.99c-.362-.763-1.013-1.362-1.823-1.598A2.875 2.875 0 0 0 8.85 3.522L5.897 9.733c-.079.163-.31.158-.378-.005v-.005a2.86 2.86 0 0 0-2.665-1.797c-.378 0-.751.073-1.108.22-1.472.615-2.129 2.35-1.52 3.82.558 1.33 1.472 2.586 2.66 3.669.084.078.11.2.063.304l-.956 2.008c-.673 1.419-.132 3.148 1.266 3.857.41.205.846.31 1.298.31a2.882 2.882 0 0 0 2.596-1.64l.825-1.729a.254.254 0 0 1 .305-.136 11.46 11.46 0 0 0 3.006.42c1.119 0 2.222-.168 3.29-.478a.263.263 0 0 1 .31.137l.814 1.713c.483 1.02 1.492 1.713 2.617 1.718.457 0 .898-.1 1.313-.31 1.403-.71 1.94-2.443 1.267-3.868l-1.025-2.154a.265.265 0 0 1 .058-.305c1.986-1.85 3.452-4.272 4.004-6.973ZM6.212 20.017a1.835 1.835 0 0 1-.676.762 1.835 1.835 0 0 1-.98.284c-.272 0-.55-.063-.808-.19-.904-.446-1.246-1.57-.81-2.48l.794-1.665c.068-.148.257-.2.383-.106.169.121.342.237.52.353.7.446 1.43.825 2.182 1.135a.26.26 0 0 1 .141.352l-.746 1.555Zm5.076-2.044c-4.209 0-8.654-2.853-10.126-6.495a1.829 1.829 0 0 1 1.01-2.38c.225-.09.456-.137.682-.137.725 0 1.409.43 1.698 1.145.92 2.281 4.004 4.21 6.736 4.21.42 0 .841-.042 
281.256-.116a.264.264 0 0 1 .284.142l1.377 2.9a.261.261 0 0 1-.163.363c-.899.237-1.818.368-2.754.368Zm-.599-4.93.636-1.334a.145.145 0 0 1 .258 0l.62 1.303c.042.084-.016.19-.105.205a5.892 5.892 0 0 1-.8.058 5.063 5.063 0 0 1-.488-.026c-.11-.016-.163-.121-.12-.205Zm8.46 7.825a1.831 1.831 0 0 1-2.032-.278 1.83 1.83 0 0 1-.432-.578L11.698 9.528c-.1-.21-.4-.21-.494 0L9.66 12.781a.262.262 0 0 1-.32.137c-1.051-.363-2.05-.978-2.79-1.719a.255.255 0 0 1-.048-.294l3.342-7.03a1.53 1.53 0 0 1 .52-.621c1.052-.688 2.281-.258 2.738.704l6.858 14.425c.431.914.095 2.039-.81 2.485Zm-1.444-9.648a.258.258 0 0 1 .031-.273c.783-1.004 1.356-2.175 1.603-3.42a1.83 1.83 0 0 1 2.239-1.42c.972.242 1.534 1.251 1.33 2.234-.484 2.301-1.683 4.388-3.317 6.022a.263.263 0 0 1-.425-.068l-1.461-3.075Z",fill:"currentColor"})]}),lp=e=>(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e,children:[(0,a.jsx)("title",{children:"Opera"}),(0,a.jsx)("path",{d:"M8.051 5.238c-1.328 1.566-2.186 3.883-2.246 6.48v.564c.061 2.598.918 4.912 2.246 6.479 1.721 2.236 4.279 3.654 7.139 3.654a8.65 8.65 0 0 0 4.807-1.471 11.928 11.928 0 0 1-8.567 3.042C5.064 23.689 0 18.436 0 12 0 5.371 5.373 0 12 0h.045a11.965 11.965 0 0 1 7.953 3.055c-1.408-.93-3.051-1.471-4.81-1.471-2.858 0-5.417 1.42-7.14 3.654h.003zM24 12c0 3.556-1.545 6.748-4.002 8.945-3.078 1.5-5.946.451-6.896-.205 3.023-.664 5.307-4.32 5.307-8.74 0-4.422-2.283-8.075-5.307-8.74.949-.654 3.818-1.703 6.896-.205A11.96 11.96 0 0 1 24 12z",fill:"currentColor"})]}),lg=e=>(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",...e,children:[(0,a.jsx)("title",{children:"Vivaldi"}),(0,a.jsx)("path",{d:"M12 0C6.75 0 3.817 0 1.912 1.904.007 3.81 0 6.75 0 12s0 8.175 1.912 10.08C3.825 23.985 6.75 24 12 24c5.25 0 8.183 0 10.088-1.904C23.993 20.19 24 17.25 24 12s0-8.175-1.912-10.08C20.175.015 17.25 0 12 0zm-.168 3a9 9 0 0 1 6.49 2.648 9 9 0 0 1 0 12.704A9 9 0 1 1 11.832 3zM7.568 7.496a1.433 1.433 0 0 0-.142.004A1.5 1.5 0 0 0 6.21 9.75l1.701 3c.93 1.582 1.839 3.202 2.791 4.822a1.417 1.417 0 0 0 1.41.75 1.5 1.5 0 0 0 1.223-.81l4.447-7.762A1.56 1.56 0 0 0 18 8.768a1.5 1.5 0 1 0-2.828.914 2.513 2.513 0 0 1 .256 1.119v.246a2.393 2.393 0 0 1-2.52 2.13 2.348 2.348 0 0 1-1.965-1.214c-.307-.51-.6-1.035-.9-1.553-.42-.72-.826-1.41-1.246-2.16a1.433 1.433 0 0 0-1.229-.754Z",fill:"currentColor"})]});var lx=e.i(341948);function lb({onNext:e,onBack:t,onSkip:r}){let s=(0,n.useAtomValue)(T.extensionAvailableAtom),o=(0,ex.default)(),[i,l]=(0,p.useState)(!1);return((0,p.useEffect)(()=>{if(s&&!i){l(!0);let t=setTimeout(e,1200);return()=>clearTimeout(t)}},[s,i,e]),o)?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-2",children:[(0,a.jsx)(i3.ModalTitle,{className:"text-xl text-center",children:"One more thing"}),(0,a.jsx)(i3.ModalDescription,{className:"text-sm mt-1 text-center",children:"On desktop, our browser extension fetches feeds directly. On mobile, we handle it for you through our servers."})]}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-6",children:(0,a.jsx)("div",{className:"rounded-lg border bg-muted/30 p-4",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:"For the fastest experience with unlimited refreshes, try us on desktop with the extension installed."})})}),(0,a.jsxs)(i3.ModalFooter,{className:"gap-2",children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:t,children:"Back"}),(0,a.jsx)(u.Button,{onClick:e,children:"Continue"})]})]}):s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i3.ModalHeader,{className:"text-center pb-2",children:(0,a.jsx)(i3.ModalTitle,{className:"text-xl text-center",children:"Extension connected"})}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-8",children:(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-full bg-green-500/10 flex items-center justify-center",children:(0,a.jsx)(li.CheckCircle2,{className:"h-6 w-6 text-green-500"})}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:"Feeds will load directly in your browser."})]})}),(0,a.jsx)(i3.ModalFooter,{children:(0,a.jsx)(u.Button,{onClick:e,className:"w-full",children:"Continue"})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center pb-1",children:[(0,a.jsx)(i3.ModalTitle,{className:"text-xl text-center",children:"Unlock unlimited reading"}),(0,a.jsx)(i3.ModalDescription,{className:"text-sm mt-1.5 text-center",children:"The extension fetches feeds directly in your browser—faster, private, and without limits."})]}),(0,a.jsx)(i3.ModalBody,{className:"px-6 py-5",children:(0,a.jsxs)("div",{className:"space-y-5",children:[(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("a",{href:tK.EXTENSION_URLS.CHROME,target:"_blank",rel:"noopener noreferrer",className:(0,A.cn)("group flex flex-col items-center gap-3 p-5 rounded-xl border-2","bg-gradient-to-b from-background to-muted/30","border-border/60 hover:border-foreground
28/20","transition-all duration-200 hover:shadow-md"),children:[(0,a.jsx)(ov.default,{className:"h-10 w-10 text-foreground/80 group-hover:text-foreground transition-colors"}),(0,a.jsxs)("div",{className:"relative flex items-center justify-center text-sm font-medium",children:[(0,a.jsx)("span",{children:"Chrome"}),(0,a.jsx)(rc.ArrowRight,{className:"absolute left-full ml-1.5 h-3.5 w-3.5 opacity-0 -translate-x-1 group-hover:opacity-70 group-hover:translate-x-0 transition-all"})]})]}),(0,a.jsx)("div",{className:"flex items-center justify-center gap-1",children:[{Icon:iJ,name:"Edge"},{Icon:lh,name:"Brave"},{Icon:lf,name:"Arc"},{Icon:lp,name:"Opera"},{Icon:lg,name:"Vivaldi"}].map(({Icon:e,name:t})=>(0,a.jsx)("a",{href:tK.EXTENSION_URLS.CHROME,target:"_blank",rel:"noopener noreferrer",title:`Install for ${t}`,className:"p-1.5 rounded-md hover:bg-muted/50 transition-colors",children:(0,a.jsx)(e,{className:"h-4 w-4 text-muted-foreground/60 hover:text-muted-foreground transition-colors"})},t))})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("a",{href:tK.EXTENSION_URLS.FIREFOX,target:"_blank",rel:"noopener noreferrer",className:(0,A.cn)("group flex flex-col items-center gap-3 p-5 rounded-xl border-2","bg-gradient-to-b from-background to-muted/30","border-border/60 hover:border-foreground
28/20","transition-all duration-200 hover:shadow-md"),children:[(0,a.jsx)(oy.default,{className:"h-10 w-10 text-foreground/80 group-hover:text-foreground transition-colors"}),(0,a.jsxs)("div",{className:"relative flex items-center justify-center text-sm font-medium",children:[(0,a.jsx)("span",{children:"Firefox"}),(0,a.jsx)(rc.ArrowRight,{className:"absolute left-full ml-1.5 h-3.5 w-3.5 opacity-0 -translate-x-1 group-hover:opacity-70 group-hover:translate-x-0 transition-all"})]})]}),(0,a.jsx)("div",{className:"h-[30px]"})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3 text-xs text-muted-foreground/70",children:[(0,a.jsxs)("a",{href:tK.EXTENSION_URLS.SOURCE,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 hover:text-muted-foreground transition-colors",children:[(0,a.jsx)(lx.default,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:"Source code"})]}),(0,a.jsx)("span",{children:"·"}),(0,a.jsxs)("a",{href:"/cors-and-rss",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 hover:text-muted-foreground transition-colors",children:[(0,a.jsx)("span",{children:"Why this is needed"}),(0,a.jsx)(ez.ExternalLink,{className:"h-2.5 w-2.5"})]})]})]})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col sm:flex-row gap-2",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:r,className:"w-full sm:w-auto text-muted-foreground",children:"Skip Tour"}),(0,a.jsxs)("div",{className:"flex gap-2 w-full sm:w-auto",children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:t,className:"flex-1 sm:flex-none",children:"Back"}),(0,a.jsx)(u.Button,{variant:"ghost",onClick:e,className:"flex-1 sm:flex-none",children:"Continue without"})]})]})]})}function ly(){let e=(0,ru.useMounted)(),t=(0,ex.default)(),[r,s]=(0,p.useState)(!1),{shouldShowOnboarding:o,step:n,selectedBlogs:i,selectedCount:l,onboardingInProgress:c,nextStep:d,prevStep:u,skipAll:m,toggleBlog:h,followSelectedBlogs:f,completeOnboarding:g,goToStep:x}=rv(),b=(0,p.useRef)(!1);return((0,p.useEffect)(()=>{!e||(o||c)&&!r&&(s(!0),b.current||((0,ey.trackOnboardingStepViewed)("welcome"),b.current=!0))},[o,c,e,r]),e&&(o||c))?(0,a.jsx)(i3.Modal,{open:r,onOpenChange:function(e){e||(c||m(),s(!1))},children:(0,a.jsxs)(i3.ModalContent,{className:"md:max-w-2xl!",children:[(0,a.jsx)("div",{className:"flex justify-center px-6 pt-3 pb-1 flex-shrink-0",children:(0,a.jsx)(lm,{currentStep:n,onGoToStep:x})}),(0,a.jsx)(rT.AnimatePresence,{mode:"wait",children:(0,a.jsx)(rS.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:t?.2:.3,ease:"easeInOut"},className:"flex flex-col flex-1 min-h-0",children:(()=>{switch(n){case 0:return(0,a.jsx)(i9,{onNext:d,onSkip:m});case 1:return(0,a.jsx)(i7,{onNext:d,onBack:u,onSkip:m});case 2:return(0,a.jsx)(lb,{onNext:d,onBack:u,onSkip:m});case 3:return(0,a.jsx)(ln,{selectedBlogs:i,onToggleBlog:h,onFollow:f,onBack:u,onSkip:()=>{d()}});case 4:return(0,a.jsx)(ll,{blogsFollowedCount:l,onComplete:g});default:return null}})()},n)})]})}):null}var lv=e.i(929532);function lj(){let[e,t]=(0,p.useState)(!1),[r,s]=(0,n.useAtom)(ls.referralBlogAtom),[o,i]=(0,n.useAtom)(ls.referralModalShownAtom),l=(0,n.useAtomValue)(er.blogsLoadingAtom);(0,lv.useReferralBlog)();let{data:c=[],isLoading:d}=(0,nq.useFollowedBlogs)(),m=(0,nq.useFollowDirectoryBlog)(),h=!!r&&c.some(e=>e.directory_blog_id===r.id);(0,p.useEffect)(()=>{if(l||d||o||!r)return;let e=c.length>0;h?(0,ls.clearReferralState)():e&&r&&t(!0)},[r,o,c.length,h,l,d]);let f=async()=>{if(r)try{await m.mutateAsync({directoryBlogId:r.id,directoryBlogData:{feed_url:r.feed_url,title:r.title,description:r.description,url:r.url,site_icon:r.site_icon??void 0,has_full_content:r.has_full_content,category:r.category,requires_proxy:r.requires_proxy,posts_require_proxy:r.posts_require_proxy,blocks_iframe:r.blocks_iframe}}),i(!0),(0,ls.clearReferralState)(),t(!1)}catch{}},g=()=>{i(!0),(0,ls.clearReferralState)(),t(!1)};return r?(0,a.jsx)(i3.Modal,{open:e,onOpenChange:e=>!e&&g(),children:(0,a.jsxs)(i3.ModalContent,{className:"sm:max-w-md",children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center",children:[(0,a.jsx)(i3.ModalTitle,{children:"Follow This Blog?"}),(0,a.jsx)(i3.ModalDescription,{children:"You arrived here from a blog on our directory"})]}),(0,a.jsx)("div",{className:"px-6 py-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-4 roun
28ded-lg border bg-muted/30 p-4",children:[r.site_icon?(0,a.jsx)("img",{src:r.site_icon,alt:"",className:"h-12 w-12 shrink-0 rounded-lg object-cover"}):(0,a.jsx)("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-muted",children:(0,a.jsx)($.Rss,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"truncate font-semibold",children:r.title}),r.description&&(0,a.jsx)("p",{className:"mt-1 line-clamp-2 text-sm text-muted-foreground",children:r.description}),(0,a.jsxs)("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Visit blog",(0,a.jsx)(ez.ExternalLink,{className:"h-3 w-3"})]})]})]})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col gap-2 sm:flex-row",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:g,className:"w-full sm:w-auto",children:"No thanks"}),(0,a.jsx)(u.Button,{onClick:f,disabled:m.isPending,className:"w-full sm:w-auto",children:m.isPending?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(H.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Following..."]}):"Follow This Blog"})]})]})}):null}function lw(){return(0,a.jsx)(p.Suspense,{fallback:null,children:(0,a.jsx)(lj,{})})}var lN=e.i(625959),lk=e.i(950216),lC=e.i(761911);function lA({match:e,selected:t,onToggle:r,disabled:s}){let{importedBlog:o,catalogBlog:n,matchType:i}=e,l="directory"===n.catalogType;return(0,a.jsxs)("label",{className:(0,A.cn)("flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors",t?"border-primary bg-primary/5":"border-border hover:border-primary/50",s&&"opacity-50 cursor-not-allowed"),children:[(0,a.jsx)(lN.Checkbox,{checked:t,onCheckedChange:r,disabled:s,className:"mt-1"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:o.title})}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:o.url}),(0,a.jsxs)("div",{className:"flex flex-row gap-4 lg:gap-6 w-full md:pl-2 mt-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 my-2 text-muted-foreground",children:[(0,a.jsx)(rc.ArrowRight,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-xs",children:"exact_feed_url"===i?"Exact match":"Domain match"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2 p-2 bg-primary/5 rounded",children:[n.site_icon&&(0,a.jsx)("img",{src:n.site_icon,alt:"",className:"w-6 h-6 rounded flex-shrink-0",onError:e=>{e.currentTarget.style.display="none"}}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium truncate",children:n.title}),(0,a.jsx)("span",{className:(0,A.cn)("inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs",l?"bg-primary/10 text-primary":"bg-violet-500/10 text-violet-600 dark:text-violet-400"),children:l?"Directory":"Community"})]}),n.follower_count>0&&(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1 text-xs text-muted-foreground",children:[(0,a.jsx)(lC.Users,{className:"h-3 w-3"}),n.follower_count.toLocaleString()," follower",1!==n.follower_count?"s":""]})]})]})]})]})]})}function lS(){let{isOpen:e,phase:t,matches:r,selectedBlogIds:s,toggleSelection:o,selectAll:i,performConversion:l,dismiss:c}=function(){let[e,t]=(0,n.useAtom)(rd.opmlImportIntentAtom),[r,s]=(0,n.useAtom)(rd.opmlDirectoryConversionStateAtom),a=(0,f.useStorage)(),o=(0,f.useUserId)(),i=(0,tg.useQueryClient)(),l=(0,p.useRef)(null),c=(0,p.useCallback)(async()=>{if(e&&e.importedBlogs.length&&l.current!==e.timestamp){l.current=e.timestamp,s({phase:"checking",matches:[],selectedBlogIds:new Set});try{let r=await fetch("/api/opml/check-directory-matches",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogs:e.importedBlogs})});if(!r.ok)throw Error("Failed to check directory matches");let a=(await r.json()).matches||[];if(0===a.length){t(null),s(null);return}let o=new Set(a.map(e=>e.importedBlog.id));s({phase:"ready",matches:a,selectedBlogIds:o})}catch(e){console.error("Error checking directory matches:",e),t(null),s(null)}}},[e,t,s]);(0,p.useEffect)(()=>
28{if(e&&e.importedBlogs.length>0){let e=setTimeout(()=>{c()},500);return()=>clearTimeout(e)}},[e,c]);let d=(0,p.useCallback)(e=>{if(!r)return;let t=new Set(r.selectedBlogIds);t.has(e)?t.delete(e):t.add(e),s({...r,selectedBlogIds:t})},[r,s]),u=(0,p.useCallback)(e=>{if(!r)return;let t=e?new Set(r.matches.map(e=>e.importedBlog.id)):new Set;s({...r,selectedBlogIds:t})},[r,s]),m=(0,p.useCallback)(async()=>{if(!r||!o)return;let e=r.matches.filter(e=>r.selectedBlogIds.has(e.importedBlog.id));if(0===e.length){t(null),s(null);return}s({...r,phase:"converting"});let n=0,l=0;for(let t of e)try{let e,{catalogBlog:r}=t,s=await (0,tp.deleteBlog)(a,o,t.importedBlog.id,"custom");if(!s.success){console.error(`Failed to delete custom blog ${t.importedBlog.id}:`,s.error),l++;continue}(0,ey.trackBlogUnfollowed)("custom"),(0,s3.deleteCachedContentForBlog)(t.importedBlog.id).catch(()=>{}),(0,tS.cleanupCacheForFeed)(t.importedBlog.feed_url).catch(()=>{});let i={feed_url:r.feed_url,title:r.title,description:r.description||void 0,url:r.url,site_icon:r.site_icon||void 0,has_full_content:r.has_full_content||void 0,category:r.category||void 0};if("directory"===r.catalogType?(e=await (0,tp.followDirectoryBlog)(a,o,r.id,[],i)).success&&(0,ey.trackDirectoryFollow)(r.id):(e=await (0,tp.followCommunityBlog)(a,o,r.id,[],i)).success&&(0,ey.trackCommunityFollow)(r.id),!e.success&&!e.error?.includes("already following")){console.error(`Failed to follow ${r.catalogType} blog ${r.id}:`,e.error),l++;continue}n++}catch(e){console.error(`Error converting blog ${t.importedBlog.id}:`,e),l++}i.invalidateQueries({queryKey:["blogs","followed",o]}),i.invalidateQueries({queryKey:["timeline"]}),i.invalidateQueries({queryKey:["user-blog-counts"]}),n>0&&0===l?th.toast.success(`Converted ${n} blog${1===n?"":"s"} to catalog subscriptions`):n>0&&l>0?th.toast.warning(`Converted ${n} blog${1===n?"":"s"}, ${l} failed`):l>0&&th.toast.error("Failed to convert blogs"),t(null),s(null)},[r,o,a,t,s,i]),h=(0,p.useCallback)(()=>{t(null),s(null),l.current=null},[t,s]);return{isOpen:null!==r,phase:r?.phase||null,matches:r?.matches||[],selectedBlogIds:r?.selectedBlogIds||new Set,error:r?.error,toggleSelection:d,selectAll:u,performConversion:m,dismiss:h}}(),d="checking"===t,m="converting"===t,h=s.size,g=h===r.length&&r.length>0;return(0,a.jsx)(i3.Modal,{open:e,onOpenChange:e=>!e&&c(),children:(0,a.jsxs)(i3.ModalContent,{className:"sm:max-w-[550px]",children:[(0,a.jsxs)(i3.ModalHeader,{children:[(0,a.jsx)(i3.ModalTitle,{children:"Directory Matches Found"}),(0,a.jsx)(i3.ModalDescription,{children:d?"Checking your imported feeds against our curated directory...":`We found ${r.length} of your imported blog${1!==r.length?"s":""} in our directory. Convert them for enhanced features and verified metadata.`})]}),(0,a.jsx)(i3.ModalBody,{className:"space-y-4",children:d?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 gap-4",children:[(0,a.jsx)(lk.Spinner,{className:"h-8 w-8"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:"Looking for directory blogs matching your imported feeds..."})]}):r.length>0?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between py-2 border-b",children:[(0,a.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,a.jsx)(lN.Checkbox,{checked:g,onCheckedChange:e=>i(!!e),disabled:m}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:["Select all (",r.length,")"]})]}),(0,a.jsxs)("span",{className:"text-sm text-muted-foreground",children:[h," selected"]})]}),(0,a.jsx)("div",{className:"space-y-3 max-h-[40vh] overflow-y-auto pr-1 thin-scrollbars",children:r.map(e=>(0,a.jsx)(lA,{match:e,selected:s.has(e.importedBlog.id),onToggle:()=>o(e.importedBlog.id),disabled:m},e.importedBlog.id))}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Converting replaces your custom subscription with the directory version, giving you access to verified metadata and curated features."})]}):null}),(0,a.jsxs)(i3.ModalFooter,{className:"gap-2",children:[(0,a.jsx)(u.Button,{variant:"outline",onClick:c,disabled:m,children:0!==h||d?"Skip":"Close"}),!d&&r.length>0&&(0,a.jsx)(u.Button,{onClick:l,disabled:m||0===h,children:m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(lk.Spinner,{className:"h-4 w-4 mr-2"}
28),"Converting..."]}):`Convert ${h} Blog${1!==h?"s":""}`})]})]})})}function lT(){let[e,t]=(0,p.useState)(!1),[r,s]=(0,n.useAtom)(nP),[o,i]=(0,n.useAtom)(nI),l=(0,n.useAtomValue)(nL),[c,d]=(0,n.useAtom)(nD),m=(0,n.useAtomValue)(er.blogsLoadingAtom),{data:h=[],isLoading:f}=(0,nq.useFollowedBlogs)(),g=(0,nq.useFollowDirectoryBlog)(),x=(0,nq.useFollowCommunityBlog)(),y=o?h.find(e=>"directory"===o.source?e.directory_blog_id===o.id:e.community_blog_id===o.id):null,v=(0,n.useSetAtom)(b.selectedBlogIdAtom),j=(0,n.useSetAtom)(b.viewFilterAtom),w=(0,n.useSetAtom)(b.selectedTagsAtom),N=(0,n.useSetAtom)(b.selectedSourcesAtom),k=(0,n.useSetAtom)(b.selectedCategoriesAtom),C=(0,n.useSetAtom)(b.exploreModeAtom),A=(0,n.useSetAtom)(b.searchModeAtom);(0,p.useEffect)(()=>{r&&t(!0)},[r]);let S=()=>{s(null),i(null),d(null)},T=()=>{t(!1),S()},E=async()=>{if(o)try{"directory"===o.source?await g.mutateAsync({directoryBlogId:o.id,directoryBlogData:{feed_url:o.feed_url,title:o.title,description:o.description,url:o.url,site_icon:o.site_icon??void 0,has_full_content:o.has_full_content,category:o.category,requires_proxy:o.requires_proxy,posts_require_proxy:o.posts_require_proxy,blocks_iframe:o.blocks_iframe}}):await x.mutateAsync({communityBlogId:o.id,communityBlogData:{feed_url:o.feed_url,title:o.title,description:o.description,url:o.url,site_icon:o.site_icon??void 0,has_full_content:o.has_full_content,category:o.category,requires_proxy:o.requires_proxy,posts_require_proxy:o.posts_require_proxy,blocks_iframe:o.blocks_iframe}}),t(!1),S()}catch{}},M=g.isPending||x.isPending,_=l||m&&!h.length||f;return e?(0,a.jsx)(i3.Modal,{open:e,onOpenChange:e=>!e&&T(),children:(0,a.jsxs)(i3.ModalContent,{className:"sm:max-w-md",children:[_&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center",children:[(0,a.jsx)(i3.ModalTitle,{children:"Looking up blog..."}),(0,a.jsx)(i3.ModalDescription,{children:"Searching our catalog for this blog"})]}),(0,a.jsx)("div",{className:"flex justify-center px-6 py-8",children:(0,a.jsx)(H.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"})})]}),!_&&c&&!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center",children:[(0,a.jsx)(i3.ModalTitle,{children:"Blog Not Found"}),(0,a.jsx)(i3.ModalDescription,{children:c})]}),(0,a.jsx)("div",{className:"flex justify-center px-6 py-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border bg-muted/30 p-4 text-sm text-muted-foreground",children:[(0,a.jsx)(O.AlertCircle,{className:"h-5 w-5 shrink-0"}),(0,a.jsx)("p",{children:"This blog isn't in our directory yet. You can add it manually from your dashboard."})]})}),(0,a.jsx)(i3.ModalFooter,{children:(0,a.jsx)(u.Button,{variant:"ghost",onClick:T,className:"w-full sm:w-auto",children:"Dismiss"})})]}),!_&&o&&y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center",children:[(0,a.jsx)(i3.ModalTitle,{children:"Already Following"}),(0,a.jsx)(i3.ModalDescription,{children:"You're already following this blog"})]}),(0,a.jsx)("div",{className:"px-6 py-4",children:(0,a.jsx)(lE,{blog:o})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col gap-2 sm:flex-row",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:T,className:"w-full sm:w-auto",children:"Dismiss"}),(0,a.jsx)(u.Button,{onClick:()=>{y&&(v((0,tR.getEffectiveBlogId)(y)),j("all"),w([]),N([]),k([]),C(!1),A(!1),t(!1),S())},className:"w-full sm:w-auto",children:"View Posts"})]})]}),!_&&o&&!y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(i3.ModalHeader,{className:"text-center",children:[(0,a.jsx)(i3.ModalTitle,{children:"Follow This Blog?"}),(0,a.jsx)(i3.ModalDescription,{children:"Add this blog to your reading list"})]}),(0,a.jsx)("div",{className:"px-6 py-4",children:(0,a.jsx)(lE,{blog:o})}),(0,a.jsxs)(i3.ModalFooter,{className:"flex-col gap-2 sm:flex-row",children:[(0,a.jsx)(u.Button,{variant:"ghost",onClick:T,className:"w-full sm:w-auto",children:"No thanks"}),(0,a.jsx)(u.Button,{onClick:E,disabled:M,className:"w-full sm:w-auto",children:M?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(H.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Following..."]}):"Follow This Blog"})]})]})]})}):null}function lE({blog:e}){return(0,a.jsxs)("div",{className:"flex items-start gap-4 roun
28ded-lg border bg-muted/30 p-4",children:[e.site_icon?(0,a.jsx)("img",{src:e.site_icon,alt:"",className:"h-12 w-12 shrink-0 rounded-lg object-cover"}):(0,a.jsx)("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-muted",children:(0,a.jsx)($.Rss,{className:"h-6 w-6 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"truncate font-semibold",children:e.title}),e.description&&(0,a.jsx)("p",{className:"mt-1 line-clamp-2 text-sm text-muted-foreground",children:e.description}),(0,a.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Visit blog",(0,a.jsx)(ez.ExternalLink,{className:"h-3 w-3"})]})]})]})}function lM(){return(0,a.jsx)(p.Suspense,{fallback:null,children:(0,a.jsx)(lT,{})})}let l_=()=>(0,a.jsx)("div",{className:"p-3 mx-auto flex flex-col items-center justify-center",children:(0,a.jsx)("div",{className:" items-center justify-center",children:(0,a.jsx)("div",{className:"bouncingDots"})})});var lz=e.i(869561),lR=e.i(959411);let lP=(0,p.lazy)(()=>e.A(519009).then(e=>({default:e.KeyboardShortcutsDialog}))),lI=(0,p.lazy)(()=>e.A(763475).then(e=>({default:e.CommandPalette}))),lL=(0,p.lazy)(()=>e.A(308977).then(e=>({default:e.SettingsModal}))),lD=(0,p.lazy)(()=>e.A(866376).then(e=>({default:e.AddBlogDialog}))),lF=(0,p.lazy)(()=>e.A(471078).then(e=>({default:e.ManageBlogsModal}))),lO=(0,p.lazy)(()=>e.A(370092).then(e=>({default:e.AuthModal}))),lB=(0,p.lazy)(()=>e.A(439662).then(e=>({default:e.ExtensionQueueModal}))),l$=(0,p.lazy)(()=>e.A(534500).then(e=>({default:e.ExtensionPromptModal}))),lU=(0,p.lazy)(()=>e.A(643345).then(e=>({default:e.SignOutDialog}))),lV=(0,p.lazy)(()=>e.A(822181).then(e=>({default:e.HighlightRuleDialog}))),lq=(0,p.lazy)(()=>e.A(55070).then(e=>({default:e.OPMLImportModal}))),lH=(0,p.lazy)(()=>e.A(992999).then(e=>({default:e.BlogStatusTestingModal}))),lG=(0,p.lazy)(()=>e.A(593701).then(e=>({default:e.SaveByUrlDialog})));function lW({onClose:e}){return(0,a.jsxs)(i3.Modal,{open:!0,onOpenChange:t=>{t||e()},children:[(0,a.jsx)(lR.VisuallyHidden,{children:(0,a.jsx)(i3.ModalHeader,{children:(0,a.jsx)(i3.ModalTitle,{children:"Loading..."})})}),(0,a.jsx)(i3.ModalContent,{className:"sm:max-w-md",children:(0,a.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,a.jsx)(l_,{})})})]})}function lK({atom:e,children:t}){let r=(0,n.useAtomValue)(e),s=(0,n.useSetAtom)(e);return r?(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"modal",onClose:()=>s(!1),children:(0,a.jsx)(p.Suspense,{fallback:(0,a.jsx)(lW,{onClose:()=>s(!1)}),children:t})}):null}let lY=()=>{let t,r,[s,o]=(0,n.useAtom)(b.blogPendingTestAtom);return t=(0,n.useSetAtom)(W.modalChunksReadyAtom),r=(0,p.useRef)(!1),(0,p.useEffect)(()=>{let s=()=>{r.current||((r.current=!0,navigator.onLine)?Promise.allSettled([e.A(519009),e.A(763475),e.A(308977),e.A(866376),e.A(471078),e.A(370092),e.A(439662),e.A(534500),e.A(643345),e.A(822181),e.A(55070),e.A(992999),e.A(593701)]).then(()=>t(!0)):t(!0))};if("requestIdleCallback"in window){let e=requestIdleCallback(s);return()=>cancelIdleCallback(e)}{let e=setTimeout(s,5e3);return()=>clearTimeout(e)}},[t]),!function(){let[e,t]=(0,n.useAtom)(b.pendingBlogTestsAtom),[,r]=(0,n.useAtom)(b.blogTestingProgressAtom);(0,n.useAtomValue)(T.extensionAvailableAtom);let s=(0,f.useStorage)(),a=(0,f.useUserId)(),{user:o}=(0,i4.useAuthUser)(),i=!!o,l=(0,tg.useQueryClient)(),c=(0,p.useRef)(!1),d=(0,p.useRef)(void 0),u=(0,p.useCallback)(async e=>{let t=await fetch("/api/blogs/test-all-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedUrl:e.feed_url,blogId:e.id})});if(!t.ok)throw Error((await t.json().catch(()=>({}))).error||`Request failed: ${t.status}`);let r=await t.json();return{requiresProxy:r.requiresProxy,hasFullContent:r.hasFullContent,postsRequireProxy:r.postsRequireProxy,blocksIframe:r.blocksIframe,errors:r.errors||[],method:"direct",extensionRequired:!1,extensionUsed:!1}},[]),m=(0,p.useCallback)(async e=>{let t=await (0,s0.testBlogStatusViaExtension)(e.feed_url);return{requiresProxy:t.requiresProxy??!1,hasFullContent:t.hasFull
28Content,postsRequireProxy:t.postsRequireProxy,blocksIframe:t.blocksIframe,errors:t.errors,method:"extension",extensionRequired:!1,extensionUsed:!0}},[]),h=(0,p.useCallback)(async(e,t,r)=>{try{let o=await (0,tp.updateBlogStatusValues)(s,a,e.id,e.source||"custom",{requires_proxy:t.requiresProxy,has_full_content:t.hasFullContent,posts_require_proxy:t.postsRequireProxy,blocks_iframe:t.blocksIframe,site_icon:r?.siteIcon||null});o.success||console.warn("[Batch Testing] Could not save results locally:",o.error)}catch(e){console.warn("[Batch Testing] Could not save results locally:",e)}},[s,a]),g=(0,p.useCallback)(async(e,t)=>{try{let r=await fetch("/api/blogs/update-proxy-values",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogId:e.id,requiresProxy:t.requiresProxy,postsRequireProxy:t.postsRequireProxy,hasFullContent:t.hasFullContent,blocksIframe:t.blocksIframe})});if(!r.ok){let e=await r.json().catch(()=>({}));console.warn("[Batch Testing] Could not save to Supabase:",e.error||r.status)}}catch(e){console.warn("[Batch Testing] Could not save to Supabase:",e)}},[]),x=(0,p.useCallback)(async e=>{if((0,s0.getExtensionAvailability)())try{return await (0,s0.discoverImagesViaExtension)(e)}catch(e){console.warn("[Batch Testing] Could not discover images:",e);return}},[]),y=(0,p.useCallback)(async(e,t)=>{try{let r,s=t;if((0,s0.getExtensionAvailability)())if(e.url&&!t){let[t,a]=await Promise.all([m(e),x(e.url)]);r=t,s=a}else r=await m(e);else r=i?await u(e):await (0,i6.testBlogStatusClient)(e.feed_url);return await h(e,r,s),i&&await g(e,r),{blog:e,success:!0,result:r,images:s}}catch(t){return console.error("[Batch Testing] Error testing blog:",e.title,t),{blog:e,success:!1,error:t instanceof Error?t.message:"Unknown error"}}},[i,m,u,x,h,g]),v=(0,p.useCallback)(async e=>{if(0===e.length)return;console.log(`[Batch Testing] Starting tests for ${e.length} blog(s)`);let t=[];d.current=th.toast.loading(1===e.length?`Testing "${e[0].title}"...`:`Testing ${e.length} blogs...`,{duration:1/0});let s=new Map;if((0,s0.getExtensionAvailability)()&&e.length>1){let t=e.filter(e=>e.url);if(t.length>1){console.log(`[Batch Testing] Pre-discovering images for ${t.length} blogs...`);try{let e=await (0,s0.discoverImagesBatchViaExtension)(t.map(e=>e.url));for(let t of e.results)t.success&&t.images&&s.set(t.blogUrl,t.images);console.log(`[Batch Testing] Pre-discovered images: ${e.successCount} succeeded, ${e.errorCount} failed`)}catch(e){console.warn("[Batch Testing] Batch image discovery failed, will fall back to per-blog discovery:",e)}}}for(let a=0;a<e.length;a++){let o=e[a];r({current:a+1,total:e.length,currentBlogTitle:o.title}),e.length>1&&th.toast.loading(`Testing blog ${a+1}/${e.length}: "${o.title}"...`,{id:d.current,duration:1/0});let n=o.url?s.get(o.url):void 0,i=await y(o,n);t.push(i),a<e.length-1&&await new Promise(e=>setTimeout(e,300))}r(null),await l.invalidateQueries({queryKey:["blogs"]}),await l.invalidateQueries({queryKey:["timeline"]});let a=t.filter(e=>e.success),o=t.filter(e=>!e.success),n=a.filter(e=>e.result?.hasFullContent===!0).length,i=a.filter(e=>e.result?.requiresProxy===!1&&e.result?.postsRequireProxy===!1).length;if(0===o.length){let e="";if(1===a.length){let t=a[0].result;t?.hasFullContent?e="Full articles available in feed":t?.requiresProxy===!1&&(e="Direct access available")}else{let t=[];n>0&&t.push(`${n} with full content`),i>0&&t.push(`${i} with direct access`),t.length>0&&(e=t.join(", "))}th.toast.success(1===a.length?`"${a[0].blog.title}" ready`:`${a.length} blogs tested`,{id:d.current,description:e||void 0,duration:5e3})}else a.length>0?th.toast.warning(`Tested ${a.length}, failed ${o.length}`,{id:d.current,description:o.map(e=>e.blog.title).join(", "),duration:5e3}):th.toast.error("Testing failed",{id:d.current,description:1===o.length?o[0].error:`Could not test ${o.length} blogs`,duration:5e3});d.current=void 0},[r,y,l]);(0,p.useEffect)(()=>{if(0===e.length||c.current)return;c.current=!0;let r=[...e];t([]),v(r).finally(()=>{c.current=!1})},[e,t,v]),(0,p.useEffect)(()=>()=>{d.current&&th.toast.dismiss(d.current)},[])}(),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(lK,{atom:b.keyboardShortcutsDialogOpenAtom,children:(0,a.jsx)(lP,{})}),(0,a.jsx)(lK,{atom:b.commandPaletteOpenAtom,children:(0,a.jsx)(lI,{})}),(0,a.jsx)(lK,{atom:b.settingsDialogOpenAtom,children:(0,a.jsx)(lL,{})}),(0,a.jsx)(lK,{atom:b.addFeedDialogOpenAtom,children:(0,a.jsx)(lD,{})}),(0,a.jsx)(lK,{atom:b.manageBlogsDialogOpenAtom,children:(0,a.jsx)(lF,{})}),(0,a.jsx)(lK,{atom:b.authModalOpenAtom,children:(0,a.jsx)(lO,{})}),(0,a.jsx)(lK,{atom:T.extensionQueueModalOpenAtom,children:(0,a.jsx)(lB,{})}),(0,a.jsx)(lK,{atom:T.extensionPromptOpenAtom,children:(0,a.jsx)(l$,{})}),(0,a.jsx)(lK,{atom:b.signOutDialogOpenAtom,children:(0,a.jsx)(lU,{})}),(0,a.jsx)(lK,{atom:lz.highlightRuleDialogOpenAtom,children:(0,a.jsx)(lV,{})}),(0,a.jsx)(lK,{atom:rd.opmlImportModalOpenAtom,children:(0,a.jsx)(lq,{})}),(0,a.jsx)(lK,{atom:b.saveByUrlDialogOpenAtom,children:(0,a.jsx)(lG,{})}),(0,a.jsx)(ly,{}),(0,a.jsx)(lw,{}),(0,a.jsx)(lM,{}),(0,a.jsx)(lS,{}),s&&(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"modal",onClose:()=>o(null),children:(0,a.jsx)(p.Suspense,{fallback:(0,a.jsx)(lW,{onClose:()=>o(null)}),children:(0,a.jsx)(lH,{open:!0,onOpenChange:e=>{e||o(null)},blog:s,autoStart:!0,isNewBlog:!0})})})]})};var lQ=e.i(908821),lQ=lQ;function lX(){let e=(0,ru.useMounted)(),t=(0,ex.default)(),r=function(){let{isSuccess:e,isError:t}=(0,nq.useFollowedBlogs)();return e||t}(),s=(0,n.useAtomValue)(er.blogsAtom),o=(0,n.useAtomValue)(b.exploreModeAtom),{reopenOnboarding:i}=rv();return e&&!t&&r&&0===s.length&&!o?(0,a.jsx)("div",{className:"fixed top-4 right-4 z-50",children:(0,a.jsx)(v.TooltipProvider,{children:(0,a.jsxs)(v.Tooltip,{children:[(0,a.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,a.jsxs)(u.Button,{onClick:i,size:"sm",className:"gap-2 shadow-lg",variant:"default",children:[(0,a.jsx)(lQ.default,{className:"size-4"}),"Setup Wizard"]})}),(0,a.jsx)(v.TooltipContent,{children:(0,a.jsx)("p",{children:"Reo
28pen the onboarding wizard to get started"})})]})})}):null}let lZ=()=>(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(lX,{})});var lJ=e.i(423796);function l0(e){let t=lJ.AVAILABLE_FONTS.find(t=>t.name===e);return!t||t.system?null:`https://fonts.googleapis.com/css2?family=${e.replace(/\s+/g,"+")}:wght@${t.weights}&display=swap`}function l1(e){return fetch(e,{mode:"cors",credentials:"omit",priority:"low"}).then(()=>{}).catch(()=>{})}async function l2(e){try{let t=await fetch(e,{mode:"cors",credentials:"omit",priority:"low"});if(!t.ok)return;let r=await t.text(),s=[...new Set([...r.matchAll(/url\((https:\/\/fonts\.gstatic\.com\/[^)]+)\)/g)].map(e=>e[1]))];s.length>0&&await Promise.allSettled(s.map(e=>fetch(e,{mode:"cors",credentials:"omit",priority:"low"}).then(()=>{})))}catch{}}function l5(e,t=1e4){if("requestIdleCallback"in window){let r=requestIdleCallback(e,{timeout:t});return()=>cancelIdleCallback(r)}let r=setTimeout(e,t);return()=>clearTimeout(r)}let l3=["google-fonts-stylesheets","google-fonts-webfonts","cdn-styles","syntax-theme-styles"];async function l4(){try{let e=await caches.keys(),t={};for(let r of l3){let s=e.includes(r),a=0;if(s)try{let e=await caches.open(r);a=(await e.keys()).length}catch{}t[r]={exists:s,entryCount:a}}return{valid:Object.values(t).some(e=>e.exists&&e.entryCount>0),timestamp:Date.now(),details:t}}catch{return{valid:!1,timestamp:Date.now(),details:{}}}}var l6=e.i(680319);let l8=(0,o.default)(()=>e.A(549111).then(e=>({default:e.DirectoryBrowser})),{loadableGenerated:{modules:[941894]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}),l7=(0,o.default)(()=>e.A(441657).then(e=>({default:e.SearchBrowser})),{loadableGenerated:{modules:[802858]},ssr:!1,loading:()=>(0,a.jsx)("div",{className:"flex h-full items-center justify-center",children:(0,a.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}),l9=(0,s8.isDesktopApp)()?(0,o.default)(()=>e.A(445786),{loadableGenerated:{modules:[721125]},ssr:!1}):()=>null,ce=(0,p.memo)(function(){let e=(0,n.useAtomValue)(b.mobileViewAtom);return(0,a.jsx)("div",{className:"overflow-hidden",style:{height:"calc(100dvh - env(safe-area-inset-top, 0px))",paddingBottom:"calc(4rem + env(safe-area-inset-bottom, 0px))"},children:"search"===e?(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"panel",children:(0,a.jsx)(l7,{hasSelectedPost:!1})}):"list"===e?(0,a.jsx)(sg,{}):"explore"===e?(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"panel",children:(0,a.jsx)(l8,{})}):(0,a.jsx)(ib,{})})}),ct=(0,p.memo)(function(){let e=(0,n.useAtomValue)(er.selectedPostIdAtom),{defaultLayout:t,onLayoutChanged:r}=nk({id:"search-panel-layout2",storage:localStorage});return e?(0,a.jsxs)(nM,{orientation:"horizontal",defaultLayout:t,onLayoutChanged:r,className:"flex-1",children:[(0,a.jsx)(n_,{id:"search-list",defaultSize:"30%",minSize:"20%",maxSize:"40%",children:(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"panel",children:(0,a.jsx)(l7,{hasSelectedPost:!0})})}),(0,a.jsx)(nz,{withHandle:!0}),(0,a.jsx)(n_,{id:"search-reader",defaultSize:"70%",minSize:"50%",children:(0,a.jsx)(oS,{})})]}):(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"panel",children:(0,a.jsx)(l7,{hasSelectedPost:!1})})})}),cr=(0,p.memo)(function(){return(0,n.useAtomValue)(b.exploreModeAtom)?(0,a.jsx)(sf.ChunkErrorBoundary,{variant:"panel",children:(0,a.jsx)(l8,{})}):(0,a.jsx)(oS,{})}),cs=(0,p.memo)(function(){let e=(0,n.useAtomValue)(b.readingFocusModeAtom),t=(0,n.useAtomValue)(b.searchModeAtom),{defaultLayout:r,onLayoutChanged:s}=nk({id:"main-panel-layout2",storage:localStorage});return e?(0,a.jsx)("div",{className:"flex-1 overflow-hidden",children:(0,a.jsx)(oS,{})}):t?(0,a.jsx)(ct,{}):(0,a.jsxs)(nM,{orientation:"horizontal",defaultLayout:r,onLayoutChanged:s,className:"flex-1",children:[(0,a.jsx)(n_,{id:"post-list",defaultSize:"30%",minSize:"20%",maxSize:"40%",children:(0,a.jsx)(sg,{})}),(0,a.jsx)(nz,{withHandle:!0}),(0,a.jsx)(n_,{id:"post-reader",defaultSize:"70%",minSize:"50%",children:(0,a.jsx)(cr,{})})]})});
28function ca(){let e=(0,ex.default)(),t=(0,n.useStore)(),r=(0,n.useAtomValue)(er.selectedPostIdAtom),s=(0,n.useAtomValue)(b.mobileHasVisitedSelectedPostAtom),a=(0,n.useSetAtom)(b.mobileViewAtom),o=(0,n.useSetAtom)(b.mobileHasVisitedSelectedPostAtom);return(0,p.useEffect)(()=>{!e||!r||s||t.get(b.exploreModeAtom)||t.get(b.searchModeAtom)||(a("reader"),o(!0))},[e,r,s,a,o,t]),null}let co=(0,p.memo)(function(){let e=(0,n.useAtomValue)(b.readingFocusModeAtom);return(0,a.jsx)("div",{className:(0,A.cn)(e&&"hidden"),children:(0,a.jsx)(tQ,{})})});e.s(["default",0,({children:t})=>{let r,s,o,i,l,c,u,m,h,f,g,x,y,v,j,w,N,k,C,A,S,E,M,_,z,R=(0,n.useSetAtom)(W.layoutChunksReadyAtom);(0,nR.useKeyboardShortcuts)(),r=(0,ef.useSearchParams)(),s=(0,ef.useRouter)(),o=(0,ef.usePathname)(),i=(0,n.useSetAtom)(b.selectedBlogIdAtom),l=(0,n.useSetAtom)(er.selectedPostIdAtom),(0,p.useEffect)(()=>{let e=r.get("blog"),t=r.get("post");if(e&&(console.log("[Blog Focus] Setting focus to blog:",e),i(e)),t&&(console.log("[Blog Focus] Setting focus to post:",t),l(t)),e||t){let e=new URLSearchParams(r.toString());e.delete("blog"),e.delete("post");let t=e.toString()?`${o}?${e}`:o;s.replace(t)}},[r,o,s,i,l]),c=(0,ef.useSearchParams)(),u=(0,ef.useRouter)(),m=(0,ef.usePathname)(),h=(0,n.use
28SetAtom)(nP),f=(0,n.useSetAtom)(nI),g=(0,n.useSetAtom)(nL),x=(0,n.useSetAtom)(nD),y=(0,p.useRef)(!1),(0,p.useEffect)(()=>{let e=c.get("follow");if(!e)return;h(e);let t=new URLSearchParams(c.toString());t.delete("follow");let r=t.toString()?`${m}?${t}`:m;u.replace(r),y.current||(y.current=!0,g(!0),x(null),f(null),fetch(`/api/follow/lookup?url=${encodeURIComponent(e)}`).then(async e=>{if(!e.ok)throw Error((await e.json().catch(()=>({}))).error||"Blog not found in our catalog");return e.json()}).then(e=>{f(e.blog)}).catch(e=>{x(e.message)}).finally(()=>{g(!1),y.current=!1}))},[c,m,u,h,f,g,x]);let P=(0,p.useRef)(!1);(0,p.useEffect)(()=>{let t=()=>{P.current||((P.current=!0,navigator.onLine)?Promise.allSettled([e.A(409915),e.A(322785)]).then(()=>R(!0)):R(!0))};if("requestIdleCallback"in window){let e=requestIdleCallback(t);return()=>cancelIdleCallback(e)}{let e=setTimeout(t,5e3);return()=>clearTimeout(e)}},[R]),v=(0,n.useSetAtom)(W.settingsChunksReadyAtom),j=(0,n.useSetAtom)(W.readerAssetsReadyAtom),w=(0,p.useRef)(!1),(0,p.useEffect)(()=>{let t=[];return t.push(l5(()=>{if(!w.current){if(w.current=!0,!navigator.onLine){v(!0),j(!0);return}Promise.allSettled([e.A(704694),e.A(325346),e.A(4619)]).then(()=>v(!0)),t.push(l5(()=>{let e=[];for(let t of function(){let e=new Set;lJ.DEFAULT_READER_CUSTOMIZATION.fontFamily&&e.add(lJ.DEFAULT_READER_CUSTOMIZATION.fontFamily);let t=localStorage.getItem("reader_customization_");if(t)try{let r=JSON.parse(t);r.unified?.fontFamily&&e.add(r.unified.fontFamily),r.light?.fontFamily&&e.add(r.light.fontFamily),r.dark?.fontFamily&&e.add(r.dark.fontFamily),r.fontFamily&&e.add(r.fontFamily)}catch{}return Array.from(e).map(l0).filter(e=>null!==e)}())e.push(l2(t));t.push(l5(()=>{for(let t of(e.push(l1(oc)),function(){let e=new Set;e.add(lJ.DEFAULT_SYNTAX_HIGHLIGHTING.lightTheme),e.add(lJ.DEFAULT_SYNTAX_HIGHLIGHTING.darkTheme);let t=localStorage.getItem("syntax-highlighting-settings");if(t)try{let r=JSON.parse(t);r.lightTheme&&e.add(r.lightTheme),r.darkTheme&&e.add(r.darkTheme)}catch{}return Array.from(e).map(e=>{let t=(0,ol.getThemeById)(e);return t?t.cdnUrl||`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/${t.cssFile}`:null}).filter(e=>null!==e)}()))e.push(l1(t));Promise.allSettled(e).then(()=>j(!0))}))}))}}
28)),()=>t.forEach(e=>e())},[v,j]),N=(0,n.useAtomValue)(T.desktopAppAtom),k=(0,n.useAtomValue)(W.offlineReadyAtom),C=(0,n.useAtomValue)(W.offlineReadinessAtom),A=(0,p.useRef)(void 0),(0,p.useEffect)(()=>{if(N)return clearTimeout(A.current),A.current=setTimeout(()=>{window.electronBridge?.invoke("SET_OFFLINE_READINESS",{ready:k,categories:C})},500),()=>clearTimeout(A.current)},[N,k,C]),S=(0,n.useAtomValue)(W.offlineReadyAtom),E=(0,n.useAtomValue)(W.swDevModeAtom),M=(0,n.useSetAtom)(W.cacheValidationAtom),_=(0,p.useRef)(!1),z=(0,p.useCallback)(()=>{E?M({valid:!0,timestamp:Date.now(),details:{}}):l4().then(M)},[E,M]),(0,p.useEffect)(()=>{S&&!_.current&&(_.current=!0,z())},[S,z]),(0,p.useEffect)(()=>{if(!_.current)return;let e=()=>{"visible"===document.visibilityState&&z()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[z]),(0,l6.useDeadLetterListener)();let I=(0,ex.default)();return(0,a.jsx)(iy.ErrorBoundary,{children:(0,a.jsxs)(it,{children:[(0,a.jsx)(l9,{}),(0,a.jsx)(i5,{children:(0,a.jsxs)(d.SidebarProvider,{children:[(0,a.jsx)(nB,{}),(0,a.jsx)(n$,{}),(0,a.jsx)(nO,{}),(0,a.jsx)(ca,{}),(0,a.jsxs)("div",{className:"flex h-dvh w-full overflow-hidden",children:[(0,a.jsx)(co,{}),(0,a.jsxs)("main",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,a.jsx)(nV,{variant:I?"compact":"full"}),(0,a.jsx)(nU,{variant:I?"compact":"full"}),I?(0,a.jsx)(ce,{}):(0,a.jsx)(cs,{})]})]}),(0,a.jsx)(lY,{}),(0,a.jsx)(lZ,{}),I&&(0,a.jsx)(im,{})]})})]})})}],342081)}]);

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.