1import{f as qe,r as n,j as e,L as Fe}from"./vendor-react-CdSkYK6A.js";import{u as W,y as pe,s as oe,B as v,k as i,I as N,j as Te}from"./index-Bkpzml6u.js";import{L as S}from"./label-BTRMdqOW.js";import{U as M,a7 as le,a8 as ie,a9 as be,O as de,aa as Re,ab as Ge,a2 as Oe,q as Me,x as De,ac as ce,ad as He,d as je,e as Ue,a1 as J,p as Qe,V as Ke,J as me,M as Je,A as ue,ae as We}from"./vendor-icons-B6Pw7kvU.js";import"./vendor-radix-DZ5WJj_n.js";import"./vendor-supabase-C0gOjPry.js";import"./vendor-query-Cv6EpE7x.js";const Xe="882239959719-9vesq4qaemdjbrsi9s4h7bmcs52dhlgf.apps.googleusercontent.com",Ye="promokod_otp_bot",Ve=["Toshkent shahri","Toshkent viloyati","Andijon","Buxoro","Farg'ona","Jizzax","Namangan","Navoiy","Qashqadaryo","Qoraqalpog'iston","Samarqand","Sirdaryo","Surxondaryo","Xorazm"],$e={"Toshkent shahri":"гоÑод ТаÑкенÑ","Toshkent viloyati":"ТаÑкенÑÑÐºÐ°Ñ Ð¾Ð±Ð»Ð°ÑÑÑ",Andijon:"Ðндижан",Buxoro:"ÐÑÑ
аÑа","Farg'ona":"ФеÑгана",Jizzax:"Ðжизак",Namangan:"Ðаманган",Navoiy:"Ðавои",Qashqadaryo:"ÐаÑкадаÑÑÑ","Qoraqalpog'iston":"ÐаÑакалпакÑÑан",Samarqand:"СамаÑканд",Sirdaryo:"СÑÑдаÑÑÑ",Surxondaryo:"СÑÑÑ
андаÑÑÑ",Xorazm:"ХоÑезм"},H="bg-card rounded-2xl border border-border shadow-card p-5 sm:p-6",xe="flex h-11 w-full rounded-xl border border-input bg-background px-3 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",he="inline-flex items-center gap-2 h-9 rounded-full border border-border bg-card px-3.5 text-sm font-medium text-foreground shadow-sm hover:bg-muted transition-colors",ge={uz:{already_has_phone:"Bu hisobga allaqachon telefon bog'langan",already_has_email:"Bu hisobga allaqachon email bog'langan",use_google:"Bu email Google orqali ochilgan â Google bilan bog'lang",wrong_password:"Parol noto'g'ri",wrong_code:"Kod noto'g'ri",expired:"Kod muddati tugagan. Qaytadan urinib ko'ring",no_contact:"Avval botda raqamingizni ulashing",bad_input:"Ma'lumot noto'g'ri kiritildi",invalid_token:"Google tasdiqlash amalga oshmadi",email_unverified:"Google email tasdiqlanmagan",unauthorized:"Avtorizatsiya xatosi"},ru:{already_has_phone:"Ð ÑÑÐ¾Ð¼Ñ Ð°ÐºÐºÐ°ÑнÑÑ Ñже пÑивÑзан ÑелеÑон",already_has_email:"Ð ÑÑÐ¾Ð¼Ñ Ð°ÐºÐºÐ°ÑнÑÑ Ñже пÑивÑзан email",use_google:"ÐÑÐ¾Ñ email Ñоздан ÑеÑез Google â пÑивÑжиÑе ÑеÑез Google",wrong_password:"ÐевеÑнÑй паÑолÑ",wrong_code:"ÐевеÑнÑй код",expired:"СÑок дейÑÑÐ²Ð¸Ñ ÐºÐ¾Ð´Ð° иÑÑÑк. ÐопÑобÑйÑе еÑÑ Ñаз",no_contact:"СнаÑала оÑпÑавÑÑе боÑÑ Ñвой номеÑ",bad_input:"ÐаннÑе Ð²Ð²ÐµÐ´ÐµÐ½Ñ Ð½ÐµÐ²ÐµÑно",invalid_token:"Ðе ÑдалоÑÑ Ð¿Ð¾Ð´ÑвеÑдиÑÑ ÑеÑез Google",email_unverified:"Email Google не подÑвеÑждÑн",unauthorized:"ÐÑибка авÑоÑизаÑии"}},Ze=(d,o,a)=>d&&(ge[a]||ge.uz)[d]||o("error"),z={uz:{profileSaved:"Profil saqlandi!",interestsSaved:"Qiziqishlar saqlandi!",onlyImage:"Faqat rasm tanlang",imageTooBig:"Rasm hajmi 3MB dan kichik bo'lsin",loggedOut:"Hisobdan chiqdingiz",accountDeleted:"Hisob o'chirildi",enter4Digit:"4 xonali kodni kiriting",phoneLinked:"Telefon bog'landi!",emailLinked:"Email bog'landi!",googleLinked:"Google bog'landi!",home:"Bosh sahifa",changePhoto:"Rasmni o'zgartirish",userFallback:"Foydalanuvchi",coins:"tanga",streak:"kunlik",personalInfo:"Shaxsiy ma'lumotlar",fillProfile:"Profilingizni to'ldiring",name:"Ism",yourName:"Ismingiz",gender:"Jins",notSelected:"Tanlanmagan",male:"Erkak",female:"Ayol",profession:"Kasb",yourProfession:"Kasbingiz",birthday:"Tug'ilgan kun",region:"Viloyat",save:"Saqlash",yourInterests:"Qiziqishlaringiz",interestsSubtitle:"Sizga mos kodlarni ko'rsatamiz",saveInterests:"Qiziqishlarni saqlash",logout:"Hisobdan chiqish",deleteAccount:"Hisobni o'chirish",yesDelete:"Ha, o'chir",cancel:"Bekor qilish",notLinked:"Bog'lanmagan",active:"Faol",link:"Bog'lash",linkAccount:"Hisobni bog'lash",linkAccountSubtitle:"Bitta profil â ham telefon, ham email orqali kiring",phone:"Telefon",yourPhone:"Telefon raqamingiz",openBotShare:"Botni ochib, raqamni ulashing",codeFromBot:"Botdan kelgan kod",linkPhone:"Telefonni bog'lash",orEmailPw:"yoki email + parol",pwNewOrExisting:"Parol (yangi yoki mavjud)",linkEmail:"Emailni bog'lash",mergeHint:"Agar bu email bilan alohida hisobingiz bo'lsa, u shu profilga birlashtiriladi",googleLink:"Google bilan bog'lash"},ru:{profileSaved:"ÐÑоÑÐ¸Ð»Ñ ÑоÑ
ÑанÑн!",interestsSaved:"ÐнÑеÑеÑÑ ÑоÑ
ÑаненÑ!",onlyImage:"ÐÑбеÑиÑе ÑолÑко изобÑажение",imageTooBig:"Ð Ð°Ð·Ð¼ÐµÑ Ð¸Ð·Ð¾Ð±ÑÐ°Ð¶ÐµÐ½Ð¸Ñ Ð´Ð¾Ð»Ð¶ÐµÐ½ бÑÑÑ Ð¼ÐµÐ½ÑÑе 3ÐÐ",loggedOut:"ÐÑ Ð²ÑÑли из аккаÑнÑа",accountDeleted:"ÐккаÑÐ½Ñ ÑдалÑн",enter4Digit:"ÐведиÑе 4-знаÑнÑй код",phoneLinked:"ТелеÑон пÑивÑзан!",emailLinked:"Email пÑивÑзан!",googleLinked:"Google пÑивÑзан!",home:"ÐлавнаÑ",changePhoto:"ÐзмениÑÑ ÑоÑо",userFallback:"ÐолÑзоваÑелÑ",coins:"монеÑ",streak:"дней подÑÑд",personalInfo:"ÐиÑнÑе даннÑе",fillProfile:"ÐаполниÑе Ñвой пÑоÑилÑ",name:"ÐмÑ",yourName:"ÐаÑе имÑ",gender:"Ðол",notSelected:"Ðе вÑбÑано",male:"ÐÑжÑкой",female:"ÐенÑкий",profession:"ÐÑоÑеÑÑиÑ
1",yourProfession:"ÐаÑа пÑоÑеÑÑиÑ",birthday:"ÐаÑа ÑождениÑ",region:"Регион",save:"СоÑ
ÑаниÑÑ",yourInterests:"ÐаÑи инÑеÑеÑÑ",interestsSubtitle:"Ðокажем подÑ
одÑÑие вам кодÑ",saveInterests:"СоÑ
ÑаниÑÑ Ð¸Ð½ÑеÑеÑÑ",logout:"ÐÑйÑи из аккаÑнÑа",deleteAccount:"УдалиÑÑ Ð°ÐºÐºÐ°ÑнÑ",yesDelete:"Ðа, ÑдалиÑÑ",cancel:"ÐÑмена",notLinked:"Ðе пÑивÑзано",active:"ÐкÑивно",link:"ÐÑивÑзаÑÑ",linkAccount:"ÐÑивÑзка аккаÑнÑа",linkAccountSubtitle:"Ðдин пÑоÑÐ¸Ð»Ñ â вÑ
одиÑе и по ÑелеÑонÑ, и по email",phone:"ТелеÑон",yourPhone:"ÐÐ°Ñ Ð½Ð¾Ð¼ÐµÑ ÑелеÑона",openBotShare:"ÐÑкÑойÑе боÑа и оÑпÑавÑÑе номеÑ",codeFromBot:"Ðод из боÑа",linkPhone:"ÐÑивÑзаÑÑ ÑелеÑон",orEmailPw:"или email + паÑолÑ",pwNewOrExisting:"ÐаÑÐ¾Ð»Ñ (новÑй или ÑÑÑеÑÑвÑÑÑий)",linkEmail:"ÐÑивÑзаÑÑ email",mergeHint:"ÐÑли Ñ ÑÑим email еÑÑÑ Ð¾ÑделÑнÑй аккаÑнÑ, он бÑÐ´ÐµÑ Ð¾Ð±ÑединÑн Ñ ÑÑим пÑоÑилем",googleLink:"ÐÑивÑзаÑÑ Google"}};function U({icon:d,title:o,subtitle:a,tint:t}){return e.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl grid place-items-center shrink-0 "+t,children:e.jsx(d,{className:"w-[18px] h-[18px]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"font-semibold text-foreground leading-tight",children:o}),a&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:a})]})]})}function D({id:d,label:o,icon:a,children:t}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:d,className:"text-xs font-medium text-muted-foreground",children:o}),e.jsxs("div",{className:"relative",children:[e.jsx(a,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-[18px] h-[18px] text-muted-foreground pointer-events-none"}),t]})]})}function es({className:d}){return e.jsxs("svg",{className:d,viewBox:"0 0 48 48","aria-hidden":"true",focusable:"false",children:[e.jsx("path",{fill:"#EA4335",d:"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"}),e.jsx("path",{fill:"#4285F4",d:"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"}),e.jsx("path",{fill:"#FBBC05",d:"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.28-3.14.76-4.59l-7.97-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"}),e.jsx("path",{fill:"#34A853",d:"M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"}),e.jsx("path",{fill:"none",d:"M0 0h48v48H0z"})]})}function ss({label:d,onCredential:o}){const a=n.useRef(null),t=n.useRef(null),r=n.useRef(o);return r.current=o,n.useEffect(()=>{let g=!0,f=null,m,y=0,c=null;const b=()=>{const x=a.current?.clientWidth||window.innerWidth-48;return Math.round(Math.min(400,Math.max(200,x)))},j=()=>{const x=window.google;if(!g||!x||!t.current)return;const h=b();y=h,t.current.innerHTML="";try{x.accounts.id.renderButton(t.current,{theme:"outline",size:"large",width:h,text:"continue_with",shape:"pill"})}catch{}},p=()=>{const x=window.google;if(!(!g||!x||!t.current)){try{x.accounts.id.initialize({client_id:Xe,auto_select:!1,callback:h=>{h?.credential&&r.current(h.credential)}})}catch{}j(),typeof ResizeObserver<"u"&&a.current&&(f=new ResizeObserver(()=>{b()!==y&&(window.clearTimeout(m),m=window.setTimeout(j,150))}),f.observe(a.current))}};return window.google?p():(c=document.getElementById("google-gsi-client"),c||(c=document.createElement("script"),c.src="https://accounts.google.com/gsi/client",c.async=!0,c.defer=!0,c.id="google-gsi-client",document.body.appendChild(c)),c.addEventListener("load",p)),()=>{g=!1,f?.disconnect(),window.clearTimeout(m),c?.removeEventListener("load",p)}},[]),e.jsxs("div",{ref:a,className:"relative h-11 w-full overflow-hidden",children:[e.jsxs("button",{type:"button",tabIndex:-1,"aria-hidden":"true",className:"pointer-events-none absolute inset-0 mx-auto flex h-11 w-full max-w-[400px] items-center justify-center gap-2 rounded-full border border-border bg-background text-sm font-medium text-foreground",children:[e.jsx(es,{className:"w-[18px] h-[18px] shrink-0"}),e.jsx("span",{className:"truncate",children:d})]}),e.jsx("div",{ref:t,className:"absolute inset-0 flex items-center justify-center opacity-0"})]})}const ms=()=>{const d=qe(),{t:o,language:a}=W(),t=z[a]||z.uz,{account:r,loading:g,logout:f,callOtp:m}=pe(),y=n.useRef(null),[c,b]=n.useState(""),[j,p]=n.useState(""),[x,h]=n.useState(""),[P,C]=n.useState(""),[L,k]=n.useState(""),[w,B]=n.useState(""),[I,q]=n.useState(!1),[E,F]=n.useState(!1),[Q,T]=n.useState(!1),[l,A]=n.useState([]),[X,Y]=n.useState([]),[V,$]=n.useState(!1),[Z,ee]=n.useState([]),[ve,se]=n.useState(!1),[Ne,te]=n.useState(null),[_,ae]=n.useState(null);if(n.useEffect(()=>{!g&&!r&&d("/auth",{replace:!0})},[g,r,d]),n.useEffect(()=>{r&&(b(r.name||""),p(r.email||""),h(r.gender||""),C(r.profession||""),k(r.birthday||""),B(r.region||""),Y(Array.isArray(r.interests)?r.interests:[]))},[r]),n.useEffect(()=>{(async()=>{const{data:s}=await oe.from("categories").select("id, name, name_ru, slug").order("name");s&&A(s)})()},[]),n.useEffect(()=>{const s=r?.interests||[];
1if(!s.length){ee([]);return}(async()=>{se(!0);const{data:u}=await oe.from("promo_codes").select("id, code, short_discount, short_discount_ru, discount, discount_ru, slug, brands(name, logo_url)").in("category_id",s).eq("is_active",!0).order("copy_count",{ascending:!1}).limit(12);ee(u||[]),se(!1)})()},[r?.interests]),g||!r)return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent rounded-full"})});const ye=async()=>{q(!0);try{(await m("complete_profile",{name:c,email:j,gender:x,profession:P,birthday:L,region:w}))?.ok?i.success(t.profileSaved):i.error(o("saveError"))}catch{i.error(o("error"))}finally{q(!1)}},ke=s=>Y(u=>u.includes(s)?u.filter(K=>K!==s):[...u,s]),we=async()=>{$(!0);try{(await m("set_interests",{interests:X}))?.ok?i.success(t.interestsSaved):i.error(o("saveError"))}catch{i.error(o("error"))}finally{$(!1)}},_e=async s=>{try{await Te(s.code),te(s.id),i.success(o("codeCopied")),setTimeout(()=>te(u=>u===s.id?null:u),1500)}catch{i.error(o("copyError"))}},Se=()=>y.current?.click(),Ce=async s=>{const u=s.target.files?.[0];if(s.target.value="",!!u){if(!u.type.startsWith("image/")){i.error(t.onlyImage);return}if(u.size>3*1024*1024){i.error(t.imageTooBig);return}F(!0);try{const K=await new Promise((Ie,Ae)=>{const O=new FileReader;O.onload=()=>Ie(O.result.split(",")[1]||""),O.onerror=Ae,O.readAsDataURL(u)});(await m("upload_avatar",{image_base64:K}))?.ok?i.success(o("imageUpdated")):i.error(o("imageUploadError"))}catch{i.error(o("error"))}finally{F(!1)}}},Ee=()=>{f(),i.success(t.loggedOut),d("/")},ze=async()=>{try{(await m("delete_account"))?.ok?(f(),i.success(t.accountDeleted),d("/")):i.error(o("deleteError"))}catch{i.error(o("error"))}},R="h-11 rounded-xl pl-10",re=[{key:"profil",title:t.personalInfo,icon:M},{key:"qiziqish",title:t.yourInterests,icon:le},{key:"tavsiya",title:o("forYou"),icon:ie},{key:"hisob",title:t.linkAccount,icon:be}],G=_??"profil",Pe=re.find(s=>s.key===G)?.title||t.personalInfo,Le=s=>"w-full min-w-0 flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm text-left transition-colors "+(_===s?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground "+(s==="profil"&&_===null?"md:bg-muted md:font-medium md:text-foreground":"")),Be=()=>G==="qiziqish"?e.jsxs("div",{className:H+" md:h-full",children:[e.jsx(U,{icon:le,title:t.yourInterests,subtitle:t.interestsSubtitle,tint:"bg-rose-500/10 text-rose-600 dar
1k:text-rose-400"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(s=>{const u=X.includes(s.id);return e.jsx("button",{type:"button",onClick:()=>ke(s.id),className:"px-3.5 py-2 rounded-full text-sm font-medium border transition-all "+(u?"gradient-hero text-primary-foreground border-transparent shadow-glow scale-[1.02]":"bg-background text-muted-foreground border-border hover:border-primary/40 hover:text-foreground"),children:a==="ru"&&s.name_ru?s.name_ru:s.name},s.id)})}),e.jsx(v,{className:"w-full mt-5 h-11 rounded-xl",onClick:we,disabled:V,children:V?e.jsx("span",{className:"animate-spin w-5 h-5 border-2 border-white border-t-transparent rounded-full"}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"})," ",t.saveInterests]})})]}):G==="tavsiya"?e.jsxs("div",{className:H+" md:h-full md:flex md:flex-col",children:[e.jsx(U,{icon:ie,title:o("forYou"),subtitle:o("forYouSubtitle"),tint:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}),r.interests?.length?ve?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx("div",{className:"animate-spin w-7 h-7 border-4 border-primary border-t-transparent rounded-full"})}):Z.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6 md:flex md:flex-1 md:items-center md:justify-center",children:o("noCodesInterest")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Z.map(s=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border bg-background p-3 hover:border-primary/30 transition-colors",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted flex items-center justify-center overflow-hidden shrink-0",children:s.brands?.logo_url?e.jsx("img",{src:s.brands.logo_url,alt:"",className:"w-full h-full object-contain"}):e.jsx(He,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:s.brands?.name||"Promokod"}),e.jsx("p",{className:"text-xs text-primary font-bold truncate",children:a==="ru"?s.short_discount_ru||s.short_discount||s.discount_ru||s.discount||"":s.short_discount||s.discount||""})]}),e.jsxs("button",{onClick:()=>_e(s),className:"shrink-0 inline-flex items-center gap-1 rounded-lg bg-muted hover:bg-muted/70 px-2.5 py-1.5 text-xs font-mono font-semibold text-foreground transition-colors",children:[Ne===s.id?e.jsx(je,{className:"w-3.5 h-3.5 text-green-600"}):e.jsx(Ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"max-w-[90px] truncate",children:s.code})]})]},s.id))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6 md:flex md:flex-1 md:items-center md:justify-center",children:o("pickInterestHint")})]}):G==="hisob"?e.jsx(ts,{}):e.jsxs("div",{className:H+" md:h-full",children:[e.jsx(U,{icon:M,title:t.personalInfo,subtitle:t.fillProfile,tint:"bg-primary/10 text-primary"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(D,{id:"p-name",label:t.name,icon:M,children:e.jsx(N,{id:"p-name",value:c,onChange:s=>b(s.target.value),className:R,placeholder:t.yourName})}),e.jsx(D,{id:"p-email",label:"Email",icon:J,children:e.jsx(N,{id:"p-email",type:"email",value:j,onChange:s=>p(s.target.value),className:R,placeholder:"[email protected]"})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"p-gender",className:"text-xs font-medium text-muted-foreground",children:t.gender}),e.jsxs("select",{id:"p-gender",value:x,onChange:s=>h(s.target.value),className:xe,children:[e.jsx("option",{value:"",children:t.notSelected}),e.jsx("option",{value:"erkak",children:t.male}),e.jsx("option",{value:"ayol",children:t.female})]})]}),e.jsx(D,{id:"p-prof",label:t.profession,icon:Qe,children:e.jsx(N,{id:"p-prof",value:P,onChange:s=>C(s.target.value),className:R,placeholder:t.yourProfession})}),e.jsx(D,{id:"p-bday",label:t.birthday,icon:Ke,children:e.jsx(N,{id:"p-bday",type:"date",value:L,onChange:s=>k(s.target.value),className:R})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"p-region",className:"text-xs font-medium text-muted-foreground",children:t.regi
1on}),e.jsxs("select",{id:"p-region",value:w,onChange:s=>B(s.target.value),className:xe,children:[e.jsx("option",{value:"",children:t.notSelected}),Ve.map(s=>e.jsx("option",{value:s,children:a==="ru"&&$e[s]||s},s))]})]})]}),e.jsx(v,{className:"w-full mt-6 h-11 rounded-xl",onClick:ye,disabled:I,children:I?e.jsx("span",{className:"animate-spin w-5 h-5 border-2 border-white border-t-transparent rounded-full"}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{className:"w-4 h-4 mr-2"})," ",t.save]})})]}),ne=e.jsx("div",{className:"text-center",children:Q?e.jsxs("div",{className:"mx-auto max-w-sm rounded-xl border border-destructive/30 bg-destructive/5 p-4 space-y-3 text-left",children:[e.jsx("p",{className:"text-sm text-foreground",children:o("deleteAccountConfirm")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(v,{variant:"destructive",size:"sm",className:"flex-1",onClick:ze,children:t.yesDelete}),e.jsx(v,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>T(!1),children:t.cancel})]})]}):e.jsx("button",{onClick:()=>T(!0),className:"text-xs text-muted-foreground/60 hover:text-destructive underline underline-offset-4 transition-colors",children:t.deleteAccount})});return e.jsx("div",{className:"min-h-screen bg-muted/30 pb-12",children:e.jsxs("div",{className:"w-full max-w-5xl mx-auto px-4 pt-5",children:[e.jsxs(Fe,{to:"/",className:he+(_?" hidden md:inline-flex":""),children:[e.jsx(de,{className:"w-4 h-4"})," ",t.home]}),e.jsxs("div",{className:"mt-4 md:grid md:grid-cols-[280px_1fr] md:gap-6",children:[e.jsxs("aside",{className:(_?"hidden md:block":"block")+" md:self-start md:sticky md:top-6",children:[e.jsxs("div",{className:"bg-card rounded-2xl border border-border shadow-card p-5",children:[e.jsxs("div",{className:"flex flex-col items-center text-center min-w-0",children:[e.jsxs("div",{className:"relative shrink-0",children:[e.jsx("div",{className:"w-20 h-20 rounded-full overflow-hidden bg-muted ring-4 ring-background flex items-center justify-center",children:r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"avatar",className:"w-full h-full object-cover"}):e.jsx(M,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("button",{onClick:Se,disabled:E,className:"absolute -bottom-1 -right-1 w-8 h-8 rounded-full bg-primary text-primary-foreground shadow-lg grid place-items-center hover:scale-105 transition-transform","aria-label":t.changePhoto,children:E?e.jsx("span",{className:"animate-spin w-4 h-4 border-2 border-primary-foreground border-t-transparent rounded-full"}):e.jsx(Re,{className:"w-4 h-4"})}),e.jsx("input",{ref:y,type:"file",accept:"image/*",className:"hidden",onChange:Ce})]}),e.jsx("h1",{className:"mt-3 w-full text-lg font-bold text-foreground truncate",children:r.name||t.userFallback}),(r.phone||r.email)&&e.jsx("p",{className:"w-full text-xs text-muted-foreground truncate mt-0.5",children:r.phone||r.email}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-primary/10 text-primary px-3 py-1.5 text-xs font-bold",children:[e.jsx(Ge,{className:"w-3.5 h-3.5"})," ",r.coin_balance,e.jsx("span",{className:"font-normal opacity-70",children:t.coins})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 px-3 py-1.5 text-xs font-bold",children:[e.jsx(Oe,{className:"w-3.5 h-3.5"})," ",r.coin_streak,e.jsx("span",{className:"font-normal opacity-70",children:t.streak})]})]})]}),e.jsx("nav",{className:"mt-5 space-y-1",children:re.map(s=>e.jsxs("button",{type:"button",onClick:()=>ae(s.key),className:Le(s.key),children:[e.jsx(s.icon,{className:"w-[18px] h-[18px] shrink-0"}),e.jsx("span",{className:"truncate",children:s.title}),e.jsx(Me,{className:"ml-auto w-4 h-4 shrink-0 opacity-50 md:hidden"})]},s.key))}),e.jsx("div",{className:"my-3 h-px bg-border"}),e.jsxs("button",{onClick:Ee,className:"w-full min-w-0 flex items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors",children:[e.jsx(De,{className:"w-[18px] h-[18px] shrink-0"}),e.jsx("span",{className:"truncate",children:t.logout})]})]}),e.jsx("div",{className:"mt-10 md:hidden",children:ne})]}),e.jsxs("main",{className:(_?"block":"hidden md:block")+" min-w-0 mt-4 md:mt-0 md:flex md:flex-col",children:[_&&e.jsxs("button",{type:"button",onClick:()=>ae(null),className:he+" md:hidden mb-3 max-w-full",children:[e.jsx(de,{className:"w-4 h-4 shrink-0"}),e.jsx("span",{className:"truncate",children:Pe})]}),e.jsx("div",{className:"md:flex-1",children:Be()}),e.jsx("div",{className:"mt-10 hidden md:block",children:ne})]})]})]})})};function fe({icon:d,title:o,value:a,linked:t,onToggle:r,children:g}){const{language:f}=W(),m=z[f]||z.uz;return e.jsxs("div",{className:"rounded-xl border border-border bg-background p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg grid place-items-center shrink-0 "+(t?"bg-green-500/10 text-green-600 dark:text-green-400":"bg-muted text-muted-foreground"),children:e.jsx(d,{className:"w-[18px] h-[18px]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:o}),t?e.jsx("p",{className:"text-xs text-green-600 dark:text-green-400 truncate",children:a}):e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:m.notLinked})]})]}),t?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-600 dark:text-green-400 shrink-0",children:[e.jsx(je,{className:"w-4 h-4"})," ",m.active]}):e.jsxs(v,{size:"sm",variant:"outline",onClick:r,className:"shrink-0 rounded-lg",children:[e.jsx(We,{className:"w-4 h-4 mr-1"})," ",m.link]})]}),g]})}function ts(){const{t:d,language:o}=W(),a=z[o]||z.uz,{account:t,callOtp:r,setSession:g}=pe(),[f,m]=n.useState(!1),[y,c]=n.useState(!1),[b,j]=n.useState(""),[p,x]=n.useState(""),[h,P]=n.useState(""),[C,L]=n.useState(""),[k,w]=n.useState(!1),B=!!t?.phone,I=!!t?.email,q=`https://t.me/${Ye}?start=login`,E=(l,A)=>l?.ok&&l.session?(g(l.session),i.success(A),!0):(i.error(Ze(l?.error,d,o)),!1),F=async()=>
1{if(!/^\d{4}$/.test(p.trim())){i.error(a.enter4Digit);return}w(!0);try{const l=await r("link_phone",{phone:b,code:p.trim()});E(l,a.phoneLinked)&&(m(!1),j(""),x(""))}catch{i.error(d("error"))}finally{w(!1)}},Q=async()=>{if(!h.includes("@")||C.length<6){i.error(d("emailPasswordInvalid"));return}w(!0);try{const l=await r("link_email_password",{email:h.trim(),password:C});E(l,a.emailLinked)&&(c(!1),P(""),L(""))}catch{i.error(d("error"))}finally{w(!1)}},T=async l=>{try{const A=await r("link_google",{id_token:l});E(A,a.googleLinked)&&c(!1)}catch{i.error(d("error"))}};return e.jsxs("div",{className:H+" md:h-full",children:[e.jsx(U,{icon:be,title:a.linkAccount,subtitle:a.linkAccountSubtitle,tint:"bg-blue-500/10 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(fe,{icon:me,title:a.phone,value:t?.phone,linked:B,onToggle:()=>m(l=>!l),children:!B&&f&&e.jsxs("div",{className:"mt-4 space-y-3 border-t border-border pt-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"lk-phone",className:"text-xs font-medium text-muted-foreground",children:a.yourPhone}),e.jsxs("div",{className:"relative",children:[e.jsx(me,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-[18px] h-[18px] text-muted-foreground"}),e.jsx(N,{id:"lk-phone",type:"tel",inputMode:"tel",placeholder:"+998 90 123 45 67",value:b,onChange:l=>j(l.target.value),className:"h-11 rounded-xl pl-10"})]})]}),e.jsx("a",{href:q,target:"_blank",rel:"noopener noreferrer",className:"block",children:e.jsxs(v,{type:"button",variant:"outline",className:"w-full h-11 rounded-xl",children:[e.jsx(Je,{className:"w-4 h-4 mr-2"})," ",a.openBotShare]})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"lk-code",className:"text-xs font-medium text-muted-foreground",children:a.codeFromBot}),e.jsx(N,{id:"lk-code",inputMode:"numeric",maxLength:4,placeholder:"0000",value:p,onChange:l=>x(l.target.value.replace(/\D/g,"")),className:"h-12 rounded-xl text-center text-xl tracking-[0.4em] font-bold"})]}),e.jsx(v,{className:"w-full h-11 rounded-xl",onClick:F,disabled:k,children:k?e.jsx("span",{className:"animate-spin w-5 h-5 border-2 border-white border-t-transparent rounded-full"}):e.jsxs(e.Fragment,{children:[a.linkPhone," ",e.jsx(ue,{className:"w-4 h-4 ml-2"})]})})]})}),e.jsx(fe,{icon:J,title:"Email",value:t?.email,linked:I,onToggle:()=>c(l=>!l),children:!I&&y&&e.jsxs("div",{className:"mt-4 space-y-3 border-t border-border pt-4",children:[e.jsx(ss,{label:a.googleLink,onCredential:T}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.orEmailPw}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"lk-email",className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(J,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-[18px] h-[18px] text-muted-foreground"}),e.jsx(N,{id:"lk-email",type:"email",placeholder:"[email protected]",value:h,onChange:l=>P(l.target.value),className:"h-11 rounded-xl pl-10"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(S,{htmlFor:"lk-pw",className:"text-xs font-medium text-muted-foreground",children:a.pwNewOrExisting}),e.jsx(N,{id:"lk-pw",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:C,onChange:l=>L(l.target.value),className:"h-11 rounded-xl"})]}),e.jsx(v,{className:"w-full h-11 rounded-xl",onClick:Q,disabled:k,children:k?e.jsx("span",{className:"animate-spin w-5 h-5 border-2 border-white border-t-transparent rounded-full"}):e.jsxs(e.Fragment,{children:[a.linkEmail," ",e.jsx(ue,{className:"w-4 h-4 ml-2"})]})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:a.mergeHint})]})})]})]})}export{ms 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.