(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[93862],{5754:function(e,n,t){"use strict";var a,r=t(67597);function o(){return o=Object.assign?Object.assign.bind():function(e){for(var n=1;n{const{__scopeProgress:t,value:a,max:r,getValueLabel:s=_,...c}=e,d=C(r)?r:u,p=E(a,d)?a:null,m=x(p)?s(p,d):void 0;return(0,i.createElement)(g,{scope:t,value:p,max:d},(0,i.createElement)(l.WV.div,(0,o.Z)({"aria-valuemax":d,"aria-valuemin":0,"aria-valuenow":x(p)?p:void 0,"aria-valuetext":m,role:"progressbar","data-state":h(p,d),"data-value":null!==p&&void 0!==p?p:void 0,"data-max":d},c,{ref:n})))}));v.propTypes={max(e,n,t){const a=e[n],r=String(a);return a&&!C(a)?new Error(function(e,n){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${n}\`. Only numbers greater than 0 are valid max values. Defaulting to \`100\`.`}(r,t)):null},value(e,n,t){const a=e[n],r=String(a),o=C(e.max)?e.max:u;return null==a||E(a,o)?null:new Error(function(e,n){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${n}\`. The \`value\` prop must be:\n - a positive number\n - less than the value passed to \`max\` (or 100 if no \`max\` prop is set)\n - \`null\` if the progress is indeterminate.\n\nDefaulting to \`null\`.`}(r,t))}};const f="ProgressIndicator",y=(0,i.forwardRef)(((e,n)=>{var t;const{__scopeProgress:a,...r}=e,s=m(f,a);return(0,i.createElement)(l.WV.div,(0,o.Z)({"data-state":h(s.value,s.max),"data-value":null!==(t=s.value)&&void 0!==t?t:void 0,"data-max":s.max},r,{ref:n}))}));function _(e,n){return`${Math.round(e/n*100)}%`}function h(e,n){return null==e?"indeterminate":e===n?"complete":"loading"}function x(e){return"number"===typeof e}function C(e){return x(e)&&!isNaN(e)&&e>0}function E(e,n){return x(e)&&!isNaN(e)&&e<=n&&e>=0}const j=v,N=y;var Z,w=t(37014),b=t.n(w),k=t(75302),S=t.n(k);!function(e){e.Small="small",e.Medium="medium",e.Large="large"}(Z||(Z={}));var P=function(e){var n,t=e.value,o=e.rootStyles,i=e.size,s=void 0===i?Z.Small:i,l=e.indicatorStyles,c=b()(S().progressRoot,(n={},(0,a.Z)(n,S().progressSmall,s===Z.Small),(0,a.Z)(n,S().progressMedium,s===Z.Medium),(0,a.Z)(n,S().progressLarge,s===Z.Large),n),o);return(0,r.jsx)(j,{className:c,value:t,children:(0,r.jsx)(N,{className:b()(S().progressIndicator,l),style:{transform:"translateX(-".concat(100-t,"%)")}})})}},83548:function(e,n,t){"use strict";t.d(n,{Z:function(){return h}});var a,r=t(57044),o=t(16946),i=t(67597),s=t(61395),l=t(648),c=t(99968),u=t(5330);!function(e){e.QURAN="QURAN"}(a||(a={}));var d=t(15721),p=t(9740),g=t(37572),m=t(19226),v=t(85149),f=t(43609),y=function(){return(0,i.useMemo)((function(){var e=[],n=new Date,t=new Date(n);0!==n.getDay()&&t.setDate(n.getDate()-n.getDay());for(var a=0;a<7;a+=1){var r=new Date(t);r.setDate(t.getDate()+a),e.push({current:r.getDate()===n.getDate(),date:r,dateString:(0,v.Bz)(r)})}return e}),[])},_=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=(0,s.Z)("reading-goal"),r=a.t,o=a.lang;return(0,i.useMemo)((function(){var a=[],i=n>1,s=0;!t&&i&&e.forEach((function(e,t){e.current&&(i=n>t+1,s=t)}));for(var l=0;l<7;l+=1){var c=void 0;if(t)c={localizedNumber:(0,f.rQ)(l+1,o),title:(0,v.Zu)(e[l].date,o)};else{var u=(0,f.rQ)(i?n-s+l:l+1,o);c={localizedNumber:u,title:r("day-x",{day:u})}}a.push(c)}return a}),[o,t,n,r,e])},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.showDayName,t=e.disableIfNoGoalExists,s=y(),v=(0,l.v9)(u.Ho,l.wU),f=(0,l.v9)(u.z$,l.wU),h=(0,d.$P)(v,f).mushaf,x=(0,i.useState)(null),C=x[0],E=x[1],j={mushafId:h,from:s[0].dateString,to:s[s.length-1].dateString,type:a.QURAN},N=(0,c.ZP)((0,m.jl)()&&!0!==C?(0,g.G_)():null,(function(){return(0,p.DG)(j)}),{revalidateOnFocus:!1}),Z=N.data,w=N.isValidating,b=N.error;(0,i.useEffect)((function(){null===C&&t&&Z&&E(!Z.data.goal)}),[t,C,Z]);var k=w&&!Z,S=(null===Z||void 0===Z?void 0:Z.data)||{activityDays:[],goal:void 0,streak:0},P=S.activityDays,T=S.goal,R=S.streak,A=(0,i.useMemo)((function(){if(!P)return{};var e={};return P.forEach((function(n){e[n.date]=(0,o.Z)((0,r.Z)({},n),{hasRead:n.pagesRead>0||n.secondsRead>0||n.ranges.length>0||n.manuallyAddedSeconds>0})})),e}),[P]),G=(0,i.useMemo)((function(){var e;return A[null===(e=s.find((function(e){return e.current})))||void 0===e?void 0:e.dateString]}),[A,s]),M=_(s,R,n),D=(0,i.useMemo)((function(){return{days:s.map((function(e,n){return(0,o.Z)((0,r.Z)({},e),{info:M[n]})})),readingDaysMap:A}}),[s,M,A]);return{isLoading:k,error:b,weekData:D,streak:R,goal:T,activityDays:P,currentActivityDay:G}}},40235:function(e,n,t){"use strict";t.r(n),t.d(n,{__N_SSG:function(){return Pe},default:function(){return Te}});var a,r=t(57611),o=t(67597),i=t(37014),s=t.n(i),l=t(15129),c=t(61395),u=t(86719),d=t.n(u),p=t(96771),g=t.n(p),m=t(98038),v=t(21648),f=t(1997),y=t(57044),_=t(69976),h=t(51726),x=t(99968),C=t(16946),E=t(30098);function j(){return j=Object.assign?Object.assign.bind():function(e){for(var n=1;n6&&n.period===R.r_.Continuous&&a>5;return(0,r.jsx)("li",{className:s()(L().dayPreview,c&&L().lastDay),children:c?(0,r.jsx)("h3",{children:i("plus-x-more-days",{count:n.duration-6,days:(0,pe.rQ)(n.duration-6,l)})}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(oe.default,{content:(0,de.ZC)(o,l),children:(0,r.jsx)("h3",{children:(0,de.Zu)(o,l)})}),(0,r.jsx)("p",{children:v(t,a)})]})},e.date)}))})}}),t]})]})},fe=t(12195);!function(e){e.ExamplesTab="examples",e.ContinuityTab="continuity",e.TypeTab="type",e.AmountTab="amount",e.PreviewTab="preview"}(S||(S={}));var ye=(P={},(0,O.Z)(P,S.ExamplesTab,Q),(0,O.Z)(P,S.ContinuityTab,q),(0,O.Z)(P,S.TypeTab,J),(0,O.Z)(P,S.AmountTab,H),(0,O.Z)(P,S.PreviewTab,ve),P),_e=Object.keys(ye).map((function(e){return{key:e,Component:ye[e]}})),he=function(e,n,t){(0,fe.MY)("create_goal_".concat(e,"_tab_").concat(n),t)},xe=t(23998),Ce=t(85494),Ee=t(66498),je=t(85609),Ne=t(75038),Ze=t(89932),we=t(4845),be=function(){var e=(0,c.Z)("reading-goal").t,n=(0,l.useRouter)(),t=(0,o.useContext)(re.Z),a=(0,Ne.Z)(),i=(0,o.useState)(!1),u=i[0],p=i[1],g=(0,o.useState)(0),m=g[0],v=g[1],C=(0,_.Z)(D(),2),E=C[0],j=C[1],N=(0,je.useToast)(),Z=(0,x.kY)().cache,w=(0,o.useCallback)(function(){var e=(0,f.Z)((function(e){return(0,h.__generator)(this,(function(n){switch(n.label){case 0:return[4,(0,le.Ec)(e).then((function(){Z.delete((0,ce.G_)())}))];case 1:return n.sent(),[2]}}))}));return function(n){return e.apply(this,arguments)}}(),[Z]),b=_e[m],k=function(){var t=(0,f.Z)((function(){var t,r;return(0,h.__generator)(this,(function(o){switch(o.label){case 0:t=E.type===R.lC.PAGES?E.pages:E.type===R.lC.TIME?E.seconds:"".concat(E.rangeStartVerse,"-").concat(E.rangeEndVerse),r={mushafId:a,type:E.type,amount:t,category:R.c9.QURAN},E.period===R.r_.Continuous&&(r.duration=E.duration),(0,fe.dz)("create_goal",(0,y.Z)({duration:null},r)),p(!0),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,w(r)];case 2:return o.sent(),N(e("set-reading-goal-success"),{status:je.ToastStatus.Success}),n.push("/"),[3,4];case 3:return o.sent(),N(e("common:error.general"),{status:je.ToastStatus.Error}),[3,4];case 4:return p(!1),[2]}}))}));return function(){return t.apply(this,arguments)}}(),P=b.key===S.PreviewTab,T=P?100:m/_e.length*100;return(0,r.jsxs)("div",{className:s()(d().flowItem),children:[(0,r.jsx)(Ee.Z,{value:T}),(0,r.jsx)("div",{className:L().tabContainer,children:u?(0,r.jsx)(te.Z,{isCentered:!0,size:te.E.Large}):(0,r.jsx)(b.Component,{onTabChange:v,state:E,dispatch:j,logClick:function(e){he(b.key,e)},logChange:function(e,n,t){!function(e,n,t,a){(0,fe.Q8)("create_goal_".concat(e,"_tab_").concat(n),t.currentValue,t.newValue,a)}(b.key,e,n,t)},nav:(0,r.jsxs)("div",{className:L().navigationContainer,children:[m>0&&(0,r.jsx)(Ce.ZP,{className:L().navigateButton,size:Ce.qE.Large,prefix:(0,r.jsx)(Ze.Z,{}),onClick:function(){0!==m&&"custom"!==E.exampleKey?(v(0),he(b.key,"previous")):(v((function(e){return e-1})),he(b.key,"previous"))},type:Ce.L$.Secondary,children:e("common:prev")}),(0,r.jsx)(Ce.ZP,{className:L().navigateButton,size:Ce.qE.Large,suffix:P?void 0:(0,r.jsx)(we.Z,{}),isDisabled:b.key===S.ExamplesTab&&!E.exampleKey||b.key===S.AmountTab&&!(0,xe.w)(t,{type:E.type,pages:E.pages,seconds:E.seconds,range:{startVerse:E.rangeStartVerse,endVerse:E.rangeEndVerse}},a),onClick:function(){P?k():(0===m&&"custom"!==E.exampleKey?v(_e.length-1):v((function(e){return e+1})),function(e,n){var t;e===S.ExamplesTab?t={example:n.exampleKey}:e===S.TypeTab?t={goal_type:n.type}:e===S.AmountTab?t={pages:n.type===R.lC.PAGES?n.pages:null,seconds:n.type===R.lC.TIME?n.seconds:null,range:n.type===R.lC.RANGE?"".concat(n.rangeStartVerse,"-").concat(n.rangeEndVerse):null,duration:n.period===R.r_.Continuous?n.duration:null}:e===S.ContinuityTab&&(t={goal_period:n.period}),he(e,"next",t)}(b.key,E))},children:e(P?"start-journey":"common:next")})]})})})]})},ke=t(83548),Se=t(84020),Pe=!0,Te=(0,m.Z)((function(){var e=(0,c.Z)("reading-goal"),n=e.t,t=e.lang,a=(0,l.useRouter)(),i=(0,ke.Z)(),u=i.goal,p=i.isLoading||!a.isReady||!!u;return(0,o.useEffect)((function(){u&&a.push("/")}),[a,u]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.Z,{title:n("reading-goal"),url:(0,Se.Z2)(t,(0,Se.we)()),languageAlternates:(0,pe.qc)((0,Se.we)()),nofollow:!0,noindex:!0}),(0,r.jsx)("div",{className:d().pageContainer,children:(0,r.jsx)("div",{className:s()(d().flow,p&&g().loadingContainer),children:p?(0,r.jsx)(te.Z,{}):(0,r.jsx)(be,{})})})]})}))},36685:function(e,n,t){"use strict";var a,r,o;t.d(n,{EQ:function(){return r},JF:function(){return o},Nk:function(){return a}}),function(e){e.From="from",e.To="to"}(a||(a={})),function(e){e.Start="start",e.End="end"}(r||(r={})),function(e){e.StartingChapter="starting-chapter",e.StartingVerse="starting-verse",e.EndingChapter="ending-chapter",e.EndingVerse="ending-verse"}(o||(o={}))},47898:function(e,n,t){"use strict";var a,r,o;t.d(n,{c9:function(){return a},lC:function(){return r},r_:function(){return o}}),function(e){e.QURAN="QURAN"}(a||(a={})),function(e){e.TIME="QURAN_TIME",e.PAGES="QURAN_PAGES",e.RANGE="QURAN_RANGE"}(r||(r={})),function(e){e.Daily="DAILY",e.Continuous="CONTINUOUS"}(o||(o={}))},17453:function(e){e.exports={icon:"OptionButton_icon__w5iJa",button:"OptionButton_button__koa5L",textContainer:"OptionButton_textContainer__KGc0j",title:"OptionButton_title__fLEFm",description:"OptionButton_description__paNw7",selected:"OptionButton_selected__9vy3U",recommended:"OptionButton_recommended__sDzVm"}},27061:function(e){e.exports={tabContainer:"ReadingGoalPage_tabContainer__mzLNd",optionsContainer:"ReadingGoalPage_optionsContainer__3v9HQ",titleContainer:"ReadingGoalPage_titleContainer__A2zup",title:"ReadingGoalPage_title__s7pGO",subtitle:"ReadingGoalPage_subtitle__ljYxq",navigationContainer:"ReadingGoalPage_navigationContainer__0nY0E",previewWrapper:"ReadingGoalPage_previewWrapper__sykGt",dayPreview:"ReadingGoalPage_dayPreview__M4mrU",lastDay:"ReadingGoalPage_lastDay__ieeGh",rangePreview:"ReadingGoalPage_rangePreview__xB27p",rangeInputContainer:"ReadingGoalPage_rangeInputContainer__SkyH9",inputContainer:"ReadingGoalPage_inputContainer__RmukP",input:"ReadingGoalPage_input__T_M3H",label:"ReadingGoalPage_label__04sb1"}},75302:function(e){e.exports={progressRoot:"Progress_progressRoot__Np4He",progressSmall:"Progress_progressSmall__xl_va",progressMedium:"Progress_progressMedium__ys5Rw",progressLarge:"Progress_progressLarge__smmtV",progressIndicator:"Progress_progressIndicator__dPgS9"}},86719:function(e){e.exports={pageContainer:"index_pageContainer__Pxtn3",loadingContainer:"index_loadingContainer__WEZFc",flow:"index_flow__rCTR5",flowItem:"index_flowItem__GnXWz",additionalVerticalGap:"index_additionalVerticalGap__nzYz6",fullWidth:"index_fullWidth__1n4ux"}},96771:function(e){e.exports={loadingContainer:"reading-goal_loadingContainer__5MEZB"}}},function(e){e.O(0,[87373,13769,70303,49774,92888,40179],(function(){return n=21515,e(e.s=n);var n}));var n=e.O();_N_E=n}]); //# sourceMappingURL=reading-goal-6020e7d4ae50e444.js.map