import{X as u,j as B,al as H}from"./vendor-mui-core-CDEc-eG6.js";import{r as s}from"./vendor-react-DX7tU9aY.js";import{ah as K,ai as T,aE as X,a2 as _,as as V,c0 as Y,aB as ee,ay as te,p as se,au as oe}from"./vendor-ux-PO0jFgJf.js";import{a as o,G as ie,b as v,h as re,i as ae,g as ne}from"./vendor-hooks-Ca2cSNuD.js";import{c as A,n as ce}from"./vendor-utils-_C9URqjS.js";import{a4 as I,bk as pe}from"./index-CgSpL7jz.js";function le({blocklet:d,action:c,sourceAppPid:i,connectState:p,enableSwitchApp:t}){const r=s.use(I),l=o(()=>t===!0?!0:!(t===!1||r?.session?.user&&!["login","invite","connect-to-did-space","connect-to-did-domain"].includes(c)),[c,r?.session?.user]),h=o(()=>{if(A(i)){const a=K(d),f=T(d);if(a&&f?.appPid)return f.appPid}return i},[i,d]);return{appInfoList:o(()=>X(d).filter(a=>l?!0:A(i)?A(p.sourceAppPid)?r?.session?.user?a.sourceAppPid===r.session.user.sourceAppPid:a.sourceAppPid===h:a.sourceAppPid===p.sourceAppPid:a.sourceAppPid===i),[l,i,p.sourceAppPid,h,r?.session?.user]),autoGenerateSourceAppPid:h,canSwitchApp:l}}const j=s.createContext({isWalletWebview:!1,isMobile:!1,matchSmallScreen:!1,blocklet:null}),{Provider:ue,Consumer:Se}=j;function de({children:d,blocklet:c,masterBlocklet:i=void 0,action:p,extraParams:t={},locale:r="en",testOnlyBorderColor:l=void 0,...h}){const a=ie(),[f,W]=s.useState([]),[R,E]=s.useState(!1),[b,L]=s.useState(""),N=o(()=>new Map(f.map(e=>[e.name,e])),[f]),Z=v(e=>N.get(e)),$=re(b),G=v((e,P={})=>_(pe,e,r,"en",P)),q=s.use(I),n=ae({sourceAppPid:void 0,status:"created",autoActiveWebview:!0,deeplink:void 0,chooseMethod:"",walletMethod:"",retryConnect:ce}),J=s.useRef({cancelCount:0}),m=V(),{appInfoList:x,autoGenerateSourceAppPid:w,canSwitchApp:k}=le({blocklet:c,connectState:n,action:p,sourceAppPid:t?.sourceAppPid,enableSwitchApp:t?.forceSwitch||t?.enableSwitchApp}),U=o(()=>{try{return localStorage.getItem(Y)}catch{return""}},[]),y=s.useRef(null),C=ne(y),M=o(()=>(C?.width||0)<500,[C?.width]),g=o(()=>{if(k)return{...t,sourceAppPid:A(n.sourceAppPid)?w:n.sourceAppPid};const e=T(c)?.appPid,P=T(globalThis.blocklet)?.appPid;return q?.session?.user&&(e===P||!e)?A(t?.sourceAppPid)?{...t,sourceAppPid:q.session.user?.sourceAppPid}:t:{...t,sourceAppPid:w}},[k,t,n.sourceAppPid,p,w,q?.session?.user]),z=o(()=>{const e=window?.navigator?.userAgent;return e.indexOf("Edge")>-1||e.indexOf("Edg")>-1?"edge":e.indexOf("Chrome")>-1?"chrome":"unknown"},[]);s.useEffect(()=>{n.sourceAppPid=g.sourceAppPid},[g.sourceAppPid]);const F=v(e=>{n.status=e||"created"}),S=globalThis.blocklet?ee(c):globalThis.env,O=o(()=>{if(l)return l;const e=S.appPid,P=te(e),D=P?void 0:se(e);return P?oe(e):D.color},[S.appId,l]),Q=o(()=>({isWalletWebview:m.wallet||m.arcSphere,isMobile:m.mobile.any,matchSmallScreen:M,connectState:n,staticState:J,reactiveState:n,appInfoList:x,extraParams:g,blocklet:c,masterBlocklet:i,browserBrand:z,currentAppInfo:S,currentAppColor:O,t:G,locale:r,action:p,changeStatus:F,getPlugin:Z,latestActivePlugin:$,plugins:f,setPlugins:W,selectedPlugin:b,setSelectedPlugin:L,forceUpdate:a,showWalletOptions:R,setShowWalletOptions:E,lastLoginMethod:U}),[m.wallet,m.arcSphere,m.mobile.any,M,JSON.stringify(n),JSON.stringify(x),JSON.stringify(g),c,i,r,b,a,S,O]);return B.jsx(ue,{value:Q,children:B.jsx(H,{...h,ref:y,children:d})})}de.propTypes={children:u.any.isRequired,blocklet:u.object.isRequired,masterBlocklet:u.object,action:u.string.isRequired,extraParams:u.object,locale:u.string,testOnlyBorderColor:u.string};function be(){return s.use(j)}const qe={width:24,height:24,body:'<path fill="currentColor" d="M12 17q.425 0 .713-.288T13 16v-4q0-.425-.288-.713T12 11q-.425 0-.713.288T11 12v4q0 .425.288.713T12 17Zm0-8q.425 0 .713-.288T13 8q0-.425-.288-.713T12 7q-.425 0-.713.288T11 8q0 .425.288.713T12 9Zm0 13q-2.075 0-3.9-.788t-3.175-2.137q-1.35-1.35-2.137-3.175T2 12q0-2.075.788-3.9t2.137-3.175q1.35-1.35 3.175-2.137T12 2q2.075 0 3.9.788t3.175 2.137q1.35 1.35 2.138 3.175T22 12q0 2.075-.788 3.9t-2.137 3.175q-1.35 1.35-3.175 2.138T12 22Zm0-2q3.35 0 5.675-2.325T20 12q0-3.35-2.325-5.675T12 4Q8.65 4 6.325 6.325T4 12q0 3.35 2.325 5.675T12 20Zm0-8Z"/>'};export{qe as d,de as m,be as x};
