import{j as B,ak as H,W as l}from"./vendor-mui-core-CKKG_1TN.js";import{r as s}from"./vendor-react-CTtPmzVP.js";import{a6 as K,a7 as T,ax as _,G as V,al as X,az as Y,av as ee,ar as te,g as se,an as oe}from"./vendor-ux-DjXlxcvL.js";import{a as o,B as ie,b as v,f as re,g as ae,e as ne}from"./vendor-hooks-DQAdyHrE.js";import{c as g,n as ce}from"./vendor-utils-CUs2ebe7.js";import{a3 as I,bu as pe}from"./index-BEfIUbZC.js";function ue({blocklet:d,action:c,sourceAppPid:i,connectState:p,enableSwitchApp:t}){const r=s.use(I),u=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]),A=o(()=>{if(g(i)){const a=K(d),f=T(d);if(a&&f?.appPid)return f.appPid}return i},[i,d]);return{appInfoList:o(()=>_(d).filter(a=>u?!0:g(i)?g(p.sourceAppPid)?r?.session?.user?a.sourceAppPid===r.session.user.sourceAppPid:a.sourceAppPid===A:a.sourceAppPid===p.sourceAppPid:a.sourceAppPid===i),[u,i,p.sourceAppPid,A,r?.session?.user]),autoGenerateSourceAppPid:A,canSwitchApp:u}}const W=s.createContext({isWalletWebview:!1,isMobile:!1,matchSmallScreen:!1,blocklet:null}),{Provider:le,Consumer:Se}=W;function de({children:d,blocklet:c,masterBlocklet:i=void 0,action:p,extraParams:t={},locale:r="en",testOnlyBorderColor:u=void 0,...A}){const a=ie(),[f,j]=s.useState([]),[R,$]=s.useState(!1),[b,E]=s.useState(""),L=o(()=>new Map(f.map(e=>[e.name,e])),[f]),Z=v(e=>L.get(e)),z=re(b),G=v((e,P={})=>V(pe,e,r,"en",P)),q=s.use(I),n=ae({sourceAppPid:void 0,status:"created",autoActiveWebview:!0,deeplink:void 0,chooseMethod:"",retryConnect:ce}),J=s.useRef({cancelCount:0}),m=X(),{appInfoList:x,autoGenerateSourceAppPid:w,canSwitchApp:k}=ue({blocklet:c,connectState:n,action:p,sourceAppPid:t?.sourceAppPid,enableSwitchApp:t?.forceSwitch||t?.enableSwitchApp}),N=o(()=>{try{return localStorage.getItem(Y)}catch{return""}},[]),y=s.useRef(null),C=ne(y),M=o(()=>(C?.width||0)<500,[C?.width]),h=o(()=>{if(k)return{...t,sourceAppPid:g(n.sourceAppPid)?w:n.sourceAppPid};const e=T(c)?.appPid,P=T(globalThis.blocklet)?.appPid;return q?.session?.user&&(e===P||!e)?g(t?.sourceAppPid)?{...t,sourceAppPid:q.session.user?.sourceAppPid}:t:{...t,sourceAppPid:w}},[k,t,n.sourceAppPid,p,w,q?.session?.user]),U=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=h.sourceAppPid},[h.sourceAppPid]);const F=v(e=>{n.status=e||"created"}),S=globalThis.blocklet?ee(c):globalThis.env,O=o(()=>{if(u)return u;const e=S.appPid,P=te(e),D=P?void 0:se(e);return P?oe(e):D.color},[S.appId,u]),Q=o(()=>({isWalletWebview:m.wallet||m.arcSphere,isMobile:m.mobile.any,matchSmallScreen:M,connectState:n,staticState:J,reactiveState:n,appInfoList:x,extraParams:h,blocklet:c,masterBlocklet:i,browserBrand:U,currentAppInfo:S,currentAppColor:O,t:G,locale:r,action:p,changeStatus:F,getPlugin:Z,latestActivePlugin:z,plugins:f,setPlugins:j,selectedPlugin:b,setSelectedPlugin:E,forceUpdate:a,showWalletOptions:R,setShowWalletOptions:$,lastLoginMethod:N}),[m.wallet,m.arcSphere,m.mobile.any,M,JSON.stringify(n),JSON.stringify(x),JSON.stringify(h),c,i,r,b,a,S,O]);return B.jsx(le,{value:Q,children:B.jsx(H,{...A,ref:y,children:d})})}de.propTypes={children:l.any.isRequired,blocklet:l.object.isRequired,masterBlocklet:l.object,action:l.string.isRequired,extraParams:l.object,locale:l.string,testOnlyBorderColor:l.string};function be(){return s.use(W)}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};
