import{y as d,b as l,H as g,t as S,af as m,bQ as f}from"./index-6Jqoo2rk.js";import{p as _}from"./putPreloader-WBjcuDFX.js";import{A as I}from"./AuthCard-Cghujz7c.js";import{u as A,s as y}from"./bootstrapIm-BS8HLnlI.js";import"./iconTsx-Cr8T7ZIv.js";import"./transition-DuxZkCEv.js";const b=S("<div>");function z(s){const{managers:r,navigate:n,toIm:c}=A();let i;d(()=>{r.appStateManager.pushToState("authState",{_:"authStateSignImport",data:s.spec.payload}),_(i,!0),h()});async function h(){const{dcId:t,token:o,tgAddr:p}=s.spec.payload;let a;try{r.apiManager.setBaseDcId(t);const e=await r.apiManager.invokeApi("auth.importWebTokenAuthorization",{api_id:m.id,api_hash:m.hash,web_auth_token:o},{dcId:t,ignoreErrors:!0});e._==="auth.authorization"&&(await r.apiManager.setUser(e.user),a=()=>c())}catch(e){if(e.type==="SESSION_PASSWORD_NEEDED")a=()=>n({name:"password"});else{console.error("authorization import error:",e);const u=f.authState._;u==="authStateSignIn"?a=()=>n({name:"signIn"}):u==="authStateSignQr"&&(a=()=>n({name:"signQR"}))}}location.hash=p?.trim()?"#?tgaddr="+encodeURIComponent(p):"",a&&await a()}return l(I,{get class(){return y.pageSignImport},inputWrapper:!1,get children(){const t=b(),o=i;return typeof o=="function"?g(o,t):i=t,t}})}export{z as default};
//# sourceMappingURL=SignImportCard-BrsPagQ1.js.map
