1import{x as L,l as H,V as Y,d as j,C as ue,D as ie,N as Q,u as J,k as g,o as re,r as Z,b as w,c as M,z as G,U as R,j as e,t as p,n as T,F as D,e as l,a2 as V,Z as I,ah as ce,B as b,h as U,i as N,aG as W,K as q,aO as X,b5 as de,aQ as ee,w as _e,I as E,M as me}from"./DVTi7wDo.js";import{C as he}from"./BWwoocnv.js";import{v as te}from"./xPGEof6T.js";import{l as ve}from"./B0gNa8Vh.js";import{m as oe,O as F,i as pe}from"./DnIDvHQg.js";import{E as fe}from"./D2wQUEu0.js";function ge(){const i=L();return function(f,r){const _=new URLSearchParams({client_id:i.public.auth.googleOauthClientId,redirect_uri:oe(),response_type:"code",scope:"https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile",state:JSON.stringify({path:f,state:r})});window.location.href=`https://accounts.google.com/o/oauth2/auth?${_.toString()}`}}function we(){const i=H(),c=Y();return function(){if(!F.some(u=>u in i.query))return;const _=Object.fromEntries(Object.entries(i.query).filter(([u])=>!F.includes(u)));c.replace({query:_}).catch(()=>{})}}const be={class:"auth-modal__head"},ye=["textContent"],Ce={class:"auth-modal__method-tabs"},ke={class:"auth-modal__fields"},$e={class:"auth-modal__submit _column"},Ae={class:"ui-modal__confirm _center"},Oe={class:"ui-modal__confirm_icon"},xe=["textContent"],Ve=["textContent"],Se={class:"ui-modal__confirm_buttons"},Be=j({__name:"AuthLogin",setup(i){const{locale:c}=ue(),f=Y(),r=H(),_=ie(),u=Q(),A=L(),{$notify:m}=J(),C=ge(),O=we(),k=q(()=>!!A.public.auth.googleOauthClientId),n=g("password"),y=g(!1),x=g(z()),h=g(!1),t=X({save_me:!0,access_code:"",login:"",password:""}),o=g({}),d=q(()=>n.value==="password"?{login:{label:"auth.login.label",placeholder:"auth.login.placeholder",name:"login",validate:{required:!0}},password:{label:"auth.password.label",placeholder:"auth.password.placeholder",name:"password",validate:{required:!0}},save_me:{label:"auth.save_me.label"}}:{access_code:{label:"auth.access_code.label",placeholder:"auth.access_code.placeholder",name:"login",validate:{required:!0}},save_me:{label:"auth.save_me.label"}});function $(){u.showAuth({show:!0,mode:"restore",restoreType:n.value})}function S(s){n.value!==s&&(n.value=s,o.value={})}async function se(){try{const{status:s,errors:a}=await te(d.value,t);if(o.value=a,!s)return;y.value=!0;const P=await u.signIn(n.value==="password"?{login:t.login,password:t.password,save_me:t.save_me}:{access_code:t.access_code,save_me:t.save_me}),B=n.value==="password"?"login":"access_code";P.auth_success?(o.value[B]="",h.value=!0):(o.value[B]=n.value==="password"?"auth.login.invalid":"auth.access_code.invalid",h.value=!1)}catch(s){h.value=!1,o.value[n.value==="password"?"login":"access_code"]="errors.internal",console.warn("invalid auth",s)}y.value=!1}function ae(){C(r.fullPath,"googleAuth")}function z(){return pe(r.query)}async function le(s){x.value=!0;try{(await u.signInGoogle({code:s,redirect_uri:oe(),client_id:A.public.auth.googleOauthClientId})).auth_success?h.value=!0:m("auth.google_not_found","warn","error")}catch(a){m("errors.internal_short","warn","error"),console.warn("google auth failed",a)}x.value=!1,O()}function K(){h.value=!1,y.value=!1,t.access_code="",t.login="",t.password="",t.save_me=!0,o.value={},u.showAuth({show:!1})}function ne(){const s=L();s.public.buildMode==="site"?(f.push(_({name:"lk_proxy"})),K()):window.location.href=ve(s.public.domains.site+de.lk.home,c.value)}return re(()=>{z()&&le(r.query.code)}),(s,a)=>{const P=ce,B=Z("Icon");return w(),M("div",null,[G(e("form",{onSubmit:W(se,["prevent"])},[e("div",be,[e("div",{class:"auth-modal__head_h1",textContent:p(s.$t("auth.title"))},null,8,ye)]),e("div",Ce,[e("button",{type:"button",class:T(["auth-modal__method-tab",{_active:n.value==="password"}]),onClick:a[0]||(a[0]=v=>S("password"))},p(s.$t("auth.method_password")),3),e("button",{type:"button",class:T(["auth-modal__method-tab",{_active:n.value==="access_code"}]),onClick:a[1]||(a[1]=v=>S("access_code"))},p(s.$t("auth.method_access_code")),3)]),e("div",ke,[n.value==="password"?(w(),M(D,{key:0},[l(I,V({modelValue:t.login,"onUpdate:modelValue":a[2]||(a[2]=v=>t.login=v),modelModifiers:{trim:!0}},d.value.login,{error:o.value.login}),null,16,["modelValue","error"]),l(I,V({modelValue:t.password,"onUpdate:modelValue":a[3]||(a[3]=v=>t.password=v),modelModifiers:{trim:!0},type:"password"},d.value.password,{error:o.value.password,"password-eye":!0,"sub-action":"auth.password.forgot",onSubActionClick:$}),null,16,["modelValue","error"])],64)):(w(),M(D,{key:1},[l(P,{text:"auth.access_code.legacy_notice",color:"blue-semi",class:"_full-width"}),l(I,V({modelValue:t.access_code,"onUpdate:modelValue":a[4]||(a[4]=v=>t.access_code=v),modelModifiers:{trim:!0},type:"password","auto-capitalize":!1,"auto-correct":!1},d.value.access_code,{error:o.value.access_code,"password-eye":!0,"sub-action":"auth.forgot_password",onSubActionClick:$}),null,16,["modelValue","error"])],64)),l(he,V({modelValue:t.save_me,"onUpdate:modelValue":a[5]||(a[5]=v=>t.save_me=v)},d.value.save_me),null,16,["modelValue"])]),e("div",$e,[l(b,{title:"auth.submit",color:"blue-semi",loading:y.value,type:"submit",style:{width:"100%"}},null,8,["loading"]),k.value?(w(),U(b,{key:0,title:"auth.login_google",left_icon:"google",color:"blue-semi_secondary",loading:x.value,type:"button",style:{width:"100%"},onClick:ae},null,8,["loading"])):N("",!0)]),N("",!0)],544),[[R,!h.value]]),G(e("div",Ae,[e("div",Oe,[l(B,{name:"success"})]),e("div",{class:"ui-modal__confirm_title",textContent:p(s.$t("auth.success.title"))},null,8,xe),e("div",{class:"ui-modal__confirm_text",textContent:p(s.$t("auth.success.subtitle"))},null,8,Ve),e("div",Se,[l(b,{title:"auth.success.go_lk",onClick:ne}),l(b,{title:"buttons.close",color:"pic_secondary",onClick:K})])],512),[[R,h.value]])])}}}),Me=Object.assign(Be,{__name:"AuthLogin"}),Ie={rule:i=>!i||typeof i=="string"&&fe.test(i),text:"errors.invalid_email"},Ue={class:"auth-modal__head"},Ge={class:"auth-modal__head_h1"},Re={class:"text-light"},qe={class:"auth-modal__fields"},Pe={class:"auth-modal__submit _start"},Ee={class:"ui-modal__confirm _center"},Le={class:"ui-modal__confirm_icon"},Ne=["textContent"],je=["textContent"],Qe={class:"ui-modal__confirm_buttons"},ze=j({__name:"AuthRemember",emits:["goBack"],setup(i,{emit:c}){const f=c,{$api:r,$notify:_}=J(),u=Q(),{auth_modal_restore_type:A}=ee(u),m=q(()=>A.value==="password"?"auth.restore_password":"auth.restore_code"),C=g(!1),O=g(!1),k=X({email:""}),n=g({}),y=q(()=>({email:{label:"labels.email",placeholder:"labels.email_placeholder",validate:{required:!0,custom:[Ie]}}}));async function x(){if(!C.value){try{const{status:o,errors:d}=await te(y.value,k);if(n.value=d,!o)return;C.value=!0;const $=await r.auth.restorePassword(k.email);console.log($),O.value=!0}catch{_("errors.internal_short","warn","error")}C.value=!1}}function h(){u.showAuth({show:!1})}function t(){f("goBack")}return(o,d)=>{const $=Z("Icon");return w(),M("div",null,[G(e("form",{onSubmit:W(x,["prevent"])},[e("div",Ue,[e("div",Ge,p(o.$t(`${m.value}.title`)),1),e("div",Re,p(o.$t(`${m.value}.subtitle`)),1)]),e("div",qe,[l(I,V({modelValue:k.email,"onUpdate:modelValue":d[
10]||(d[0]=S=>k.email=S)},y.value.email,{error:n.value.email}),null,16,["modelValue","error"])]),e("div",Pe,[l(b,{title:`${m.value}.submit`,loading:C.value,wide_padding:!0,type:"submit"},null,8,["title","loading"]),l(b,{title:"labels.back",color:"pic_secondary",onClick:t})])],544),[[R,!O.value]]),G(e("div",Ee,[e("div",Le,[l($,{name:"success"})]),e("div",{class:"ui-modal__confirm_title",textContent:p(o.$t(`${m.value}.success.title`))},null,8,Ne),e("div",{class:"ui-modal__confirm_text",textContent:p(o.$t(`${m.value}.success.subtitle`))},null,8,je),e("div",Qe,[l(b,{title:"auth.submit",onClick:t}),l(b,{title:"buttons.close",color:"pic_secondary",onClick:h})])],512),[[R,O.value]])])}}}),Ke=Object.assign(ze,{__name:"AuthRemember"}),Te=j({__name:"AuthModal",setup(i){const c=Q(),{auth_modal_show:f,auth_modal_mode:r}=ee(c);function _(){c.showAuth({show:!0,mode:"auth"})}function u(){c.showAuth({show:!1})}return(A,m)=>(w(),U(me,{show:E(f),type:"blue-head",onClose:u},{default:_e(()=>[E(r)==="auth"?(w(),U(Me,{key:0})):E(r)==="restore"?(w(),U(Ke,{key:1,onGoBack:_})):N("",!0)]),_:1},8,["show"]))}}),We=Object.assign(Te,{__name:"AuthModal"});export{We as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.