try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},r=(new e.Error).stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="471f3c97-acfd-4999-a447-8a18e26c42e8",e._sentryDebugIdIdentifier="sentry-dbid-471f3c97-acfd-4999-a447-8a18e26c42e8")}()}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2985],{10142:(e,r,l)=>{l.r(r),l.d(r,{ReviewsCarousel:()=>s});var t=l(65183),o=l(24375),n=l(39812);let a=(0,o.memo)(function(e){var r;let{review:l,showRating:a,showBorder:s,index:i,onCardClick:c}=e,d=(0,o.useCallback)(()=>c(i),[c,i]),u=(0,o.useCallback)(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),c(i))},[c,i]);return(0,t.jsx)("div",{className:"w-52 md:w-72 h-48 shrink-0 flex snap-center","data-index":i,onClick:d,onKeyDown:u,role:"button",tabIndex:0,"aria-label":"Center review ".concat(i+1," of ").concat((null==(r=l.author)?void 0:r.name)||"anonymous"),children:(0,t.jsx)(n.ReviewCard,{review:l,showRating:a,showBorder:s,className:"h-full"})})}),s=(0,o.memo)(function(e){let{reviews:r,showRatings:l,title:n="Some reviews",width:s,height:i,showBorder:c=!0}=e,d=(0,o.useRef)(null),{isDragging:u,handleDragStart:m,handleDragEnd:h,handleDragMove:x}=(e=>{let[r,l]=(0,o.useState)(!1),t=(0,o.useRef)({x:0,scrollLeft:0}),n=(0,o.useCallback)(r=>{var o,n;e.current&&(l(!0),t.current={x:"touches"in r&&r.touches&&r.touches.length>0&&null!=(n=null==(o=r.touches[0])?void 0:o.clientX)?n:r.clientX,scrollLeft:e.current.scrollLeft})},[e]),a=(0,o.useCallback)(()=>{l(!1)},[]),s=(0,o.useCallback)(l=>{var o,n;if(!r||!e.current)return;l.preventDefault();let a="touches"in l&&l.touches&&l.touches.length>0&&null!=(n=null==(o=l.touches[0])?void 0:o.clientX)?n:l.clientX,s=t.current.x-a;e.current.scrollLeft=t.current.scrollLeft+s},[r,e]);return{isDragging:r,handleDragStart:n,handleDragEnd:a,handleDragMove:s}})(d),b=(0,o.useCallback)(e=>{if(d.current){let r=d.current.children[e];r&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})}},[d]),f=(0,o.useCallback)(e=>{if(!d.current)return;let r=d.current;r.scrollLeft;let l=r.clientWidth,t=r.querySelector(".carousel-item");if(!t)return;let o=t.getBoundingClientRect().width,n=(l-o*Math.floor(l/o))/(Math.floor(l/o)-1||1),a=o+n;"ArrowRight"===e.key?r.scrollBy({left:a,behavior:"smooth"}):"ArrowLeft"===e.key&&r.scrollBy({left:-a,behavior:"smooth"})},[]),p=(0,o.useCallback)(e=>r=>{(null==r?void 0:r.currentTarget)&&(null==r?void 0:r.target)&&(r.persist(),e(r))},[]),g=r.length<2,y=r.length<3&&"lg"===s;return(0,t.jsxs)("div",{className:"".concat("sm"===i?"mt-0 mb-0 p-0":"")+" p-4",children:[(0,t.jsx)("h3",{className:"text-xl font-semibold mb-4",children:n}),(0,t.jsx)("div",{className:"w-full relative",children:(0,t.jsx)("div",{className:"relative",onKeyDown:f,role:"region",tabIndex:0,"aria-label":"Reviews carousel - use arrow keys to navigate, or drag to scroll",children:(0,t.jsx)("div",{className:"mx-auto mb-4 relative overflow-x-scroll select-none\n max-w-[280px] sm:max-w-[380px] md:max-w-[420px] ".concat("lg"===s?"lg:max-w-[600px]":"","\n cursor-grab active:cursor-grabbing ").concat(g?"flex justify-center":"","\n scrollbar-hide h-48\n scroll-smooth snap-x snap-mandatory"),ref:d,onMouseDown:p(m),onMouseUp:p(h),onMouseLeave:p(h),onMouseMove:p(x),onTouchStart:p(m),onTouchEnd:p(h),onTouchMove:p(x),role:"region","aria-label":"Reviews carousel - drag to scroll or click on a review to center it","aria-live":"polite",children:(0,t.jsx)("div",{className:"flex space-x-4 md:space-x-6 h-full ".concat(y?"md:justify-center":""),children:r.map((e,r)=>(0,t.jsx)(a,{review:e,showRating:l,showBorder:c,index:r,onCardClick:b},"review-".concat(r)))})})})})]})})},15423:(e,r,l)=>{l.d(r,{B:()=>d});var t=l(65183),o=l(9613),n=l(26408),a=l(24375),s=l(71390),i=l(56275);let c="/books/preorder",d=a.memo(e=>{let{book:r,isOpen:l,onOpenChange:d}=e,{sendEvent:u}=(0,i.s)(),m=!!(null==r?void 0:r.title),h=(0,a.useMemo)(()=>{if(!m)return[];let e=[];return(r.amazonLink||c)&&e.push({type:"Paperback",href:r.amazonLink||c}),(r.myStoreLink||c)&&e.push({type:"eBook",href:r.myStoreLink||c}),r.hasAudiobook&&r.myStoreLink&&e.push({type:"Audiobook",href:r.myStoreLink}),r.hasAudible&&r.amazonLink&&e.push({type:"Audible",href:r.amazonLink}),e},[r,m]),x=(0,a.useCallback)(e=>{try{!e&&m&&s.qk.modalClose("BuyBookModal"),null==d||d(e)}catch(e){console.error("Error closing modal:",e),o.Cp(e)}},[d,m]);if(!m){let e=Error("BuyBookModal: Book or book title is missing");return console.error(e),o.Cp(e),null}if(0===h.length){let e=Error("BuyBookModal: No purchase options available for book: ".concat(r.title));return console.warn(e),o.wd(e.message,{level:"warning"}),null}return(0,t.jsx)(n.aF,{isOpen:l,onOpenChange:x,children:(0,t.jsx)(n.$m,{className:"pb-0",onOpenChange:x,children:e=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.rQ,{className:"flex flex-col gap-1",children:(0,t.jsxs)("div",{className:"flex w-full items-center justify-between",children:[(0,t.jsxs)("h4",{children:["Buy ",r.title]}),(0,t.jsx)(n.$n,{variant:"ghost",size:"sm",onClick:e,className:"p-2 h-8 w-8 min-w-0 rounded-full hover:bg-gray-100","aria-label":"Close purchase options modal",children:"✕"})]})}),(0,t.jsx)(n.cw,{children:h.map(e=>{let{type:l,href:a}=e;return(0,t.jsxs)(n.$n,{href:a,variant:"primary",className:"w-full mb-2",target:a.startsWith("http")?"_blank":void 0,"aria-label":"Buy ".concat(l," version of ").concat(r.title),onClick:()=>{try{if(!a)return;s.qk.buttonClick("".concat(l," Purchase"),r.title),s.jU.externalLink(a,"".concat(l," purchase for ").concat(r.title)),u({name:"redirect_to_ext_store_with_intent_to_buy",params:{book_title:r.title,format:l}}),a.startsWith("http")&&window.open(a,"_blank","noopener,noreferrer")}catch(e){console.error("Error handling button press:",e),o.Cp(e)}},children:[l,"Audible"===l&&(0,t.jsx)("span",{className:"text-xs",children:"(only on Amazon.com \uD83C\uDDFA\uD83C\uDDF8)"})]},l)})})]})})})});d.displayName="BuyBookModal"},26408:(e,r,l)=>{l.d(r,{$n:()=>t.$,aF:()=>s,cw:()=>d,$m:()=>i,rQ:()=>c}),l(71307);var t=l(50849);l(85386);var o=l(65183),n=l(24375);l(43834),l(53911);var a=l(92382);function s(e){let{children:r,isOpen:l,onOpenChange:t,className:s}=e,i=(0,n.useCallback)(e=>{"Escape"===e.key&&t(!1)},[t]);return((0,n.useEffect)(()=>{if(l)return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[l,i]),l)?(0,o.jsxs)("div",{className:(0,a.QP)("fixed inset-0 z-50 flex items-center justify-center bg-black/50",s),onClick:e=>{e.target===e.currentTarget&&t(!1)},onKeyDown:e=>{"Escape"===e.key&&t(!1)},role:"button",tabIndex:0,"aria-label":"Click outside or press Escape to close this modal","aria-describedby":"modal-backdrop-description",children:[(0,o.jsx)("div",{id:"modal-backdrop-description",className:"sr-only",children:"Click outside or press Escape to close this modal"}),r]}):null}function i(e){let{children:r,className:l,onOpenChange:t}=e;return(0,o.jsx)("div",{className:(0,a.QP)("relative bg-white rounded-lg shadow-xl max-w-xl w-full mx-4 max-h-[90vh] overflow-hidden",l),children:"function"==typeof r?r(()=>t(!1)):r})}function c(e){let{children:r,className:l}=e;return(0,o.jsx)("div",{className:(0,a.QP)("px-6 py-4 border-b border-gray-200",l),children:r})}function d(e){let{children:r,className:l}=e;return(0,o.jsx)("div",{className:(0,a.QP)("px-6 py-4",l),children:r})}},41648:(e,r,l)=>{l.d(r,{BuyBookButton:()=>d});var t=l(65183),o=l(9613),n=l(24375),a=l(71390),s=l(50849),i=l(15423),c=l(80346);let d=(0,n.memo)(e=>{let{book:r,className:l}=e,{isOpen:n,onOpen:d,onOpenChange:u}=(0,c.j)();return r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.$,{variant:"primary",onClick:()=>{try{a.r2.buyButtonClick(r.title),a.qk.modalOpen("BuyBookModal"),null==d||d()}catch(e){console.error("Error opening modal:",e),o.Cp(e)}},"aria-label":"Buy ".concat(r.title),className:l,children:"Buy Now"}),(0,t.jsx)(i.B,{book:r,isOpen:n,onOpenChange:u})]}):(o.wd("BuyBookButton: No book provided",{level:"warning"}),null)});d.displayName="BuyBookButton"},43834:(e,r,l)=>{l.d(r,{E:()=>i});var t=l(65183);l(24375);var o=l(92382);let n={default:"bg-gray-100 text-gray-800 border border-gray-200",primary:"bg-primary text-white border border-primary",secondary:"bg-gray-200 text-gray-700 border border-gray-400",success:"bg-success-light text-green-800 border border-success-border",warning:"bg-warning-light text-yellow-800 border border-warning-border",danger:"bg-error-light text-red-800 border border-error-border",info:"bg-info-light text-blue-800 border border-info-border",bordered:"bg-white text-gray-700 border-2 border-gray-400"},a={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"},s={none:"",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",full:"rounded-full"};function i(e){let{children:r,className:l,variant:i="default",size:c="md",rounded:d="md"}=e,u=(0,o.QP)("inline-flex items-center font-medium",n[i],a[c],s[d],l);return(0,t.jsx)("span",{className:u,children:r})}},53911:(e,r,l)=>{l.d(r,{P:()=>s});var t=l(65183);l(24375);var o=l(92382);let n={sm:"w-4 h-4",md:"w-6 h-6",lg:"w-8 h-8"},a={primary:"text-primary",secondary:"text-muted",success:"text-success",warning:"text-warning",danger:"text-error"};function s(e){let{size:r="md",color:l="primary",className:s,"aria-label":i="Loading..."}=e;return(0,t.jsx)("div",{className:(0,o.QP)("inline-block",n[r],s),role:"status","aria-label":i,children:(0,t.jsxs)("svg",{className:(0,o.QP)("animate-spin",n[r],a[l]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,t.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})}},80346:(e,r,l)=>{l.d(r,{j:()=>o});var t=l(24375);function o(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],[r,l]=(0,t.useState)(e),o=(0,t.useCallback)(()=>l(!0),[]),n=(0,t.useCallback)(()=>l(!1),[]);return{isOpen:r,onOpen:o,onClose:n,onToggle:(0,t.useCallback)(()=>l(e=>!e),[]),onOpenChange:(0,t.useCallback)(e=>l(e),[])}}},85386:(e,r,l)=>{l.d(r,{m:()=>s});var t=l(65183);l(24375);var o=l(92382);let n={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","3xl":"max-w-3xl","4xl":"max-w-4xl",full:"max-w-full",none:""},a={none:"",sm:"px-4",md:"px-6",lg:"px-8",xl:"px-12"};function s(e){let{children:r,className:l,as:s="div",maxWidth:i="lg",padding:c="md",centered:d=!0,fluid:u=!1}=e,m=(0,o.QP)("w-full",!u&&"none"!==i&&n[i],!u&&d&&"mx-auto",a[c],l);return(0,t.jsx)(s,{className:m,children:r})}}}]);