(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[67314],{21572:function(e,n,r){"use strict";var t,a=r(67597);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var n=1;n0&&void 0!==n[0])||n[0])||_?(Ne(x.current)&&(x.current.send(JSON.stringify(Ce)),e&&x.current.close()),j(),y&&y.current.disconnect(),E&&E.current.disconnect(),b&&b.current.disconnect(),"running"!==N.current.state?[3,2]:[4,N.current.close()]):[2];case 1:r.sent(),r.label=2;case 2:return[2]}}))})),[j,_]),T=(0,l.useCallback)((function(e){var n=JSON.parse(e.data),r=n.event,t=n.data;switch(r){case pe.SEARCH_LOADING:o(!0);break;case pe.SEARCH_RESULT:var a;o(!1),p(t),(null===(a=t.matches)||void 0===a?void 0:a.length)||(0,k.Dy)({query:t.queryText,source:re.Z.Tarteel,type:fe.Z.Voice,service:ne.Z.Tarteel}),S();break;case pe.PARTIAL_TRANSCRIPT:o(!1),v(t.queryText);break;case pe.ERROR:o(!1),(0,k.Kz)("tarteel_error",{error:r}),d(F.RESPONSE_ERROR)}}),[S]),Z=(0,l.useCallback)((0,me.Z)((function(){return(0,_e.__generator)(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,N.current.audioWorklet.addModule(new ve(r.tu(new URL(r.p+r.u(14368),r.b))))];case 1:return e.sent(),(0,k.Kz)("tarteel_websocket_initialize"),o(!0),x.current=new WebSocket("wss://voice-v2.tarteel.io/search/?Authorization=".concat(ge.env.NEXT_PUBLIC_TARTEEL_VS_API_KEY)),x.current.onopen=function(){(0,k.Kz)("tarteel_websocket_open"),o(!1),y.current=N.current.createAnalyser(),y.current.smoothingTimeConstant=.8,y.current.fftSize=1024;var e=new Uint8Array(y.current.frequencyBinCount);E.current=new AudioWorkletNode(N.current,"MicInputProcessor"),x.current.send(JSON.stringify(xe)),b.current.connect(y.current),y.current.connect(E.current),E.current.connect(N.current.destination),E.current.port.onmessage=function(n){t(function(e,n){e.getByteFrequencyData(n);for(var r=0,t=n.length,a=0;a100?100:i}(y.current,e)),Ne(x.current)&&x.current.send(n.data)}},x.current.onmessage=function(e){T(e)},x.current.onerror=function(){(0,k.Kz)("tarteel_websocket_error"),o(!1),d(F.SOCKET_ERROR),j()},[3,3];case 2:return e.sent(),(0,k.Kz)("voice_search_worklet_error"),d(F.WORKLET_ERROR),[3,3];case 3:return[2]}}))})),[T,j]),O=(0,l.useCallback)((0,me.Z)((function(){var e,n,r;return(0,_e.__generator)(this,(function(t){switch(t.label){case 0:d(null),v(null),p(null),C(!0),N.current=new window.AudioContext({sampleRate:Re.sampleRate}),t.label=1;case 1:return t.trys.push([1,4,5,6]),[4,navigator.mediaDevices.getUserMedia({audio:ye})];case 2:e=t.sent(),a.current=e;try{b.current=N.current.createMediaStreamSource(e)}catch(i){throw(0,k.Kz)("voice_search_create_media_stream_error"),S(),new Error(Ee)}return[4,Z()];case 3:return t.sent(),[3,6];case 4:return(n=t.sent()).message===Ee?((0,k.Kz)("voice_search_not_supported"),d(F.NOT_SUPPORTED)):((r="NotAllowedError"===n.name)&&(0,k.Kz)("voice_search_permission_denied"),d(r?F.NO_PERMISSION:F.GENERAL_ERROR)),[3,6];case 5:return C(!1),[7];case 6:return[2]}}))})),[S,Z]);return{isLoading:s,error:u,partialTranscript:_,searchResult:f,volume:n,isWaitingForPermission:R,startRecording:O,stopRecording:S}},je=function(e){var n,r=e.isCommandBar,t=void 0!==r&&r,a=be(),s=a.isLoading,o=a.partialTranscript,c=a.searchResult,d=a.error,_=a.volume,v=a.isWaitingForPermission,h=a.startRecording,f=a.stopRecording;(0,l.useEffect)((function(){return h(),function(){f()}}),[]);var p,g;return s?(0,u.jsx)(de.Z,{size:de.E.Large}):d||v?(0,u.jsx)("div",{className:m()((0,i.Z)({},ue().container,!t)),children:(0,u.jsx)(V,{isCommandBar:t,error:d,isWaitingForPermission:v})}):c&&!(null===(n=c.matches)||void 0===n?void 0:n.length)?(0,u.jsx)("div",{className:m()((p={},(0,i.Z)(p,ue().container,!t),(0,i.Z)(p,ue().noResultContainer,t),p)),children:(0,u.jsx)(le.Z,{searchQuery:o})}):(0,u.jsx)(u.Fragment,{children:c?(0,u.jsx)(oe,{searchResult:c,isCommandBar:t}):(0,u.jsx)("div",{className:m()((g={},(0,i.Z)(g,ue().container,!t),(0,i.Z)(g,ue().commandBarContainer,t),g)),children:(0,u.jsx)(X,{verticalLayout:!t,partialTranscript:o,volume:_,stopRecording:function(){f(!1)}})})})},Se=r(62076),Te=r(42366),Ze=r(17678),Oe=[{name:"Juz 1",key:1,resultType:T.H.JUZ},{name:"Hizb 1",key:1,resultType:T.H.HIZB},{name:"Rub el Hizb 1",key:1,resultType:T.H.RUB_EL_HIZB},{name:"Page 1",key:1,resultType:T.H.PAGE},{name:"Surah Yasin",key:36,resultType:T.H.SURAH},{name:"2:255",key:"2:255",resultType:T.H.AYAH}],we=function(){var e=(0,h.Z)("common").t,n=(0,f.v9)(w.cl,ae.Hj),r=(0,f.v9)(Ze.ID,f.wU),t=(0,l.useState)(null),a=t[0],d=t[1],_=(0,Se.Z)(a,1500);(0,l.useEffect)((function(){_&&(0,k.tL)(_,re.Z.CommandBar)}),[_]);var p=(0,l.useCallback)((function(e){d(e.currentTarget.value||null)}),[]),g=(0,l.useCallback)((function(){return n.map((function(n){return(0,o.Z)((0,s.Z)({},n),{group:e("command-bar.recent-navigations"),isClearable:!0})})).concat(Oe.map((function(n){return(0,o.Z)((0,s.Z)({},n),{group:e("command-bar.try-navigating"),isClearable:!1})})))}),[n,e]),R=(0,l.useCallback)((function(r){var t=[],i=0;return r?(t=(0,c.Z)(r.result.navigation.map((function(n){return(0,o.Z)((0,s.Z)({},n),{group:e("command-bar.navigations")})}))).concat([{key:a,resultType:T.H.SEARCH_PAGE,name:a,group:e("search.title")}]),i=r.result.navigation.length+1):(t=g(),i=n.length+Oe.length),(0,u.jsx)(A,{commandGroups:{groups:v()(t.map((function(e,n){return(0,o.Z)((0,s.Z)({},e),{index:n})})),(function(e){return e.group})),numberOfCommands:i}})}),[g,n.length,a,e]);return(0,u.jsxs)("div",{className:B().container,children:[(0,u.jsx)("div",{className:m()(B().inputContainer,(0,i.Z)({},B().voiceFlowContainer,r)),children:!r&&(0,u.jsxs)("div",{className:B().textInputContainer,children:[(0,u.jsx)(Te.Z,{}),(0,u.jsx)("input",{onChange:p,placeholder:e("command-bar.placeholder"),className:B().input,type:"text",inputMode:"text",autoFocus:!0})]})}),(0,u.jsx)("div",{className:B().bodyContainer,children:r?(0,u.jsx)(je,{isCommandBar:!0}):(0,u.jsx)(H.Z,{queryKey:a?(0,te.do)({query:a}):null,render:R})})]})}},99807:function(e,n,r){"use strict";var t=r(57611),a=(r(67597),r(61395)),i=r(36773),s=r.n(i),o=r(42366);n.Z=function(e){var n=e.searchQuery,r=(0,a.Z)("common").t;return(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("div",{className:s().container,children:(0,t.jsxs)("div",{className:s().mainBody,children:[(0,t.jsx)("div",{className:s().iconContainer,children:(0,t.jsx)(o.Z,{})}),(0,t.jsx)("p",{className:s().mainMessage,children:r("search.no-results")}),(0,t.jsx)("p",{className:s().secondaryMessage,children:r("search.no-results-suggestion",{searchQuery:n})})]})})})}},17580:function(e,n,r){"use strict";var t=r(57611),a=r(67597),i=r(61395),s=r(77684),o=r.n(s),c=r(57830),u=r(18636),l=r(15104),d=r(61388),m=r(22582),_=r(12195),v=r(43609),h=r(84020),f=r(69640);n.Z=function(e){var n,r=e.result,s=e.source,p=e.service,g=void 0===p?d.Z.QDC:p,R=(0,i.Z)("quran-reader").lang,C=(0,a.useMemo)((function(){return(0,v.Tj)(r.verseKey,R)}),[R,r.verseKey]),x=(0,l.Z)(R);if(!x)return null;var y=(0,f.Tc)(r.verseKey),E=(0,m.dy)(x,y.toString());return(0,t.jsx)("div",{className:o().container,children:(0,t.jsxs)("div",{className:o().itemContainer,children:[(0,t.jsxs)(c.Z,{className:o().verseKey,href:(0,h.P6)(r.verseKey),onClick:function(){(0,_.MY)("search_result_item",{service:g,source:s})},children:[E.transliteratedName," ",C]}),(0,t.jsx)("div",{className:o().quranTextContainer,children:(0,t.jsx)("div",{className:o().quranTextResult,translate:"no",children:r.words.map((function(e,n){return(0,t.jsx)(u.Z,{isHighlighted:!!e.highlight,word:e,isWordByWordAllowed:!1,isAudioHighlightingAllowed:!1},"".concat(r.verseKey,":").concat(n+1))}))})}),null===(n=r.translations)||void 0===n?void 0:n.map((function(e){return(0,t.jsxs)("div",{className:o().translationContainer,children:[(0,t.jsx)("div",{dangerouslySetInnerHTML:{__html:e.text}}),(0,t.jsxs)("p",{className:o().translationName,children:[" - ",e.resourceName]})]},e.resourceId)}))]})})}},81858:function(e,n,r){"use strict";r.d(n,{Oz:function(){return a},gZ:function(){return s},lT:function(){return o},nv:function(){return i}});var t=r(67597),a=function(e){var n=(0,t.useRef)(null);return[function(){n.current&&n.current.scrollIntoView(e)},n]},i={block:"center",behavior:"smooth"},s={block:"start",behavior:"smooth"},o={block:"nearest"};n.ZP=a},48842:function(e,n,r){"use strict";r.d(n,{Nl:function(){return i},aS:function(){return t},ox:function(){return a}});var t=function(e,n){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...",t=e.split("",n),a="",i=0;i]+)>)/gi,"")},i=function(e){if(!e)return"";var n=e.split("-");return 1===n.length?n[0]:n[n.length-1]}},67534:function(e){e.exports={container:"CommandBarBody_container__s5HGd",textInputContainer:"CommandBarBody_textInputContainer__nA99M",input:"CommandBarBody_input__EiX78",inputContainer:"CommandBarBody_inputContainer__mYwbs",voiceFlowContainer:"CommandBarBody_voiceFlowContainer__FlqZy",bodyContainer:"CommandBarBody_bodyContainer__R267m",attribution:"CommandBarBody_attribution__8GTI0"}},51805:function(e){e.exports={noResult:"CommandList_noResult__oTg7n",groupHeader:"CommandList_groupHeader___yWaG",command:"CommandList_command__BB_Gf",selected:"CommandList_selected__rVGLj",highlight:"CommandList_highlight__1HwZs",keyboardInputContainer:"CommandList_keyboardInputContainer__9XbOW"}},78831:function(e){e.exports={commandPrefix:"CommandPrefix_commandPrefix__MOHuk",container:"CommandPrefix_container__xqFc2",name:"CommandPrefix_name__P_IKZ"}},36773:function(e){e.exports={container:"NoResults_container__I2jHF",mainBody:"NoResults_mainBody__GC8l_",iconContainer:"NoResults_iconContainer__ks7uY",mainMessage:"NoResults_mainMessage__o3ksN",secondaryMessage:"NoResults_secondaryMessage__CNI0d"}},77684:function(e){e.exports={translationName:"SearchResultItem_translationName__5mkDi",translationContainer:"SearchResultItem_translationContainer__OaPZE",container:"SearchResultItem_container__Cvqx0",itemContainer:"SearchResultItem_itemContainer__NRd1r",quranTextResult:"SearchResultItem_quranTextResult__texyH",verseKey:"SearchResultItem_verseKey__dyumW"}},82531:function(e){e.exports={container:"Error_container__yeY3V"}},37646:function(e){e.exports={outerContainer:"PartialResult_outerContainer__AcDv0",innerContainer:"PartialResult_innerContainer__v1QDG",transcript:"PartialResult_transcript__Lcscd",suggestTitle:"PartialResult_suggestTitle__e8lBr",suggestSubtitle:"PartialResult_suggestSubtitle__utXHd",micCircle:"PartialResult_micCircle__ioN7o",circlesContainer:"PartialResult_circlesContainer__EWZIJ",volumeCircle:"PartialResult_volumeCircle__GvhbK",verticalLyaout:"PartialResult_verticalLyaout__XWlc6"}},49326:function(e){e.exports={container:"VoiceSearchBodyContainer_container__GpMSO",noResultContainer:"VoiceSearchBodyContainer_noResultContainer__lv_Zl",commandBarContainer:"VoiceSearchBodyContainer_commandBarContainer__U85vU"}}}]); //# sourceMappingURL=67314.f06616b99fcd8263.js.map