{"version":3,"sources":["webpack://fair-labour/./assets/project/script-loader/script-loader.js"],"names":["ScriptLoader","src","flag","_classCallCheck","this","isLoaded","isLoading","callbacks","key","value","_this","script","document","createElement","async","defer","onload","setTimeout","setLoaded","timer","window","setInterval","clearInterval","body","appendChild","forEach","cb","load","push"],"mappings":"6bACMA,EAAY,WACd,SAAAA,EAAYC,EAAKC,I,4FAAMC,CAAA,KAAAH,GACnBI,KAAKC,UAAW,EAChBD,KAAKE,WAAY,EACjBF,KAAKG,UAAY,GACjBH,KAAKH,IAAMA,EACXG,KAAKF,KAAOA,CAChB,C,QAsCC,O,EAtCAF,G,EAAA,EAAAQ,IAAA,OAAAC,MAED,WAAQ,IAAAC,EAAA,KACJ,IAAKN,KAAKE,YAAcF,KAAKC,SAAU,CACnCD,KAAKE,WAAY,EACjB,IAAMK,EAASC,SAASC,cAAc,UACtCF,EAAOG,OAAQ,EACfH,EAAOI,OAAQ,EACfJ,EAAOV,IAAMG,KAAKH,IAClBU,EAAOK,OAAS,WACZ,GAAkB,OAAdN,EAAKR,KACLe,WAAWP,EAAKQ,UAAW,UAE3B,IAAMC,EAAQC,OAAOC,aAAY,WACzBX,EAAKR,OACLkB,OAAOE,cAAcH,GACrBT,EAAKQ,YAEb,GAAG,GAEX,EACAN,SAASW,KAAKC,YAAYb,EAC9B,CACJ,GAAC,CAAAH,IAAA,YAAAC,MAED,WACIL,KAAKC,UAAW,EAChBD,KAAKE,WAAY,EACjBF,KAAKG,UAAUkB,SAAQ,SAACC,GAAE,OAAKA,GAAI,GACvC,GAAC,CAAAlB,IAAA,UAAAC,MAED,SAAQiB,GACCtB,KAAKE,WAAcF,KAAKC,UAAUD,KAAKuB,OACxCvB,KAAKC,SACLqB,IAEAtB,KAAKG,UAAUqB,KAAKF,EAE5B,M,ufAAC1B,CAAA,CA7Ca,GAgDlB,K","file":"6335.7a7999136d74437b10e7.js","sourcesContent":["\nclass ScriptLoader {\n constructor(src, flag) {\n this.isLoaded = false;\n this.isLoading = false;\n this.callbacks = [];\n this.src = src;\n this.flag = flag;\n }\n\n load () {\n if (!this.isLoading && !this.isLoaded) {\n this.isLoading = true;\n const script = document.createElement('script');\n script.async = true;\n script.defer = true;\n script.src = this.src;\n script.onload = () => {\n if (this.flag === null) {\n setTimeout(this.setLoaded, 150);\n } else {\n const timer = window.setInterval(() => {\n if (this.flag) {\n window.clearInterval(timer);\n this.setLoaded();\n }\n }, 10);\n }\n };\n document.body.appendChild(script);\n }\n };\n\n setLoaded () {\n this.isLoaded = true;\n this.isLoading = false;\n this.callbacks.forEach((cb) => cb());\n };\n\n onReady(cb) {\n if (!this.isLoading && !this.isLoaded) this.load();\n if (this.isLoaded) {\n cb();\n } else {\n this.callbacks.push(cb);\n }\n };\n\n};\nexport default ScriptLoader;\n"],"sourceRoot":""}