try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9f0ac320-4d5b-4eaa-aceb-02ebe7885bca",e._sentryDebugIdIdentifier="sentry-dbid-9f0ac320-4d5b-4eaa-aceb-02ebe7885bca")}catch(e){}"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9597],{14398:(e,t,r)=>{r.d(t,{s:()=>s});let o={writeKey:r(55036).env.NEXT_PUBLIC_SEGMENT_WRITE_KEY||""};var n=r(75785),l=r(83982);let a={gaId:r(55036).env.NEXT_PUBLIC_GA_ID||""};function s(){let e=(0,l.useCallback)(e=>{let{name:t,params:r}=e;try{if(a.gaId){let e={event:t};if(r)for(let t in r)e[t]=r[t];(0,n.sendGAEvent)(e)}}catch(e){console.error("Failed to send Google Analytics event:",e)}(e=>{let{event:t,properties:r}=e;if(o.writeKey&&window.analytics)try{window.analytics.track(t,r)}catch(e){console.error("Failed to track Segment event:",e)}})({event:t,properties:r})},[]);return{sendEvent:e,identifyUser:(0,l.useCallback)(e=>{let{userId:t,traits:r}=e;(e=>{let{userId:t,traits:r}=e;if(o.writeKey&&window.analytics)try{window.analytics.identify(t,r)}catch(e){console.error("Failed to identify Segment user:",e)}})({userId:t,traits:r})},[]),trackPage:(0,l.useCallback)(()=>{if(o.writeKey&&window.analytics)try{window.analytics.page()}catch(e){console.error("Failed to track Segment page:",e)}},[])}}},17871:(e,t,r)=>{r.d(t,{B:()=>p});var o=r(48958),n=r(57370),l=r(20669),a=r(37319),s=r(82432),i=r(47309),c=r(53022),u=r(53172),d=r(85032),h=r(83982),m=r(14398);let f="/books/preorder",p=h.memo(e=>{let{book:t,isOpen:r,onOpenChange:p}=e,{sendEvent:b}=(0,m.s)(),y=!!(null==t?void 0:t.title),w=(0,h.useMemo)(()=>{if(!y)return[];let e=[];return(t.amazonLink||f)&&e.push({type:"Paperback",href:t.amazonLink||f}),(t.myStoreLink||f)&&e.push({type:"eBook",href:t.myStoreLink||f}),t.hasAudiobook&&t.myStoreLink&&e.push({type:"Audiobook",href:t.myStoreLink}),t.hasAudible&&t.amazonLink&&e.push({type:"Audible",href:t.amazonLink}),e},[t,y]),g=(0,h.useCallback)(e=>{null==p||p(e)},[p]);if(!y){let e=Error("BuyBookModal: Book or book title is missing");return console.error(e),n.Cp(e),null}if(0===w.length){let e=Error("BuyBookModal: No purchase options available for book: ".concat(t.title));return console.warn(e),n.wd(e.message,{level:"warning"}),null}return(0,o.jsx)(l.Y,{isOpen:r,onOpenChange:g,size:"sm",hideCloseButton:!0,children:(0,o.jsx)(a.g,{className:"pb-0",children:e=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(s.c,{className:"flex flex-col gap-1",children:["Buy ",t.title]}),(0,o.jsx)(i.h,{children:w.map(e=>{let{type:r,href:l}=e;return(0,o.jsxs)(c.T,{as:u.h,href:l,color:"primary",className:"w-full mb-2",isExternal:l.startsWith("http"),"aria-label":"Buy ".concat(r," version of ").concat(t.title),onPress:()=>{try{if(!l)return;b({name:"redirect_to_ext_store_with_intent_to_buy",params:{book_title:t.title,format:r}}),l.startsWith("http")&&window.open(l,"_blank","noopener,noreferrer")}catch(e){console.error("Error handling button press:",e),n.Cp(e)}},children:[r,"Audible"===r&&(0,o.jsx)("span",{className:"text-xs",children:"(only on Amazon.com \uD83C\uDDFA\uD83C\uDDF8)"})]},r)})}),(0,o.jsx)(d.q,{children:(0,o.jsx)(c.T,{color:"primary",variant:"light",onPress:()=>{try{null==e||e()}catch(e){console.error("Error closing modal:",e),n.Cp(e)}},className:"shadow-none text-white","aria-label":"Close purchase options modal",children:"Close"})})]})})})});p.displayName="BuyBookModal"},35982:(e,t,r)=>{r.r(t),r.d(t,{ReviewsCarousel:()=>i});var o=r(48958),n=r(83982),l=r(42997);let a={DEFAULT_CARD_MARGIN:16},s=(0,n.memo)(function(e){var t;let{review:r,showRating:n,isLast:a,showBorder:s,index:i,onCardClick:c}=e;return(0,o.jsx)("div",{className:"w-48 md:w-64 shrink-0 ".concat(a?"":"mr-4 md:mr-8"),onClick:()=>c(i),onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),c(i))},role:"button",tabIndex:0,"aria-label":"View review ".concat(i+1," of ").concat((null==(t=r.author)?void 0:t.name)||"anonymous"),children:(0,o.jsx)(l.ReviewCard,{review:r,showRating:n,showBorder:s})})}),i=(0,n.memo)(function(e){let{reviews:t,showRatings:r,title:l="Some reviews",width:i,height:c,showBorder:u=!0}=e,d=(0,n.useRef)(null),h=(0,n.useCallback)(()=>{},[]),{isDragging:m,handleDragStart:f,handleDragEnd:p,handleDragMove:b}=(e=>{let[t,r]=(0,n.useState)(!1),o=(0,n.useRef)({x:0,scrollLeft:0}),l=(0,n.useCallback)(t=>{e.current&&(r(!0),o.current={x:"touches"in t?t.touches[0].clientX:t.clientX,scrollLeft:e.current.scrollLeft})},[e]),a=(0,n.useCallback)(()=>{r(!1)},[]),s=(0,n.useCallback)(r=>{if(!t||!e.current)return;r.preventDefault();let n="touches"in r?r.touches[0].clientX:r.clientX,l=o.current.x-n;e.current.scrollLeft=o.current.scrollLeft+l},[t,e]);return{isDragging:t,handleDragStart:l,handleDragEnd:a,handleDragMove:s}})(d),y=(0,n.useCallback)(e=>{if(m||!t.length||e<0||e>=t.length)return;let r=d.current;if(!r)return;let o=r.querySelector(":scope > div > div");if(!o)return;let n=o.offsetWidth;if(0===n)return;let l=parseInt(window.getComputedStyle(o).marginRight,10)||a.DEFAULT_CARD_MARGIN,s=r.clientWidth,i=r.scrollWidth-r.clientWidth,c=Math.max(0,Math.min(0===e?0:e===t.length-1?i:e*(n+l)-(s-n)/2,i));r.scrollTo({left:c,behavior:"smooth"})},[m,t.length]),w=(0,n.useCallback)(e=>{(null==e?void 0:e.currentTarget)&&(null==e?void 0:e.target)&&(e.persist(),b(e))},[b]),g=(0,n.useCallback)(e=>{(null==e?void 0:e.currentTarget)&&(null==e?void 0:e.target)&&(e.persist(),f(e))},[f]),k=(0,n.useCallback)(e=>{(null==e?void 0:e.currentTarget)&&(null==e?void 0:e.target)&&(e.persist(),p())},[p]),v=t.length<2,x=t.length<3&&"lg"===i;return(0,o.jsxs)("section",{className:"".concat("sm"===c?"mt-0 mb-0 p-0":""," section-separator"),children:[(0,o.jsx)("h3",{className:"text-2xl font-bold mb-4",children:l}),(0,o.jsx)("div",{className:"w-full relative",children:(0,o.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"===i?"lg:max-w-[600px]":"","\n cursor-grab active:cursor-grabbing ").concat(v?"flex justify-center":"","\n ").concat(m?"scrollbar-default":"scrollbar-hide"),ref:d,onScroll:h,onMouseDown:g,onMouseUp:k,onMouseLeave:k,onMouseMove:w,onTouchStart:g,onTouchEnd:k,onTouchMove:w,children:(0,o.jsx)("div",{className:"flex ".concat(x?"md:justify-center":""),children:t.map((e,n)=>(0,o.jsx)(s,{review:e,showRating:r,isLast:n===t.length-1,showBorder:u,index:n,onCardClick:y},"review-".concat(n)))})})})]})})},45984:(e,t,r)=>{r.d(t,{BuyBookButton:()=>c});var o=r(48958),n=r(57370),l=r(86290),a=r(53022),s=r(83982),i=r(17871);let c=(0,s.memo)(e=>{let{book:t,className:r}=e,{isOpen:s,onOpen:c,onOpenChange:u}=(0,l.j)();return t?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.T,{color:"primary",onPress:e=>{try{null==c||c()}catch(e){console.error("Error opening modal:",e),n.Cp(e)}},"aria-label":"Buy ".concat(t.title),className:"".concat(r," rounded-lg shadow-lg text-white"),children:"Buy Now"}),(0,o.jsx)(i.B,{book:t,isOpen:s,onOpenChange:u})]}):(!function(){let e="BuyBookButton: No book provided";console.warn(e),n.wd(e,{level:"warning",extra:{component:"BuyBookButton"}})}(),null)});c.displayName="BuyBookButton"}}]);