import{j as e,at as $,W as v,J as A,ak as r,b4 as F,b0 as U,T as N,bP as z,bQ as X,bR as H,a$ as B,av as J,bF as V,bS as G,bT as Q}from"./vendor-mui-core-CnXrAOs3.js";import{p as O,d as q,n as I,_ as K,s as Y,V as Z}from"./vendor-ux-5OlTXZBe.js";import{r as d}from"./vendor-react-Dvs43sk9.js";import{g as ee,n as te}from"./vendor-hooks-CjESGRlR.js";import{v as D,J as L,H as se,S as oe,s as ae,b as ne}from"./index-Cq3xfsOS.js";import{T as re}from"./vendor-utils-cJEl_UEd.js";import{N as ie}from"./index-nYsahwVM.js";import{W as ce}from"./did-address-C5FXzeAS.js";import{w as le}from"./wrap-locale-CyFByfaX.js";import{u as pe}from"./use-passport-id-B-b-_oYF.js";import{g as de}from"./get-safe-url-mKD2PdwN.js";import{c as me}from"./passport-C04lgrV5.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-CqplRmyi.js";import"./index-sE6ANlb1.js";import"./create-passport-svg-B2TKOs7K.js";function W({list:s=[],width:l=300,height:m=400,cardSpace:p=40,onSelect:i=()=>{},defaultIndex:k=0}){const[u,h]=d.useState(0),[o,x]=d.useState(0),b=d.useRef(null),f=n=>{if(n<0||n>s.length-1)return;h(n);const c=b.current.clientWidth;x(n*(l+p)-(c-l)/2+p*.5),i(n)};d.useEffect(()=>{f(k);const n=c=>c.preventDefault();b.current.addEventListener("touchmove",n,{passive:!1})},[]);let a;const j=n=>{a=n.touches[0].clientX},y=n=>{const c=n.changedTouches[0],w=a-c.clientX;Math.abs(w)>60&&(w>0?f(u+1):f(u-1))};return e.jsx(ue,{ref:b,onTouchStart:j,onTouchEnd:y,children:e.jsx("div",{className:"card-container",style:{transform:`translate(${-o}px, 0)`},children:s.map((n,c)=>e.jsx("div",{className:`card-item ${c===u?"selected":""}`,style:{width:l,height:m,margin:p/2},onClick:()=>f(c),children:n.display?e.jsx("div",{className:"card-content",children:e.jsx(ie,{data:n.display,style:{width:"100%",height:"100%"}})}):e.jsx("div",{className:"card-content",dangerouslySetInnerHTML:{__html:n.src}})},n.id))})})}const ue=$.div`
  overflow: hidden;
  mask-image: linear-gradient(to left, transparent, black 3%, black 97%, transparent);
  overflow: hidden;
  .card-container {
    display: flex;
    white-space: nowrap;
    width: max-content;
    transition: all ease 0.3s;
  }
  .card-item {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;

    .card-content {
      pointer-events: none;
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
      outline: #526ded solid 0;
      transition: all ease 0.2s;
      box-shadow: rgba(0, 0, 0, 0.2) 0 0 10px;
    }
    &.selected {
      cursor: default;
      .card-content {
        outline: #526ded solid 5px;
      }
    }
  }
`;W.propTypes={list:v.array,width:v.number,height:v.number,cardSpace:v.number,onSelect:v.func,defaultIndex:v.number};function he({icon:s,active:l,completed:m}){const p={1:e.jsx(Q,{className:"step-icon"}),2:e.jsx(G,{className:"step-icon"}),3:e.jsx(V,{className:"step-icon"})},i=["step-icon-w"];return l&&i.push("step-icon-w--active"),m&&i.push("step-icon-w--completed"),e.jsx("div",{className:i.join(" "),children:p[String(s)]})}function xe({SessionContext:s,webWalletUrl:l,createPassportSvg:m,passportColor:p,onLogin:i,teamDid:k}){const{api:u}=d.useContext(s),h=A(t=>t.breakpoints.down("sm")),o=ee({user:null,passport:null,success:!1,activeStep:0}),x=d.useRef({sessionToken:"",refreshToken:""}),{setPassportId:b,clearPassportId:f}=pe(),{t:a,locale:j}=d.useContext(O),{wallet:y}=q(),[n,c]=d.useState(0),{searchParams:w}=new URL(window.location.href),P=()=>{o.activeStep++},E=t=>{o.user=t.user},M=()=>{P()},R=(t,g)=>{t?.passportId&&b(t.passportId),t?.sessionToken&&(x.current.sessionToken=g(t.sessionToken)),t?.refreshToken&&(x.current.refreshToken=g(t.refreshToken)),o.success=!0,P()},S=async()=>{if(y&&L()){K(()=>import("./index-CgdhTqWX.js").then(g=>g.i),[],import.meta.url).then(g=>{g.call("arcClosePage")});return}re(i)&&i({sessionToken:x.current.sessionToken,refreshToken:x.current.refreshToken});const t=w.get("redirect");if(t){window.location.replace(de(t));return}f(),window.location.replace("/")},_=t=>{o.passport=t.target.value},[T]=te({leftTime:n,onEnd:()=>{S()}}),C=[{label:a("lostPassport.recoverPassport"),content:()=>{if(!o.user){const t=w.get("scope")||"passport";return e.jsx(D,{popup:!0,open:!0,hideCloseButton:!0,className:"connect",action:"lost-passport-list",forceConnected:!1,autoConnect:!1,checkFn:u.get,checkTimeout:10*60*1e3,webWalletUrl:l,onSuccess:E,locale:j,messages:{title:a("lostPassport.recoverDialog.title"),scan:a("lostPassport.recoverDialog.scan"),confirm:a("lostPassport.recoverDialog.confirm"),success:a("lostPassport.recoverDialog.success")},extraParams:{scope:t}})}return e.jsxs(r,{className:"select-passport",children:[e.jsxs(r,{className:"user-info",sx:{my:1,display:"flex",alignItems:"center"},children:[e.jsx(F,{src:o.user.avatar,style:{width:48,height:48,backgroundColor:"transparent",marginRight:16}}),e.jsxs(r,{children:[e.jsx(r,{className:"name",children:o.user.fullName}),e.jsx(r,{className:"did",sx:{mt:1},children:e.jsx(ce,{responsive:!h,compact:h,did:o.user.did})})]})]}),e.jsx(r,{children:e.jsx(W,{width:h?180:230,height:h?240:306,cardSpace:24,list:o.user.passportTypes.map(t=>({src:m({scope:t.scope,role:t.role,title:t.scope==="kyc"?t.name:t.title,issuer:t.issuer.name,issuerDid:t.issuer.id,ownerDid:o.user.did,ownerName:o.user.fullName,ownerAvatarUrl:o.user.avatar,preferredColor:p||"auto",extra:t.scope==="kyc"?{key:"Email",value:t.name}:void 0}),name:t.title,id:t.id,display:t.display})),onSelect:t=>_({target:{value:o.user.passportTypes[t].id}}),defaultIndex:0})}),e.jsx(r,{sx:{textAlign:"center"},children:e.jsx(I,{variant:"contained",color:"primary",onClick:()=>M(),disabled:!o.passport,children:a("common.next")})})]})}},{label:a("lostPassport.receivePassport"),content:()=>{const t={receiverDid:o.user.did,passportId:o.passport,teamDid:k||window?.blocklet?.did};return e.jsx(D,{popup:!0,open:!0,hideCloseButton:!0,className:"connect",action:"lost-passport-issue",checkFn:u.get,checkTimeout:10*60*1e3,webWalletUrl:l,onSuccess:R,forceConnected:!1,locale:j,messages:{title:`${a("lostPassport.receiveDialog.title")}`,scan:a("lostPassport.receiveDialog.scan"),confirm:a("lostPassport.receiveDialog.confirm"),success:a("lostPassport.receiveDialog.success")},extraParams:t})}},{label:a("common.complete"),content:()=>(n===0&&c(3e3),e.jsxs(r,{sx:{textAlign:"center"},children:[e.jsx(r,{sx:{mb:3,color:"success.main"},children:e.jsx(U,{style:{fontSize:60}})}),e.jsx(N,{component:"p",variant:"body1",className:"subheader",children:a("issuePassport.dialog.success")}),e.jsx(N,{component:"p",variant:"body2",color:"gray",children:y&&L()?a("issuePassport.dialog.autoClose",{seconds:Math.round(T/1e3)}):a("issuePassport.dialog.autoJump",{seconds:Math.round(T/1e3)})}),e.jsx(I,{style:{marginTop:40},variant:"contained",color:"primary",onClick:S,children:a("issuePassport.dialog.loginWithPassport")})]}))}];return e.jsx(fe,{children:e.jsxs(r,{className:"stepper",children:[e.jsx(z,{className:"stepper-progress",alternativeLabel:!0,activeStep:o.activeStep,children:C.map(({label:t})=>e.jsx(X,{children:e.jsx(H,{slots:{stepIcon:he},children:t})},t))}),e.jsx(r,{className:"stepper-content",children:C[o.activeStep].content()}),!o.success&&e.jsx(r,{sx:{textAlign:"center",fontSize:12},children:e.jsx(B,{href:"/",sx:{color:"#4598FA",textDecoration:"none"},children:a("lostPassport.return")})})]})})}const fe=$(J)`
  padding-top: 46px;
  padding-bottom: 46px;
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
    display: block;
  }
  .header {
    text-align: center;
    margin-bottom: 24px;
  }

  .stepper {
    padding: 24px;
    height: auto;
    width: 100%;
    min-height: 640px;
    display: flex;
    flex-direction: column;

    @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
      min-height: auto;
    }

    .stepper-progress {
      padding: 0;
      flex: 0;
      margin-bottom: 24px;

      .MuiStepLabel-label.MuiStepLabel-alternativeLabel {
        margin-top: 8px;
      }

      .MuiStepConnector-alternativeLabel {
        top: 24px;
      }

      .MuiStepConnector-lineHorizontal {
        height: 3px;
        border: none;
        background-color: #eaeaf0;
        border-radius: 1px;
      }

      .step-icon-w {
        background-color: ${s=>s.theme.palette.grey[500]};
        z-index: 1;
        color: ${s=>s.theme.palette.common.white};
        width: 50px;
        height: 50px;
        display: flex;
        border-radius: 50%;
        justify-content: center;
        align-items: center;
        .step-icon {
          font-size: 30px;
        }
      }

      .step-icon-w--active {
        background-color: ${s=>s.theme.palette.primary.main};
      }

      .step-icon-w--completed {
        background-color: ${s=>s.theme.palette.secondary.main};
      }
    }

    .stepper-content {
      padding: 0 64px;
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-bottom: 24px;

      .stepper-icon {
        margin-left: 40px;
      }

      .stepper-auth {
        padding: 0;

        .auth-title {
          margin-bottom: 16px;
        }
      }

      .stepper-tip {
        text-align: center;
        margin-bottom: 16px;
      }
      @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
        padding: 0;
      }
    }

    .stepper-actions {
      flex: 0;
      text-align: right;
      padding: 0 64px;
      display: none;
      .step-button {
        margin-right: 8px;
      }
    }

    .select-passport {
      width: 80%;
      @media (max-width: ${s=>s.theme.breakpoints.values.sm}px) {
        width: 100%;
      }
    }

    .user-info {
      .name {
        font-weight: 500;
        font-size: 18px;
        line-height: 25px;
        color: ${s=>s.theme.palette.text.primary};
      }
    }
  }

  .connect {
    background: #fafafa;
  }
`,ge=le(xe);function Ee(){const s=Y(),{t:l}=Z(),m=({sessionToken:p,refreshToken:i}={})=>{p&&ae(p),i&&ne(i)};return e.jsxs(e.Fragment,{children:[e.jsx(se,{children:e.jsx("title",{children:l("pageTitle.lostPassport")})}),e.jsx(ge,{SessionContext:oe,webWalletUrl:s,createPassportSvg:me,passportColor:window?.env?.passportColor||"auto",onLogin:m})]})}export{Ee as default};
