al-quran.reflectslight.io/build/al-quran/js/loaders/surah-stream-loader.js

1 line
3.3 KiB
JavaScript
Raw Normal View History

2024-09-30 20:53:21 +02:00
(()=>{"use strict";const e=(e,t)=>({priority:1,group:"fonts",requestId:"font",href:t,fontFamily:e}),t=(e,t)=>({priority:4,group:"scripts",requestId:"script",href:e,props:t}),r=(e,t)=>({priority:5,group:"json",requestId:"json",href:e,props:t}),n=e=>e,o={font(e){const{fontFamily:t,href:r}=e;return new FontFace(t,r).load()},script(e,t={}){const{href:r}=e;return fetch(r,t).then((e=>e.text())).then((t=>({type:"application/javascript",text:t,...e.props}))).then((e=>Object.assign(document.createElement("script"),e)))},css(e,t={}){const{href:r}=e;return fetch(r,t).then((e=>e.text())).then((e=>({innerText:e}))).then((e=>Object.assign(document.createElement("style"),e)))},image(e){const{href:t}=e;return new Promise(((e,r)=>{const n=document.createElement("img");n.onload=()=>e(n),n.onerror=r,n.src=t}))},json(e,t={}){const{href:r}=e;return fetch(r,t).then((e=>e.text())).then((e=>({type:"application/json",text:e}))).then((t=>Object.assign(t,e.props||{}))).then((e=>Object.assign(document.createElement("script"),e)))}};var s=Object.defineProperty,a=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,u=(e,t,r)=>t in e?s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;!function(){const s=document.documentElement,l=s.querySelector("meta[name='revision']").getAttribute("content"),{surahId:f}=document.querySelector(".root").dataset,p={name:s.lang,direction:s.dir,displayName:""},m=s.querySelector(".postman.loader"),h=s.querySelector(".css.postman"),d=m.querySelector("progress"),y=m.querySelector(".percentage"),g="rtl"===s.dir?[e("Cairo Regular","url(/fonts/cairo-regular.ttf)"),e("Cairo Bold","url(/fonts/cairo-bold.ttf)"),e("Amiri Quran Regular","url(/fonts/amiri-quran-regular.ttf)")]:[e("Kanit Regular","url(/fonts/kanit-regular.ttf)")];(function(...e){const t=Object.create(null),r={fonts:[],images:[],css:[],scripts:[],json:[]},[n,s]=function(e){const t=[];let r=e=>e;return e.forEach((e=>{"function"==typeof e?r=e:t.push(e)})),[t,r]}(e);n.sort(((e,t)=>e.priority>=t.priority?1:-1));let a=0;const c=e=>(a++,a<=n.length&&s(a/n.length*100),e);return t.fetch=async()=>(await Promise.all((()=>{const e=n.map((e=>{if("fontFamily"in e)return(0,o.font)(e).then((e=>c(e))).then((e=>r.fonts.push(e))).then((()=>r));if("font"!==e.requestId&&"fonts"!==e.group){const t=o[e.requestId],n=r[e.group];return t(e).then((e=>c(e))).then((e=>n.push(e))).then((()=>r))}return null}));return e})()),r),t})(t(`/js/main/vendor.js?v=${l}`,{id:"0"}),t(`/js/main/surah-stream.js?v=${l}`,{id:"1"}),...g,r(`/json/${s.lang}/${f}/info.json?v=${l}`,{className:"json surahinfo"}),r(`/json/${s.lang}/${f}/surah.json?v=${l}`,{className:"json surah"}),r(`/json/durations/${f}.json?v=${l}`,{className:"json durations"}),n((e=>{d.value=e,y.innerText=function(e,t,r={}){const n="ar"===e.name?"ar-SA":e.name;return new Intl.NumberFormat(n,((e,t)=>{for(var r in t||(t={}))c.call(t,r)&&u(e,r,t[r]);if(a)for(var r of a(t))i.call(t,r)&&u(e,r,t[r]);return e})({maximumFractionDigits:1},r)).format(t)}(p,Number(e.toFixed(0)))}))).fetch().then((e=>{[m,h].forEach((e=>e.remove())),e.fonts.forEach((e=>document.fonts.add(e))),e.css.forEach((e=>document.head.appendChild(e))),e.json.forEach((e=>document.body.appendChild(e))),e.scripts.sort(((e,t)=>Number(e.id)-Number(t.id))).forEach((e=>{document.body.removeChild(document.body.appendChild(e))}))}))}()})();