1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[975],{3998:(e,t,a)=>{a.d(t,{$:()=>d,r:()=>n});var s=a(95155),r=a(12115),l=a(32467),o=a(83101),i=a(64269);let n=(0,o.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",success:"bg-success text-success-foreground hover:bg-success/90",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=r.forwardRef((e,t)=>{let{className:a,variant:r,size:o,asChild:d=!1,...c}=e,u=d?l.DX:"button";return(0,s.jsx)(u,{className:(0,i.cn)(n({variant:r,size:o,className:a})),ref:t,...c})});d.displayName="Button"},15894:(e,t,a)=>{a.d(t,{dj:()=>u});var s=a(12115);let r=0,l=new Map,o=e=>{if(l.has(e))return;let t=setTimeout(()=>{l.delete(e),d({type:"REMOVE_TOAST",toastId:e})},1e6);l.set(e,t)},i=[],n={toasts:[]};function d(e){n=((e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===t.toast.id?{...e,...t.toast}:e)};case"DISMISS_TOAST":{let{toastId:a}=t;return a?o(a):e.toasts.forEach(e=>{o(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===a||void 0===a?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===t.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(n,e),i.forEach(e=>{e(n)})}function c(e){let{...t}=e,a=(r=(r+1)%Number.MAX_SAFE_INTEGER).toString(),s=()=>d({type:"DISMISS_TOAST",toastId:a});return d({type:"ADD_TOAST",toast:{...t,id:a,open:!0,onOpenChange:e=>{e||s()}}}),{id:a,dismiss:s,update:e=>d({type:"UPDATE_TOAST",toast:{...e,id:a}})}}function u(){let[e,t]=s.useState(n);return s.useEffect(()=>(i.push(t),()=>{let e=i.indexOf(t);e>-1&&i.splice(e,1)}),[e]),{...e,toast:c,dismiss:e=>d({type:"DISMISS_TOAST",toastId:e})}}},17037:(e,t,a)=>{a.d(t,{F:()=>i});var s=a(95155),r=a(12115),l=a(59034),o=a(64269);let i=r.forwardRef((e,t)=>{let{className:a,children:r,...i}=e;return(0,s.jsxs)(l.bL,{ref:t,className:(0,o.cn)("relative overflow-hidden",a),...i,children:[(0,s.jsx)(l.LM,{className:"h-full w-full rounded-[inherit]",children:r}),(0,s.jsx)(n,{}),(0,s.jsx)(l.OK,{})]})});i.displayName=l.bL.displayName;let n=r.forwardRef((e,t)=>{let{className:a,orientation:r="vertical",...i}=e;return(0,s.jsx)(l.VM,{ref:t,orientation:r,className:(0,o.cn)("flex touch-none select-none transition-colors","vertical"===r&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...i,children:(0,s.jsx)(l.lr,{className:"relative flex-1 rounded-full bg-border"})})});n.displayName=l.VM.displayName},18332:(e,t,a)=>{a.d(t,{Fc:()=>n,TN:()=>c,XL:()=>d});var s=a(95155),r=a(12115),l=a(83101),o=a(64269);let i=(0,l.F)("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),n=r.forwardRef((e,t)=>{let{className:a,variant:r,...l}=e;return(0,s.jsx)("div",{ref:t,role:"alert",className:(0,o.cn)(i({variant:r}),a),...l})});n.displayName="Alert";let d=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("h5",{ref:t,className:(0,o.cn)("mb-1 font-medium leading-none tracking-tight",a),...r})});d.displayName="AlertTitle";let c=r.forwardRef((e,t)=>
1{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,o.cn)("text-sm [&_p]:leading-relaxed",a),...r})});c.displayName="AlertDescription"},20243:(e,t,a)=>{a.d(t,{E:()=>l});var s=a(95155),r=a(64269);function l(e){let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,r.cn)("animate-pulse rounded-md bg-muted",t),...a})}},31511:(e,t,a)=>{a.d(t,{e:()=>eC});var s=a(95155),r=a(52619),l=a.n(r),o=a(28263),i=a(94374),n=a(59338),d=a(67600),c=a(54753),u=a(21255),f=a(4056),m=a(61916),h=a(36922),p=a(97776),g=a(46181),x=a(59971),b=a(26302),j=a(85989),v=a(12784),y=a(73368),N=a(58956),w=a(43737),k=a(44622),A=a(77187),C=a(12453),S=a(98428),D=a(75283),R=a(42997),I=a(20243),L=a(3998),E=a(12115),T=a(11658),F=a(63263),B=a(72251),O=a(75797),M=a(64269);let $=T.bL,z=T.l9;T.YJ;let U=T.ZL,_=T.Pb,P=T.z6,V=E.forwardRef((e,t)=>{let{className:a,inset:r,children:l,...o}=e;return(0,s.jsxs)(T.ZP,{ref:t,className:(0,M.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",a),...o,children:[(0,s.jsx)("div",{className:"flex-grow flex items-center gap-2",children:l}),(0,s.jsx)(F.A,{className:"ml-2 h-4 w-4"})]})});V.displayName=T.ZP.displayName;let W=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(T.ZL,{children:(0,s.jsx)(T.G5,{ref:t,className:(0,M.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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",a),...r})})});W.displayName=T.G5.displayName;let J=E.forwardRef((e,t)=>{let{className:a,sideOffset:r=4,align:l="end",...o}=e;return(0,s.jsx)(T.ZL,{children:(0,s.jsx)(T.UC,{ref:t,sideOffset:r,align:l,className:(0,M.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md 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","w-56",a),...o})})});J.displayName=T.UC.displayName;let G=E.forwardRef((e,t)=>{let{className:a,inset:r,...l}=e;return(0,s.jsx)(T.q7,{ref:t,className:(0,M.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",a),...l})});G.displayName=T.q7.displayName,E.forwardRef((e,t)=>{let{className:a,children:r,checked:l,...o}=e;return(0,s.jsxs)(T.H_,{ref:t,className:(0,M.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),checked:l,...o,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(T.VF,{children:(0,s.jsx)(B.A,{className:"h-4 w-4"})})}),r]})}).displayName=T.H_.displayName;let H=E.forwardRef((e,t)=>{let{className:a,children:r,...l}=e;return(0,s.jsxs)(T.hN,{ref:t,className:(0,M.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a),...l,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(T.VF,{children:(0,s.jsx)(O.A,{className:"h-2 w-2 fill-current"})})}),r]})});H.displayName=T.hN.displayName,E.forwardRef((e,t)=>
1{let{className:a,inset:r,...l}=e;return(0,s.jsx)(T.JU,{ref:t,className:(0,M.cn)("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",a),...l})}).displayName=T.JU.displayName;let Y=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(T.wv,{ref:t,className:(0,M.cn)("-mx-1 my-1 h-px bg-muted",a),...r})});Y.displayName=T.wv.displayName;var Z=a(41186),Q=a(83101),q=a(26615);let K=Z.bL,X=Z.l9;Z.bm;let ee=Z.ZL,et=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(Z.hJ,{className:(0,M.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...r,ref:t})});et.displayName=Z.hJ.displayName;let ea=(0,Q.F)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),es=E.forwardRef((e,t)=>{let{side:a="right",className:r,children:l,...o}=e;return(0,s.jsxs)(ee,{children:[(0,s.jsx)(et,{}),(0,s.jsxs)(Z.UC,{ref:t,className:(0,M.cn)(ea({side:a}),r),...o,children:[l,(0,s.jsxs)(Z.bm,{className:"absolute right-4 top-4 roun
1ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,s.jsx)(q.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});es.displayName=Z.UC.displayName;let er=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,M.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};er.displayName="SheetHeader";let el=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(Z.hE,{ref:t,className:(0,M.cn)("text-lg font-semibold text-foreground",a),...r})});el.displayName=Z.hE.displayName,E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(Z.VY,{ref:t,className:(0,M.cn)("text-sm text-muted-foreground",a),...r})}).displayName=Z.VY.displayName;var eo=a(58018),ei=a(86259),en=a(46998),ed=a(44385),ec=a(17037),eu=a(5379);function ef(e){let{stats:t,isLoading:a,onImportBooksClick:r,onExportBooksClick:T,onFindAllDetailsClick:F,onFindAllGenresClick:B,isFindingAllDetailsInProgress:O,isAnyDetailFindingInProgress:M,onStopFindingAllDetailsClick:Z,onViewStatsClick:Q,onChangeAllToAudioClick:q,onBackupToCloud:ee,onRestoreFromCloudClick:et,onCorrectAllAuthorNamesClick:ea,onCorrectAllBookshelfAuthorNamesClick:ef,onStripAllDescriptionsClick:em,onCleanAllGenresClick:eh}=e,{user:ep,loading:eg,signOutUser:ex}=(0,eo.A)(),{defaultBookFormat:eb,setDefaultBookFormat:ej}=(0,en._)(),ev=(0,ed.a)(),[ey,eN]=E.useState(!1),{setTheme:ew}=(0,eu.D)();return(0,s.jsx)("header",{className:"py-6 px-4 md:px-8 border-b border-border/50 shadow-sm",children:(0,s.jsxs)("div",{className:"container mx-auto flex items-center justify-between flex-wrap gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(A.A,{className:"h-8 w-8 text-primary"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold tracking-tight text-foreground",children:"Jamie's Library Tracker"}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground -mt-1",children:[(0,s.jsx)("span",{children:"v4.11.2"}),t&&!a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ei.w,{orientation:"vertical",className:"h-3"}),(0,s.jsxs)("div",{className:"flex items-center gap-1",title:"".concat(t.totalBooks," books read"),children:[(0,s.jsx)(C.A,{className:"h-3 w-3"}),(0,s.jsxs)("span",{children:[t.totalBooks," Books Read"]})]})]}),a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ei.w,{orientation:"vertical",className:"h-3"}),(0,s.jsx)(I.E,{className:"h-4 w-20"})]})]})]})]}),(0,s.jsx)("div",{className:"flex items-center gap-4",children:eg?(0,s.jsx)(I.E,{className:"h-10 w-48 rounded-md"}):ep?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(L.$,{onClick:ex,variant:"outline",size:"sm",children:[(0,s.jsx)(S.A,{className:"mr-2 h-4 w-4"})," Sign Out"]}),(0,s.jsx)("span",{className:"text-sm",children:ep.email}),null===ev?(0,s.jsx)(I.E,{className:"h-10 w-10"}):ev?(0,s.jsxs)(K,{open:ey,onOpenChange:eN,children:[(0,s.jsx)(X,{asChild:!0,children:(0,s.jsxs)(L.$,{variant:"outline",size:"icon",disabled:!!M,title:"More library actions",className:"h-10 w-10",children:[(0,s.jsx)(k.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:"More actions"})]})}),(0,s.jsxs)(es,{side:"right",className:"w-full max-w-sm flex flex-col",children:[(0,s.jsx)(er,{children:(0,s.jsx)(el,{children:"Library Actions"})}),(0,s.jsx)(ec.F,{className:"flex-grow",children:(0,s.jsxs)("div",{className:"py-4 space-y-2 pr-4",children:[(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{Q(),eN(!1)},children:[(0,s.jsx)(i.A,{}),"View Reading Stats"]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("p",{className:"font-semibold px-2 py-1.5 flex items-center gap-2",children:[(0,s.jsx)(n.A,{className:"w-4 h-4"}),"AI & Automation"]}),(0,s.jsxs)("div",{className:"pl-4 space-y-1",children:[O?(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{Z(),eN(!1)},children:[(0,s.jsx)(d.A,{}),"Stop Finding Details"]}
1):(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{F(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(c.A,{}),"Find All Book Details"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{B(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(u.A,{}),"Find All Genres (Beta)"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ea(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(f.A,{}),"Correct Library Authors"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ef(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(f.A,{}),"Correct Bookshelf Authors"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{em(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(m.A,{}),"Clean All Descriptions"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{eh(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(u.A,{}),"Clean All Genres"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{q(),eN(!1)},disabled:!!M,children:[(0,s.jsx)(h.A,{}),"Change All to Audio"]})]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("p",{className:"font-semibold px-2 py-1.5 flex items-center gap-2",children:[(0,s.jsx)(p.A,{className:"w-4 h-4"}),"Cloud Sync"]}),(0,s.jsxs)("div",{className:"pl-4 space-y-1",children:[(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ee(),eN(!1)},disabled:M,children:[(0,s.jsx)(p.A,{}),"Backup to Cloud"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{et(),eN(!1)},disabled:M,children:[(0,s.jsx)(g.A,{}),"Restore from Cloud"]})]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("p",{className:"font-semibold px-2 py-1.5 flex items-center gap-2",children:[(0,s.jsx)(x.A,{className:"w-4 h-4"}),"Import / Export"]}),(0,s.jsxs)("div",{className:"pl-4 space-y-1",children:[(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{r(),eN(!1)},disabled:M,children:[(0,s.jsx)(x.A,{}),"Import Local File"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{T(),eN(!1)},disabled:M,children:[(0,s.jsx)(b.A,{}),"Backup to Local File"]})]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("p",{className:"font-semibold px-2 py-1.5 flex items-center gap-2",children:[(0,s.jsx)(j.A,{className:"w-4 h-4"}),"Theme"]}),(0,s.jsxs)("div",{className:"pl-4 space-y-1",children:[(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ew("light"),eN(!1)},children:[(0,s.jsx)(j.A,{className:"mr-2 h-4 w-4"})," Light"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ew("dark"),eN(!1)},children:[(0,s.jsx)(v.A,{className:"mr-2 h-4 w-4"})," Dark"]}),(0,s.jsxs)(L.$,{variant:"ghost",className:"w-full justify-start gap-2",onClick:()=>{ew("system"),eN(!1)},children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"})," System"]})]}),(0,s.jsx)(ei.w,{}),(0,s.jsxs)("p",{className:"font-semibold px-2 py-1.5 flex items-center gap-2",children:[(0,s.jsx)(N.A,{className:"w-4 h-4"}),"Default Book Format"]}),(0,s.jsx)("div",{className:"pl-4 space-y-1",children:(0,s.jsxs)(P,{value:eb,onValueChange:e=>ej(e),className:"flex flex-col gap-1",children:[(0,s.jsxs)(L.$,{variant:"paper"===eb?"secondary":"ghost",className:"w-full justify-start gap-2",onClick:()=>ej("paper"),children:[(0,s.jsx)(N.A,{}),"Paper"]}),(0,s.jsxs)(L.$,{variant:"digital"===eb?"secondary":"ghost",className:"w-full justify-start gap-2",onClick:()=>ej("digital"),children:[(0,s.jsx)(w.A,{}),"Digital"]}),(0,s.jsxs)(L.$,{variant:"audio"===eb?"secondary":"ghost",className:"w-full justify-start gap-2",onClick:()=>ej("audio"),children:[(0,s.jsx)(h.A,{}),"Audio"]})]})})]})})]})]}):(0,s.jsxs)($,{children:[(0,s.jsx)(z,{asChild:!0,children:(0,s.jsxs)(L.$,{variant:"outline",size:"icon",disabled:!!M,title:"More library actions",className:"h-10 w-10",children:[(0,s.jsx)(o.A,{className:"h-5 w-5"}),(0,s.jsx)("span",{className:"sr-only",children:"More actions"})]})}),(0,s.jsxs)(J,{align:"end",children:[(0,s.jsxs)(G,{onSelect:Q,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4"}),"View Reading Stats"]}),(0,s.jsx)(Y,{}),(0,s.jsxs)(_,{children:[(0,s.jsxs)(V,{disabled:M,children:[(0,s.jsx)(n.A,{className:"mr-2 h-4 w-4"}),"AI & Automation"]}),(0,s.jsx)(U,{children:(0,s.jsxs)(W,{children:[O?(0,s.jsxs)(G,{onSelect:Z,className:"cursor-pointer",children:[(0,s.jsx)(d.A,{className:"mr-2 h-4 w-4"}),"Stop Finding Details"]}
1):(0,s.jsxs)(G,{onSelect:F,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Find All Book Details"]}),(0,s.jsxs)(G,{onSelect:B,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(u.A,{className:"mr-2 h-4 w-4"}),"Find All Genres (Beta)"]}),(0,s.jsxs)(G,{onSelect:ea,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4"}),"Correct Library Authors"]}),(0,s.jsxs)(G,{onSelect:ef,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4"}),"Correct Bookshelf Authors"]}),(0,s.jsxs)(G,{onSelect:em,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"Clean All Descriptions"]}),(0,s.jsxs)(G,{onSelect:eh,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(u.A,{className:"mr-2 h-4 w-4"}),"Clean All Genres"]}),(0,s.jsxs)(G,{onSelect:q,className:"cursor-pointer",disabled:!!M,children:[(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Change All to Audio"]})]})})]}),(0,s.jsxs)(_,{children:[(0,s.jsxs)(V,{disabled:M,children:[(0,s.jsx)(p.A,{className:"mr-2 h-4 w-4"}),"Cloud Sync"]}),(0,s.jsx)(U,{children:(0,s.jsxs)(W,{children:[(0,s.jsxs)(G,{onSelect:ee,disabled:M,children:[(0,s.jsx)(p.A,{className:"mr-2 h-4 w-4"}),"Backup to Cloud"]}),(0,s.jsxs)(G,{onSelect:et,disabled:M,children:[(0,s.jsx)(g.A,{className:"mr-2 h-4 w-4"}),"Restore from Cloud"]})]})})]}),(0,s.jsxs)(_,{children:[(0,s.jsxs)(V,{disabled:M,children:[(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4"}),"Import / Export"]}),(0,s.jsx)(U,{children:(0,s.jsxs)(W,{children:[(0,s.jsxs)(G,{onSelect:r,disabled:M,children:[(0,s.jsx)(x.A,{className:"mr-2 h-4 w-4"}),"Import Local File"]}),(0,s.jsxs)(G,{onSelect:T,disabled:M,children:[(0,s.jsx)(b.A,{className:"mr-2 h-4 w-4"}),"Backup to Local File"]})]})})]}),(0,s.jsx)(Y,{}),(0,s.jsxs)(_,{children:[(0,s.jsxs)(V,{children:[(0,s.jsx)(j.A,{className:"mr-2 h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),(0,s.jsx)(v.A,{className:"absolute mr-2 h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),(0,s.jsx)("span",{className:"pl-1",children:"Theme"})]}),(0,s.jsx)(U,{children:(0,s.jsxs)(W,{children:[(0,s.jsxs)(G,{onClick:()=>ew("light"),children:[(0,s.jsx)(j.A,{className:"mr-2 h-4 w-4"})," Light"]}),(0,s.jsxs)(G,{onClick:()=>ew("dark"),children:[(0,s.jsx)(v.A,{className:"mr-2 h-4 w-4"})," Dark"]}),(0,s.jsxs)(G,{onClick:()=>ew("system"),children:[(0,s.jsx)(y.A,{className:"mr-2 h-4 w-4"})," System"]})]})})]}),(0,s.jsxs)(_,{children:[(0,s.jsxs)(V,{children:[(0,s.jsx)(N.A,{className:"mr-2 h-4 w-4"}),"Default Book Format"]}),(0,s.jsx)(U,{children:(0,s.jsx)(W,{children:(0,s.jsxs)(P,{value:eb,onValueChange:e=>ej(e),children:[(0,s.jsxs)(H,{value:"paper",children:[(0,s.jsx)(N.A,{className:"mr-2 h-4 w-4"})," Paper"]}),(0,s.jsxs)(H,{value:"digital",children:[(0,s.jsx)(w.A,{className:"mr-2 h-4 w-4"})," Digital"]}),(0,s.jsxs)(H,{value:"audio",children:[(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"})," Audio"]})]})})})]})]})]})]}):(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(L.$,{asChild:!0,variant:"outline",size:"sm",children:(0,s.jsxs)(l(),{href:"/signin",children:[(0,s.jsx)(D.A,{className:"mr-2 h-4 w-4"})," Sign In"]})}),(0,s.jsx)(L.$,{asChild:!0,variant:"default",size:"sm",children:(0,s.jsxs)(l(),{href:"/signup",children:[(0,s.jsx)(R.A,{className:"mr-2 h-4 w-4"})," Sign Up"]})})]})})]})})}var em=a(15894),eh=a(34679);let ep=eh.Kq,eg=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(eh.LM,{ref:t,className:(0,M.cn)("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:flex-col md:max-w-[420px]",a),...r})});eg.displayName=eh.LM.displayName;let ex=(0,Q.F)("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground",warning:"warning group border-amber-500 bg-amber-50 text-amber-900 dark:border-amber-600 dar
1k:bg-amber-950 dark:text-amber-100 [&>button>svg]:text-amber-900 dark:[&>button>svg]:text-amber-100"}},defaultVariants:{variant:"default"}}),eb=E.forwardRef((e,t)=>{let{className:a,variant:r,...l}=e;return(0,s.jsx)(eh.bL,{ref:t,className:(0,M.cn)(ex({variant:r}),a),...l})});eb.displayName=eh.bL.displayName,E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(eh.rc,{ref:t,className:(0,M.cn)("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",a),...r})}).displayName=eh.rc.displayName;let ej=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(eh.bm,{ref:t,className:(0,M.cn)("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600 group-[.warning]:text-amber-900 group-[.warning]:hover:text-amber-900 group-[.warning]:focus:ring-amber-400 group-[.warning]:focus:ring-offset-amber-600 dark:group-[.warning]:text-amber-100",a),"toast-close":"",...r,children:(0,s.jsx)(q.A,{className:"h-4 w-4"})})});ej.displayName=eh.bm.displayName;let ev=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(eh.hE,{ref:t,className:(0,M.cn)("text-sm font-semibold",a),...r})});ev.displayName=eh.hE.displayName;let ey=E.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)(eh.VY,{ref:t,className:(0,M.cn)("text-sm opacity-90",a),...r})});function eN(){let{toasts:e}=(0,em.dj)();return(0,s.jsxs)(ep,{children:[e.map(function(e){let{id:t,title:a,description:r,action:l,...o}=e;return(0,s.jsxs)(eb,{...o,children:[(0,s.jsxs)("div",{className:"grid gap-1",children:[a&&(0,s.jsx)(ev,{children:a}),r&&(0,s.jsx)(ey,{children:r})]}),l,(0,s.jsx)(ej,{})]},t)}),(0,s.jsx)(eg,{})]})}ey.displayName=eh.VY.displayName;var ew=a(20063),ek=a(34357),eA=a(72941);function eC(e){let{children:t,stats:a,isLoadingBooks:r,onBooksCountClick:l,onImportBooksClick:o,onExportBooksClick:i,onFindAllDetailsClick:n,isFindingAllDetailsInProgress:d,isAnyDetailFindingInProgress:c,onStopFindingAllDetailsClick:u,onViewStatsClick:f,onChangeAllToAudioClick:m,onBackupToCloud:
1h,onRestoreFromCloudClick:p,onCorrectAllAuthorNamesClick:g,onCorrectAllBookshelfAuthorNamesClick:x,onStripAllDescriptionsClick:b,onCleanAllGenresClick:j}=e,{user:v,loading:y}=(0,eo.A)(),N=(0,ew.useRouter)(),w=(0,ew.usePathname)(),{books:k,wishListBooks:A,bookshelfBooks:C,notes:S,isLoading:D}=(0,en._)(),R=(0,E.useRef)(!0),I=["/signin","/signup"].includes(w),L=(0,ek.YQ)(async()=>{if(v&&!D&&!R.current&&(0!==k.length||0!==A.length||0!==C.length||S))try{let e=await (0,eA.i)({userId:v.uid,libraryBooks:k,wishlistBooks:A,bookshelfBooks:C});if(e.success)console.log("Automatic cloud backup successful at",new Date().toLocaleTimeString());else throw Error(e.message||"An unknown error occurred during backup.")}catch(e){console.error("Automatic cloud backup failed:",e.message)}},5e3);return((0,E.useEffect)(()=>{!D&&v&&(R.current?R.current=!1:L())},[k,A,C,S,D,v,L]),(0,E.useEffect)(()=>{y||v||I||N.push("/signin")},[v,y,N,I]),y)?(0,s.jsx)("div",{className:"min-h-screen bg-background"}):v||I?(0,s.jsxs)("div",{className:"min-h-screen flex flex-col bg-background",children:[(0,s.jsx)(ef,{stats:a,isLoading:r,onImportBooksClick:o,onExportBooksClick:i,onFindAllDetailsClick:n,isFindingAllDetailsInProgress:d,isAnyDetailFindingInProgress:c,onStopFindingAllDetailsClick:u,onViewStatsClick:f,onBackupToCloud:
1h,onRestoreFromCloudClick:p,onChangeAllToAudioClick:m,onFindAllGenresClick:()=>{},onCorrectAllAuthorNamesClick:g,onCorrectAllBookshelfAuthorNamesClick:x,onStripAllDescriptionsClick:b,onCleanAllGenresClick:j}),(0,s.jsx)("main",{className:"flex-grow container mx-auto px-4 md:px-8 py-8",children:t}),(0,s.jsx)("footer",{className:"py-6 text-center text-muted-foreground border-t border-border/50",children:(0,s.jsxs)("p",{children:["\xa9 ",new Date().getFullYear()," Library Tracker. Reading proudly."]})}),(0,s.jsx)(eN,{})]}):null}},44385:(e,t,a)=>{a.d(t,{a:()=>r});var s=a(12115);function r(){let[e,t]=s.useState(null);return s.useEffect(()=>{let e=window.matchMedia("(max-width: ".concat(767,"px)")),a=()=>{t(window.innerWidth<768)};return t(window.innerWidth<768),e.addEventListener("change",a),()=>e.removeEventListener("change",a)},[]),e}},46998:(e,t,a)=>{a.d(t,{_:()=>x});var s=a(12115),r=a(11929),l=a(83549),o=a(19056),i=a(25511),n=a(81425),d=a(60399),c=a(58018),u=a(15894),f=a(34357);let m=(e,t)=>t?"".concat(e,"_").concat(t):null,h=(e,t)=>{let a=e.split(":")[0].toLowerCase().trim(),s=t.map(e=>e.toLowerCase().trim()).sort().join(",");return"".concat(a,"-").concat(s)},p={totalBooks:0,booksPerYear:[],booksPerGenre:[],averagePageCount:void 0,averageReadingDays:void 0,totalPagesRead:void 0};function g(e){if(!e)return[];if(e.includes(";")&&!e.includes(",")){let t=e.split(";").map(e=>e.trim()).filter(e=>e),a=[];if(t.length%2==0){for(let e=0;e<t.length;e+=2)a.push("".concat(t[e+1]," ").concat(t[e]));if(a.length>0)return a}return t}return e.split(",").map(e=>{let t=e.trim(),a=t.split(" ").filter(e=>e.length>0);if(a.length>1&&a[0].endsWith(",")){let e=a[0].slice(0,-1),t=a.slice(1).join(" ");return"".concat(t," ").concat(e)}if(t.includes(" ")&&t.indexOf(",")>0&&t.indexOf(",")<t.indexOf(" ")){let[e,...a]=t.split(",");return"".concat(a.join(",").trim()," ").concat(e.trim())}return t}).filter(e=>e)}function x(){let{user:e,loading:t}=(0,c.A)(),{toast:a}=(0,u.dj)(),[x,b]=(0,s.useState)([]),[j,v]=(0,s.useState)([]),[y,N]=(0,s.useState)([]),[w,k]=(0,s.useState)(""),[A,C]=(0,s.useState)(!0),[S,D]=(0,s.useState)(null),[R,I]=(0,s.useState)(p),[L,E]=(0,s.useState)("audio"),[T,F]=(0,s.useState)(!1),B=(0,s.useCallback)(()=>{if(!t){if(C(!0),e){let t=m("libraryTrackerBooks",e.uid),a=m("libraryTrackerWishlist",e.uid),s=m("libraryTrackerBookshelf",e.uid),r=m("libraryTrackerDefaultFormat",e.uid),l=m("libraryTrackerNotes",e.uid);try{let e=t?localStorage.getItem(t):null;b(e?JSON.parse(e):[])}catch(e){console.error("Failed to load library books from localStorage:",e),b([])}try{let e=a?localStorage.getItem(a):null;v(e?JSON.parse(e):[])}catch(e){console.error("Failed to load wishlist books from localStorage:",e),v([])}try{let e=s?localStorage.getItem(s):null;N(e?JSON.parse(e):[])}catch(e){console.error("Failed to load bookshelf books from localStorage:",e),N([])}try{let e=l?localStorage.getItem(l):null;k(e||"")}catch(e){console.error("Failed to load notes from localStorage:",e),k("")}try{let e=r?localStorage.getItem(r):null;e&&["paper","digital","audio"].includes(e)?E(e):E("audio")}catch(e){console.error("Failed to load default format from localStorage:",e),E("audio")}}else b([]),v([]),N([]),k(""),E("audio");C(!1)}},[e,t]);(0,s.useEffect)(()=>{B()},[e,t,B]);let O=(0,f.YQ)(()=>{if(t||!e)return;let a=m("libraryTrackerBooks",e.uid),s=m("libraryTrackerWishlist",e.uid),r=m("libraryTrackerBookshelf",e.uid),l=m("libraryTrackerDefaultFormat",e.uid),o=m("libraryTrackerNotes",e.uid),i=!1,n=(e,t,a)=>{if(e)try{localStorage.setItem(e,JSON.stringify(t))}catch(t){i=!0;let e="Browser storage is full for ".concat(a,". New changes may not be saved.");S!==e&&(D(e),console.warn("LocalStorage Quota Warning (".concat(a,"): ").concat(e),t))}};n(a,x,"library"),n(s,j,"wishlist"),n(r,y,"bookshelf");var d="notes";if(o)try{localStorage.setItem(o,w)}catch(t){i=!0;let e="Browser storage is full for ".concat(d,". New changes may not be saved.");S!==e&&(D(e),console.warn("LocalStorage Quota Warning (".concat(d,"): ").concat(e),t))}if(l)try{localStorage.setItem(l,L)}catch(e){console.warn("LocalStorage Quota Warning (defaultFormat): Could not save default format.",e)}!i&&S&&D(null),F(!1)},1e3);(0,s.useEffect)(()=>{A||t||O()},[x,j,y,L,w,A,t,O]),(0,s.useEffect)(()=>{let e=x.filter(e=>"read"===e.status&&e.finishDate&&(0,l.f)((0,o.H)(e.finishDate))),t=e.length,a={};
1e.forEach(e=>{if(e.finishDate)try{let t=(0,o.H)(e.finishDate),s=(0,i.GP)(t,"yyyy");a[s]=(a[s]||0)+1}catch(t){if(e.finishDate.match(/^\d{4}$/))a[e.finishDate]=(a[e.finishDate]||0)+1;else if(e.finishDate.match(/^\d{4}-\d{2}$/)){let t=e.finishDate.substring(0,4);a[t]=(a[t]||0)+1}else console.warn('Could not parse finishDate "'.concat(e.finishDate,'" for book "').concat(e.title,'" for yearly stats.'))}});let s=Object.entries(a).map(e=>{let[t,a]=e;return{year:t,books:a}}).sort((e,t)=>parseInt(e.year)-parseInt(t.year)),r=0,c=0;e.forEach(e=>{e.pageCount&&Number(e.pageCount)>0&&(r+=Number(e.pageCount),c++)});let u=c>0?Math.round(r/c):void 0,f=0,m=0;e.forEach(e=>{if(e.startedReading&&e.finishDate)try{let s=(0,o.H)(e.startedReading),r=(0,o.H)(e.finishDate);if((0,l.f)(s)&&(0,l.f)(r)&&r>=s){let e=(0,n.m)(r,s)+1;f+=e,m++}else{var t,a;let i=new Date("2000-01-01T00:00:00.000Z"),c=!1,u=!1,h=s,p=r;for(let t of["MM/dd/yyyy","yyyy/MM/dd","dd-MM-yyyy","M/d/yy","MM-dd-yyyy"])!(0,l.f)(h)&&e.startedReading&&(h=(0,d.qg)(e.startedReading,t,i)),!(0,l.f)(p)&&e.finishDate&&(p=(0,d.qg)(e.finishDate,t,i));if(c=(0,l.f)(h),u=(0,l.f)(p),!c&&(null==(t=e.startedReading)?void 0:t.match(/^\d{4}(-\d{2})?$/))&&(h=(0,o.H)(4===e.startedReading.length?"".concat(e.startedReading,"-01-01"):"".concat(e.startedReading,"-01")),c=(0,l.f)(h)),!u&&(null==(a=e.finishDate)?void 0:a.match(/^\d{4}(-\d{2})?$/))&&(p=(0,o.H)(4===e.finishDate.length?"".concat(e.finishDate,"-01-01"):"".concat(e.finishDate,"-01")),u=(0,l.f)(p)),c&&u&&p>=h){let e=(0,n.m)(p,h)+1;f+=e,m++}else console.warn('Could not parse dates for reading duration for book "'.concat(e.title,'". Started: ').concat(e.startedReading,", Finished: ").concat(e.finishDate))}}catch(t){console.warn('Error parsing dates for reading duration for book "'.concat(e.title,'":'),t)}});let h=m>0?parseFloat((f/m).toFixed(1)):void 0,p={};e.forEach(e=>{e.genres&&e.genres.length>0&&e.genres.forEach(e=>{p[e]=(p[e]||0)+1})});let g=Object.entries(p).map(e=>{let[a,s]=e;return{genre:a,books:s,percentage:t>0?parseFloat((s/t*100).toFixed(1)):0}}).sort((e,t)=>t.books-e.books);I({totalBooks:t,booksPerYear:s,booksPerGenre:g,averagePageCount:u,averageReadingDays:h,totalPagesRead:r>0?r:void 0})},[x]);let M=(0,s.useCallback)(e=>{let t={...e,id:(0,r.A)(),status:e.status||"read",format:e.format||"paper",notes:e.notes||void 0,finishDate:"dnf"===e.status?void 0:e.finishDate,coverImageUrl:e.coverImageUrl||void 0,description:e.description||void 0,publicationDate:e.publicationDate||void 0,pageCount:e.pageCount||void 0,startedReading:e.startedReading||void 0,rating:e.rating||void 0,genres:e.genres||void 0};return b(e=>[...e,t]),t},[]),$=(0,s.useCallback)(e=>{let t={...e,finishDate:e.finishDate,status:e.finishDate?"dnf"===e.status?"dnf":"read":"dnf"===e.status?"dnf":"reading"};b(e=>e.map(e=>e.id===t.id?t:e))},[]),z=(0,s.useCallback)((e,t)=>{b(a=>a.map(a=>{if(a.id===e){var s,r,l,o;let e={...a,...t};return Object.prototype.hasOwnProperty.call(t,"coverImageUrl")&&(e.coverImageUrl=null!=(s=t.coverImageUrl)?s:void 0),Object.prototype.hasOwnProperty.call(t,"description")&&(e.description=null!=(r=t.description)?r:void 0),Object.prototype.hasOwnProperty.call(t,"publicationDate")&&(e.publicationDate=null!=(l=t.publicationDate)?l:void 0),Object.prototype.hasOwnProperty.call(t,"pageCount")&&(e.pageCount=null!=(o=t.pageCount)?o:void 0),e}return a}))},[]),U=(0,s.useCallback)(e=>{b(t=>t.filter(t=>t.id!==e))},[]),_=(0,s.useCallback)(e=>{let t=new Set(e);b(e=>e.filter(e=>!t.has(e.id)))},[]),P=(0,s.useCallback)(()=>{b([])},[]),V=(0,s.useCallback)(()=>{let e=0;return b(t=>(e=t.length,t.map(e=>({...e,format:"audio"})))),e},[]),W=(0,s.useCallback)(()=>{let e=0,t=x.map(t=>{let a=g(t.authors.join(", ")),s=new Set(t.authors.map(e=>e.trim())),r=new Set(a.map(e=>e.trim()));return s.size===r.size&&[...s].every(e=>r.has(e))?t:(e++,{...t,authors:a})});return e>0&&b(t),e},[x]),J=(0,s.useCallback)(()=>{let e=0,t=y.map(t=>{let a=g(t.authors.join(", ")),s=new Set(t.authors.map(e=>e.trim())),r=new Set(a.map(e=>e.trim()));return s.size===r.size&&[...s].every(e=>r.has(e))?t:(e++,{...t,authors:a})});return e>0&&N(t),e},[y]),G=(0,s.useCallback)(()=>{let e=0,t=(t,a)=>{a(t.map(t=>{if(t.description){let a=t.description.replace(/<[^>]*>?/gm,"");if(a!==t.description)return e++,{...t,description:a}}return t}))};return t(x,b),t(j,v),t(y,N),e},[x,j,y]),H=(0,s.useCallback)(()=>{let e=0,t=(t,a)=>{a(t.map(t=>{let{cleaned:a,changed:s}=(e=>{if(!e||0===e.length)return{cleaned:[],changed:!1};let t=new Set(e),a=new Set;
1e.forEach(e=>{e.split(/[/,]/).forEach(e=>{let t=e.trim();t&&a.add(t)})});let s=t.size!==a.size||![...t].every(e=>a.has(e));return{cleaned:Array.from(a),changed:s}})(t.genres);return s?(e++,{...t,genres:a}):t}))};return t(x,b),t(j,v),t(y,N),e},[x,j,y]),Y=(0,s.useCallback)(t=>{if(!e)throw Error("User must be logged in to restore data.");if(t&&Array.isArray(t.library)&&Array.isArray(t.wishlist)){let a=m("libraryTrackerBooks",e.uid),s=m("libraryTrackerWishlist",e.uid),r=m("libraryTrackerBookshelf",e.uid),l=m("libraryTrackerNotes",e.uid);if(!a||!s||!r||!l)throw Error("Could not construct storage keys for restore.");try{localStorage.setItem(a,JSON.stringify(t.library||[])),localStorage.setItem(s,JSON.stringify(t.wishlist||[])),localStorage.setItem(r,JSON.stringify(t.bookshelf||[])),localStorage.setItem(l,t.notes||"")}catch(e){throw console.error("Error writing restored data to localStorage:",e),Error("Failed to save restored data to local storage. Storage might be full.")}return B(),{libraryCount:t.library.length,wishlistCount:t.wishlist.length,bookshelfCount:(t.bookshelf||[]).length}}throw Error("Invalid backup file format. Missing 'library' or 'wishlist' array.")},[e,B]),Z=(0,s.useCallback)(e=>x.find(t=>t.id===e),[x]),Q=(0,s.useCallback)(e=>{let t=g(e.authors.join(",")),a={title:e.title,authors:t,id:(0,r.A)(),status:"to-read",format:e.format||"paper",notes:e.notes||void 0,finishDate:void 0,startedReading:void 0,pageCount:e.pageCount||void 0,publicationDate:e.publicationDate||void 0,coverImageUrl:e.coverImageUrl||void 0,description:e.description||void 0,rating:e.rating||void 0,genres:e.genres||void 0};return v(e=>[...e,a]),a},[]),q=(0,s.useCallback)(e=>{v(t=>t.map(t=>t.id===e.id?e:t))},[]),K=(0,s.useCallback)(e=>{v(t=>t.filter(t=>t.id!==e))},[]),X=(0,s.useCallback)(e=>{let t=j.find(t=>t.id===e);t&&(M({title:t.title,authors:t.authors,format:t.format,publicationDate:t.publicationDate,pageCount:t.pageCount,notes:t.notes,coverImageUrl:t.coverImageUrl,description:t.description,status:"to-read",finishDate:void 0,startedReading:void 0,rating:t.rating,genres:t.genres}),K(e))},[j,M,K]),ee=(0,s.useCallback)((e,t)=>{v(a=>{let s=[...a],r=s.findIndex(t=>t.id===e);if(-1===r)return a;let[l]=s.splice(r,1);if(null===t)s.push(l);else{let e=s.findIndex(e=>e.id===t);if(-1===e)return a;s.splice(e,0,l)}return s})},[]),et=(0,s.useCallback)(e=>{let t=g(e.authors.join(",")),a={...e,authors:t};N(e=>{let t=[...e],s={...a,id:(0,r.A)(),status:"to-read",onBookshelf:!0,bookshelfLocation:""};if(!a.bookshelfLocation||!a.bookshelfLocation.includes(":"))return console.error("addBookToBookshelf: Invalid or missing bookshelf location. Appending book without re-ordering."),[...t,s];let l=a.bookshelfLocation.split(":"),o=l[0].trim(),i=parseInt(l[1].trim(),10);if(isNaN(i))return console.error("addBookToBookshelf: Invalid position number. Appending book."),[...t,s];let n=t.filter(e=>{var t;return null==(t=e.bookshelfLocation)?void 0:t.startsWith("".concat(o,":"))}),d=t.filter(e=>{var t;return!(null==(t=e.bookshelfLocation)?void 0:t.startsWith("".concat(o,":")))}),c=Math.max(1,Math.min(i,n.length+1));n.splice(c-1,0,s);let u=n.length;return[...d,...n.map((e,t)=>({...e,bookshelfLocation:"".concat(o,": ").concat(t+1,"/").concat(u)}))]})},[]),ea=(0,s.useCallback)(e=>{N(t=>{let a=new Set([...x,...t].map(e=>h(e.title,e.authors))),s=new Map;for(let t of e){let e=g(t.authors.join(",")),a={...t,authors:e},r=h(a.title,a.authors);s.has(r)||s.set(r,a)}return[...t,...Array.from(s.values()).filter(e=>{let t=h(e.title,e.authors);return!a.has(t)}).map(e=>({...e,id:(0,r.A)(),status:"to-read",onBookshelf:!0}))]})},[x]),es=(0,s.useCallback)(e=>{N(t=>t.map(t=>t.id===e.id?e:t))},[]),er=(0,s.useCallback)(e=>{N(t=>{let a=[...t],s=new Set,r=new Set(e),l=[...a.filter(e=>!r.has(e.id)||(e.bookshelfLocation&&s.add(e.bookshelfLocation.split(":")[0].trim()),!1))];return s.forEach(e=>{let t=l.filter(t=>{var a;return null==(a=t.bookshelfLocation)?void 0:a.startsWith("".concat(e,":"))}).sort((e,t)=>(e.bookshelfLocation?parseInt(e.bookshelfLocation.split(":")[1].trim().split("/")[0]):0)-(t.bookshelfLocation?parseInt(t.bookshelfLocation.split(":")[1].trim().split("/")[0]):0)),a=t.length;t.forEach((t,s)=>{let r=l.findIndex(e=>e.id===t.id);-1!==r&&(l[r].bookshelfLocation="".concat(e,": ").concat(s+1,"/").concat(a))})}),l})},[]),el=(0,s.useCallback)(()=>{N([])},[]),eo=(0,s.useMemo)(()=>{let e=new Set;
1return y.forEach(t=>{if(t.bookshelfLocation){let a=t.bookshelfLocation.split(":")[0].trim();a&&e.add(a)}}),Array.from(e).sort()},[y]),ei=(0,s.useCallback)((e,t)=>{if(!e||!t||e===t)return 0;let a=0;return N(y.map(s=>{var r;if(null==(r=s.bookshelfLocation)?void 0:r.startsWith("".concat(e,":"))){let r=s.bookshelfLocation.substring(e.length+1).trim();return a++,{...s,bookshelfLocation:"".concat(t,": ").concat(r)}}return s})),a},[y]),en=(0,s.useCallback)(e=>{if(!e)return 0;let t=0;return N(y.filter(a=>{var s;return null==(s=a.bookshelfLocation)||!s.startsWith("".concat(e,":"))||(t++,!1)})),t},[y]),ed=(0,s.useCallback)(e=>{E(e)},[]);return{books:x,addBook:M,updateBook:$,updateBookDetails:z,deleteBook:U,deleteBooks:_,deleteAllBooks:P,setAllBooksToAudio:V,correctAllAuthorNames:W,correctAllBookshelfAuthorNames:J,stripAllDescriptions:G,cleanAllGenres:H,importBooks:(e,t,a)=>{let s=new Set([...t,...a].map(e=>h(e.title,e.authors))),l=new Map;for(let t of e){let e=g(t.authors.join(",")),a={...t,authors:e},s=h(a.title,a.authors);l.has(s)||l.set(s,a)}let o=Array.from(l.values()).filter(e=>{let t=h(e.title,e.authors);return!s.has(t)}).map(e=>({...e,id:(0,r.A)(),status:e.status||"read",format:e.format||"audio",notes:e.notes||void 0,finishDate:"dnf"===e.status?void 0:e.finishDate,coverImageUrl:e.coverImageUrl||void 0,description:e.description||void 0,publicationDate:e.publicationDate||void 0,pageCount:e.pageCount||void 0,startedReading:e.startedReading||void 0,rating:e.rating||void 0,genres:e.genres||void 0}));return o.length>0&&b(e=>[...e,...o]),o.length},restoreFromBackup:Y,getBookById:Z,stats:R,isLoading:A,storageWarning:S,loadDataFromStorage:B,clearAllData:()=>{},setBooks:b,setWishListBooks:v,wishListBooks:j,addBookToWishList:Q,updateWishlistBook:q,deleteBookFromWishList:K,moveWishListBookToLibrary:X,reorderWishlistBook:ee,bookshelfBooks:y,addBookToBookshelf:et,addBooksToBookshelf:ea,updateBookshelfBook:es,deleteBooksFromShelf:er,deleteAllBookshelfBooks:el,getUniqueShelfNames:eo,renameShelf:ei,deleteShelf:en,notes:w,setNotes:(0,s.useCallback)(e=>{F(!0),k(e)},[]),isSavingNotes:T,defaultBookFormat:L,setDefaultBookFormat:ed}}},58018:(e,t,a)=>{a.d(t,{AuthProvider:()=>f,A:()=>m});var s=a(95155),r=a(12115),l=a(59253),o=a(52078),i=a(19708);let n=(0,o.Dk)().length?(0,o.Sx)():(0,o.Wp)({projectId:"library-tracker-rltyo",appId:"1:5017400893:web:b6dee412f0e12301529c54",storageBucket:"library-tracker-rltyo.firebasestorage.app",apiKey:"AIzaSyBZy2V-7mY0gdg3NuEGbz_Dx9827rkfOoM",authDomain:"library-tracker-rltyo.firebaseapp.com",messagingSenderId:"5017400893"});(0,l.xI)(n),(0,i.aU)(n);var d=a(20063);let c=(0,l.xI)(n),u=(0,r.createContext)(void 0),f=e=>{let{children:t}=e,[a,o]=(0,r.useState)(null),[i,n]=(0,r.useState)(!0),f=(0,d.useRouter)();return(0,r.useEffect)(()=>{let e=(0,l.hg)(c,e=>{o(e),n(!1)});return()=>e()},[]),(0,s.jsx)(u.Provider,{value:{user:a,loading:i,signUp:(e,t)=>(0,l.eJ)(c,e,t),signIn:(e,t)=>(0,l.x9)(c,e,t),signOutUser:()=>(0,l.CI)(c).then(()=>{f.push("/signin")})},children:t})},m=()=>{let e=(0,r.useContext)(u);if(void 0===e)throw Error("useAuth must be used within an AuthProvider");return e}},64269:(e,t,a)=>{a.d(t,{cn:()=>l});var s=a(2821),r=a(75889);function l(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,r.QP)((0,s.$)(t))}},65142:(e,t,a)=>{a.d(t,{p:()=>o});var s=a(95155),r=a(12115),l=a(64269);let o=r.forwardRef((e,t)=>{let{className:a,type:r,...o}=e;return(0,s.jsx)("input",{type:r,className:(0,l.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",a),ref:t,...o})});o.displayName="Input"},72941:(e,t,a)=>{a.d(t,{i:()=>r});var s=a(30926);let r=(0,s.createServerReference)("40210478279d4256909af364e8aa7a6c8f3fe83f0d",s.callServer,void 0,s.findSourceMapURL,"backupUserData")},76444:(e,t,a)=>{a.d(t,{J:()=>d});var s=a(95155),r=a(12115),l=a(10489),o=a(83101),i=a(64269);let n=(0,o.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=r.forwardRef((e,t)=>
1{let{className:a,...r}=e;return(0,s.jsx)(l.b,{ref:t,className:(0,i.cn)(n(),a),...r})});d.displayName=l.b.displayName},86259:(e,t,a)=>{a.d(t,{w:()=>i});var s=a(95155),r=a(12115),l=a(57268),o=a(64269);let i=r.forwardRef((e,t)=>{let{className:a,orientation:r="horizontal",decorative:i=!0,...n}=e;return(0,s.jsx)(l.b,{ref:t,decorative:i,orientation:r,className:(0,o.cn)("shrink-0 bg-border","horizontal"===r?"h-[1px] w-full":"h-full w-[1px]",a),...n})});i.displayName=l.b.displayName},86948:(e,t,a)=>{a.d(t,{BT:()=>d,Wu:()=>c,ZB:()=>n,Zp:()=>o,aR:()=>i,wL:()=>u});var s=a(95155),r=a(12115),l=a(64269);let o=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",a),...r})});o.displayName="Card";let i=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",a),...r})});i.displayName="CardHeader";let n=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",a),...r})});n.displayName="CardTitle";let d=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",a),...r})});d.displayName="CardDescription";let c=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("p-6 pt-0",a),...r})});c.displayName="CardContent";let u=r.forwardRef((e,t)=>{let{className:a,...r}=e;return(0,s.jsx)("div",{ref:t,className:(0,l.cn)("flex items-center p-6 pt-0",a),...r})});u.displayName="CardFooter"}}]);
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.