al-quran.reflectslight.io/build/al-quran/js/loaders/surah-stream-loader.js
2024-10-02 21:01:13 -03:00

1 line
No EOL
3.5 KiB
JavaScript

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