1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-ChuG2Ra-.css"])))=>i.map(i=>d[i]); 2import{_ as u}from"./preload-helper-BXtGQ0on.js";import{z as b,G as $e,h as ie,S as fe,T as Ne,a as pe,U as dt,V as ft,W as pt,X as mt,Y as _t,p as qe,i as yt,N as ht,D as gt,A as N,Z as St,_ as F,d as w,$ as xe,a0 as J,g as me,o as G,H as vt,f as Fe,a1 as ke}from"./index-DOARK-DV.js";import{d as q,e as wt,s as bt}from"./state-vendor-B2bKdg16.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e7e3c582-1409-4c80-9fe8-56e13d20a5bd",e._sentryDebugIdIdentifier="sentry-dbid-e7e3c582-1409-4c80-9fe8-56e13d20a5bd")}catch{}})();const E={role:"user",tier:"free",viewAsTier:null,isCoach:!1,clubAdminOf:[],isLoaded:!1};let V=0;const R=q(e=>({...E,hydrate:async()=>{const t=++V,n=b();if(!n){e({...E,isLoaded:!0});return}e({...E,isLoaded:!1});try{const r=await $e();if(t!==V||b()!==n)return;if(!r){e({...E,isLoaded:!0});return}e({role:r.role||"user",tier:r.tier||"free",isCoach:r.is_coach===!0,clubAdminOf:Array.isArray(r.club_admin_of)?r.club_admin_of:[],isLoaded:!0})}catch(r){if(t!==V||b()!==n)return;ie(r,"permissions.hydrate",{silent:!0}),e({...E,isLoaded:!0})}},clear:()=>{V+=1,e({...E})}
2,setViewAsTier:t=>e({viewAsTier:t})})),K="togyz",kt=["product_home","lobby","solo_lab","pvp","ranked","review","history","coach","puzzles","scan","skins","tournaments","how_to_play","local_pass_play","spectator","guest_qr","friend_challenge","custom_seek","wagers","leaderboard","clubs","forum","news","achievements","training_ground","saga","daily_puzzle","trainer_oracle","live_coach","voice_coach","golden_moves","shared_game_preview"],Pt=["product_home","lobby","solo_lab","pvp","ranked","review","history","skins","how_to_play","local_pass_play","spectator","guest_qr","friend_challenge","custom_seek","wagers","leaderboard"],At=["product_home","lobby","pvp","ranked","review","history","local_pass_play","friend_challenge","custom_seek","leaderboard"];function se(e,t,n){return{pitsPerSide:e,sides:2,initialStonesPerPit:t,hasStores:n.hasStores,storeCount:n.hasStores?2:0,hasTuzdyk:n.hasTuzdyk,totalStones:e*2*t}}function T(e,t){return`games.${e}.${t}`}function B(e,t,n){return{productKey:e,gameFamily:"mancala",variantId:e,rulesetVersion:`${e}.v1`,labelKey:T(e,"label"),shortLabelKey:T(e,"shortLabel"),fallbackLabel:t,boardLabel:`${n.pitsPerSide}x2`,geometry:se(n.pitsPerSide,n.initialStonesPerPit,{hasStores:n.hasStores,hasTuzdyk:!1}),defaultRoute:`/${e}/`,howToPlaySlug:e,seoSlug:e,mobileDeepLinkScheme:e,capabilities:Pt,requiredFeatureFlags:[`game_${e}_enabled`]}}const _e=[{productKey:"togyz",gameFamily:"togyz",variantId:"togyzkumalak",rulesetVersion:"togyzkumalak.v1",labelKey:T("togyz","label"),shortLabelKey:T("togyz","shortLabel"),fallbackLabel:"Togyzkumalak",boardLabel:"9x2",geometry:se(9,9,{hasStores:!1,hasTuzdyk:!0}),defaultRoute:"/",howToPlaySlug:"togyzkumalak",seoSlug:"togyzkumalak",mobileDeepLinkScheme:"togyzarena",capabilities:kt,requiredFeatureFlags:[]},B("kalah","Kalah",{pitsPerSide:6,initialStonesPerPit:4,hasStores:!0}),B("mangala","Mangala",{pitsPerSide:6,initialStonesPerPit:4,hasStores:!0}),B("oware","Oware",{pitsPerSide:6,initialStonesPerPit:4,hasStores:!1}),B("bestemshe","Bestemshe",{pitsPerSide:5,initialStonesPerPit:5,hasStores:!1}),{productKey:"chess",gameFamily:"chess",variantId:"chess",rulesetVersion:"chess.v1",labelKey:T("chess","label"),shortLabelKey:T("chess","shortLabel"),fallbackLabel:"Chess",boardLabel:"8x8",geometry:se(8,0,{hasStores:!1,hasTuzdyk:!1}),defaultRoute:"/chess/",howToPlaySlug:"chess",seoSlug:"chess",mobileDeepLinkScheme:"chess",capabilities:At,requiredFeatureFlags:["game_chess_enabled"]}];function Pe(e){return _e.find(t=>t.productKey===e)}function S(e){return Pe(e)??Pe(K)}function Ge(e){return _e.find(t=>t.variantId===e)}function nr(e){return _e.filter(t=>t.capabilities.includes(e))}function rr(e){return S(e).fallbackLabel}const Et="tk-game-selection",M={productKey:K,variantId:S(K).variantId};function ye(e){return{productKey:e.productKey,variantId:e.variantId}}function I(e){const t=S(e.productKey);return{selectedProductKey:t.productKey,selectedVariantId:t.variantId,selectedProduct:t}}function L(e){if(!e)return ye(M);if(e.variantId){const n=Ge(e.variantId);if(n&&n.productKey===e.productKey)return{productKey:n.productKey,variantId:n.variantId}}const t=S(e.productKey);return{productKey:t.productKey,variantId:t.variantId}}function Ve(e){if(!e)return null;const t=L(e),n=S(t.productKey);return{source:e.source,productKey:t.productKey,variantId:t.variantId,path:e.path||n.defaultRoute,rawPath:e.rawPath,entryContextId:e.entryContextId,createdAt:e.createdAt||new Date().toISOString()}}function Tt(e){return e?.source==="landing"||e?.source==="blog"||e?.source==="deeplink"}function Be(e,t,n,r){const o=S(e.productKey);return{source:t,productKey:o.productKey,variantId:o.variantId,path:o.defaultRoute,rawPath:n,entryContextId:r,createdAt:new Date().toISOString()}}function ce(e){const t=e?.toString()??"";return new URLSearchParams(t.startsWith("?")?t.slice(1):t)}function We(e){if(!e)return null;const t=e.toLowerCase();return t.includes("blog")?"blog":t.includes("deeplink")?"deeplink":t.includes("profile")?"profile":t.includes("settings")?"settings":t.includes("manual")?"manual":"landing"}function Q(e,t,n,r=null){const o=ce(t),a=o.get("product")?.trim()||null,i=o.get("entry_context")?.trim()||void 0,s=e.split("/").filter(
2Boolean)[0]??null;return{productSlug:a??s,rawPath:n,source:We(i)??r,entryContextId:i}}function Ye(e){if(e instanceof URL){const t=e.protocol.replace(":","");if(S(t).productKey===t){const o=ce(e.search).get("entry_context")?.trim()||void 0;return{productSlug:t,rawPath:e.toString(),source:We(o)??"deeplink",entryContextId:o}}const r=Q(e.pathname,e.search,`${e.pathname}${e.search}`,null);return r.entryContextId||ce(e.search).has("product"),r}if(typeof e=="object"){const t=e.pathname??"",n=e.search?.toString()??"";return Q(t,n,`${t}${n}`)}try{const t=new URL(e);return Ye(t)}catch{const[t]=e.split("#"),n=t.indexOf("?"),r=n>=0?t.slice(0,n):t,o=n>=0?t.slice(n):"";return Q(r,o,t)}}function or(e,t){const n=Ye(e);if(!n.productSlug)return null;const r=S(n.productSlug);return r.productKey!==n.productSlug?null:Be({productKey:r.productKey,variantId:r.variantId},n.source??"landing",n.rawPath,n.entryContextId)}const It=I(M),Ct={...It,defaultPreference:ye(M),entryContext:null,queuedProfilePreference:null};function Lt(e,t){const n=e,r=L({productKey:n?.selectedProductKey,variantId:n?.selectedVariantId});return{...t,...I(r),defaultPreference:L(n?.defaultPreference),entryContext:Ve(n?.entryContext),queuedProfilePreference:n?.queuedProfilePreference?L(n.queuedProfilePreference):null}}const Je=q()(wt((e,t)=>({...Ct,selectProduct:(n,r={})=>{const o=S(n),a={productKey:o.productKey,variantId:o.variantId};e({...I(a),entryContext:{source:r.source??"manual",productKey:a.productKey,variantId:a.variantId,path:r.path??o.defaultRoute,rawPath:r.rawPath,entryContextId:r.entryContextId,createdAt:r.createdAt??new Date().toISOString()},queuedProfilePreference:null})},selectVariant:(n,r={})=>{const o=Ge(n)??S(K);t().selectProduct(o.productKey,{...r,source:r.source??"manual"})},applyEntryContext:n=>{const r=Ve(n);r&&e({...I(r),entryContext:r,queuedProfilePreference:null})},setDefaultPreference:n=>{e({defaultPreference:L(n)})},applyProfilePreference:n=>{const r=L(n),o=t().entryContext;if(Tt(o)){e({defaultPreference:r,queuedProfilePreference:r});return}e({...I(r),defaultPreference:r,entryContext:Be(r,"profile"),queuedProfilePreference:null})},clearEntryContext:()=>{e({entryContext:null,queuedProfilePreference:null})},resetToDefault:()=>{e({...I(M),defaultPreference:ye(M),entryContext:null,queuedProfilePreference:null})}}),{name:Et,version:1,partialize:e=>({selectedProductKey:e.selectedProductKey,selectedVariantId:e.selectedVariantId,defaultPreference:e.defaultPreference,entryContext:e.entryContext,queuedProfilePreference:e.queuedProfilePreference}),merge:Lt}));let D=null,ee=null,te=0;const Ae="analytics_anonymous_id_v1",Ee="analytics_client_session_id_v1",zt="utm_params",Rt=new Set(["screen_name","current_plan","trigger","game_mode","time_control","rating_type","opponent_type","currency","value","items","error_code","error_type","platform","path","device_type","app_version","os_name","browser_name","device_model"]);function he(){if(typeof globalThis.crypto?.randomUUID=="function")return globalThis.crypto.randomUUID();const e=new Uint8Array(16);if(typeof globalThis.crypto?.getRandomValues=="function")globalThis.crypto.getRandomValues(e);else for(let n=0;n<e.length;n+=1)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Ot(){const e=ht(Ae);if(e)return e;const t=he();return gt(Ae,t),t}function Dt(){const e=qe(Ee);if(e)return e;const t=he();return yt(Ee,t),t}function Ut(){const e={};try{const t=qe(zt),n=t?JSON.parse(t):{};for(const r of["utm_source","utm_medium","utm_campaign"]){const o=n[r];typeof o=="string"&&o.trim()&&(e[r]=o.trim())}}catch{}try{document.referrer&&(e.referrer_host=new URL(document.referrer).hostname)}catch{}return e}function Kt(e){const t={};for(const[n,r]of Object.entries(e))Rt.has(n)&&r!==void 0&&(t[n]=r);return t}async function ar(){try{const e={device_type:dt(),platform:Ne()},t=ft();t&&(e.app_version=t);const n=pt();n&&(e.os_name=n);const r=mt();r&&(e.browser_name=r);const o=_t();o&&(e.device_model=o),je("session_start",e);const a=await pe("/api/analytics/session",e);a?.session_id&&(D=a.session_id)}catch{}}function ir(){if(!D)return;const e=b(),t=`${N}/api/analytics/session/${D}/end`;try{if(!e){D=null;return}fetch(t,{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:"{}",keepalive:!0})}catch{}D=null}function sr(e){const t=Date.now();if(fe()==="accepted"&&ee&&te){const r=t-te;pe("/api/analytics/screen",{screen_name:ee,duration_ms:r}).catch(()=>{})}ee=e,te=t}function je(e,t={}){const n=e.trim().toLowerCase();if(!n||fe()!=="accepted")return;const r=Je.getState(),o={platform:Ne(),path:typeof window<"u"?window.location.pathname:void 0,...t},a=typeof t.product_key=="string"?t.product_key:r.selectedProductKey,i=typeof t.variant_id=="string"?t.variant_id:r.selectedVariantId;pe("/api/analytics/event",{event_id:he(),event_name:n,anonymous_id:Ot(),client_session_id:Dt(),product_key:a,variant_id:i,properties:Kt(o),attribution:Ut()}).catch(()=>{})}const Mt="G-NW5PSFGJBZ",$t=new Set(["play_cta_click","view_pricing","begin_checkout","checkout_error","screen_view"]);function $(...e){typeof window.gtag=="function"?window.gtag(...e):(window.dataLayer=window.dataLayer||[],window.dataLayer.push(e))}function m(e,t){const{isMock:n}=St.getState(),r={...t};n&&(r.debug_mode=!0,r.data_source="mock"),$("event",e,r);const o=e==="page_view"?"screen_view":e;$t.has(o)&&fe()==="accepted"&&je(o,e==="page_view"?{screen_name:r.page_title}:r)}function W(e,t){$("config",Mt,{user_id:e}),t&&$("set","user_properties",t)}function Nt(e){$("set","user_properties",{current_plan:e})}const qt=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function cr(){try{if(sessionStorage.getItem("utm_sent"))return;const e=new URLSearchParams(window.location.search),t={};for(const n of qt){const r=e.get(n);r&&(t[n]=r)}if(Object.keys(t).length===0)return;sessionStorage.setItem("utm_params",JSON.stringify(t)),sessionStorage.setItem("utm_sent","1"),m("campaign_details",{campaign_id:t.utm_campaign,source:t.utm_source,medium:t.utm_medium,term:t.utm_term,content:t.utm_content})}catch{}}function xt(e="email"){m("sign_up",{method:e})}const Ft="AW-18005670557",Gt="5aQjCJrQlIYcEJ314olD";function Vt(){$("event","conversion",{send_to:`${Ft}/${Gt}`,value:1,currency:"UAH"})}function lr(e="email"){m("login",{method:e})}function ur(e,t){m("play_cta_click",{game_mode:e,time_control:t?.timeControl,rating_type:t?.ratingType})}function dr(e){m("view_ai_trainer",{current_plan:e})}function fr(e,t){m("view_pricing",{current_plan:e,trigger:t})}function pr(e,t){m("game_start",{game_mode:e,time_control:t?.timeControl??"",rating_type:t?.ratingType,opponent_type:t?.opponentType})}function mr(e,t,n){m("game_complete",{result:e,game_mode:t,opponent_type:n?.opponentType,game_duration_seconds:n?.gameDurationSeconds})}function _r(){m("puzzle_start")}function yr(e){m("tournament_join",{tournament_id:e})}function hr(e){m("invite_friend",{method:e})}function gr(){m("view_leaderboard")}function Sr(){m("view_battle_page")}function vr(e,t,n){m("begin_checkout",{currency:e,value:t,items:n})}const Te=new Set;function wr(e,t,n,r){if(!Te.has(e)){try{if(sessionStorage.getItem(`ga_sent_txn_${e}`))return}catch{}Te.add(e);try{sessionStorage.setItem(`ga_sent_txn_${e}`,"1")}catch{}m("purchase",{transaction_id:e,value:t,currency:n,items:r})}}const Bt=3,Wt=3e4,Yt=3e4,y=new Map;let k=!1;function Jt(e,t){if(t===!1&&e.idleDegrade){e.idleStreak+=1,e.idleStreak>=Bt&&(e.idleStreak=0,e.effectiveInterval=Math.min(e.effectiveInterval*2,e.maxIdleMs));return}e.idleStreak=0,e.effectiveInterval=e.baseInterval}function Ze(e){e.idleStreak=0,e.effectiveInterval=e.baseInterval}function ge(e){e.errorCount+=1,e.effectiveInterval=Math.min(e.baseInterval*Math.pow(2,e.errorCount),Yt)}function Se(e,t){k||(t.timerId=setTimeout(async()=>
2{if(!(k||!y.has(e))){try{Jt(t,await t.fn()),t.errorCount=0}catch{ge(t)}y.has(e)&&Se(e,t)}},t.effectiveInterval))}function X(e){e.timerId!==null&&(clearTimeout(e.timerId),e.timerId=null)}function jt(e,t,n,r){y.has(e)&&X(y.get(e));const o={fn:t,baseInterval:n,effectiveInterval:n,errorCount:0,idleStreak:0,maxIdleMs:r?.maxIdleMs??Wt,idleDegrade:r?.idleDegrade??!0,timerId:null};y.set(e,o),k||Se(e,o)}function Zt(e){const t=y.get(e);t&&(X(t),y.delete(e))}function Ht(){y.forEach(e=>X(e)),y.clear()}function Xt(e){const t=y.get(e);!t||k||(async()=>{try{await t.fn(),t.errorCount=0,Ze(t)}catch{ge(t)}})()}async function He(){for(const[e,t]of y){try{await t.fn(),t.errorCount=0,Ze(t)}catch{ge(t)}y.has(e)&&!k&&Se(e,t)}}typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.hidden?(k=!0,y.forEach(e=>X(e))):(k=!1,He())});const Qt={register:jt,unregister:Zt,unregisterAll:Ht,fireAll:He,fireNow:Xt},en=[{id:"none",labelKey:"avatar_effect.none.label",descKey:"avatar_effect.none.desc"},{id:"aurora",labelKey:"avatar_effect.aurora.label",descKey:"avatar_effect.aurora.desc"},{id:"prism",labelKey:"avatar_effect.prism.label",descKey:"avatar_effect.prism.desc"},{id:"ember",labelKey:"avatar_effect.ember.label",descKey:"avatar_effect.ember.desc"},{id:"pulse",labelKey:"avatar_effect.pulse.label",descKey:"avatar_effect.pulse.desc"}],tn="none",nn=new Set(en.map(e=>e.id));function Ie(e){if(typeof e=="string"){const t=e.trim().toLowerCase();if(nn.has(t))return t}return tn}const rn=["kk","ru","en","ky","tr","uz"],on={kk:"kk-KZ",ru:"ru-RU",en:"en-US",ky:"ky-KG",tr:"tr-TR",uz:"uz-UZ"},Xe=["AE","AZ","CA","CN","DE","FR","GB","JP","KG","KR","KZ","MN","TJ","TM","TR","UA","US","UZ"],an=new Set(Xe);function sn(e){const t=String(e??"").trim().toLowerCase().slice(0,2);return rn.find(n=>n===t)??"ru"}function le(e){const t=String(e??"").trim().toUpperCase();return!t||t==="RU"?null:an.has(t)?t:null}function cn(e,t){const n=le(e);if(!n)return"";const r=sn(t),o=on[r];try{return new Intl.DisplayNames([o,"en-US"],{type:"region"}).of(n)??n}catch{return n}}function br(e){return Xe.map(t=>({code:t,label:cn(t,e)}))}const ln=15e3,Ce=250;function un(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.product_key=="string"?t.product_key:typeof t.productKey=="string"?t.productKey:void 0,r=typeof t.variant_id=="string"?t.variant_id:typeof t.variantId=="string"?t.variantId:void 0;return!n&&!r?null:{productKey:n,variantId:r}}class dn extends Error{detail;constructor(t){super("account_frozen"),this.name="FrozenAccountError",this.detail=t}}function fn(e){try{return JSON.parse(atob(e.split(".")[1]))}catch{return null}}function pn(e){return e?typeof e.can_claim=="boolean"?e.can_claim:typeof e.already_claimed=="boolean"?!e.already_claimed:!(e.coins_awarded!=null||typeof e.bonus_type=="string"||typeof e.streak_day!="number"&&typeof e.preview_coins!="number"&&typeof e.coins_today!="number"):!1}function mn(){if(typeof window>"u")return;const e=window;if(typeof e.notifyMobileLogout=="function")try{e.notifyMobileLogout()}catch{}}function _n(){if(typeof window>"u")return;const e=window;e.electronAPI?.isElectron!==!0||typeof e.electronAPI.logout!="function"||e.electronAPI.logout().catch(()=>{})}const yn=q((e,t)=>({user:null,isLoading:!0,isAuthenticated:!1,subscriptionTier:"free",dbUsername:null,displayName:null,avatarUrl:null,accountCreatedAt:null,countryCode:null,avatarEffect:"none",blitzRating:null,playerRatings:{},ratingsLoaded:!1,totalWins:0,homeTotalGames:0,homeStreak:0,homeBonusAvailable:!1,homeWeeklyStats:null,homeStreakShields:0,homeStreakFreezes:0,homeBundleLoaded:!1,pushRewardClaimed:!1,coachSettings:{},assistantSettings:{skin:"sage",gender:"M",voice:"Kore",style:"academic"},showEmailPrompt:!1,bannedUntil:null,banReason:null,initialize:async()=>{let n;const r=()=>{n!==void 0&&(window.clearTimeout(n),n=void 0)},o=f=>{const l=fn(f);return!l||!l.exp||l.exp*1e3<=Date.now()?!1:(r(),G(f),e({user:{id:l.sub,email:l.email||""},isAuthenticated:!0,isLoading:!1}),W(l.sub),R.getState().hydrate(),setTimeout(()=>t().fetchMyProfile(),500),!0)},a=()=>{b()||t().logout()};window.addEventListener("auth:unauthorized",a);const i=()=>
2{if(t().isAuthenticated)return;const f=b();f&&(o(f)||(F(),e({isLoading:!1})))};window.addEventListener("storage",i);const s=vt({platform:window.__TOGYZ_PLATFORM__,userAgent:navigator.userAgent}),c=b(),_=c?o(c):!1;if(c&&!_&&F(),!_)if(s){e({isLoading:!0});const f=Date.now()+ln,l=()=>{if(n=void 0,t().isAuthenticated)return;const d=b();if(d){if(o(d))return;F()}const g=f-Date.now();if(g<=0){e({isLoading:!1});return}n=window.setTimeout(l,Math.min(Ce,g))};n=window.setTimeout(l,Ce)}else e({isLoading:!1});return()=>{r(),window.removeEventListener("auth:unauthorized",a),window.removeEventListener("storage",i)}},install401Listener:()=>{const n=()=>{b()||t().logout()};return window.addEventListener("auth:unauthorized",n),()=>{window.removeEventListener("auth:unauthorized",n)}},login:async(n,r)=>{const o=await J("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,password:r,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone})},{context:"auth.login",silent:!0});if(!o)throw new Error("Network error");const a=await o.json().catch(()=>({}));if(!o.ok){const s=a?.detail;throw s?.code==="account_frozen"&&s?.restore_token&&s?.challenge?new dn(s):new Error(typeof s=="string"?s:"Invalid email or password")}if(a&&typeof a=="object"&&"promo_celebrations"in a){const s=a.promo_celebrations;Array.isArray(s)&&s.length>0&&de.getState().addCelebrations(s)}const i=a;G(i.access_token),e({user:i.user,isAuthenticated:!0}),W(i.user.id),R.getState().hydrate(),t().fetchMyProfile()},completeFrozenRestore:async n=>{const r=await J("/api/auth/frozen/restore/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)},{context:"auth.frozen_restore_complete",silent:!0});if(!r)throw new Error("Network error");const o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.detail||"Ðе ÑдалоÑÑ Ð²Ð¾ÑÑÑановиÑÑ Ð°ÐºÐºÐ°ÑнÑ");const a=o;G(a.access_token),e({user:a.user,isAuthenticated:!0}),W(a.user.id),R.getState().hydrate(),t().fetchMyProfile()},register:async(n,r,o)=>{const a=await J("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:n,password:r,username:o,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,locale:me()})},{context:"auth.register",silent:!0});if(!a)throw new Error("Network error");const i=await a.json().catch(()=>({}));if(!a.ok)throw new Error(i?.detail||"Registration failed");if(i&&typeof i=="object"&&"promo_celebrations"in i){const c=i.promo_celebrations;Array.isArray(c)&&c.length>0&&de.getState().addCelebrations(c)}const s=i;return G(s.access_token),e({user:s.user,isAuthenticated:!0}),W(s.user.id,{registration_method:"email"}),xt("email"),Vt(),R.getState().hydrate(),t().fetchMyProfile(),{is_new_user:s.is_new_user}},fetchMyProfile:async()=>{try{const n=await $e();if(!n)return;const r=typeof n.username=="string"?n.username:null,o=typeof n.display_name=="string"&&n.display_name.trim()?n.display_name.trim():null,a=typeof n.avatar_url=="string"&&n.avatar_url.trim()?n.avatar_url:null,i=typeof n.created_at=="string"?n.created_at:null,s=le(typeof n.country_code=="string"?n.country_code:null),c=n.settings&&typeof n.settings=="object"?n.settings:null,_=un(c?.game_preference??c?.gamePreference),f=Ie(c?.avatar_effect),l={};if(c)for(const A of["coach_avatar","coach_gender","coach_voice","coach_persona"])typeof c[A]=="string"&&(l[A]=c[A]);const d={skin:c?.ai_assistant_skin||l.coach_avatar||"sage",gender:c?.ai_assistant_gender||l.coach_gender||"M",voice:c?.ai_assistant_voice||l.coach_voice||"Kore",style:c?.ai_assistant_style||l.coach_persona||"academic"};r&&e({dbUsername:r}),e({displayName:o,avatarUrl:a,accountCreatedAt:i,countryCode:s,avatarEffect:f,coachSettings:l,assistantSettings:d}),_&&Je.getState().applyProfilePreference(_);try{s?localStorage.setItem("profile_country_code",s):localStorage.removeItem("profile_country_code")}catch{}const g=typeof n.banned_until=="string"?n.banned_until:null,h=typeof n.ban_reason=="string"?n.ban_reason:null;e({bannedUntil:g,banReason:h}),typeof n.push_reward_claimed=="boolean"&&e({pushRewardClaimed:n.push_reward_claimed});const v=n.tier;(v==="free"||v==="pro"||v==="elite")&&(e({subscriptionTier:v}),Nt(v));const P=typeof n.locale=="string"?n.locale:null;if(P&&["kk","ru","en","ky","tr","uz"].includes(P)){const A=localStorage.getItem("locale");(!A||A!==P)&&localStorage.setItem("locale",P)}const x=Intl.DateTimeFormat().resolvedOptions().timeZone,ut=localStorage.getItem("tz_synced");x&&x!==ut&&xe("/api/me",{timezone:x}).then(()=>{localStorage.setItem("tz_synced",x)}).catch(()=>{})}catch(n){ie(n,"auth.profile",{silent:!0})}t().fetchPlayerRatings().catch(()=>{})},fetchPlayerRatings:async()=>
2{if(t().ratingsLoaded)return;const n=await w("/api/me/ratings");if(!n?.ratings)return;const r={};for(const a of n.ratings)r[a.rating_type]={rating:Math.round(a.rating??1500),rd:Math.round(a.rd??350)};const o=r.blitz?.rating??null;e({playerRatings:r,ratingsLoaded:!0,...o!==null?{blitzRating:o}:{}})},applyRatingDelta:(n,r)=>{if(!n)return;const o=n[r],a=o?.after??o?.new_rating;if(!a)return;const i=Math.round(a);e(s=>({blitzRating:i,playerRatings:{...s.playerRatings,blitz:{...s.playerRatings.blitz??{},rating:i}}}))},fetchHomeStats:async(n=!1)=>{if(!(t().homeBundleLoaded&&!n))try{const[r,o]=await Promise.all([w("/api/me/home-bundle"),w("/api/me/streak-risk")]);if(!r)return;const a=r.ratings?.blitz?.rating,i=o?.freeze_count??r.streak?.available_freezes??r.streak?.freeze_count??0,s=o?.available_protections??(o?.shields??0)+i;e({homeBundleLoaded:!0,totalWins:r.total_wins??0,homeTotalGames:r.total_games??r.ratings?.blitz?.games_played??0,homeStreak:r.streak?.current_streak??0,homeBonusAvailable:pn(r.daily_bonus),homeWeeklyStats:r.weekly_stats??null,homeStreakShields:s,homeStreakFreezes:i,...typeof a=="number"?{blitzRating:a}:{}})}catch{}},incrementHomeWins:()=>e(n=>({totalWins:n.totalWins+1})),setHomeBonusAvailable:n=>e({homeBonusAvailable:n}),setAvatarUrl:n=>e({avatarUrl:n}),setAvatarEffect:n=>e({avatarEffect:Ie(n)}),setCountryCode:n=>{const r=le(n);e({countryCode:r});try{r?localStorage.setItem("profile_country_code",r):localStorage.removeItem("profile_country_code")}catch{}}
2,fetchSubscriptionTier:async()=>{try{const n=await w("/api/me/subscription");if(!n)return;const r=n.tier;(r==="free"||r==="pro"||r==="elite")&&e({subscriptionTier:r})}catch(n){ie(n,"auth.subscription",{silent:!0})}},logout:async()=>{Qt.unregisterAll(),mn(),_n(),F(),e({user:null,isAuthenticated:!1,dbUsername:null,displayName:null,avatarUrl:null,accountCreatedAt:null,countryCode:null,avatarEffect:"none",blitzRating:null,playerRatings:{},ratingsLoaded:!1,totalWins:0,homeTotalGames:0,homeStreak:0,homeBonusAvailable:!1,homeWeeklyStats:null,homeStreakShields:0,homeStreakFreezes:0,homeBundleLoaded:!1,pushRewardClaimed:!1,subscriptionTier:"free"});try{localStorage.removeItem("profile_country_code")}catch{}R.getState().clear()}})),hn=/[\u0400-\u04FF]/u,Qe=/(?:\u00D0.|\u00D1.|\u00C3.|\u00C2.){2,}/u,et=/(?:\u0420.|\u0421.|\u0422.|\u0423.){2,}/u,gn={1026:128,1027:129,8218:130,1107:131,8222:132,8230:133,8224:134,8225:135,8364:136,8240:137,1033:138,8249:139,1034:140,1036:141,1035:142,1039:143,1106:144,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,8482:153,1113:154,8250:155,1114:156,1116:157,1115:158,1119:159,160:160,1038:161,1118:162,1032:163,164:164,1168:165,166:166,167:167,1025:168,169:169,1028:170,171:171,172:172,173:173,174:174,1031:175,176:176,177:177,1030:178,1110:179,1169:180,181:181,182:182,183:183,1105:184,8470:185,1108:186,187:187,1112:188,1029:189,1109:190,1111:191},Sn={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159};function Le(e){if(!e||e.length===0)return null;try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return null}}function vn(e){const t=[];for(const n of e){const r=n.charCodeAt(0);if(r<=255){t.push(r);continue}const o=Sn[r];if(o!=null){t.push(o);continue}return null}return new Uint8Array(t)}function wn(e){const t=[];for(const n of e){const r=n.charCodeAt(0);if(r<=127){t.push(r);continue}if(r>=1040&&r<=1103){t.push(r-848);continue}const o=gn[r];if(o!=null){t.push(o);continue}return null}return new Uint8Array(t)}function ze(e){let t=0;return hn.test(e)&&(t+=4),Qe.test(e)||(t+=2),et.test(e)||(t+=2),e.includes("�")||(t+=1),t}function Re(e){if(typeof e!="string"||e.length===0)return e??"";const t=[e];if(Qe.test(e)){const o=Le(vn(e));o&&t.push(o)}if(et.test(e)){const o=Le(wn(e));o&&t.push(o)}let n=e,r=ze(e);for(const o of t){const a=ze(o);a>r&&(n=o,r=a)}return n}function Oe(e){let t=e;if(typeof t=="string"){const r=t;try{t=JSON.parse(t)}catch{return{ru:Re(r)}}}if(!t||typeof t!="object"||Array.isArray(t))return null;const n=Object.entries(t).flatMap(([r,o])=>typeof o!="string"?[]:[[r,Re(o)]]);return n.length>0?Object.fromEntries(n):null}const bn={Ð:"A",Ð:"B",Ð:"V",Ð:"G",Ð:"D",Ð:"E",Ð:"Yo",Ð:"Zh",Ð:"Z",Ð:"I",Ð:"Y",Ð:"K",Ð:"L",Ð:"M",Ð:"N",Ð:"O",Ð:"P",Ð :"R",С:"S",Т:"T",У:"U",Ф:"F",Ð¥:"Kh",Ц:"Ts",Ч:"Ch",Ш:"Sh",Щ:"Shch",Ъ:"",Ы:"Y",Ь:"",Ð:"E",Ю:"Yu",Я:"Ya",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",Ñ:"yo",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",Ñ:"r",Ñ:"s",Ñ:"t",Ñ:"u",Ñ:"f",Ñ
:"kh",Ñ:"ts",Ñ:"ch",Ñ:"sh",Ñ:"shch",Ñ:"",Ñ:"y",Ñ:"",Ñ:"e",Ñ:"yu",Ñ:"ya",Ó:"A",Ó:"a",Ò:"Gh",Ò:"gh",Ò:"Q",Ò:"q",Ò¢:"Ng",Ò£:"ng",Ó¨:"O",Ó©:"o",Ò°:"U",Ò±:"u",Ò®:"U",Ò¯:"u",Òº:"H",Ò»:"h",Ð:"I",Ñ:"i"},kn=/[\u0400-\u04FF\u0500-\u052F]/;function Pn(e){return kn.test(e)}function An(e){let t="";for(const n of e)t+=bn[n]??n;return t}const En=new Set(["en","tr","uz"]);function Tn(e){if(!e)return e;const t=me();return En.has(t)&&Pn(e)?An(e):e}const In=["pits_9_tuzdyk","pits_6_store","pits_6_no_store","pits_5_no_store"],tt=["pits_9_tuzdyk"],Cn=new Set(In);function Ln(e){return Cn.has(String(e??"").trim().toLowerCase())}function zn(e,t=tt){const n=Array.isArray(e)?e:typeof e=="string"?e.split(","):[],r=[];for(const o of n){const a=String(o??"").trim().toLowerCase();!Ln(a)||r.includes(a)||r.push(a)}return r.length>0?r:[...t]}function Rn(e){const t=S(e||K),{pitsPerSide:n,hasStores:r,hasTuzdyk:o}=t.geometry;return n===9&&o?["pits_9_tuzdyk"]:n===6&&r?["pits_6_store"]:n===6&&!r?["pits_6_no_store"]:n===5&&!r?["pits_5_no_store"]:[...tt]}function On(e,t){return Rn(t),[...e]}const De="".replace(/\/+$/,""),Y=new Map;function Ue(e){if(!De)return"";const t=e.startsWith("/")?e:`/${e}`;return`${De}${t}`}function Dn(e){if(!e)return!1;const t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"}function nt(e){const t=globalThis.location;return!t?.origin||Dn(t.hostname)?`${N}${e}
2`:new URL(e,t.origin).toString()}function O(e){if(typeof e!="string")return null;const t=e.trim();if(!t)return null;const n=t.toLowerCase();return n==="undefined"||n==="null"?null:t}function U(e){return e?/^https?:\/\//i.test(e)||e.startsWith("//")?e:e.startsWith("/api/skins/assets/")?nt(e):e.startsWith("/api/")||e.startsWith("/uploads/")?`${N}${e}`:e:""}function ne(e,t){if(!t)return"";const n=U(t);if(n!==t||/^https?:\/\//i.test(t)||t.startsWith("//"))return n;try{const r=/^https?:\/\//i.test(e)||e.startsWith("//")?e:nt(e);return new URL(t,r).toString()}catch{return n}}function Un(e){return e==="board"||e==="stones"||e==="effects"?e:e==="background"||e==="animation"?"effects":null}function Kn(e){return Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!1}function Mn(e){return Kn(e)?zn(e):[]}async function $n(e){if(!e)return"Network error";let t="";try{const n=await e.clone().json().catch(()=>null);typeof n?.detail=="string"&&(t=n.detail)}catch{t=""}return e.status===404?"Skin not found":e.status===409?"Skin already owned":e.status===400&&t?t:t||`Purchase failed (${e.status})`}function Ke(e,t){let n=!1;const r=e.map(o=>o.id!==t||o.isOwned&&o.ownedPermanent===!0?o:(n=!0,{...o,isOwned:!0,ownedPermanent:!0}));return n?r:e}const re=[{id:"board-classic",name:"Classic",type:"board",thumbnailUrl:"",assetUrl:"",rarity:"common",isOwned:!0,isEquipped:!0,geometryTags:[]},{id:"stones-classic",name:"Classic",type:"stones",thumbnailUrl:"",assetUrl:"",rarity:"common",isOwned:!0,isEquipped:!0,geometryTags:[]},{id:"effects-classic",name:"Classic",type:"effects",thumbnailUrl:"",assetUrl:"",rarity:"common",isOwned:!0,isEquipped:!0,geometryTags:[]}],oe={board:"board-classic",stones:"stones-classic",effects:"effects-classic"},Me=q()(bt((e,t)=>({skins:re,equippedSkins:{...oe},collection:[],assets:{textures:new Map,sounds:new Map,config:new Map},isLoading:!1,loadedAssets:new Set,skinsInitialized:!1,skinsLocale:null,loadSkins:async()=>{const n=me(),r=t();if(!(r.skinsInitialized&&r.skinsLocale===n)){e({isLoading:!0});try{const o=await w(`/api/skins?locale=${encodeURIComponent(n)}`);if(!o)throw new Error("No data");const a=(o.skins||[]).flatMap(i=>{const s=Un(i.skin_type);if(!s)return[];const c=Oe(i.name_localized),_=Oe(i.description_localized),f=ke(c,i.code??i.id,n),l=ke(_,"",n);return[{id:i.id,code:i.code??void 0,name:Tn(f),description:l||void 0,type:s,thumbnailUrl:U(i.preview_url??(i.code?Ue(`/skins/${i.code}/thumb.png`):"")),assetUrl:U(i.assets_url??(i.code?Ue(`/skins/${i.code}/assets.json`):"")),rarity:i.rarity??"common",isOwned:i.is_owned??!1,ownedPermanent:i.owned_permanent??void 0,ownedBySubscription:i.owned_by_subscription??void 0,subscriptionTierRequired:i.subscription_tier_required??null,canPurchasePermanently:i.can_purchase_permanently??void 0,availableOnPlatform:i.available_on_platform??void 0,isEquipped:i.is_equipped??!1,priceCoins:i.price_coins??void 0,priceGems:i.price_gems??void 0,unlockType:i.unlock_type??void 0,geometryTags:Mn(i.geometry_tags)}]});if(a.length>0){const i={};for(const s of a)s.isEquipped&&(i[s.type]=s.id);if(!i.board){const s=a.find(c=>c.type==="board"&&c.isOwned);s&&(i.board=s.id)}e(s=>({skins:a,equippedSkins:{...s.equippedSkins,...i}}))}else e({skins:re,equippedSkins:{...oe}})}catch{e({skins:re,equippedSkins:{...oe}})}finally{e({isLoading:!1,skinsInitialized:!0,skinsLocale:n})}}},equipSkin:async n=>{const r=O(n);if(!r)return console.debug("[SkinStore] equipSkin skipped: empty skinId"),!1;const o=t().skins.find(s=>s.id===r);if(!o)return console.warn("[SkinStore] Skin not found:",r),!1;t().loadedAssets.has(r)||await t().loadSkinAssets(r);const a={...t().equippedSkins},i=t().skins.map(s=>({...s}));e(s=>({equippedSkins:{...s.equippedSkins,[o.type]:r},skins:s.skins.map(c=>c.type===o.type?{...c,isEquipped:c.id===r}:c)}));try{return await xe("/api/me/skins/equip",{skin_id:r})!==null?!0:(e({equippedSkins:a,skins:i}),console.warn("[SkinStore] Failed to persist equipped skin (API returned error):",r),!1)}catch(s){return e({equippedSkins:a,skins:i}),console.warn("[SkinStore] Failed to persist equipped skin:",s),!1}},restoreEquipped:async()=>{try{const n=await w("/api/me/skins/equipped");if(!n)return;const r=t().skins,o={},a=O(n.board),i=O(n.stones),s=O(n.effects??n.background??n.animation);a&&r.some(c=>
2c.id===a&&c.type==="board")&&(o.board=a),i&&r.some(c=>c.id===i&&c.type==="stones")&&(o.stones=i),s&&r.some(c=>c.id===s&&c.type==="effects")&&(o.effects=s),Object.keys(o).length>0&&e(c=>{const _={...c.equippedSkins,...o};return{equippedSkins:_,skins:c.skins.map(f=>({...f,isEquipped:_[f.type]===f.id}))}})}catch{}},loadSkinAssets:async n=>{const r=t().skins.find(a=>a.id===n);if(!r||t().loadedAssets.has(n))return;if(Y.has(n))return Y.get(n);const o=(async()=>{try{const a=U(r.assetUrl);if(!a)return;const i=await J(a);if(!i?.ok)throw new Error(`HTTP ${i?.status??"network-error"}`);const s=await i.json();if(t().assets.config.set(n,s),s.textures){const l=Object.entries(s.textures);await Promise.allSettled(l.map(async([d,g])=>{const h=new Image;h.crossOrigin="anonymous",h.src=ne(a,g),await new Promise((v,P)=>{h.onload=()=>v(),h.onerror=()=>P(new Error(`Failed to load texture: ${d}`))}),t().assets.textures.set(`${n}:${d}`,h)}))}const c=t().assets.textures.has(`${n}:scene_bg`)||t().assets.textures.has(`${n}:scene`),_=typeof s.scene_url=="string"&&s.scene_url.trim().length>0?s.scene_url:null,f=s.renderMode==="style3d"||!!s.style3d;if(!c&&(_||!f)){const l=_?ne(a,_):a.replace(/\/[^/]+$/,"/scene_bg.webp");try{const d=new Image;d.crossOrigin="anonymous",d.src=l,await new Promise(g=>{d.onload=()=>g(),d.onerror=()=>g()}),d.naturalWidth>0&&t().assets.textures.set(`${n}:scene_bg`,d)}catch{}}if(s.sounds){const l=Object.entries(s.sounds).map(async([d,g])=>{const h=new Audio(ne(a,g));h.preload="auto",await new Promise(v=>{h.oncanplaythrough=v,h.onerror=v}),t().assets.sounds.set(`${n}:${d}`,h)});await Promise.all(l)}e(l=>{const d=new Set(l.loadedAssets);return d.add(n),{loadedAssets:d}})}catch(a){console.warn(`[SkinStore] Failed to load assets for ${n}:`,a)}finally{Y.delete(n)}})();return Y.set(n,o),o},preloadAllAssets:async()=>{const r=t().skins.filter(o=>o.isOwned).map(o=>t().loadSkinAssets(o.id));await Promise.all(r)},fetchCollection:async()=>{try{const n=await w("/api/me/skins/collection");n&&e({collection:(n.items||[]).map(r=>({...r,preview_url:U(r.preview_url??"")||null}))})}catch{}},purchaseSkin:async(n,r)=>{try{const o=O(n);if(!o)return{success:!1,error:"Skin not found"};const a=await Fe(`/api/skins/${o}/purchase`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({currency:r})},{context:"skinStore.purchaseSkin",silent:!0});if(!a?.ok)return{success:!1,error:await $n(a)};e(s=>({skins:Ke(s.skins,o)})),e({skinsInitialized:!1,skinsLocale:null}),await t().loadSkins(),e(s=>({skins:Ke(s.skins,o)}));const i=await t().equipSkin(o);return await t().fetchCollection(),typeof window<"u"&&window.dispatchEvent(new Event("balance:refresh")),{success:!0,equipped:i}}catch{return{success:!1,error:"Network error"}}},getEquippedSkin:n=>{const r=t().equippedSkins[n];return t().skins.find(o=>o.id===r)},getSkinsByType:n=>t().skins.filter(r=>r.type===n),getSkinsCompatibleWithProduct:n=>On(t().skins,n),getSkinById:n=>{if(n)return t().skins.find(r=>r.id===n)},isAssetLoaded:n=>t().loadedAssets.has(n)}))),rt=4500,Nn=6e4,qn=9e4,ae=new Map,xn=new Set,ue=new Set,Z=new Map,H=new Map;function ve(){return typeof Me.getState=="function"?Me.getState():null}const Fn={play:()=>u(()=>import("./PlayView-nul0xPmN.js"),__vite__mapDeps([0])),lobby:()=>u(()=>import("./LobbyView-JVID5Wqb.js"),__vite__mapDeps([0])),game:()=>u(()=>import("./GameView-BDuOU015.js"),__vite__mapDeps([0])),"pvp-game":()=>u(()=>import("./PvpGameView-LPtMYLT5.js"),__vite__mapDeps([0])),"local-game":()=>u(()=>import("./LocalGameView-BTSVh0mw.js"),__vite__mapDeps([0])),"training-ground":()=>u(()=>import("./TrainingGroundView-C5GmPAPQ.js"),__vite__mapDeps([0])),puzzle:()=>u(()=>import("./PuzzleView-DxYz4Bme.js"),__vite__mapDeps([0])),trainer:()=>u(()=>import("./TrainerView-BWMtZaq9.js").then(e=>e.T),__vite__mapDeps([0])),review:()=>u(()=>import("./GameReviewView-DCusDxUE.js"),__vite__mapDeps([0])),saga:()=>u(()=>import("./AutonomousSagaView-D2e4TWfO.js"),__vite__mapDeps([0])),"how-to-play":()=>u(()=>import("./HowToPlayView-DahwJYSw.js"),__vite__mapDeps([0])),shop:()=>u(()=>import("./ShopView-C_XtaOa1.js"),__vite__mapDeps([0])),"skin-showcase":()=>u(()=>import("./SkinShowcaseModal-DhLSRENS.js"),__vite__mapDeps([0]))},Gn={"promo-celebration":()=>u(()=>import("./PromoCelebrationModal-DptCuZV7.js"),__vite__mapDeps([0])),achievement:()=>u(()=>import("./AchievementUnlockModal-Ceo8iXKK.js"),__vite__mapDeps([0])),"daily-bonus":()=>u(()=>import("./DailyLoginBonus-Cwqa2zdo.js"),__vite__mapDeps([0])),paywall:()=>u(()=>import("./PaywallModal-CVZG_Lkt.js"),__vite__mapDeps([0])),challenge:()=>u(()=>import("./ChallengeModal-CYowDbeW.js"),__vite__mapDeps([0])),"streak-rescue":()=>u(()=>import("./StreakRescueSheet-DC1KmVw7.js"),__vite__mapDeps([0])),narrative:()=>u(()=>import("./SagaAdvanceOverlay-COMbYrsM.js"),__vite__mapDeps([0]))};function Vn(e){return new Promise(t=>{globalThis.setTimeout(()=>t(void 0),e)})}function z(e,t,n=rt){const r=ae.get(e);if(r)return r;const o=Promise.race([Promise.resolve().then(t),Vn(n)]).then(a=>(xn.add(e),a)).catch(()=>{}).finally(()=>{ae.delete(e)});return ae.set(e,o),o}function we(){if(typeof navigator>"u")return!0;const e=navigator.connection;if(e?.saveData)return!1;const t=e?.effectiveType?.toLowerCase();return t!=="slow-2g"&&t!=="2g"}function Bn(e){if(!e)return!1;const t=e.toLowerCase();return t==="localhost"||t==="127.0.0.1"||t==="::1"||t==="[::1]"}function Wn(e){const t=globalThis.location;return!t?.origin||Bn(t.hostname)?`${N}${e}
2`:new URL(e,t.origin).toString()}function be(e){return e?/^https?:\/\//i.test(e)||e.startsWith("//")?e:e.startsWith("/api/skins/assets/")?Wn(e):e.startsWith("/api/")?`${N}${e}`:e:null}function C(e,t=rt){const n=be(e);return!n||!we()||ue.has(n)?Promise.resolve(void 0):z(`image:${n}`,()=>new Promise((r,o)=>{const a=new Image;a.onload=()=>{ue.add(n),r(a)},a.onerror=()=>o(new Error(`Failed to preload image: ${n}`)),a.src=n}),t)}function kr(e){const t=be(e);return!!(t&&ue.has(t))}function p(e){return z(`route:${e}`,Fn[e])}function j(e){return z(`modal:${e}`,Gn[e])}function Yn(){return we()?Promise.all([C("/backgrounds/bg1.png"),C("/backgrounds/bg2.png"),C("/backgrounds/bg3.png"),C("/backgrounds/bg4.png")]):Promise.resolve([])}function ot(e){return e?z(`skin:${e}`,async()=>{const t=ve();!t||!t.getSkinById(e)?.assetUrl||t.loadedAssets.has(e)||await t.loadSkinAssets(e)}):Promise.resolve(void 0)}function Jn(){const e=ve();if(!e)return Promise.resolve([]);const t=Array.from(new Set(Object.values(e.equippedSkins).filter(Boolean)));return Promise.all(t.map(n=>ot(n)))}function Pr(e,t=[]){if(!e)return Promise.resolve([]);p("skin-showcase");const n=ve();if(!n)return Promise.resolve([]);const r=n.getSkinById(e),o=r?Object.entries(n.equippedSkins).filter(([c])=>c!==r.type).map(([,c])=>c):Object.values(n.equippedSkins),a=Array.from(new Set([e,...o,...t].filter(Boolean))),i=a.map(c=>C(n.getSkinById(c)?.thumbnailUrl)),s=a.map(c=>ot(c));return Promise.all([...i,...s])}function at(){return yn.getState().user?.id??"guest"}function jn(){return new Date().toISOString().slice(0,10)}function it(e){return e&&e!=="daily"?e:"daily"}function Zn(e){const t=it(e),n=new Set(["easy","medium","hard","beginner","expert"]),r=new Set(["tactical_master"]);return t==="daily"?"/api/puzzles/daily":n.has(t)?`/api/puzzles/random?difficulty=${t}`:r.has(t)?`/api/puzzles/random?theme=${t}`:`/api/puzzles/${t}`}function st(e){return`${at()}:${jn()}:${it(e)}`}function Hn(e){const t=st(e),n=Z.get(t);if(n&&n.expiresAt>Date.now())return Promise.resolve(n.payload);const r=Zn(e);return z(`data:puzzle:${t}`,async()=>{const o=await w(r,{context:"gamePreload.puzzle",silent:!0});return o&&Z.set(t,{payload:o,expiresAt:Date.now()+Nn}),o})}function Ar(e){const t=st(e),n=Z.get(t);return!n||n.expiresAt<=Date.now()?(Z.delete(t),null):n.payload}function ct(e){return typeof e=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)}function lt(e){return`${at()}:${e}`}function Er(e){if(!ct(e))return Promise.resolve(void 0);const t=lt(e),n=H.get(t);return n&&n.expiresAt>Date.now()?Promise.resolve(n):z(`data:review:${t}`,async()=>{const[r,o,a]=await Promise.all([w(`/api/replays/${e}`,{context:"gamePreload.replay",silent:!0}).catch(()=>null),w(`/api/games/${e}`,{context:"gamePreload.game",silent:!0}).catch(()=>null),Fe(`/api/games/${e}/golden-moves`,void 0,{context:"gamePreload.goldenMovesCache",silent:!0}).then(async s=>s?.ok?s.json():null).catch(()=>null)]),i={...r?{replay:r}:{},...o?{game:o}:{},...a?{goldenMoves:a}:{},expiresAt:Date.now()+qn};return H.set(t,i),i})}function Tr(e){if(!ct(e))return null;const t=lt(e),n=H.get(t);return!n||n.expiresAt<=Date.now()?(H.delete(t),null):n}function Xn(e){const t=be(e.celebration?.image_url);return Promise.all([j("promo-celebration"),C(t)])}function Ir(){p("play"),p("lobby"),p("puzzle"),p("trainer"),p("review"),j("promo-celebration"),j("achievement"),j("daily-bonus"),Yn()}function Cr(e){if(e==="play"){p("play"),p("lobby"),p("game"),p("pvp-game"),p("local-game"),we()&&Jn();return}if(e==="trainer"){p("trainer"),p("puzzle"),p("review"),Hn();return}e==="shop"&&(p("shop"),p("skin-showcase"))}const de=q(e=>({pending:[],addCelebrations:t=>{if(t?.length){for(const n of t)Xn(n);e(n=>({pending:[...n.pending,...t]}))}},dismissCurrent:()=>{e(t=>({pending:t.pending.slice(1)}))},clearAll:()=>{e({pending:[]})}})),Lr=Object.freeze(Object.defineProperty({__proto__:null,usePromoStore:de},Symbol.toStringTag,{value:"Module"}));export{be as $,mr as A,S as B,Ie as C,K as D,On as E,Tn as F,rr as G,dn as H,br as I,le as J,cn as K,_e as L,Pe as M,Ge as N,Tr as O,nr as P,dr as Q,Ar as R,_r as S,yr as T,Pr as U,gr as V,fr as W,vr as X,wr as Y,en as Z,de as _,yn as a,kr as a0,Xn as a1,ur as a2,hr as a3,Lr as a4,R as b,W as c,Vt as d,lr as e,cr as f,xt as g,p as h,j as i,
2Cr as j,sr as k,m as l,Sr as m,ir as n,pr as o,Qt as p,Ir as q,or as r,ar as s,je as t,Je as u,Me as v,Jn as w,Yn as x,Hn as y,Er as z};
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.