import{r as u,j as f}from"./vendor-react-BUCujlKS.js";function $(t,s){const n=u.createContext(s),x=r=>{const{children:e,...o}=r,c=u.useMemo(()=>o,Object.values(o));return f.jsx(n.Provider,{value:c,children:e})};x.displayName=t+"Provider";function i(r){const e=u.useContext(n);if(e)return e;if(s!==void 0)return s;throw new Error(`\`${r}\` must be used within \`${t}\``)}return[x,i]}function j(t,s=[]){let n=[];function x(r,e){const o=u.createContext(e),c=n.length;n=[...n,e];const d=p=>{const{scope:m,children:v,...a}=p,S=m?.[t]?.[c]||o,h=u.useMemo(()=>a,Object.values(a));return f.jsx(S.Provider,{value:h,children:v})};d.displayName=r+"Provider";function C(p,m){const v=m?.[t]?.[c]||o,a=u.useContext(v);if(a)return a;if(e!==void 0)return e;throw new Error(`\`${p}\` must be used within \`${r}\``)}return[d,C]}const i=()=>{const r=n.map(e=>u.createContext(e));return function(o){const c=o?.[t]||r;return u.useMemo(()=>({[`__scope${t}`]:{...o,[t]:c}}),[o,c])}};return i.scopeName=t,[x,P(i,...s)]}function P(...t){const s=t[0];if(t.length===1)return s;const n=()=>{const x=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(r){const e=x.reduce((o,{useScope:c,scopeName:d})=>{const p=c(r)[`__scope${d}`];return{...o,...p}},{});return u.useMemo(()=>({[`__scope${s.scopeName}`]:e}),[e])}};return n.scopeName=s.scopeName,n}export{$ as a,j as c};
