import{a as p}from"./chunk-EF43U47C.js";import{Cb as O,Fb as F,Gb as E,Hb as S,Lb as v,Mb as w,Nb as L,Ob as P,Pb as U,b as C}from"./chunk-RISKGE32.js";import{I as h,ba as q,ca as m,p as y}from"./chunk-6O6MLDWR.js";import{d as _,g as s,n}from"./chunk-CLPINNGF.js";n();s();var M=_(q());n();s();n();s();var H={},N=H;var l=m(O(()=>({})));async function z(){let t=await E(F()),o=Object.values(h).reduce((e,i)=>{let a=t.features?.find(u=>u.name===i);return e[i]={status:a&&(a.lifecycles??[]).length>0?"active":"inactive",config:a?.config||{},lifecycles:a?.lifecycles||[]},e},{});t.parser&&(o["standard-player"].config=t.parser??{}),S.debug("Initializing config store with state",o),l.setState(o,!0);let r=Object.values(N).map(e=>v(e));return()=>{l.setState({},!0),r.forEach(e=>e())}}var b=[["config",z,l],["featureflags",L,w],["user",U,P]],c=m(()=>({}));async function K(){return Promise.all(b.map(([,t])=>t()))}var W=C(1);function Y(){let t={};for(let[e,,i]of b)t[e]=i.getState();let o=new Set;for(let e of Object.values(t))Object.keys(e||{}).forEach(i=>o.add(i));let r=Array.from(o).reduce((e,i)=>{let a=i,u={},d="active",g=[];for(let[T,I]of Object.entries(t)){let f=I[a];u[T]=f?.config??{},d=f?.status??d,g=f?.lifecycles?.length?f?.lifecycles:g}return e[a]={status:d,config:u,lifecycles:Array.from(new Set(g))},e},{});S.debug("Updating combined state",r),c.setState(r)}var R=()=>W(Y);function k(){let t=[],o=(0,M.default)(R,500);return b.forEach(([,,r])=>{let e=r.subscribe(o);t.push(e)}),()=>{t.forEach(r=>r())}}function D(){return c.getState()}function B(t){let o=p(D());return c.subscribe(()=>{let r=D(),e=Object.keys(r).reduce((i,a)=>(y(r[a],o[a])||(i[a]=r[a]),i),{});t(r,e),o=p(r)})}async function pt(){let t=await K();R();let o=k();return()=>{o(),t.map(r=>r()),c.setState({},!0)}}var bt={useConfig:c},yt=async()=>{await new Promise(t=>{let o=B(()=>{t(),o()})})};export{D as a,B as b,pt as c,bt as d,yt as e};
//# sourceMappingURL=chunk-56NWWOIX.js.map
