1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,838963,e=>{"use strict";e.i(607422);var t=e.i(110831),r=e.i(190560),a=e.i(10723),n=e.i(959161);class i{artId;offerPageUrl;constructor(e,t){this.artId=e,this.offerPageUrl=t,this.purchaseOperationType="ppd",this.offerType="one_art"}purchaseOperationType;offerType;buildOrderCreationParams(){return{type:this.offerType,art_id:this.artId}}}class s{podcastCollectionId;offerPageUrl;constructor(e,t){this.podcastCollectionId=e,this.offerPageUrl=t,this.purchaseOperationType="ppd",this.offerType="podcast_collection"}purchaseOperationType;offerType;buildOrderCreationParams(){return{type:this.offerType,podcast_collection_id:this.podcastCollectionId}}}class o extends n.PpdOffer{artBackendData;constructor(e){super(),this.artBackendData=e,this.offerType="one_art",this.getDiscountForArt=()=>{let e=this.artBackendData;return!this.totalPrice.checkIfZero()&&this.discountPercentage.checkIfPositive()?new a.Money((e.prices?.full_price||0)-(e.prices?.final_price||0),this.currency):new a.Money(0,this.currency)},this.getAccountMoneyThatCanBeUsedForArt=()=>{let e=this.artBackendData;return!e.prices?.account_money||this.totalPrice.checkIfZero()?new a.Money(0,this.currency):e.prices.account_money<=this.totalPrice.value?new a.Money(e.prices.account_money,this.currency):this.totalPrice}}offerType;get offerId(){return this.artBackendData.id.toString()}get artId(){return this.artBackendData.id}get artTypeNumber(){return this.artBackendData.art_type}get artTitle(){return this.artBackendData.title}get listOfArtAuthors(){return this.artBackendData.persons?this.artBackendData.persons.filter(e=>"author"===e.role).map(e=>e.full_name):[]}get offerPageUrl(){return this.artBackendData.url||void 0}get currency(){return this.artBackendData.prices?.currency||"RUB"}get totalPrice(){return new a.Money(this.artBackendData.prices?.final_price||0,this.currency)}get earnedBonusesAmount(){return this.artBackendData.prices?.earned_bonuses_amount||0}get canEarnedBonusesAmountAfterSignUpLoyalty(){let e=this.artBackendData.prices;return e?.can_earned_bonuses_amount_after_sign_up_loyalty||0}get priceWithBonus(){return new a.Money(this.artBackendData.prices?.price_with_bonus||0,this.currency)}get realMoneyInTotalPrice(){return new a.Money(this.artBackendData.prices?.cost_with_bonus||0,this.currency)}get discountInTotalPrice(){return this.getDiscountForArt()}get accountMoneyInTotalPrice(){return this.getAccountMoneyThatCanBeUsedForArt()}get fullPrice(){return new a.Money(this.artBackendData.prices?.full_price||0,this.artBackendData.prices?.currency||"RUB")}get discountPercentage(){return this.artBackendData.prices?.discount_percent?new r.Percentage(this.artBackendData.prices?.discount_percent??0):(this.totalPrice.lesserThen(this.fullPrice)&&(0,r.calculateDiffPercentage)(this.fullPrice.value,this.totalPrice.value),new r.Percentage(0))}get canBeFullyPaidByAccountMoney(){return!!this.artBackendData.prices?.can_be_paid_by_account_money}get isPodcastCollection(){return this.artBackendData.art_type===t.EArtType.podcast}get offeredItemsIds(){return[this.artBackendData.id]}get type(){switch(this.artBackendData.art_type){case 1:case t.EArtType.audioSeries:return"audio";case 22:return"podcast";case 23:return"podcast-part";case 25:return"webtoon";case 26:return"webtoon-part";default:return"text"}}get isDrm(){return this.artBackendData.is_drm||!1}get isDraft(){return this.artBackendData.is_draft||!1}get isArtForPreorder(){return"number"==typeof this.artBackendData.availability&&this.artBackendData.availability>1}get isAutoSpeechGift(){return this.artBackendData.is_auto_speech_gift}get podcastsLeftToBuy(){return this.artBackendData.podcast_left_to_buy||0}get promotions(){return this.artBackendData.prices?.promotions||[]}getDiscountForArt;getAccountMoneyThatCanBeUsedForArt;toOrderCreation(){return this.isPodcastCollection?new s(this.artId,this.offerPageUrl):new i(this.artId,this.offerPageUrl)}}e.s(["OfferedArt",0,o],838963)},959161,e=>{"use strict";var t=e.i(139269);e.s(["PpdOffer",0,class{purchaseOperationType="ppd";get canAccountMoneyBeUsedForPayment(){return this.accountMoneyInTotalPrice.checkIfPositive()}get isPriceReducedByAccountMoneyOrBonuses(){return[(0,t.default)(this.earnedBonusesAmount)&&this.earnedBonusesAmount>0,this.canAccountMoneyBeUsedForPayment].some(e=>!0===e)}get isOneArt(){return 1===this.offeredItemsIds.length}}])},517436,e=>{"use strict";var t=e.i(125784),r=e.i(150417);e.s(["usePaymentEntryPointControlMethods",0,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{onGoingToPayment:t.noop},{onGoingToPayment:a}=e,[n,i]=(0,r.useState)(!1),s=(0,r.useRef)(null);return{goToPayment:(0,r.useCallback)(async e=>{if(!s.current)return void console.error("Need to pass paymentEntryPointControlRef to props of payment entry point component");e&&(e.stopPropagation(),e.preventDefault());let{isGoingToPaymentFrame:t,canGoToPayment:r}=s.current.goToPaymentOperation(e);i(t),await r?a():i(!1)},[a]),paymentEntryPointControlRef:s,isGoingToPaymentFrame:n}}])},771390,e=>{"use strict";var t=e.i(615792),r=e.i(150417),a=e.i(520198);let n=(0,r.forwardRef)(function(e,r){let{offeredArt:n,alignNotificationRef:i,cameFromSourceData:s,afterPurchaseRedirectParams:o,purchaseTraceId:l,onGoingToPayment:c,onRetryGoingToPayment:d,shouldRedirectToAuthPage:u,payByClickMode:f}=e;return(0,t.jsx)(a.PpdPayment,{ppdOffer:n,cameFromSource:s.cameFromSource,cameFromSourcePayload:s.cameFromSourcePayload,afterPurchaseRedirectParams:o,purchaseTraceId:l,alignNotificationRef:i,onRetryGoingToPayment:d,onGoingToPayment:c,ref:r,payByClickMode:f,shouldRedirectToAuthPage:u})});e.s(["OneArtPpdPayment",0,n])},520198,e=>{"use strict";var t=e.i(615792),r=e.i(150417),a=e.i(561209),n=e.i(465596),i=e.i(125784),s=e.i(591565),o=e.i(213907),l=e.i(123920),c=e.i(752961),d=e.i(30788),u=e.i(712211),f=e.i(173578),p=e.i(156678),h=e.i(596890),y=e.i(692021),_=e.i(26820),m=e.i(184563),g=e.i(59341),P=e.i(682195),A=e.i(695905),T=e.i(893575),w=e.i(195408),b=e.i(959161);let v=!1;var E=e.i(566906),S=e.i(597161);let I=(0,r.forwardRef)(function(e,S){let{ppdOffer:I,alignNotificationRef:R,onRetryGoingToPayment:D,onGoingToPayment:O=i.noop,cameFromSource:M,cameFromSourcePayload:C,afterPurchaseRedirectParams:B,purchaseTraceId:L,shouldRedirectToAuthPage:N,shouldUsePortalErrorNotification:U,isBonusesSpendingSetOnOfferPage:F,receiptEmail:x,payByClickMode:Y=h.EPayByClickMode.notAvailable}=e,$=(0,a.useDispatch)(),z=(0,p.usePreciseDeviceType)(),j=(0,o.useRouter)(),G=(0,y.useLastSelectedPaymentMethodId)(),H=(0,n.useAppSelector)(e=>e.foundationUser.is_tester),[K,W]=(0,r.useState)(null),q=(0,r.useCallback)(()=>{W(null)},[]),Q=(0,r.useCallback)(e=>{(0,l.isLitresError)(e)?e.extendedParams?.skipEmit||e.emit({cameFromSource:M,totalPrice:I.totalPrice.value,currency:I.currency}):(0,c.paymentFacadeError)("FrontendLogicError","Trying to open new payment frame",{originalError:e}).emit(),W(e)},[M,I.currency,I.totalPrice.value]),V=(0,r.useCallback)(async()=>{try{let e=await k({ppdOffer:I,purchaseTraceId:L,dispatch:$,cameFromSource:M,cameFromSourcePayload:C,afterPurchaseRedirectParams:B,paymentMethodId:G,isBonusesSpendingSetOnOfferPage:F,receiptEmail:x,payByClickMode:Y,isTestUser:H,deviceType:z});j.push(e)}catch(e){throw Q(e),e}},[B,M,C,$,Q,F,x,Y,I,L,G,j]),Z=(0,E.useAuthorizationAndOpenAuthPopup)($,I),{openAuthWithOrderCreationRedirect:X,isUserAuthenticated:J}=(0,u.useOrderCreationRedirect)({orderCreationUrlParams:{offer:I,cameFromSource:M,cameFromSourcePayload:C,afterPurchaseRedirectParams:B,traceId:L,offerPageUrl:(0,f.getCurrentPageUrlForOfferPage)()},shouldRedirectToAuthPage:N,onAuthSuccess:O}),ee=(0,r.useCallback)(async()=>
1{if(!J){let e=!!(0,s.getCookie)("redeemed_promocode_jwt"),t={[m.GO_TO_PPD_PAYMENT_FOR_QUERY_PARAM]:I.offerId.toString(),"block-phone-asking":"1"};if(e&&(t[m.GO_TO_PPD_PAYMENT_ONLY_IF_PROMOCODE_ACTIVATED]="1"),e&&!N){let{isAuthPopupOpened:e}=Z(t,O);if(e)return{canPay:!1}}let{isAuthPopupOpened:r}=X();if(r)return{canPay:!1};if(!r){let{isAuthPopupOpened:e}=Z(t,O);if(e)return{canPay:!1}}}O();try{await V()}catch{return{canPay:!1}}return q(),{canPay:!0}},[I.offerId,J,N,q,Z,X,V,O]);(0,r.useImperativeHandle)(S,()=>({goToPaymentOperation:()=>({isGoingToPaymentFrame:!0,canGoToPayment:ee().then(e=>e.canPay)})}),[ee]);let et=(0,r.useCallback)(()=>{q(),D?D():ee()},[ee,D,q]);return!function(e,t){let a=(0,o.useRouter)(),[{activatedPromocode:i,persistedPromocode:s}]=(0,T.usePromocodeActivation)(),l=(0,n.useAppDispatch)(),c=P.hasWindow?window.location.hash:"";(0,r.useEffect)(()=>{let r=()=>{if(v)return;let r=P.hasWindow?window.location.hash.split("#")[1]:void 0,n=r?.includes(m.BUY_NOW_HASH_THE_ONLY_SALE_BLOCK_HASH)||r?.includes(w.EBookHashParams.buy_now_reg)||!!a.query[m.GO_TO_THE_ONLY_SALE_BLOCK_PPD_PAYMENT_QUERY_PARAM],o=a.query[m.GO_TO_PPD_PAYMENT_FOR_QUERY_PARAM];if(n){let t=-1;e instanceof b.PpdOffer&&(t=e.offeredItemsIds[0]),o=t.toString(),l(g.api.global.modals.setGlobalModalsShowStatus("blocked"))}let c=!!a.query[m.GO_TO_PPD_PAYMENT_ONLY_IF_PROMOCODE_ACTIVATED];!o||e instanceof b.PpdOffer&&e.offerId!==o||(!c||i&&s?.isRedeemed)&&(v=!0,(0,A.deleteQueryParams)(a,[m.GO_TO_THE_ONLY_SALE_BLOCK_PPD_PAYMENT_QUERY_PARAM,m.GO_TO_PPD_PAYMENT_FOR_QUERY_PARAM,m.GO_TO_DONATION_PAYMENT_QUERY_PARAM,m.GO_TO_PPD_PAYMENT_ONLY_IF_PROMOCODE_ACTIVATED,m.GO_TO_DONATION_PAYMENT_QUERY_PARAM,"block-phone-asking"],!!a.query.promocode),setTimeout(()=>{t(!0)},200))};return r(),window.addEventListener("hashchange",r),()=>{window.removeEventListener("hashchange",r)}},[e.offerId,i,s?.isRedeemed,c,t])}(I,ee),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_.PpdErrorNotification,{isShown:!!K,error:K,alignElementRef:R,isOneArtPurchase:I.isOneArt,onClose:q,onRetry:et,shouldUsePortal:U}),(0,t.jsx)(d.SuccessPurchaseReceiver,{artIds:I.offeredItemsIds})]})});async function k(e){let{ppdOffer:t,dispatch:r,cameFromSource:a,cameFromSourcePayload:n,purchaseTraceId:i,afterPurchaseRedirectParams:s,paymentMethodId:o,purchaseOperationTypeMode:l,isBonusesSpendingSetOnOfferPage:c,receiptEmail:d,payByClickMode:u,isTestUser:f,deviceType:p}=e;return await (0,S.startClearPurchaseFlow)({purchaseInfo:t.toOrderCreation(),purchaseTraceId:i,cameFromSource:a,cameFromSourcePayload:n,afterPurchaseRedirectParams:s,dispatch:r,paymentMethodId:o,purchaseOperationTypeMode:l,isBonusesSpendingSetOnOfferPage:c,receiptEmail:d,payByClickMode:u,isTestUser:f,deviceType:p})}e.s(["PpdPayment",0,I],520198)},644902,e=>{e.v({message:"Overlay-module-scss-module__EZekSq__message",root:"Overlay-module-scss-module__EZekSq__root"})},178959,e=>{"use strict";var t=e.i(682195),r=e.i(499808);let a="last_selected_payment_method_id";e.s(["getLastSelectedPaymentMethodIdFromLocalStorage",0,function(){if(t.hasWindow)return(0,r.getFromLocalStorage)(a)??void 0},"saveLastSelectedPaymentMethodIdToLocalStorage",0,function(e){t.hasWindow&&(0,r.saveToLocalStorage)({[a]:e})}])},692021,e=>{"use strict";var t=e.i(150417),r=e.i(178959);e.s(["useLastSelectedPaymentMethodId",0,function(){let[e,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{a((0,r.getLastSelectedPaymentMethodIdFromLocalStorage)()??null)},[]),e??void 0}])},712211,173578,e=>{"use strict";var t=e.i(59341),r=e.i(465596),a=e.i(112752),n=e.i(218294),i=e.i(294352),s=e.i(682195),o=e.i(741121),l=e.i(791407),c=e.i(35492),d=e.i(48702);class u{}let f={donation:new class extends u{offerType="donation";buildSearchParams(e){return{"offer-type":this.offerType,"person-id":String(e.personId)}}},subscription_product:new class extends u{offerType="subscription_product";buildSearchParams(e){return{"offer-type":this.offerType,"purchase-type":e.purchaseOperationType,"tariff-id":String(e.tariffId)}}},one_art:new class extends u{offerType="one_art";buildSearchParams(e){return{"offer-type":this.offerType,art:String(e.artId)}}},bundle:new class extends u{offerType="bundle";buildSearchParams(e){return{"offer-type":this.offerType,"art-ids":e.artIds.join(",")}}},art_pack:new class extends u{offerType="art_pack";buildSearchParams(e){return{"offer-type":this.offerType,"art-ids":e.artIds.join(",")}}},cart:new class extends u{offerType="cart";buildSearchParams(e){return{"offer-type":this.offerType}}},gift_ppd:new class extends u{offerType="gift_ppd";buildSearchParams(e){return{"offer-type":this.offerType,"gift-id":String(e.giftId),"gift-type":e.giftType}}},podcast_collection:new class extends u{offerType="podcast_collection";buildSearchParams(e){return{"offer-type":this.offerType,"podcast-collection-id":String(e.podcastCollectionId)}}},series:new class extends u{offerType="series";buildSearchParams(e){return{"offer-type":this.offerType,"series-id":String(e.seriesId),"series-type":e.mediaType}}},payment_method_linking:new class extends u{offerType="payment_method_linking";buildSearchParams(e){let t={"offer-type":this.offerType};return e.subscriptionId&&(t["subscription-id"]=String(e.subscriptionId)),t}},audio_series_episode:new class extends u{offerType="audio_series_episode";buildSearchParams(e){return{"offer-type":this.offerType,art:String(e.artId),"chapter-ids":e.chapterIds.join(",")}}}};class p{constructor(e=Object.values(f)){this.builders=new Map(e.map(e=>[e.offerType,e]))}builders;buildSearchParams(e){let t=this.builders.get(e.offerType);if(!t)throw Error(`No URL params builder for offerType: ${e.offerType}`);return t.buildSearchParams(e)}}class h{static url="/purchase/order-creation/";static resolver=new p;static buildPaymentFrameSearchParams(e){let t=e.traceId||o.OrderCreation.createPurchaseTraceId(),r=(0,c.getUrlDataForClearPurchaseProcess)({orderId:0,cameFromSource:e.from,purchaseTraceId:t,offerPageUrl:e.offerPageUrl??"/",cameFromSourcePayload:e.cameFromSourcePayload,afterPurchaseRedirectParams:e.afterPurchaseRedirectParams,paymentMethodId:e.paymentMethodId,shouldSpendToken:e.shouldSpendToken}),a=new d.PurchaseProcessUrlDataSaver(r).getSearchParamsToWriteInUrl();return delete a.order,a}static buildPurchaseInfoSearchParams(e){return this.resolver.buildSearchParams(e)}static build(e,t,r){let a=this.buildPaymentFrameSearchParams(t),n=Object.assign({},a,this.buildPurchaseInfoSearchParams(e),{"offer-page":a["offer-page"],"device-type":r});return`${this.url}?${(0,l.getSearchParamsString)(n)}`}}function y(){return s.hasWindow?window.location.pathname+window.location.search:"/"}e.s(["OrderCreationUrlBuilder",0,h,"getCurrentPageUrlForOfferPage",0,y],173578);var _=e.i(736764),m=e.i(156678),g=e.i(692021);e.s(["useOrderCreationRedirect",0,function(e){let{orderCreationUrlParams:s,shouldRedirectToAuthPage:o,onAuthSuccess:l,subscriptionAuthPromo:c,subscriptionTokenAuthPromo:d}=e,{t:u}=(0,a.useTranslation)(),f=(0,r.useAppSelector)(e=>e.browser.clientHost),p=(0,r.useAppDispatch)(),P=(0,i.useIsUserAuthenticated)(),A=(0,n.isSchoolDomain)(f)||(0,n.isBiblioDomain)(f),T=(0,m.usePreciseDeviceType)(),w=(0,g.useLastSelectedPaymentMethodId)();return{openAuthWithOrderCreationRedirect:()=>{if(P||A)return{isAuthPopupOpened:!1};let{offer:e,traceId:r,offerPageUrl:a,cameFromSource:n,cameFromSourcePayload:i,afterPurchaseRedirectParams:f,shouldSpendToken:m}=s,g=h.build(e.toOrderCreation(),{from:n,cameFromSourcePayload:i,traceId:r,offerPageUrl:a||y(),paymentMethodId:w,afterPurchaseRedirectParams:f,shouldSpendToken:m},T);return o?(window.parent.location.href=(0,_.buildLoginRedirectUrl)(g),{isAuthPopupOpened:!1}):(p(t.api.global.interfaceRequests.setAuthPopupState({isOpen:!0,uiOptions:{fullScreen:!1,noCancel:!1,phoneFirst:!1},errorText:d?void 0:u("ÐвÑоÑизÑйÑеÑÑ Ð´Ð»Ñ Ð¿Ð¾ÐºÑпки"),subscriptionAuthPromo:c,subscriptionTokenAuthPromo:d,urlParam
1s:{redirectAfterAuthURL:g},onAuthSuccess:l?()=>{l(),window.location.href=g}:void 0})),{isAuthPopupOpened:!0})},isUserAuthenticated:P}}],712211)},30788,331441,566906,e=>{"use strict";var t=e.i(615792),r=e.i(637867),a=e.i(150417);e.i(651464);var n=e.i(30364),i=e.i(199255),s=e.i(112752),o=e.i(644902);let l=e=>{let r=(0,a.useRef)(null),{t:n}=(0,s.useTranslation)(),l=n("ÐбновлÑем ÑÑÑаниÑÑ Ð¿Ð¾Ñле ÑÑпеÑной покÑпки"),{message:c=l}=e;return(0,a.useEffect)(()=>{let e=document.body.style.overflow,t=r.current;document.body.style.overflow="hidden";let a=e=>{e.preventDefault()};return t&&t.addEventListener("touchmove",a,{passive:!1}),()=>{document.body.style.overflow=e,t&&t.removeEventListener("touchmove",a)}},[]),(0,t.jsxs)("div",{className:o.default.root,ref:r,children:[(0,t.jsx)("p",{className:o.default.message,children:c}),(0,t.jsx)(i.CircularLoader,{size:"large",mode:"light"})]})};e.s(["Overlay",0,l],331441);var c=e.i(584290);e.s(["SuccessPurchaseReceiver",0,e=>{let[i]=(0,a.useState)(()=>{var t;return Array.isArray(t=e.artIds)?(0,c.limitElements)(t):[t]}),[s,o]=(0,a.useState)(!1),d=(0,n.useHasWindow)(),u=(0,a.useCallback)(()=>{window.beforeReloadPageAfterSuccessPurchaseComplete||(window.beforeReloadPageAfterSuccessPurchaseComplete=1,o(!0))},[]);return((0,c.useSubscribeToSuccessPurchaseEvent)(i,u),d&&s)?(0,r.createPortal)((0,t.jsx)(l,{message:e.overlayMessage}),document.body):null}],30788);var d=e.i(59341),u=e.i(465596);e.i(916365);var f=e.i(878292),p=e.i(213907),h=e.i(218294),y=e.i(283494),_=e.i(294352),m=e.i(184563);e.s(["useAuthorizationAndOpenAuthPopup",0,(e,t)=>{let{t:r}=(0,s.useTranslation)(),n=(0,u.useAppSelector)(e=>e.browser.pda),i=(0,p.useRouter)(),o=(0,_.useIsUserAuthenticated)()?"no-authorization":"popup-cancel-emailfirst",l=(0,u.useAppSelector)(e=>e.browser.clientHost),c=(0,h.isSchoolDomain)(l),g=(0,h.isBiblioDomain)(l),P=(0,f.useVarioqubTest)("auth_acqn_1915","true"),A="true"===i.query.auth_acqn_1915,T=!c&&!g&&(P||A);return(0,a.useCallback)((a,i)=>{let s="no-authorization"!==o;if(s){let s;if(!n&&T&&"cart"===t.offerType){let e=`/my-books/cart/?${m.GO_TO_PPD_PAYMENT_FOR_QUERY_PARAM}=cart`;return window.location.href=`/auth/login?redirectAfterAuth=${encodeURIComponent(e)}`,{isAuthPopupOpened:!0}}(s=r,(e,t,r,a,n)=>{var i;let{fullScreen:o,noCancel:l,phoneFirst:c}={fullScreen:(i=t).includes("fullscreen"),popup:i.includes("popup"),cancel:i.includes("cancel"),noCancel:i.includes("nocancel"),phoneFirst:i.includes("phonefirst"),emailFirst:i.includes("emailfirst")},u=n?()=>{n(),r&&(0,y.reloadWithParams)(r,[])}:void 0;e(d.api.global.interfaceRequests.setAuthPopupState({isOpen:!0,uiOptions:{fullScreen:o,noCancel:l,phoneFirst:c},errorText:s("ÐвÑоÑизÑйÑеÑÑ Ð´Ð»Ñ Ð¿Ð¾ÐºÑпки"),urlParam
1s:r,onHide:a,onAuthSuccess:u}))})(e,o,a,void 0,i)}return{isAuthPopupOpened:s}},[e,o])}],566906)},584290,364780,e=>{"use strict";var t=e.i(150417);class r{constructor(e){this.channel=this.createChannel(e),this.listeners=new Set,this.boundMessageListener=this.messageListener.bind(this),this.boundErrorListener=this.errorListener.bind(this),this.channel?.addEventListener("message",this.boundMessageListener),this.channel?.addEventListener("messageerror",this.boundErrorListener)}channel;listeners;boundMessageListener;boundErrorListener;messageListener(e){let t=e.data;this.listeners.forEach(e=>{e(t)})}errorListener(e){console.error("[TabEventBus] СообÑение не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ ÐºÐ»Ð¾Ð½Ð¸Ñовано и пеÑедано ÑеÑез канал",e.data)}createChannel(e){if("BroadcastChannel"in window)try{return new BroadcastChannel(e)}catch(e){return console.error("[TabEventBus] Ðозникла оÑибка пÑи Ñоздании BroadcastChannel",e),null}return console.error("[TabEventBus] BroadcastChannel API не поддеÑживаеÑÑÑ Ð² ÑÑом окÑÑжении"),null}sendMessage(e){this.channel?this.channel.postMessage(e):console.warn("[TabEventBus] Ðанал недоÑÑÑпен")}subscribeToEvent(e){return this.channel?(this.listeners.add(e),()=>{this.listeners.delete(e),0===this.listeners.size&&this.closeChannel()}):(console.warn("[TabEventBus] Ðанал недоÑÑÑпен. ÐодпиÑка добавлена не бÑдеÑ."),()=>{})}closeChannel(){this.channel&&(this.channel.removeEventListener("message",this.messageListener),this.channel.removeEventListener("messageerror",this.errorListener),this.channel.close(),this.channel=null)}clear(){this.listeners=new Set,this.closeChannel()}}class a{static channels=new Map;static getChannelByName(e){if(!a.channels.has(e)){let t=new r(e);a.channels.set(e,t)}return a.channels.get(e)}static subscribeToTabEventBus(e,t){let r=this.getChannelByName(e);if(r){let n=r.subscribeToEvent(e=>{t(e)});return()=>{n(),0===r.listeners.size&&a.channels.delete(e)}}return()=>{}}static sendMessage(e,t){let r=this.getChannelByName(e);r?.sendMessage(t)}static deleteByName(e){a.channels.has(e)&&(a.getChannelByName(e).clear(),a.channels.delete(e))}static reset(){for(let e of a.channels.values())e.clear();a.channels=new Map}static get size(){return a.channels.size}}e.s(["TabEventBus",0,a],364780),e.s(["limitElements",0,function(e){return e.length>10?e.slice(0,10):e},"useSubscribeToSuccessPurchaseEvent",0,(e,r)=>{let n=(0,t.useRef)(!1),i=(0,t.useRef)(r);i.current!==r&&(i.current=r),(0,t.useEffect)(()=>{let t=()=>{"visible"===document.visibilityState&&n.current&&(i.current(),setTimeout(()=>{window.location.reload()},400))},r=a.subscribeToTabEventBus("success_purchase",t=>{e.some(e=>t.includes(e))&&(n.current=!0)});return document.addEventListener("visibilitychange",t),()=>{r(),document.removeEventListener("visibilitychange",t)}},[e])}],584290)},596890,e=>{"use strict";var t,r=((t={})[t.notAvailable=0]="notAvailable",t[t.oneClick=1]="oneClick",t[t.availableButNotUsed=2]="availableButNotUsed",t);e.s(["EPayByClickMode",()=>r])},349690,e=>{"use strict";e.i(454110);var t=e.i(829608);let r=new Map,a=new Map,n=e=>Math.round(e)/1e3,i=e=>!e||e.includes("expires=")||e.includes("real_url=")?"foundation":e.includes("download_book")||e.includes("get_mp3_trial")?"catalit":"foundation",s=e=>{if("u">typeof navigator&&!1===navigator.onLine)return{failedReason:"network",failedData:"offline"};if("object"==typeof e&&null!==e){let{code:t,status:r,data:a}=e;if("ERR_NETWORK"===t||"ECONNABORTED"===t||"ETIMEDOUT"===t)return{failedReason:"network",failedData:String(t)};if("number"==typeof r){let e=(e=>{for(let t of[e?.error?.code,e?.error?.detail,e?.error?.type,e?.error?.title,e?.detail,e?.type,e?.title])if("string"==typeof t&&t)return t})(a)??`http_${r}`;if(r>=500)return{failedReason:"server",failedData:e};if(r>=400)return{failedReason:"client",failedData:e}}}let t=(e=>{if("object"!=typeof e||null===e)return null;let t=e.target;return t?.error&&"number"==typeof t.error.code?{code:t.error.code}:"code"in e&&"number"==typeof e.code?{code:e.code}:null})(e);return t?2===t.code?{failedReason:"network",failedData:`media_error_${t.code}`}:3===t.code?{failedReason:"local",failedData:`media_error_${t.code}`}:{failedReason:"unknown",failedData:`media_error_${t.code}`}:{failedReason:"unknown",failedData:("string"==typeof e?e:"object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:"unknown error").slice(0,200)}},o=e=>{t.TM.sendEvent(["LITRES_TRACKER"],{eventType:"download_file_attempt",params:e})},l=e=>
1({art_id:e.artId,art_type:e.artType,file_id:e.fileId??"",format:"mp3",download_type:"download",stack:i(e.url),...e.sourceInternal?{source_internal:e.sourceInternal}:{}}),c=e=>{e.timeoutId&&clearTimeout(e.timeoutId),r.delete(e.artId)},d=(e,t)=>{let a=r.get(e);if(!a)return null;c(a);let i=Date.now(),d="prepare";a.linkReadyAt?d="download":null!=a.fileId&&(d="link_fetch");let{failedReason:u,failedData:f}=s(t),p="prepare"===d||"link_fetch"===d,h=n(i-a.startedAt),y=0;a.linkReadyAt?y=n(a.linkReadyAt-a.startedAt):"link_fetch"===d&&(y=n(i-a.startedAt));let _={...l(a),download_status:"fail",download_speed:0,failed_stage:d,failed_reason:u,failed_data:f};return p&&(h=0,_.size=0),_.download_time=h,_.link_fetch_time=y,o(_),{...a,finishedAt:i}},u=e=>{let t=r.get(e);if(!t)return;c(t);let a=Date.now();o({...l(t),download_status:"cancel",download_time:n(a-t.startedAt),link_fetch_time:t.linkReadyAt?n(t.linkReadyAt-t.startedAt):0})},f=(e,t)=>{let r={art_id:e.artId,art_type:e.artType,file_id:e.fileId??"",download_type:"export",stack:i(t)};return e.format&&(r.format=e.format.split(".")[0].toLowerCase()),e.sourceInternal&&(r.source_internal=e.sourceInternal),r},p=async(e,t)=>{let r=Date.now();try{let a=await t(),i=n(Date.now()-r),s={...f(e,a),download_status:"success",download_time:i,link_fetch_time:i};return void 0!==e.fileSize&&(s.size=e.fileSize),o(s),a}catch(i){let{failedReason:t,failedData:a}=s(i);throw o({...f(e),download_status:"fail",download_time:0,download_speed:0,size:0,link_fetch_time:n(Date.now()-r),failed_stage:"link_fetch",failed_reason:t,failed_data:a}),i}};e.s(["beginDownloadAttempt",0,e=>{let t=r.get(e.artId);if(t){if(t.fileId===e.fileId){t.fileSize=t.fileSize??e.fileSize,t.f
1ileDuration=t.fileDuration??e.fileDuration,t.sourceInternal=t.sourceInternal??e.sourceInternal,e.url&&!t.linkReadyAt&&(t.url=e.url,t.linkReadyAt=Date.now());return}u(e.artId)}let n=Date.now(),i={artId:e.artId,artType:e.artType,fileId:e.fileId,fileSize:e.fileSize,fileDuration:e.fileDuration,url:e.url,sourceInternal:e.sourceInternal,startedAt:n};if(e.url&&(i.linkReadyAt=n),e.hasTracklist&&(i.fileListReadyAt=n),i.timeoutId=setTimeout(()=>{d(e.artId,{message:"download attempt timeout"})},6e4),r.set(e.artId,i),!i.linkReadyAt){let t=a.get(e.artId);t&&(Date.now()-t.at<=3e4?t.fileId===e.fileId?c(i):d(e.artId,t.error):a.delete(e.artId))}},"buildFirstStartPlayBookParams",0,(e,t)=>{let r=(()=>{if("u">typeof navigator)return navigator.connection?.effectiveType})(),a=e.fileSize&&e.fileDuration?Math.round(8*e.fileSize/e.fileDuration/1e3):void 0,n={book_id:t.bookId,book_type:t.bookType,play_type:"streaming",play_result:t.playResult,stack:i(e.url),select_book_time_ms:0,get_file_list_time_ms:e.fileListReadyAt?Math.max(0,Math.round(e.fileListReadyAt-e.startedAt)):0,download_time_ms:Math.round(e.finishedAt-(e.linkReadyAt??e.startedAt)),time_ms:Math.round(e.finishedAt-e.startedAt)};return"string"==typeof r&&(n.connection_type=r),void 0!==a&&(n.bitrate_kbps=a),void 0!==e.downloadSpeedKbit&&(n.download_speed_kbps=e.downloadSpeedKbit),n},"cancelDownloadAttempt",0,u,"completeDownloadAttempt",0,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=r.get(e);if(!a)return null;c(a);let i=Date.now(),s=n(i-a.startedAt),d=a.linkReadyAt?n(a.linkReadyAt-a.startedAt):0,u=((e,t,r)=>{let a=r||e.fileDuration;if(e.fileSize&&t&&a)return Math.round(e.fileSize*Math.min(1,t/a))})(a,t.bufferedSeconds,t.mediaDuration),f=u&&s>0?Math.round(8*u/1e3/s):void 0,p={...l(a),download_status:"success",download_time:s,link_fetch_time:d};return void 0!==u&&(p.size=u),void 0!==f&&(p.download_speed=f),o(p),{...a,finishedAt:i,loadedBytes:u,downloadSpeedKbit:f}},"failDownloadAttempt",0,d,"hasPendingDownloadAttempt",0,e=>r.has(e),"markDownloadFileListReady",0,e=>{let t=r.get(e);t&&!t.fileListReadyAt&&(t.fileListReadyAt=Date.now())},"markDownloadLinkReady",0,(e,t)=>{a.delete(e);let n=r.get(e);n&&(n.fileSize=n.fileSize??t.fileSize,n.fileDuration=n.fileDuration??t.fileDuration,n.linkReadyAt||(n.url=t.url,n.linkReadyAt=Date.now()))},"noteDownloadLinkError",0,(e,t)=>{let n=a.get(e.artId);if(n&&n.fileId===e.fileId&&Date.now()-n.at<=3e4)return;a.set(e.artId,{error:t,at:Date.now(),fileId:e.fileId});let i=r.get(e.artId);i&&!i.linkReadyAt?d(e.artId,t):((e,t)=>{let{failedReason:r,failedData:a}=s(t);o({...l(e),download_status:"fail",download_time:0,download_speed:0,size:0,link_fetch_time:0,failed_stage:"link_fetch",failed_reason:r,failed_data:a})})(e,t)},"sendFirstStartPlayBook",0,e=>{t.TM.sendEvent(["LITRES_TRACKER"],{eventType:"first_start_play_book",params:e})},"trackExportDirectDownload",0,e=>{let t={...f(e,e.url),download_status:"success",download_time:0,link_fetch_time:0};void 0!==e.fileSize&&(t.size=e.fileSize),o(t)},"trackExportDownloadLink",0,p])},462417,e=>{"use strict";e.i(607422);var t=e.i(110831),r=e.i(838275);let a={none:0,preview:1,listen:2,download:3},n=[{value:.75,label:"0,75x"},{value:1,label:"1x"},{value:1.25,label:"1,25x"},{value:1.5,label:"1,5x"},{value:1.75,label:"1,75x"},{value:2,label:"2x"},{value:2.25,label:"2,25x"},{value:2.5,label:"2,5x"}],i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=24*Math.floor(e/86400)+Math.floor(e/3600%24),r=Math.floor(e/60%60),a=Math.floor(e%60);return{hours:t<10?`0${t}`:`${t}`,minutes:r<10?`0${r}`:`${r}`,seconds:a<10?`0${a}`:`${a}`}},s=[200,330,415];e.s(["ANON_PLAYER_PLAYING_CACHE",0,"player-playing-cache","ANON_PLAYER_SETTINGS_CACHE",0,"player-settings-cache","ANON_PLAYER_TIME_CACHE",0,"player-time-cache","GENRES_TREE_SUB_EVENT",0,"genres-tree:toggle","HALF_FRAGMENT_THRESHOLD",0,.5,"HIGH_STICKY_PLAYER_Z_INDEX",0,"9000","LOW_STICKY_PLAYER_Z_INDEX",0,"2000","PLAYBACK_RATES",0,n,"PLAYER_AUDIO_ELEMENT_ID",0,"litres-audio-player","SEEK_VALUE",0,15,"canDownloadTrack",0,e=>"download"===e,"canPlayFull",0,e=>a[e??"none"]>=a.listen,"getActiveAccess",0,(e,t)=>e?.find(e=>e.id===t)?.accessRights??"none","getFullTimeLabel",0,e=>{let{hours:t,minutes:r,seconds:a}=i(e);return`${t}:${r}:${a}`},"getListenProgress",0,(e,r,a,n)=>{let i=e.findIndex(e=>e.id===r),s=i<0?0:i,o=n===t.EArtType.podcast,l=o?a:e.slice(0,s).reduce((e,t)=>
1e+t.duration,0)+a,c=o?e[s]?.duration??0:e.reduce((e,t)=>e+t.duration,0),d=c?Math.min(100,Math.max(0,Math.ceil(l/c*100))):0;return{listenedSeconds:l,totalSeconds:c,percent:d}},"getMediaArtistName",0,e=>e.persons?.map(e=>e.full_name).join(", ")||"","getMediaImages",0,e=>{let t=[],a=(0,r.getCdnHost)();for(let r of s)t.push({src:`${a}/pub/c/cover_${r}/${e.id}.webp`,type:"image/webp",sizes:`${r}x${r}`},{src:`${a}/pub/c/cover_${r}/${e.id}.jpg`,type:"image/jpeg",sizes:`${r}x${r}`});return t},"getRateLabel",0,e=>n.find(t=>t.value===e)?.label||"","getSurroundingTracks",0,(e,t)=>{let r=e.findIndex(e=>e.id===t);return -1===r?{currentIndex:-1}:{currentIndex:r,current:e[r],prev:e[r-1],next:e[r+1]}},"getTimeLabel",0,e=>{let{hours:t,minutes:r,seconds:a}=i(e),n=Number(t);return 0===n?`${r}:${a}`:`${n}:${r}:${a}`},"isPreviewAccess",0,e=>"preview"===e,"toAccessRights",0,(e,t)=>e?"preview":t?"download":"listen","unlockAudioPlayback",0,e=>{e?.paused&&e.play().then(()=>{e.pause()}).catch(()=>{})}])},121290,e=>{"use strict";var t=e.i(465596),r=e.i(59341),a=e.i(561209);e.i(454110);var n=e.i(829608),i=e.i(150417),s=e.i(444902),o=e.i(842447),l=e.i(67001),c=e.i(115078),d=e.i(479304),u=e.i(349690),f=e.i(462417);let p=new Map,h=e=>{let t=p.get(e);return t?Date.now()-t.scheduledAt>6e4?(p.delete(e),null):t.payload:null};e.s(["getScheduledSourceInternal",0,e=>{let t=p.get(e)?.payload.source_internal;return"string"==typeof t?t:void 0},"usePlayerEvent",0,e=>{let y=(0,t.useAppDispatch)(),_=(0,i.useRef)(!1),m=(0,i.useRef)(!1),{error:g=null}=(0,t.useAppSelector)(e=>e.player.data.state),P=(0,a.useStore)(),A=(0,i.useRef)(null),T=(0,a.useSelector)(e=>e.foundationUser),w=(0,o.checkIfAvailableByMySubscription)({art:e,user:T}),b=!(0,o.isMyArt)(e)&&!w,v="full";(0,d.isPodcast)(e)?v="podcast":(0,d.isAudioSeries)(e)?v="audio_serial":b&&(v="fragment");let E=(0,i.useCallback)(()=>{if(!(0,u.hasPendingDownloadAttempt)(e.id))return;let t=document.getElementById(f.PLAYER_AUDIO_ELEMENT_ID),r=t&&t.buffered.length>0?t.buffered.end(t.buffered.length-1):void 0,a=(0,u.completeDownloadAttempt)(e.id,{bufferedSeconds:r,mediaDuration:t?.duration||void 0});a&&!m.current&&(m.current=!0,(0,u.sendFirstStartPlayBook)((0,u.buildFirstStartPlayBookParams)(a,{playResult:"success",bookId:e.id,bookType:v})))},[e.id,v]),S=async()=>{let{player:{data:t}}=P.getState(),a=h(e.id);if(_.current||(_.current=!0,window.UXS?.sendEvent("player_open"),n.TM.sendEvent(["LITRES_TRACKER"],{eventType:"player_open",params:(0,d.getAnalyticsData)({art:e,extra:{book_type:(0,l.getArtTypeForAnalytics)(e.art_type,e.is_draft)}})})),a&&(n.TM.sendEvent(["LITRES_TRACKER"],{eventType:"player_start",params:(0,d.getAnalyticsData)({art:e,extra:{...a,trial_flag:b,book_type:(0,l.getArtTypeForAnalytics)(e.art_type,e.is_draft),is_draft:Number(e.is_draft),position:Math.round(t.state.currentTime),speed:t.settings.playbackRate}})}),b)){let t=await (0,c.getCustomerUserId)(T.id);s.externalMarketingAnalytics.sendCustomEvent({event:s.ExternalMarketingAnalyticsEventName.START_LISTEN_FRAGMENT,content_id:e.id,customer_user_id:t},T.is_tester)}g&&y(r.api.player.data.setPlayerError(null))},I=(0,i.useCallback)(t=>{let a=t instanceof Error||"object"==typeof t&&null!==t&&"message"in t&&"string"==typeof t.message?t.message:"Unknown player error";y(r.api.player.data.setPlayerError({message:a}));let i=(0,u.failDownloadAttempt)(e.id,t);i&&!m.current&&(m.current=!0,(0,u.sendFirstStartPlayBook)((0,u.buildFirstStartPlayBookParams)(i,{playResult:"error",bookId:e.id,bookType:v})));let{player:{data:s}}=P.getState(),o=h(e.id);o&&n.TM.sendEvent(["LITRES_TRACKER"],{eventType:"player_start_fail",params:(0,d.getAnalyticsData)({art:e,extra:{...o,trial_flag:b,book_type:(0,l.getArtTypeForAnalytics)(e.art_type,e.is_draft),position:Math.round(s.state.currentTime),speed:s.settings.playbackRate,error:a}})}),y(r.api.player.data.setPlayerReady(!1)),y(r.api.player.data.setPlaying(!1)),A.current&&clearTimeout(A.current)},[e,y,b,v,P]),k=(0,i.useCallback)(function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e4;p.set(e.id,{payload:t,scheduledAt:Date.now()}),A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{let{player:{data:{state:e}}}=P.getState();e.isReady||I({message:"Player start timeout"})},r)},[e.id,I,P]);return(0,i.useEffect)(()=>()=>{A.current&&clearTimeout(A.current)},[e.id]),{scheduleEvent:k,onPlay:S,onError:I,onReady:()=>{y(r.api.player.data.setPlayerReady(!0))},onBufferEnd:E}}])},115078,e=>{"use strict";let t=async e=>{let t=await r(`${e}_D6W%{n`);return`uid_${t}`};async function r(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}e.s(["getCustomerUserId",0,t])},139269,(e,t,r)=>{var a=e.r(423748),n=e.r(819674);t.exports=function(e){return"number"==typeof e||n(e)&&"[object Number]"==a(e)}},283494,e=>{"use strict";var t=e.i(682195);e.s(["getQueryParam",0,e=>t.hasWindow&&window.location.href?new URL(window.location.href).searchParams.get(e):null,"reloadWithParams",0,(e,r)=>{if(!t.hasWindow)return;window.location.reload();let a=new URL(window.location.href);
1r&&r.forEach(e=>{a.searchParams.delete(e)}),e&&Object.entries(e).forEach(e=>{let[t,r]=e;a.searchParams.set(t,r)}),window.location.href=a.href}])}]); 2 3//# sourceMappingURL=https://www.litres.ru/_next/static/chunks/1481n1ptx1kci.js.map
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.