UNPKG

@particle-network/authkit

Version:

Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.

12 lines (11 loc) 7.8 kB
"use client"; import{j as _}from"./chunk-NSWCC5PG.mjs";import"./chunk-UXH6IVHO.mjs";import"./chunk-GYYKKPHD.mjs";import"./chunk-3RRPQ2DX.mjs";import{Q as q,X as B,h as D,l as V,m as j,ta as K,wa as U}from"./chunk-H6TXMQRA.mjs";import"./chunk-C7OWFSST.mjs";import{particleAuth as Pe}from"@particle-network/auth-core";import r,{useEffect as N,useMemo as X,useRef as R,useState as ee}from"react";import we from"react-shadow";import le,{useEffect as se}from"react";import{useEffect as oe,useRef as re}from"react";var ne=9;function I(){let e=re(null);function n(i){if(!e.current)return;let o=e.current.querySelectorAll(` a[href]:not(:disabled), button:not(:disabled), textarea:not(:disabled), input[type="text"]:not(:disabled), input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled), select:not(:disabled) `),c=o[0],y=o[o.length-1];(i.key==="Tab"||i.keyCode===ne)&&(i.shiftKey?document.activeElement===c&&(y.focus(),i.preventDefault()):document.activeElement===y&&(c.focus(),i.preventDefault()))}return oe(()=>(e.current&&(e.current.addEventListener("keydown",n),e.current.focus({preventScroll:!0})),()=>{e.current&&e.current.removeEventListener("keydown",n)}),[]),e}function O(e){let n=I();return se(()=>{!n.current||n.current.focus({preventScroll:!0})},[]),le.createElement("div",{ref:n,tabIndex:0},e.children)}import L,{forwardRef as ie,useEffect as ce,useImperativeHandle as de,useState as ue}from"react";var Y="";var me=ie((e,n)=>{var k,x,A,b,v,C,P,w;let{children:i,title:o,drawerProps:c={},modalProps:{destroyOnClose:y,...d}={}}=e,{authCoreModal:E}=j(),[W,f]=ue(e.visible||!1),s=e.locked==="drawer"||E.viewType!=="desktop"&&e.locked!=="modal",p=()=>{f(!1),e.onClose&&e.onClose()},h=()=>{f(!0),e.onOpen&&e.onOpen()};de(n,()=>({setVisible:f,onOpen:h,onClose:p})),ce(()=>{var g;f((g=e.visible)!=null?g:!1)},[e.visible]),(k=d==null?void 0:d.style)!=null&&k.top&&(d.style.top="");let T={...c};delete T.closable;let S=s?{...d.styles,...c.styles,wrapper:{...(x=d.styles)==null?void 0:x.wrapper,...c.contentWrapperStyle,...(A=c.styles)==null?void 0:A.wrapper},body:{...(b=d.styles)==null?void 0:b.body,...c.bodyStyle,...(v=c.styles)==null?void 0:v.body}}:d.styles;return L.createElement(L.Fragment,null,L.createElement("style",null,D(Y)),L.createElement(_,{title:o,open:W,okText:"",className:`${s?"w-drawer-container":""} ${e.className||""}`.trim(),wrapClassName:`${s?"":"w-model-container"}`.trim(),centered:!s,forceBottom:s,maskClosable:s&&(C=c.maskClosable)!=null?C:!1,getContainer:()=>e.containerSelector?document.querySelector(e.containerSelector):E.rootModalContainer||document.querySelector("body"),onCancel:()=>{p()},closable:(P=e.closable)!=null?P:!0,destroyOnHidden:s&&(w=c.destroyOnClose)!=null?w:y,...d,...s?T:{},styles:S,forceRender:!0},i))}),Z=me;import ye,{useEffect as fe,useRef as pe}from"react";var he=({setAuthCoreModal:e})=>{let n=pe(null);return fe(()=>{e({rootModalContainer:n.current})},[e]),ye.createElement("div",{ref:n})},G=he;var J=()=>"web_3.0.0-alpha.7";import{getLatestAuthType as Se,isSocialAuthType as be}from"@particle-network/auth-core";import{useEffect as ve}from"react";var Ce=({web3Modal:e})=>{let{connectionStatus:n}=B(),{provider:i}=K();ve(()=>{var o;e&&n==="connected"&&be(Se())&&i&&((o=e==null?void 0:e.setEIP6963Provider)==null||o.call(e,i,"Particle Wallet"))},[n,i,e])},Q=Ce;var ge=r.lazy(()=>import("./iframeWalletPlugin-NV2MDILO.mjs")),Me=r.lazy(()=>import("./accountTipModal-JT75WCCG.mjs")),Ee=r.lazy(()=>import("./paymentVerifyModal-BPWFE3IA.mjs")),Te=r.lazy(()=>import("./wrongPasswordModal-SBOLYH6O.mjs")),ke=r.lazy(()=>import("./selectSecurityAccount-LLX3MOWN.mjs")),xe=()=>{var b,v,C,P,w,g,$,z;let{modalOptions:e,authCoreModal:n,setAuthCoreModal:i,customRouter:o,authCoreModalClose:c,selectSecurityAccount:y,verifySecurityAccountState:d,wrongPassword:E,paymentVerify:W,accountTipModal:f}=V(),s=R(null),p=R(null),[h,T]=ee(null),[S,k]=ee({styleList:[{name:"resetStyle",loadStyle:()=>import("./reset-X6WS37RQ.mjs"),styleContent:""},{name:"globalStyle",loadStyle:()=>import("./global-4F6HKCIM.mjs"),styleContent:""},{name:"scrollStyle",loadStyle:()=>import("./scroll-DAY6HBTM.mjs"),styleContent:""},{name:"themeStyle",loadStyle:()=>import("./theme-LUFYGUGL.mjs"),styleContent:""}]});N(()=>{let l=S.styleList.map(t=>{var a;return(a=t==null?void 0:t.loadStyle)==null?void 0:a.call(t)});Promise.all(l).then(t=>{k({styleList:t.map(a=>({styleContent:a.default}))})})},[]),N(()=>{var l;((l=p.current)==null?void 0:l.shadowRoot)&&!h&&T(p.current.shadowRoot)},[h]),N(()=>{let l=s.current;if(!l)return;let t=m=>m.stopPropagation(),a=["click","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"];return a.forEach(m=>l.addEventListener(m,t)),()=>a.forEach(m=>l.removeEventListener(m,t))},[h]),N(()=>{var l,t;if(s.current){let F=Math.max(300,Number((l=e.customStyle)==null?void 0:l.modalWidth)),M=Math.max(500,Number((t=e.customStyle)==null?void 0:t.modalHeight));n.viewType=="mobile"&&(F=document.body.clientWidth,M=document.body.clientHeight*.86);let u=F/100;s.current.style.setProperty("--vw",u+"px"),s.current.style.setProperty("--doc-height",M+"px"),s.current.style.setProperty("--doc-width",F+"px")}},[s.current,n.viewType,(b=e.customStyle)==null?void 0:b.modalWidth,(v=e.customStyle)==null?void 0:v.modalHeight]);let x=X(()=>{var a;if(q())return"";let l=window.getComputedStyle(window.document.body).fontFamily;return`.particle-auth-core-shadow-root { --auth-core-font-family: ${((a=e==null?void 0:e.customStyle)==null?void 0:a.fontFamily)||l||'"PingFang SC", "Helvetica Neue", "Helvetica", "Arial", sans-serif'}; }`},[(C=e==null?void 0:e.customStyle)==null?void 0:C.fontFamily]),A=X(()=>{var M;let l=e.themeType,t=e.customStyle||{},a={...Object.fromEntries(Object.keys(t||{}).filter(u=>u!=="theme").map(u=>[u,(t==null?void 0:t[u])||""])),...((M=t==null?void 0:t.theme)==null?void 0:M[l==="light"?"light":"dark"])||{}},m=Object.keys(a).filter(u=>u!=="fontFamily").map(u=>{let te=u.replace(/([A-Z])/g,"-$1").toLowerCase(),H=a[u];return isNaN(Number(H))||(H=H+"px"),`--${te}:${H};`}).join(` `);return`${l==="dark"?".particle-auth-core-shadow-root.dark":".particle-auth-core-shadow-root"}{ ${m} }`},[e.themeType,e.customStyle]);return r.createElement(we.div,{ref:p,mode:"open"},h&&r.createElement(r.Fragment,null,r.createElement("div",{id:"particle-auth-core-modal",className:`particle-auth-core-shadow-root ${e.themeType}`,"data-path":o==null?void 0:o.path,"data-auth-core-modal-version":J(),"data-auth-core-version":Pe.version,ref:s},r.createElement(O,null,r.createElement("style",{"data-name":"fontStyle"},x),!!((P=S.styleList[0])!=null&&P.styleContent)&&S.styleList.map((l,t)=>r.createElement("style",{"data-name":l.name,"data-index":t,key:t},l.styleContent)),r.createElement("style",{"data-name":"customTheme"},A),n.rootModalContainer&&r.createElement(Z,{visible:n.particleModalVisible,closable:n.closable,onClose:()=>{c()},className:"root-particle-modal-container",modalProps:{footer:null,width:parseInt((w=e.customStyle)==null?void 0:w.modalWidth),height:parseInt((g=e.customStyle)==null?void 0:g.modalHeight),destroyOnClose:!0,zIndex:(($=e.customStyle)==null?void 0:$.zIndex)||1e3},drawerProps:{destroyOnClose:!0,zIndex:((z=e.customStyle)==null?void 0:z.zIndex)||1e3}},r.createElement(U,{path:o==null?void 0:o.path,state:o==null?void 0:o.state,replace:o==null?void 0:o.replace,children:o==null?void 0:o.children})),r.createElement(r.Suspense,null,r.createElement(ge,null),r.createElement(ke,{visible:y,state:d}),r.createElement(Me,{modal:f}),r.createElement(Ee,{props:W}),r.createElement(Te,{info:E})),r.createElement(G,{"data-ref":"rootModalContainer",setAuthCoreModal:i}),e.web3Modal&&r.createElement(Q,{web3Modal:e.web3Modal})))))},lt=xe;export{lt as default};