"use strict";var n=require("@babel/runtime/helpers/slicedToArray"),e=require("react"),t=require("../utils/devcenter.js");function o(n){return n&&"object"==typeof n&&"default"in n?n:{default:n}}var i=o(n),r={},u={};module.exports=function(n){var o,p=n.CLIAppComponent,l=n.CLIAppSettings,c=n.app,a=n.version,s=c.app.app_key,d=process.env.REACT_APP_DEBUG_DC_APP_KEY===s,f=d?"http://127.0.0.1:3000/app.js":null==c||null===(o=c.package)||void 0===o?void 0:o.url,v=t.getAppIdentifier({appKey:s,version:a,isLocalDebugMode:d}),m=e.useState(!1),A=i.default(m,2),g=A[0],C=A[1],E=r[v],b=p||(null==E?void 0:E.component)||null,_=l||(null==E?void 0:E.settings)||null,h=function(){C(!1),(u[v]||[]).forEach((function(n){return n()})),delete u[v]};return e.useEffect((function(){v in u&&(C(!0),u[v].push((function(){C(!1)})))}),[]),e.useEffect((function(){if(!(!f||!v||b&&_||v in u)){if(!p&&!E||null!=E&&E.component){if(C(!0),!E||!E.script){var n=document.createElement("script");n.src=f,n.onload=function(){r[v]=window[v]&&window[v].default,h()},r[v]={component:null,script:n},setTimeout((function(){return document.body.appendChild(n)}))}var e=r[v].script;if(e.onload){var t=e.onload;e.onload=function(){t(),h()}}e.onabort=h,e.error=h}u[v]=[function(){return C(!1)}]}}),[f]),{isLoading:g,AppComponent:b,AppSettings:_}};
