1import{j as e,r as t}from"./react-vendor.B75MsAI9.js";import{V as i,a4 as s,u as o,O as a,z as l,gE as n,Q as r,g as d,a as c,w as g,aY as u,b2 as m,L as p,cp as f,o as h,aQ as b,S as k,T as v,t as x,s as _,H as y,dU as S,gF as C,W as j,J as w,fs as R,cs as L,b0 as $,cf as I,cg as T,D as N,p as E,gG as B,y as A,U as F,gH as M,gI as O,fr as P,gJ as D,gK as U,bF as W,gL as H,aG as G,aH as z,E as q,gM as V,aa as J,aR as Q,F as K,aX as X,aZ as Y,ct as Z,b5 as ee,aI as te,ch as ie,aJ as se,dB as oe,dC as ae,cC as le,gN as ne,dE as re,gO as de}from"./AuthModalContainer.D3JsQqnf.js";import{g as ce,A as ge,F as ue,S as me,a as pe,O as fe,h as he,B as be,N as ke,D as ve,r as xe,E as _e,f as ye}from"./main.DrmgIV4z.js";import{u as Se}from"./RTLProvider.Bmr48mpV.js";import{L as Ce}from"./Likes.Ciwuh2Fr.js";import{A as je,a as we}from"./ActionBar.SIhZnVTJ.js";import{i as Re}from"./LazyFontLoader.5DGfhuFK.js";import{A as Le}from"./Avatar.DudPqjKy.js";import{B as $e}from"./Block.v-v90TCf.js";import{D as Ie}from"./DownloadModal.EPdLYrl-.js";import Te from"./index.Bx1hJalZ.js";import{p as Ne}from"./pick.uU6gbf1j.js";const Ee=({list:t})=>{let s=t.books[0].coverImage.sizes.map(e=>e.url),o=Re(t.datePublished),a=Re(t.dateModified),l=t.publisher||t.organisation;return e.jsxs(i,{children:[e.jsx("script",{type:"application/ld+json",children:`\n {\n "@context": "http://schema.org",\n "@type": "NewsArticle",\n "mainEntityOfPage": {\n "@type": "WebPage",\n "@id": "https://google.com/article"\n },\n "headline": "${t.title}",\n "image": ["${s||"https://google.com/logo.jpg"}"],\n "datePublished": "${o}",\n "dateModified": "${a}",\n "author": {\n "@type": "WebSite",\n "name": "${t.author.name}"\n },\n "publisher": {\n "@type": "Organization",\n "name": "${l?l.name:"User"}",\n "logo": {\n "@type": "ImageObject",\n "url": "${l?l.profileImage:"https://google.com/logo.jpg"}"\n }\n },\n "description": "${t.description}",\n "contentRating": {\n "@type": "Rating",\n "ratingValue": "G",\n "bestRating": "G",\n "worstRating": "G",\n "ratingExplanation": "This site contains only child-safe and family-friendly content."\n },\n "isFamilyFriendly": true\n }\n `}),e.jsx("script",{type:"application/ld+json",children:`\n {\n "@context": "http://schema.org",\n "@type": "BreadcrumbList",\n "itemListElement": [{\n "@type": "ListItem",\n "position": 1,\n "name": "lists",\n "item": "https://storyweaver.org.in/lists"\n },{\n "@type": "ListItem",\n "position": 2,\n "name": "list",\n "item": "https://storyweaver.org.in/lists/${t.slug}"\n }]\n }\n `})]})};Ee.propTypes={list:s.shape({title:s.string.isRequired,slug:s.string.isRequired,datePublished:s.string.isRequired,publisher:s.object,organisation:s.object,books:s.array.isRequired,author:s.object.isRequired,description:s.string.isRequired})};const Be=({index:i,book:s,editActive:x,active:_,readingList:y,storyStatus:S,disableNextRead:C,campaignType:j,listTitle:w,onReadClicked:R,campaignSetStoryStatus:L,userDetails:$,campaignType:I,campaignCheckStoryStatus:T,onDeleteBook:N,onRemoveHowToUse:E,onAddHowToUse:B,onMoveBook:A,onFieldChange:F,onFieldFocus:M,onFieldBlur:O,isRtl:P,error:D,first:U,last:W,isFetchingAssets:H})=>{const G=o(),[z,q]=t.useState(!1);t.useEffect(()=>{H||q(!1)},[H]);const V="pb-reading-list-entry",J=e=>s.usageInstructions&&null!==s.usageInstructions[e]&&void 0!==s.usageInstructions[e],Q=()=>J("txt"),K=(e,t,i,s=null,o)=>{i&&i.preventDefault(),q(!0);const a="My Bookshelf"===w?u.myBookshelf:u.listPage;R(e,t,a,o),s&&"finished"!==s&&L(e.id,$.registrationId,"started",I).then(e=>{e.ok&&T($.registrationId,I)})},X=a.storyDetails(s.slug).replace(`/${l}`,""),Y={[V]:!0,[`${V}--indexed`]:"number"==typeof i,[`${V}--index-${(i+1)%3}`]:"number"==typeof i,[`${V}--edit-active`]:x,[`${V}--active`]:_},Z={[`${V}__button`]:!0,[`${V}__button--continue-reading`]:S&&S.status===n.continue,[`${V}__button--read-again`]:S&&S.status===n.finished};return e.jsxs("div",{className:r(Y),children:[e.jsxs("div",{className:`${V}__content`,children:[e.jsx(Ee,{list:y}),e.jsxs("div",{className:`${V}__col-1`,children:["number"==typeof i?e.jsx("span",{className:`${V}__index`,children:i+1}):null,e.jsx("div",{className:`${V}__book-card`,children:e.jsx(ce,{book:s,isRtl:P,shouldDisplayMenu:!0,hideQuickViewBtn:!0,shouldShowReadIcon:!0,hideReadalong:C,showRead
1IconLoader:z,readingListNextReadBooks:y.books,onClick:e=>K(s,m.ListPageBookCard,e,S?S.status:null,C),overrideClick:!0,readSource:"My Bookshelf"===w?u.myBookshelf:c.storyTile,customMenu:!0,eventCategory:y.bookShelf?g.bookShelf:c.listDetailsPage,eventLabel:y.bookShelf?`${j}_${d.detailsPage}`:c.storyTile})})]}),e.jsxs("div",{className:`${V}__col-2`,children:[e.jsx("h3",{dir:f(s.title)?"rtl":"ltr",className:`${V}__title ${f(s.title)?`${V}__title--rtl`:""}`,children:e.jsx(p,{parentClassName:`${V}__link`,onClick:e=>K(s,m.ListPageBookTitle,e,S?S.status:null,C),href:X,isInternal:!0,children:s.title})}),(ee=V,x?e.jsx("div",{className:`${ee}__desc`,children:Q()?e.jsx(v,{id:`reading-list-entry-usage-instructions-input-${s.id}`,label:G("ReadingList.how-to-use"),value:s.usageInstructions.txt,type:"multiline",onChange:async e=>{let t=e.target.value;F("usageInstructions.txt",t)},onFocus:M,onBlur:O,error:D,isRtl:P}):e.jsx("div",{dir:f(s.synopsis)?"rtl":"ltr",children:s.synopsis})}):J("html")?e.jsxs("div",{className:`${ee}__desc`,dir:f(G("ReadingList.how-to-use"))&&f(s.title)?"rtl":"ltr",children:[e.jsxs("h3",{className:`${ee}__desc-title ${f(G("ReadingList.how-to-use"))&&f(s.title)?`${ee}__desc-title--rtl`:""}`,dir:f(G("ReadingList.how-to-use"))?"rtl":"ltr",children:[G("ReadingList.how-to-use"),":"]}),e.jsx("span",{dir:f(s.usageInstructions.txt)?"rtl":"ltr",children:s.usageInstructions.txt})]}):e.jsx("div",{className:`${ee}__desc`,dir:f(s.synopsis)?"rtl":"ltr",children:s.synopsis})),e.jsx("div",{className:`${V}__btn-wrapper`,children:S&&e.jsx(h,{variant:"fab",parentClassName:r(Z),label:S.text,onClick:e=>K(s,m.ListPageBookTitle,e,S.status,C),loading:z})})]})]}),(t=>x?e.jsx("div",{className:`${t}__footer`,children:e.jsxs(je,{noSectionSeparators:!0,noBottomBorder:!0,children:[e.jsx(we,{children:e.jsxs(b,{inline:!0,children:[e.jsxs(p,{onClick:()=>N(i),theme:"danger",children:[e.jsx(k,{name:"bin",title:G("SvgTitle.delete")}),G("global.delete")]}),Q()?e.jsxs(p,{onClick:()=>E(i),theme:"danger",children:[e.jsx(k,{name:"close-circle",title:G("SvgTitle.close-circle")}),G("global.remove")," '",G("ReadingList.how-to-use"),"'"]}):e.jsxs(p,{onClick:()=>B(i),children:[e.jsx(k,{name:"plus-circle",title:G("SvgTitle.plus-circle")}),G("global.add")," '",G("ReadingList.how-to-use"),"'"]})]})}),U&&W&&Q()?null:e.jsx(we,{children:e.jsxs(b,{inline:!0,children:[U?null:e.jsxs(p,{onClick:()=>A(i,-1),title:G("ReadingList.move-up"),children:[e.jsx(k,{name:"arrow-up",title:G("SvgTitle.arrow-up")})," ",G("ReadingList.move-up")]}),W?null:e.jsxs(p,{onClick:()=>A(i,1),title:G("ReadingList.move-down"),children:[e.jsx(k,{name:"arrow-down",title:G("SvgTitle.arrow-down")})," ",G("ReadingList.move-down")]})]})})]})}):null)(V)]});var ee};Be.propTypes={index:s.number,book:s.object.isRequired,editActive:s.bool,active:s.bool,onFieldChange:s.func,onAddHowToUse:s.func,onRemoveHowToUse:s.func,onDeleteBook:s.func,onMoveBook:s.func,onFieldFocus:s.func,onFieldBlur:s.func,onReadClicked:s.func.isRequired,readingList:s.object.isRequired,storyStatus:s.object,disableNextRead:s.bool,campaignType:s.string,listTitle:s.string,campaignSetStoryStatus:s.func,userDetails:s.object,campaignCheckStoryStatus:s.func,isRtl:s.bool,error:s.string,first:s.bool,last:s.bool,isFetchingAssets:s.bool};const Ae=({isLoggedIn:t,slug:i,openAuthModal:s,onListDownload:a,showIconOnly:l})=>{const n=o();return t?e.jsxs(p,{onClick:a,children:[e.jsx(k,{name:"download",title:n("SvgTitle.download"),size:"m",pushRight:!0}),l?"":n("global.download",1)]}):e.jsx(ge,{openAuthModal:s,toggleEl:e.jsxs(p,{children:[e.jsx(k,{name:"download",title:n("SvgTitle.download"),size:"m",pushRight:!0}),l?"":n("global.download",1)]}),loginText:n("DownloadsDropdown.please-log-in")})},Fe=e=>`${e}s`,Me=({readingList:s,editable:n,editActive:r,onReadingListFieldChange:u,onEdit:m,onSave:N,onCancel:E,onAddHowToUse:B,onRemoveHowToUse:A,onDeleteBook:F,onMoveBook:M,onLikeButtonClicked:O,onReadClicked:P,onClickAddToOffline:D,onClickRemoveFromOffline:U,viewport:W,isUpdatingReadingList:H,didEditReadingList:G,userEmail:z,userId:q,userType:V,listTitle:J,isFetchingAssets:Q,currentGlobalBookReaderSlug:K,isRtl:X,isLoggedIn:Y,availableOffline:Z,offlineBooks:ee,isAvailableOffline:te,openAuthModal:ie,profile:se,campaignCheckStoryStatus:oe,campaignSetStoryStatus:ae,storyStatus:le,staticData:ne,campaignType:re,validateSearchWordWorkFlow:de,usageErrors:ce,descriptionErr:ge,titleErr:xe,getCampaignCertificate:_e,language:ye,minCount:Se,maxCount:Re})=>{const Ne=o(),Ee=x(),Me=_(),[Oe,Pe]=t.useState({noSpaceForMoreOfflineBooks:!1,delete:!1,download:!1,deleteList:!1}),[De,Ue]=t.useState(!1),[We,He]=t.useState(!1),Ge=t.useCallback(e=>{Pe(t=>({...t,[e]:!0}))},[]),ze=t.useCallback(e=>{Pe(t=>({...t,[e]:!1}))},[]),qe=t.useCallback(e=>{e.target.value.length<=1e3?(u("description",e.target.value,"descriptionErr"),We&&He(!1)):(e.target.value=e.target.value.substring(0,1e3),He(!0))},[u,We]),Ve=t.useCallback(()=>{Ue(!0),D().then(()=>{Ee(y({type:"info",content:Ne("ReadingList.added-to-offline-library-notification")})),localStorage.setItem("sw-offline-activity","offline"+Math.random())}).then(()=>{Ue(!1),s&&et({gtmEvent:c.saveOfflineLibrary,gtmLabel:d.detailsPage,itemId:`list_${s.id}`,itemType:d.listCr})})},[D,Ee,Ne,s]),Je=t.useCallback(e=>{s&&et({gtmEvent:`clicked_${e.slice(5).toLowerCase()}`,gtmLabel:`share_${s.id}`})},[s]),Qe=t.useCallback(()=>{Ee(S()),Pe(e=>({...e,download:!1}))},[Ee]),Ke=t.useCallback(async()=>
1{if(s)try{(await Ee(C({slug:s.slug}))).data.downloadLimitReached?Pe(e=>({...e,download:!0})):(Ee(y({id:Ne("ReadingList.attribution-download-title"),content:Ne("ReadingList.attribution-download-content")})),window.open(a.downloadList(s.slug)))}catch(e){}},[s,Ee,Ne]),Xe=t.useCallback(async()=>{if(s)try{await Ee(j({listId:s.slug})),Ee(w()),Ee(y({type:"info",id:Ne("global.bookshelf-deleted-notification"),content:Ne("global.bookshelf-deleted-notification")})),localStorage.setItem("sw-bookshelf","bookshelf"+Math.random()),Me(`/users/${q}?bookShelf`)}catch(e){}},[s,q,Ee,Ne,Me]),Ye=t.useCallback(e=>{if(re&&re!==R.cbse_contest){const{backgroundImg:e,campaignText:t,certificateCompletion:i,certificateIssuedText:s,certificateNoText:o,leftSignature:a,logos:l,maxCount:n,minCount:r,partnershipText:d,rightSignature:g,schoolText:u,text1:m,text2:p,certificateNumPrefix:f,middleSignature:h,certificateLanguage:b,isRectangleLogo:k}=ne;let v=ne?{background_img:e.url,campaign_text:t,certificate_completion:i,certificate_issued_text:s,certificate_no_text:o,logos:l&&l.map(e=>e.image&&e.image.url),max_count:n,min_count:r,partnership_text:d,school_text:u,text1:m,text2:p,left_signature:a?{image:a&&a.sign&&a.sign.url,name:a.name,designation:a.designation,organisation:a.organisation}:null,right_signature:g?{image:g&&g.sign&&g.sign.url,name:g.name,designation:g.designation,organisation:g.organisation}:null,middle_signature:h?{image:h&&h.sign&&h.sign.url,name:h.name,designation:h.designation,organisation:h.organisation}:null,certificate_num_prefix:f,language:ye,certificate_language:b,is_rectangle_logo:k}:{};_e&&_e({reg_id:ne.userContest.registrationId,certificateData:v}).then(e=>{e.ok?(window.open(e.url),Ee(y({type:"success",content:e.msg})),et({gtmEvent:c.fileDownload,gtmLabel:`${re}_certificate`})):Ee(y({type:"danger",content:e.msg}))})}else W.medium?window.location.href="startedWriting"===e?`/${l}/v0/editor/story/${ne.userContest.draftStoryId}?contest_id=${ne.contestId}`:`/${l}/v0/editor/create?contest_id=${ne.contestId}`:Ee(y({id:"Book.mobile-editor-notification",content:Ne("Book.mobile-editor-notification-text")}))},[re,ne,ye,_e,W,Ee,Ne]),Ze=t.useCallback((t,i)=>s&&s.books?s.books.map((t,o,a)=>e.jsx(Be,{index:o,first:0===o,last:o===a.length-1,description:t.description,book:t,editActive:n&&r,onFieldChange:(e,t)=>
1{u(`books.${o}.${e}`,t,"usageErrors",o)},onAddHowToUse:B,onRemoveHowToUse:A,onDeleteBook:F,onMoveBook:M,isUpdatingReadingList:H,userEmail:z,userId:q,listTitle:J,readingListCategories:s.categories?s.categories.join(", "):"",onReadClicked:P,isFetchingAssets:Q,currentGlobalBookReaderSlug:K,readingList:s,isRtl:X,campaignCheckStoryStatus:oe,campaignSetStoryStatus:ae,storyStatus:le&&ne.userContest&&ne.userContest.listId===s.id&&le[t.id],userDetails:ne&&ne.userContest,disableNextRead:i,campaignType:re,validateSearchWordWorkFlow:de,error:ce&&ce[o]},`${t.title}-${o}`)):null,[s,n,r,u,B,A,F,M,H,z,q,J,P,Q,K,X,oe,ae,le,ne,re,de,ce]),et=t.useCallback(e=>{const{gtmEvent:t,gtmLabel:i,itemType:o,itemId:a,itemValue:l}=e;s&&window.dataLayer.push({category:s.bookShelf?g.bookShelf:c.listDetailsPage,event:t,label:i,item_type:o||null,item_id:a||null,item_value:l||null,user_profile:V,user_id:q})},[s,V,q]),tt=t.useCallback(t=>s&&n&&!r?e.jsxs("div",{className:`${t}__header-actions`,children:[e.jsx(h,{noMargin:!0,iconLeft:"pen",label:Ne("global.edit"),onClick:()=>{m(),et({gtmEvent:c.clickedEdit,gtmLabel:d.detailsPage,itemId:`list_${s.id}`,itemType:d.listCr})}}),s.bookShelf?e.jsx(h,{noMargin:!0,iconLeft:"bin",label:Ne("global.delete"),onClick:()=>{Ge("deleteList"),et({gtmEvent:c.clickedDelete,gtmLabel:d.detailsPage,itemId:`list_${s.id}`,itemType:d.listCr})}}):null]}):null,[n,r,m,Ge,et,s,Ne]),it=t.useCallback((t,i)=>n&&r?e.jsxs(ue,{float:!0,readingList:!0,children:[e.jsx(h,{iconLeft:"check",variant:"primary",label:Ne("global.save-changes"),onClick:N,loading:H,disabled:!i||Boolean(xe)||Boolean(ge)}),e.jsx(h,{iconLeft:"close",label:Ne("ReadingList.cancel"),onClick:E,disabled:H})]}):null,[n,r,N,E,H,G,xe,ge,Ne]),st=t.useCallback((t,i)=>{if(!s)return null;let o=s.author,l=L.USER;L.ORGANISATION in s?(o=s[L.ORGANISATION],l=L.ORGANISATION):L.PUBLISHER in s&&(o=s[L.PUBLISHER],l=L.PUBLISHER);let g=null;s.likeCount>=0&&(g=e.jsx(Ce,{parentClassName:`${t}__likes`,t:Ne,isliked:s.liked,likesCount:s.likeCount,align:!W.medium&&!X&&"left",onLike:()=>{O(s.slug),et({gtmEvent:c.clickedLike,gtmLabel:d.detailsPage,itemId:`list_${s.id}`,itemType:d.listCr})},isLoggedIn:Y,isRtl:X,openAuthModal:ie,logInMsg:Ne("global.please-log-in",{action:Ne("global.like",1),content_type:Ne("global.list",1)})}));let u=(s.books||[]).filter(e=>q&&!te(e.id,ee,"read",q));const m=se.roles&&se.roles.includes($.CONTENT_MANAGER);return e.jsxs(je,{disabled:n&&r,parentClassName:`${t}__action-bar`,isRtl:X,children:[e.jsxs(we,{children:[e.jsx(p,{noSitelLocale:!0,href:a.profile(Fe(l),o.slug,I.lists),isInternal:!0,children:e.jsx(Le,{parentClassName:`${t}__avatar`,name:o.name,size:"m",url:o.profileImage,variant:"circular"})})," ",s.bookShelf?Ne("global.bookshelf-created-by"):Ne("ReadingList.list-created-by")," ",e.jsx(p,{noSitelLocale:!0,href:a.profile(Fe(l),o.slug,I.lists),isInternal:!0,children:o.name})]}),e.jsxs(we,{children:[g,e.jsx(me,{value:s.readCount,icon:"book",isRtl:X})]}),e.jsx(we,{children:e.jsxs(b,{inline:!0,spacing:"s",parentClassName:`${t}__actions`,children:[e.jsx(pe,{showIconOnly:!0,title:s.title,align:!W.medium&&!X&&"left",href:window.location.href,viewport:W,isRtl:X,onClick:Je}),m&&!s.bookShelf&&e.jsx(Ae,{showIconOnly:!0,isLoggedIn:Y,t:Ne,slug:s.slug,openAuthModal:ie,onListDownload:Ke}),s.books.length>0&&!i?e.jsx(fe,{spacing:!s.bookShelf&&"xl",align:W.medium||X?"right":"left",showIconOnly:!0,availableOffline:Z,onClickAddToOffline:()=>{const e=u.filter(e=>!te(e.id,ee,"read")).length,t=ee.translations.filter(e=>e.userId===q).length,i=ee.books.filter(e=>!e.isFromOfflineTranslate&&e.savedUsers&&e.savedUsers.includes(q)).length;return he(t+i,u.length,ee.books.length,e)<=T?Ve():Ge("noSpaceForMoreOfflineBooks")},onClickRemoveFromOffline:()=>Ge("delete"),disabled:!("serviceWorker"in navigator),isLoggedIn:Y,isSavingOffline:De,t:Ne,openAuthModal:ie,isRtl:X}):null]})})]})},[s,Ne,W,n,r,Y,Z,ee,te,ie,X,se,q,O,et,Je,Ke,Ve,Ge,De]),ot="pb-reading-list",at=[ot];if(!s)return null;const lt=[{title:Ne("global.home"),href:a.home(),isInternal:!0},{title:Ne("global.list",2),href:a.lists()}],{userContest:nt,userProgressText:rt,userProgressFlashText:dt,keepWritingText:ct,downloadCertificate:gt,writeStoryText:ut,submissionText:mt,submittedStoryText:pt,startProgressText:ft,continueProgressText:ht,finishProgressText:bt,downloadCertActive:kt,comingSoon:vt}=ne||{};let xt,_t=nt&&s&&nt.listId===s.id;xt=re===R.cbse_contest?rt:nt&&0===nt.listProgress?ft&&ft.replace("%num",Re):nt&&nt.listStoriesCount>=Re&&nt.listProgress===nt.listStoriesCount?bt:ht&&ht.replace("%reads",nt&&nt.listProgress).replace("%num",Re);
1const yt=Ze(_t,re),St=tt(ot),Ct=st(ot,_t);let jt;n&&r&&at.push(`${ot}--edit-active`),nt&&"submitted"===nt.draftStoryStatus?jt="submitted":nt&&nt.draftStoryId&&"draft"===nt.draftStoryStatus?jt="startedWriting":nt&&nt.listStoriesCount>=Re&&nt.listProgress===nt.listStoriesCount?jt="fullyRead":nt&&(nt.listStoriesCount<Re||nt.listStoriesCount>=Re&&nt.listProgress<nt.listStoriesCount)&&(jt="halfRead");let wt,Rt,Lt,$t=!kt||"halfRead"===jt&&nt&&nt.listProgress<Se;re&&re!==R.cbse_contest?(wt=gt,Rt="download",Lt=$t?"rp_odia_download_disabled":"rp_odia_download"):(wt="startedWriting"===jt?ct:ut,Rt="write",Lt="write");const It=e.jsxs("div",{className:`${ot}__progress`,children:["halfRead"===jt&&nt&&e.jsxs("div",{className:`${ot}__progress-wrapper`,children:[e.jsx("div",{className:`${ot}__progress-text`,children:e.jsxs("span",{children:[xt," ",e.jsx("span",{className:`${ot}__blink`,children:dt})]})}),e.jsx("progress",{className:`${ot}__progress-bar`,value:nt.listProgress/Math.max(nt.listStoriesCount,Re)*100,max:"100"})]}),"fullyRead"===jt&&nt&&e.jsxs("div",{className:`${ot}__progress-wrapper`,children:[e.jsxs("div",{className:`${ot}__party-wrapper`,children:[e.jsx(k,{size:"l",name:"party",parentClassName:`${ot}__party-icon`}),e.jsx("span",{className:`${ot}__progress-text`,children:e.jsxs("span",{children:[xt," ",e.jsx("span",{className:`${ot}__blink`,children:dt})]})})]}),e.jsx("progress",{className:`${ot}__progress-bar`,value:nt.listProgress/Math.max(nt.listStoriesCount,Re)*100,max:"100"})]}),"startedWriting"===jt&&e.jsx("div",{className:`${ot}__progress-wrapper`,children:e.jsx("div",{className:`${ot}__progress-text`,children:e.jsxs("span",{children:[mt," ",e.jsx("span",{className:`${ot}__blink`,children:dt})]})})}),"submitted"===jt&&e.jsx("div",{className:`${ot}__progress-wrapper`,children:e.jsx("div",{className:`${ot}__progress-text`,children:pt})}),e.jsxs("div",{className:re&&re!==R.cbse_contest?`${ot}__download-lock-wrapper`:`${ot}__lock-wrapper`,children:["submitted"!==jt&&e.jsx(h,{label:wt,variant:"primary-complement",iconLeft:W.medium&&Lt,iconSize:"sm",title:re&&re!==R.cbse_contest&&!kt&&vt,parentClassName:$t?`${ot}__${Rt}-btn ${ot}__${Rt}-lock-btn`:`${ot}__${Rt}-btn`,disabled:!re||re===R.cbse_contest||$t,onClick:()=>Ye(jt)}),re&&re!==R.cbse_contest?null:$t&&e.jsx(k,{parentClassName:`${ot}__progress-lock`,size:"m",name:"lock"})]})]});return e.jsxs("div",{className:at.join(" "),children:[e.jsx(i,{children:e.jsx("title",{children:`${s.title} - ${Ne("global.site-title")}`})}),e.jsx($e,{children:e.jsxs("div",{className:`${ot}__wrapper`,children:[!s.bookShelf&&!re&&e.jsx(be,{paths:lt,isRtl:X}),e.jsxs("div",{className:`${ot}__header`,children:[e.jsx("div",{className:`${ot}__header-wrapper ${n&&r?`${ot}__header-wrapper--extended`:null}`,children:n&&r?e.jsx(v,{id:"reading-list-title-input",label:Ne("global.title"),size:W.medium?"l":"m",fontFamily:"alt",value:s.title,onChange:e=>u("title",e.target.value,"titleErr"),disabled:H,error:xe,customError:Boolean(xe),isRtl:X}):e.jsx("h1",{className:`${ot}__title`,dir:f(s.title)?"rtl":"ltr",children:s.title})}),St,it(ot,G)]}),Ct,e.jsxs("div",{className:`${ot}__content-wrapper`,children:[n&&r?e.jsx(v,{id:"reading-list-list-desc-input",label:s.bookShelf?Ne("global.bookshelf-desc"):Ne("global.list-desc"),value:s.description,type:"multiline",onChange:qe,disabled:H,error:ge||(We?Ne("global.bookshelf-description-limit"):null),customError:Boolean(ge)||We,bookshelfLengthExceed:We,isRtl:X}):e.jsx("div",{className:`${ot}__desc`,dir:f(s.description)?"rtl":"ltr",children:s.description}),e.jsx("div",{className:`${ot}__books`,children:yt})]})]})}),Oe.noSpaceForMoreOfflineBooks?e.jsx(ke,{viewport:W,onClose:()=>ze("noSpaceForMoreOfflineBooks"),maximum:T,isRtl:X}):null,Oe.delete?e.jsx(ve,{onConfirm:()=>{U(),et({gtmEvent:c.removeOfflineLibrary,gtmLabel:d.detailsPage,itemId:`list_${s.id}`,itemType:d.listCr})},onClose:()=>ze("delete"),viewport:W,count:s.books.length,books:s.books,userEmail:z,baseClassName:ot,addSlimNotification:y,isRtl:X}):null,e.jsx(Ie,{isVisible:Oe.download,onCloseClicked:()=>ze("download"),onFormLinkClicked:Qe,userEmail:z}),Oe.deleteList?e.jsx(Te,{t:Ne,viewport:W,title:Ne("global.bookshelf-delete-bookshelf"),text:Ne("global.bookshelf-delete-messag"),onClose:()=>ze("deleteList"),onConfirm:Xe,isRtl:X}):null,_t&&e.jsx("div",{className:`${ot}__progress-bar-wrapper`,children:It})]})};Me.propTypes={readingList:s.shape({title:s.string.isRequired,description:s.string,books:s.arrayOf(s.shape({...Be.propTypes,howToUse:s.string}))}).isRequired,editable:s.bool,editActive:s.bool,onReadingListFieldChange:s.func,onEdit:s.func,onSave:s.func,onCancel:s.func,onAddHowToUse:s.func,onRemoveHowToUse:s.func,onDeleteBook:s.func,onMoveBook:s.func,onLikeButtonClicked:s.func,onReadClicked:s.func,onClickAddToOffline:s.func,onClickRemoveFromOffline:s.func,viewport:s.object.isRequired,isUpdatingReadingList:s.bool,userEmail:s.string,userId:s.string,userType:s.string,listTitle:s.string,isFetchingAssets:s.bool,currentGlobalBookReaderSlug:s.string,isRtl:s.bool,isLoggedIn:s.bool,availableOffline:s.bool,offlineBooks:s.object,isAvailableOffline:s.func,openAuthModal:s.func,profile:s.object,campaignCheckStoryStatus:s.func,campaignSetStoryStatus:s.func,storyStatus:s.object,staticData:s.object,campaignType:s.string,validateSearchWordWorkFlow:s.func,usageErrors:s.array,descriptionErr:s.string,titleErr:s.string,getCampaignCertificate:s.func,language:s.string,didEditReadingList:s.bool,minCount:s.number,maxCount:s.number};const Oe=()=>{var i;const s=x(),{slug:l}=N(),n=o(),r=Se(),u=E(e=>e.readingLists),{isFetchingReadingList:m,readingList:p,isUpdatingReadingList:f,downloadLimitReached:h,storyStatus:b}=u,{isLoggedIn:k,profile:v,isFetchingMe:_,staticDataCbse:L,isDeletingList:$}=E(e=>e.user),I=E(e=>e.viewport),T=E(e=>e.offlineBooks),ce=E(e=>e.windowDimensions),ge=E(e=>e.network.online),{isFetchingAssets:ue,currentGlobalBookReaderSlug:me,isAddingToBookshelf:pe,book:fe}=E(e=>e.book),{isFetchingAllCampaignRegistrations:he}=E(e=>e.stem),[be,ke]=t.useState(null),[ve,Ce]=t.useState(!1),[je,we]=t.useState(!1),[Re,Le]=t.useState(!1),[$e,Ie]=t.useState(-1),[Ee,Be]=t.useState(""),[Ae,Fe]=t.useState(""),[Oe,Pe]=t.useState({}),[De,Ue]=t.useState(null),[We,He]=t.useState(null),[Ge,ze]=t.useState(null),[qe,Ve]=t.useState(null),[Je,Qe]=t.useState(!1),[Ke,Xe]=t.useState([]),Ye=t.useRef(b),Ze=t.useRef(pe),et=t.useRef(p),tt=(e,t,i,s=[])=>{if(s.length>0&&s.includes(parseInt(e,10))||!t)Qe(!1);else{const e=i.replace(/\//g,"");window.location.href=a.campaigns(e).concat("?section=enrol")}},it=()=>{const e=l.split("-")[0];let t=[];s(V()).then(i=>{if(null==i?void 0:i.data){t=i.data.map(t=>{const i=t.campaignType,s=t.campaignCard.url,o=t.certificateData,a=new Set;return t.section.forEach(t=>{t.enrollSection.forEach(t=>{t.bookshelfData.forEach(t=>
1{parseInt(t.listId,10)===parseInt(e,10)&&ze(t.languageShortName),a.add(parseInt(t.listId,10))})})}),{campaignType:i,campaignUrl:s,campaignCertDetails:o,listIds:Array.from(a)}});let o=t.filter(t=>t.listIds.includes(parseInt(e,10)));if(o&&o.length>0){const t=o[0].campaignType,i=o[0].campaignUrl,a=o[0].campaignCertDetails;Ue(t),He(a),(null==v?void 0:v.id)?s(J({user_id:v.id,campaign_type:t,list_id:e})).then(o=>{if(o&&o.data){let a=o.data.userContest,l=o.data.registeredGrades;a&&(Ve(a),s(D({registrationId:a.registrationId,campaignType:t}))),tt(e,t,i,l)}}):tt(e,t,i)}else(null==v?void 0:v.id)&&s(P({user_id:v.id,campaign_type:null,list_id:l})).then(e=>{if(e&&e.data){let t=e.data.userContest;null!==t&&(Ve(t),Ue(t.campaignType),s(D({registrationId:t.registrationId,campaignType:t.campaignType})))}}),Qe(!1)}})};t.useEffect(()=>{Qe(!0),s(w()).then(()=>{it()}),s(B({slug:l}))},[l,s]),t.useEffect(()=>{pe===Ze.current||pe||s(B({slug:l})),Ze.current=pe},[pe,l,s]),t.useEffect(()=>{!xe(Ye.current,b)&&b&&Ye.current&&(null==v?void 0:v.id)&&it(),Ye.current=b},[b,null==v?void 0:v.id,l,s]),t.useEffect(()=>{p!==et.current&&p&&(ke(A(p)),et.current=p)},[p]);const st=()=>{Le(!1),Ie(-1)};if(m||_||he||Je)return e.jsx(F,{});if(!p)return e.jsx(_e,{errorCode:404});const ot=k&&be&&(null==v?void 0:v.id)===(null==(i=be.author)?void 0:i.id),at=(null==be?void 0:be.books)||[],lt=at.every(e=>(null==v?void 0:v.id)&&ye(e.id,T,"read",v.id));return e.jsxs("div",{children:[e.jsx(Me,{readingList:be,onLikeButtonClicked:()=>{k&&(null==p?void 0:p.slug)?s(de({slug:p.slug})):s(q())},editable:ot,editActive:ve,onReadingListFieldChange:(e,t,i,s)=>{if(!be)return;const o=A(be),a=e.split(".");let l=o;for(let n=0;n<a.length-1;n++)l=l[a[n]];if(l[a[a.length-1]]=t,ke(o),we(!0),"title"===e)if(re(t))Fe(n("global.url-not-allowed"));else{const e=oe(n("global.title"),t);Fe(e[0]||"")}if("description"===e){const e=be.bookShelf?n("global.bookshelf-desc"):n("global.list-desc");if(re(t))Be(n("global.url-not-allowed"));else{const i=oe(e,t);Be(i[0]||"")}}else"descriptionErr"===i&&Be("");"usageErrors"===i&&Pe(e=>({...e,[s]:""}))},onEdit:()=>Ce(!0),onSave:async()=>{if(!je||!be)return void Ce(!1);const e=oe(n("global.title"),be.title),t=be.bookShelf?n("global.bookshelf-desc"):n("global.list-desc"),i=oe(t,be.description);let o=e[0]||"";if(!o){const e=await ae(be.title,e=>s(W({value:e})),n);e.valid||(o=e.message||n("global.url-not-allowed"))}Fe(o);let a=i[0]||"";if(!a){const e=await ae(be.description,e=>s(W({value:e})),n);e.valid||(a=e.message||n("global.url-not-allowed"))}Be(a);let l={};for(let c=0;c<be.books.length;c++){const e=be.books[c],t=e.usageInstructions&&e.usageInstructions.txt||"",i=await le(`readingList.books.${c}.usageInstructions.txt`,t,(e,t)=>{const i=A(be),s=e.split(".");let o=i;for(let a=1;a<s.length-1;a++)o=o[s[a]];o[s[s.length-1]]=t,ke(i)},n,e=>s(W({value:e})));i.valid||(l[c]=i.message)}if(Pe(l),o||a||Object.keys(l).length>0)return void window.scrollTo({top:0,behavior:"smooth"});const r=Ne(be,["title","description","books","id"]),d=["id","usageInstructions"];r.books=r.books.map(e=>Ne(e,d)),s(ne({readingList:r})).then(e=>{e&&!1===e.ok?s(y({type:"danger",content:e.error||"Invalid list data"})):(localStorage.setItem("sw-bookshelf","bookshelf"+Math.random()),Ce(!1),we(!1),Xe([]),s(w()))})},onCancel:()=>{ke(A(p)),Ce(!1),we(!1),Be(""),Fe(""),Pe({})},onAddHowToUse:e=>{if(!be)return;const t=A(be);t.books[e]&&(t.books[e]={...t.books[e],usageInstructions:{txt:""}},ke(t),we(!0))},onRemoveHowToUse:e=>{if(!be)return;const t=A(be);t.books[e]&&(t.books[e]={...t.books[e],usageInstructions:{txt:null,html:null}},ke(t),we(!0))},onDeleteBook:e=>{Le(!0),Ie(e)},onMoveBook:(e,t)=>{if(!be)return;const i=e+t;if(i<0||i>=be.books.length)return;const s=A(be),o=[...s.books],a=o[e];o[e]=o[i],o[i]=a,s.books=o,ke(s),we(!0)},viewport:I,isUpdatingReadingList:f,didEditReadingList:je,isLoggedIn:k,availableOffline:lt,offlineBooks:T,onClickAddToOffline:()=>{if(!be||!(null==v?void 0:v.id))return Promise.resolve();const e=be.books.filter(e=>!ye(e.id,T,"read",v.id)).map(e=>s(se({book:e,imageSize:ie(ce.width),userId:v.id})));return Promise.all(e)},onClickRemoveFromOffline:()=>{if(!be||!(null==v?void 0:v.id))return Promise.resolve();const e=be.books.filter(e=>ye(e.id,T,"read",v.id)).map(e=>s(te({book:e,imageSize:ie(ce.width),userId:v.id})));return Promise.all(e).then(()=>{s(y({type:"info",content:n("ReadingList.removed-from-offline-library-notification")})),localStorage.setItem("sw-offline-activity","offline"+Math.random())})},isAvailableOffline:e=>!!(null==v?void 0:v.id)&&ye(e,T,"read",v.id),userEmail:null==v?void 0:v.email,userId:null==v?void 0:v.id,userType:null==v?void 0:v.profile_type,books:at,openAuthModal:e=>s(q(e)),addGatingForm:()=>s(S()),downloadLimitReached:h,fetchListDownloadLimitWorkflow:e=>s(C({slug:e})),listTitle:null==be?void 0:be.title,addSlimNotification:e=>s(y(e)),onReadClicked:(e,t,i,o)=>{Q.shouldShowMandatoryLogin()&&ge?s(q({stage:K.mandatoryLogin})):s(X({slug:e.slug})).then(()=>{s(Y({book:e,storyId:e.id,readingListNextReadBooks:(null==be?void 0:be.books)||[],readSource:i||"listDetailsPage",regId:qe?qe.registrationId:null,disableNextRead:o,campaignType:qe?De:null})),o||s(Z({slug:e.slug})),window.dataLayer.push({event:c.startReading,category:(null==p?void 0:p.bookShelf)?g.bookShelf:c.listDetailsPage,label:(null==p?void 0:p.bookShelf)?`${De}_${d.detailsPage}`:c.storyTile,item_type:d.bookLangLevel,item_id:e.id,item_value:`${e.language}_${"5"===e.level?ee.emergentReader:e.level}`,user_profile:null==v?void 0:v.profile_type,user_id:(null==v?void 0:v.id)||"00000"}),Q.storyRead(e.slug)})},isFetchingAssets:ue,currentGlobalBookReaderSlug:me,addNotificationModal:e=>s(z(e)),removeNotificationModal:()=>s(G()),profile:v,isRtl:r,deleteUserListWorkflow:e=>s(j(e)),isDeletingList:$,history:history,fetchMeWorkflow:()=>s(w()),campaignSetStoryStatus:U,campaignCheckStoryStatus:D,getStaticDataCbse:P,getCampaignCertificate:e=>s(H(e)),staticData:De!==R.cbse_contest?{...L,...We}:L,storyStatus:b,campaignType:De,minCount:De!==R.cbse_contest?We&&We.minCount:O,maxCount:De!==R.cbse_contest?We&&We.maxCount:M,language:Ge,validateSearchWordWorkFlow:e=>s(W({value:e})),descriptionErr:Ee,titleErr:Ae,usageErrors:Oe}),Re&&e.jsx(Te,{title:n("ReadingList.confirm-delete-book-title"),text:(null==p?void 0:p.bookShelf)?n("ReadingList.confirm-delete-book-bookshelf"):n("ReadingList.confirm-delete-book"),onConfirm:()=>(e=>{if(st(),-1===e||!be)return;const t=be.books[e];Xe(e=>[...e,t]);const i=A(be);i.books=i.books.filter((t,i)=>i!==e),ke(i),we(!0)})($e),onClose:st,viewport:I,isRtl:r})]})};export{Oe as default};
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.