Files

231 lines
809 KiB
JavaScript
Raw Permalink Normal View History

(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))e(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&e(a)}).observe(document,{childList:!0,subtree:!0});function l(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function e(i){if(i.ep)return;i.ep=!0;const r=l(i);fetch(i.href,r)}})();function h1(t){const o=new URLSearchParams(location.search).get("host")??"*",l=i=>window.parent.postMessage({m3:1,...i},o);let e=0;return window.addEventListener("message",i=>{var a,s,y;if(i.source!==window.parent||o!=="*"&&i.origin!==o)return;const r=i.data;if(!(!r||r.m3!==1))switch(r.type){case"init":t.onInit(r),l({type:"ready"});break;case"state":t.onState(r.env);break;case"ack":(a=t.onAck)==null||a.call(t,r);break;case"view_changed":(s=t.onViewChanged)==null||s.call(t,r.view);break;case"cmd_failed":(y=t.onCmdFailed)==null||y.call(t,r.req_id,r.code);break}}),l({type:"loaded"}),{cmd(i,r={}){const a=++e;return l({type:"cmd",cmd_type:i,payload:r,req_id:a}),a},toast(i,r,a="info"){l({type:"toast",text_fa:i,text_en:r,kind:a})}}}const $={alpha:{bB:'<svg xmlns="http://www.w3.org/2000/svg" style="color-scheme:light only" viewBox="0 0 2048 2048"><path fill="#f9f9f9" d="M732 1290 628 993l386-417 421 375-132 380 49 152-658-9z"/><path fill="#101010" d="M768 1365q-5 39-26 82h564q-18-36-26-82zm495-73 46-73q-142-49-285-47-144-2-285 47l46 73q118-40 239-38 120-2 239 38m-432 227H624q67-116 72-229-114-119-162-223t-6-224q33-96 118-189t312-247q-17-11-46-36t-29-79q0-58 41-96t100-38q58 0 100 38t41 96q0 54-29 79t-46 36q226 153 311 247t119 189q42 119-6 224t-162 223q4 113 72 229h-207l10 16q33 53 70 60t89 7h250q76 0 142 62t65 179h-495q-123 0-223-84t-101-199q0 114-101 199t-223 84H205q0-117 65-179t142-62h250q51 0 88-7t71-60zm146-701h-95v89h95v165h94V907h95v-89h-95V714h-94z"/></svg>',bK:'<svg xmlns="http://www.w3.org/2000/svg" style="color-scheme:light only" viewBox="0 0 2048 2048"><path fill="#f9f9f9" d="m553 1485-55 320 1048 5-48-335s324-313 330-467c7-153-35-331-241-406-183-67-372 121-372 121l-182-161-190 160S658 586 587 592a373 373 0 0 0-362 333c10 331 328 560 328 560"/><path fill="#101010" d="M1024 1769h489l-12-73H547l-12 73zm0-921q-25-60-62-111 31-48 62-65 30 17 62 65-38 51-62 111m-97 454q-154 11-303 58-123-108-200-213t-77-202q0-89 74-159t148-70q67 0 135 63t102 130q30 54 75 175t46 218m-350 217-26 156 145-84zm447-907q-47 0-136 121-31-36-50-55 93-140 186-140 92 0 186 140-20 19-50 55-90-121-136-121m0 775q-1-126-42-267t-84-227l-14-27-12-23q-28-43-48-69-51-63-120-105t-134-42q-103 0-208 93T257 949q0 120 99 255t249 259q201-74 419-76m0 456H448l61-365q-325-280-326-535-1-159 125-274t267-116q78 0 159 47t142 119q61 74 99 165t49 150q12-60 49-150t99-165q61-72 142-119t159-47q140 0 266 116t126 274q-2 255-326 535l61 365zm97-541q0-97 45-218t76-175q34-68 102-130t135-63q74 0 148 70t74 159q0 96-77 202t-200 213q-150-47-303-58m350 217-119 72 145 84zm-447-132q217 2 419 76 150-125 249-259t99-255q0-136-105-229t-208-93q-66 0-135 42t-119 105q-21 26-48 69l-12 23-14 27q-44 85-85 227t-41 267m-139 159 139 86 139-84-139-86zm92-1248v-95h94v95h107v95h-107v153q-48-16-94 0V393H870v-95z"/></svg>',bN:'<svg xmlns="http://www.w3.org/2000/svg" style="color-scheme:light only" viewBox="0 0 2048 2048"><path fill="#f9f9f9" d="M1658 1806c-408-301-71-920-452-1343l60-16s296 167 320 257c182 468 41 691 135 1077zM972 523l120 176-312-3zM498 981l-93-41 42-93 127 28z"/><path fill="#101010" d="m502 868-52 1-26 64 69 21 46-55zm536-187q34 1-16-68t-80-42L826 680zm-338-98q6-39 116-107t220-144l115-154 96 217q342 172 433 418t47 603q-18 128 5 236t57 190l-1242 1q-9-178 39-301t183-238q50-11 83-39t53-59l63-1 138-29 139-97 66-207q0-17-8-34t-12-37q-62 228-161 289t-191 58q-236-42-292 60l-56 102-217-121 115-82-51-5
<defs>
<linearGradient id="cp-w-body" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="35%" stop-color="#f8fafc"/>
<stop offset="70%" stop-color="#e2e8f0"/>
<stop offset="100%" stop-color="#94a3b8"/>
</linearGradient>
<linearGradient id="cp-w-spec" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.95"/>
<stop offset="60%" stop-color="#ffffff" stop-opacity="0.3"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-w-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fef08a"/>
<stop offset="30%" stop-color="#f59e0b"/>
<stop offset="70%" stop-color="#d97706"/>
<stop offset="100%" stop-color="#78350f"/>
</linearGradient>
<radialGradient id="cp-ruby" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#fda4af"/>
<stop offset="35%" stop-color="#f43f5e"/>
<stop offset="75%" stop-color="#be123c"/>
<stop offset="100%" stop-color="#4c0519"/>
</radialGradient>
<radialGradient id="cp-pearl" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#ffffff"/>
<stop offset="45%" stop-color="#fef08a"/>
<stop offset="85%" stop-color="#f59e0b"/>
<stop offset="100%" stop-color="#b45309"/>
</radialGradient>
</defs>
`,H=`
<defs>
<linearGradient id="cp-b-body" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#334155"/>
<stop offset="25%" stop-color="#1e293b"/>
<stop offset="65%" stop-color="#0f172a"/>
<stop offset="100%" stop-color="#020617"/>
</linearGradient>
<linearGradient id="cp-b-spec" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#94a3b8" stop-opacity="0.9"/>
<stop offset="45%" stop-color="#64748b" stop-opacity="0.35"/>
<stop offset="100%" stop-color="#0f172a" stop-opacity="0"/>
</linearGradient>
<linearGradient id="cp-b-gold" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="#fde047"/>
<stop offset="30%" stop-color="#eab308"/>
<stop offset="70%" stop-color="#ca8a04"/>
<stop offset="100%" stop-color="#581c87"/>
</linearGradient>
<radialGradient id="cp-sapphire" cx="35%" cy="30%" r="70%">
<stop offset="0%" stop-color="#93c5fd"/>
<stop offset="35%" stop-color="#38bdf8"/>
<stop offset="75%" stop-color="#1d4ed8"/>
<stop offset="100%" stop-color="#091e60"/>
</radialGradient>
<radialGradient id="cp-amethyst" cx="30%" cy="30%" r="70%">
<stop offset="0%" stop-color="#e9d5ff"/>
<stop offset="45%" stop-color="#a855f7"/>
<stop offset="85%" stop-color="#6b21a8"/>
<stop offset="100%" stop-color="#2e1065"/>
</radialGradient>
</defs>
`;function f1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="28" ry="3.5" fill="${r}"/>
<path d="M 27 82 C 29 74, 34 68, 38 52 C 40 44, 42 42, 42 42 L 58 42 C 58 42, 60 44, 62 52 C 66 68, 71 74, 73 82 Z" fill="${e}"/>
<path d="M 33 80 C 35 73, 40 60, 42 50 C 45 49, 48 50, 48 51 C 45 61, 41 72, 38 80 Z" fill="${i}" stroke="none"/>
<ellipse cx="50" cy="42" rx="14" ry="4" fill="${r}"/>
<ellipse cx="50" cy="39" rx="11" ry="3" fill="${e}"/>
<circle cx="50" cy="24" r="14" fill="${e}"/>
<ellipse cx="44" cy="18" rx="6" ry="3.5" transform="rotate(-30 44 18)" fill="#ffffff" opacity="${t?"0.85":"0.5"}" stroke="none"/>
<circle cx="50" cy="9.5" r="2.5" fill="${r}"/>
<path d="M 21 89 C 30 85, 70 85, 79 89" fill="none" stroke="${t?"#e2e8f0":"#64748b"}" stroke-width="1.2" opacity="0.6"/>
</g>
</svg>`}function p1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)",a=t?"url(#cp-ruby)":"url(#cp-sapphire)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${r}"/>
<path d="M 25 82 C 32 72, 38 60, 34 50 C 31 46, 24 47, 18 43 C 14 40, 15 35, 19 32 C 24 29, 32 30, 36 24 C 40 18, 44 14, 52 11 L 55 18 C 58 14, 62 12, 65 14 C 67 15, 66 18, 64 22 C 74 26, 78 40, 77 56 C 76 68, 73 76, 75 82 Z" fill="${e}"/>
<path d="M 64 22 C 70 24, 76 29, 78 36 C 73 34, 68 33, 65 34 C 72 38, 77 44, 78 52 C 73 50, 68 49, 65 51 C 72 55, 75 62, 76 70 C 72 68, 68 67, 66 69" fill="none" stroke="${r}" stroke-width="2.6"/>
<path d="M 36 24 C 44 32, 48 44, 45 52 C 40 56, 34 52, 34 50" fill="none" stroke="${l}" stroke-width="1.8"/>
<path d="M 52 24 C 58 34, 60 52, 58 72 C 54 74, 48 74, 46 72 C 50 56, 48 38, 44 26 Z" fill="${i}" stroke="none"/>
<ellipse cx="20" cy="38" rx="2.5" ry="1.5" transform="rotate(-20 20 38)" fill="${l}"/>
<path d="M 17 41 C 21 44, 25 43, 27 41" fill="none" stroke="${l}" stroke-width="1.5"/>
<ellipse cx="36" cy="27" rx="3.5" ry="2.2" transform="rotate(-15 36 27)" fill="${a}"/>
<circle cx="35" cy="26" r="1" fill="#ffffff" stroke="none"/>
<path d="M 33 66 C 42 70, 58 70, 67 66 L 68 71 C 58 75, 42 75, 32 71 Z" fill="${r}"/>
<circle cx="50" cy="71" r="4.5" fill="${r}"/>
<circle cx="50" cy="71" r="2.5" fill="${a}"/>
</g>
</svg>`}function m1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 20 90 C 22 84, 30 82, 50 82 C 70 82, 78 84, 80 90 L 80 93 C 80 95, 76 96, 50 96 C 24 96, 20 95, 20 93 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="27" ry="3.5" fill="${r}"/>
<path d="M 29 82 C 31 72, 38 64, 40 52 L 60 52 C 62 64, 69 72, 71 82 Z" fill="${e}"/>
<path d="M 35 80 C 37 72, 42 62, 44 54 C 47 54, 49 55, 49 56 C 45 66, 42 74, 39 80 Z" fill="${i}" stroke="none"/>
<path d="M 38 52 C 44 55, 56 55, 62 52 L 63 56 C 56 59, 44 59, 37 56 Z" fill="${r}"/>
<path d="M 36 50 C 33 42, 32 30, 42 19 C 46 15, 49 13, 50 13 C 51 13, 54 15, 58 19 C 68 30, 67 42, 64 50 Z" fill="${e}"/>
<path d="M 58 22 L 40 40 L 44 43 L 61 24 Z" fill="${r}"/>
<path d="M 50 28 L 50 42 M 45 33 L 55 33" stroke="${r}" stroke-width="2.6"/>
<circle cx="50" cy="11" r="3.5" fill="${r}"/>
<circle cx="50" cy="11" r="1.8" fill="${t?"url(#cp-ruby)":"url(#cp-sapphire)"}" stroke="none"/>
<path d="M 40 24 C 36 30, 36 40, 39 46 C 40 46, 42 45, 42 44 C 40 38, 41 30, 43 25 Z" fill="${i}" stroke="none"/>
</g>
</svg>`}function g1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${r}"/>
<path d="M 26 82 L 31 34 L 69 34 L 74 82 Z" fill="${e}"/>
<path d="M 31 80 L 35 36 L 43 36 L 39 80 Z" fill="${i}" stroke="none"/>
<path d="M 23 34 L 77 34 L 75 27 L 25 27 Z" fill="${r}"/>
<rect x="28" y="29" width="6" height="4" fill="${e}"/>
<rect x="40" y="29" width="6" height="4" fill="${e}"/>
<rect x="54" y="29" width="6" height="4" fill="${e}"/>
<rect x="66" y="29" width="6" height="4" fill="${e}"/>
<path d="M 24 27 L 24 14 L 33 14 L 33 20 L 44 20 L 44 14 L 56 14 L 56 20 L 67 20 L 67 14 L 76 14 L 76 27 Z" fill="${e}"/>
<path d="M 23 14 L 34 14 M 43 14 L 57 14 M 66 14 L 77 14" stroke="${r}" stroke-width="2"/>
<path d="M 48 46 C 48 43, 52 43, 52 46 L 52 64 L 48 64 Z" fill="${l}"/>
<circle cx="50" cy="46" r="1.5" fill="${r}"/>
<path d="M 33 55 L 67 55" stroke="${l}" stroke-width="1.2" opacity="0.4"/>
</g>
</svg>`}function v1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)",a=t?"url(#cp-ruby)":"url(#cp-sapphire)",s=t?"url(#cp-pearl)":"url(#cp-amethyst)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 18 90 C 20 84, 30 82, 50 82 C 70 82, 80 84, 82 90 L 82 93 C 82 95, 78 96, 50 96 C 22 96, 18 95, 18 93 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${r}"/>
<path d="M 27 82 C 29 68, 38 60, 41 48 L 59 48 C 62 60, 71 68, 73 82 Z" fill="${e}"/>
<path d="M 32 80 C 35 68, 41 58, 44 50 C 47 49, 49 50, 49 52 C 45 64, 40 74, 37 80 Z" fill="${i}" stroke="none"/>
<path d="M 38 48 C 44 51, 56 51, 62 48 L 63 53 C 56 56, 44 56, 37 53 Z" fill="${r}"/>
<path d="M 40 48 C 37 40, 31 34, 28 32 L 72 32 C 69 34, 63 40, 60 48 Z" fill="${e}"/>
<path d="M 28 32 L 20 18 L 34 26 L 50 12 L 66 26 L 80 18 L 72 32 Z" fill="${e}"/>
<path d="M 27 32 C 40 35, 60 35, 73 32 L 73 35 C 60 38, 40 38, 27 35 Z" fill="${r}"/>
<circle cx="20" cy="17" r="3.2" fill="${s}"/>
<circle cx="34" cy="25" r="3.2" fill="${s}"/>
<circle cx="50" cy="11" r="4.2" fill="${s}"/>
<circle cx="66" cy="25" r="3.2" fill="${s}"/>
<circle cx="80" cy="17" r="3.2" fill="${s}"/>
<ellipse cx="50" cy="40" rx="3.5" ry="4.5" fill="${a}"/>
<circle cx="49" cy="38" r="1.2" fill="#ffffff" stroke="none"/>
</g>
</svg>`}function y1(t){const o=t?T:H,l=t?"#0f172a":"#020617",e=t?"url(#cp-w-body)":"url(#cp-b-body)",i=t?"url(#cp-w-spec)":"url(#cp-b-spec)",r=t?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${t?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
${o}
<g stroke="${l}" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<path d="M 16 90 C 18 84, 28 82, 50 82 C 72 82, 82 84, 84 90 L 84 94 C 84 96, 78 97, 50 97 C 22 97, 16 96, 16 94 Z" fill="${e}"/>
<ellipse cx="50" cy="83" rx="31" ry="3.8" fill="${r}"/>
<path d="M 25 82 C 27 68, 36 58, 38 46 L 62 46 C 64 58, 73 68, 75 82 Z" fill="${e}"/>
<path d="M 30 80 C 33 68, 40 56, 42 48 C 45 47, 48 48, 48 50 C 44 62, 38 74, 35 80 Z" fill="${i}" stroke="none"/>
<path d="M 34 46 C 42 49, 58 49, 66 46 L 67 51 C 58 54, 42 54, 33 51 Z" fill="${r}"/>
<path d="M 33 46 C 28 38, 28 28, 50 24 C 72 28, 72 38, 67 46 Z" fill="${e}"/>
<path d="M 50 24 L 50 46 M 34 36 C 42 34, 58 34, 66 36" stroke="${r}" stroke-width="2.6"/>
<ellipse cx="50" cy="46" rx="16" ry="3.5" fill="${r}"/>
<path d="M 46 24 L 54 24 L 52 19 L 48 19 Z" fill="${r}"/>
<path d="M 48 19 L 42 16 L 44 11 L 47 13 L 47 6 L 53 6 L 53 13 L 56 11 L 58 16 L 52 19 Z" fill="${r}"/>
<circle cx="50" cy="13" r="2.8" fill="${t?"url(#cp-ruby)":"url(#cp-sapphire)"}"/>
<circle cx="49" cy="12" r="0.9" fill="#ffffff" stroke="none"/>
</g>
</svg>`}const w1=[{id:"imperial",name:"Imperial 3miz",nameFa:"امپریال سه‌میز (پیش‌فرض)"},{id:"cburnett",name:"cburnett (Lichess)",nameFa:"سی‌برنت (استاندارد لیچس)"},{id:"merida",name:"Merida",nameFa:"مریدا (Merida)"},{id:"staunty",name:"Staunty",nameFa:"استاونتی (Staunty)"},{id:"alpha",name:"Alpha",nameFa:"آلفا (Alpha)"},{id:"california",name:"California",nameFa:"کالیفرنیا (California)"},{id:"cardinal",name:"Cardinal",nameFa:"کاردینال (Cardinal)"},{id:"dubrovny",name:"Dubrovny",nameFa:"دوبروفنی (Dubrovny)"},{id:"governor",name:"Governor",nameFa:"گاورنر (Governor)"},{id:"maestro",name:"Maestro",nameFa:"ماسترو (Maestro)"},{id:"fresca",name:"Fresca",nameFa:"فرسکا (Fresca)"},{id:"kosal",name:"Kosal",nameFa:"کوسال (Kosal)"},{id:"leipzig",name:"Leipzig",nameFa:"لایپزیگ (Leipzig)"},{id:"chess7",name:"Chess7",nameFa:"چس سون (Chess7)"},{id:"chessnut",name:"Chessnut",nameFa:"چس‌نات (Chessnut)"},{id:"companion",name:"Companion",nameFa:"کامپنیون (Companion)"},{id:"fantasy",name:"Fantasy",nameFa:"فانتزی (Fantasy)"},{id:"anarcandy",name:"Anarcandy",nameFa:"آنارکندی (شکلاتی)"},{id:"pixel",name:"Pixel",nameFa:"پیکسل (Pixel)"},{id:"papercut",name:"Papercut",nameFa:"پیپرکات (Papercut)"},{id:"spatial",name:"Spatial",nameFa:"اسپشیال ۳بعدی (Spatial)"},{id:"tatiana",name:"Tatiana",nameFa:"تاتیانا (Tatiana)"},{id:"kiwen-suwi",name:"Kiwen Suwi",nameFa:"کیون سوی (Kiwen Suwi)"},{id:"riohacha",name:"Riohacha",nameFa:"ریوهاچا (Riohacha)"},{id:"letter",name:"Letter",nameFa:"حروفی (Letter)"},{id:"xkcd",name:"xkcd",nameFa:"کمیک (xkcd)"}];let Z="imperial";function D(t){(t==="imperial"||$[t])&&(Z=t)}function k1(){return Z}const u1={p:f1,n:p1,b:m1,r:g1,q:v1,k:y1},V={};function C(t,o,l=Z){if(!t||!o)return"";const e=`${l}-${t}-${o}`;if(V[e])return V[e];if(l!=="imperial"&&$[l]){const r=`${o}${t.toUpperCase()}`,a=$[l][r];if(a){let s=a.replace("<svg ",`<svg class="piece-svg piece-${o}" `);return V[e]=s,s}}const i=u1[t];return i&&(V[e]=i(o==="w")),V[e]??""}class x1{constructor(o){this.particles=[],this.shockwaves=[],this.animId=null,this.lastTime=0,this.canvas=o,this.ctx=o.getContext("2d"),this.resize(),window.addEventListener("resize",()=>this.resize()),this.startLoop()}resize(){var e,i,r;const o=(e=this.canvas.parentElement)==null?void 0:e.getBoundingClientRect();if(!o)return;const l=window.devicePixelRatio||1;this.canvas.width=Math.round(o.width*l),this.canvas.height=Math.round(o.height*l),this.canvas.style.width=`${o.width}px`,this.canvas.style.height=`${o.height}px`,(r=(i=this.ctx).resetTransform)==null||r.call(i),this.ctx.scale(l,l)}startLoop(){if(this.animId)return;const o=l=>{const e=this.lastTime?Math.min((l-this.lastTime)/1e3,.1):.016;this.lastTime=l,this.update(e),this.render(),this.animId=requestAnimationFrame(o)};this.animId=requestAnimationFrame(o)}update(o){for(let l=this.shockwaves.length-1;l>=0;l--){const e=this.shockwaves[l];e.radius+=(e.maxRadius-e.radius)*12*o,e.alpha-=e.decay*o,(e.alpha<=0||e.radius>=e.maxRadius*.98)&&this.shockwaves.splice(l,1)}for(let l=this.particles.length-1;l>=0;l--){const e=this.particles[l];e.x+=e.vx*o,e.y+=e.vy*o,e.vx*=Math.pow(e.drag,o*60),e.vy*=Math.pow(e.drag,o*60),e.vy+=e.gravity*o,e.vRot&&e.rotation!==void 0&&(e.rotation+=e.vRot*o),e.alpha-=e.decay*o,e.alpha<=0&&this.particles.splice(l,1)}}render(){const o=this.canvas.width/(window.devicePixelRatio||1),l=this.canvas.height/(window.devicePixelRatio||1);this.ctx.clearRect(0,0,o,l);for(const e of this.shockwaves)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(e.x,e.y,Math.max(1,e.radius),0,Math.PI*2),this.ctx.strokeStyle=e.color,this.ctx.globalAlpha=Math.max(0,e.alpha),this.ctx.lineWidth=e.lineWidth,this.ctx.stroke(),this.ctx.restore();for(const e of this.particles){if(this.ctx.save(),this.ctx.globalAlpha=Math.max(0,e.alpha),this.ctx.fillStyle=e.color,e.shape==="rect"||e.shape==="spark"){this.ctx.translate(e.x,e.y),e.rotation!==void 0&&this.ctx.rotate(e.
<div id="top-bar" class="player-bar"></div>
<div class="board-container">
<canvas id="vfx-canvas"></canvas>
<div id="board-grid" class="board-grid"></div>
<div id="ghost-layer" class="ghost-layer"></div>
</div>
<div id="bottom-bar" class="player-bar"></div>
<div id="modal-container"></div>
`;const o=document.getElementById("vfx-canvas");z=new x1(o);const l=document.getElementById("board-grid");l.addEventListener("click",e=>{const i=e.target.closest(".cell");i&&i.dataset.square&&!i.disabled&&U1(i.dataset.square)});for(let e=0;e<64;e++){const i=document.createElement("button");i.className="cell",i.dataset.index=String(e),l.appendChild(i)}}function U(){var v;if(!n)return;const t=n.me,o=t!=null&&n.players[t]!==void 0;let l,e;o?(l=n.players[t],e=n.players.find(w=>w.seat!==t)||n.players[1-t]):(l=n.players.find(w=>w.color==="w")||n.players[0],e=n.players.find(w=>w.color==="b")||n.players[1]);const i=(l==null?void 0:l.color)||"w",r=i==="b",a=l?n.turn===l.seat&&n.phase==="play":!1,s=e?n.turn===e.seat&&n.phase==="play":!1;Y("top-bar",e,s,!1),Y("bottom-bar",l,a,o);const y=new Map;for(const w of n.board)y.set(w.square,w);const c=r?[7,6,5,4,3,2,1,0]:[0,1,2,3,4,5,6,7],g=r?[0,1,2,3,4,5,6,7]:[7,6,5,4,3,2,1,0],f=document.getElementById("board-grid");if(!f)return;const d=f.children;let h=0;const p=n.phase==="play"&&n.turn===t,m=n.check&&n.phase==="play"?(v=n.board.find(w=>{var x;return w.type==="k"&&w.color===((x=n.players[n.turn])==null?void 0:x.color)}))==null?void 0:v.square:null;for(const w of g)for(const x of c){const G=String.fromCharCode(97+x)+(w+1),B=y.get(G)||{type:null,color:null},j=d[h++];j.dataset.square=G,j.dataset.color=B.color||"";const t1=(x+w)%2===0?"dark":"light",F=M===G,r1=L&&(L.from===G||L.to===G),l1=m===G;j.className=`cell ${t1}`+(F?" selected":"")+(r1?" last-move":"")+(l1?" in-check":"");const i1=b.some(O=>O.target===G),o1=b.some(O=>O.target===G&&O.isCapture);let P="";const a1=r?x===7:x===0,s1=r?w===7:w===0;if(a1&&(P+=`<span class="coord-rank">${w+1}</span>`),s1&&(P+=`<span class="coord-file">${String.fromCharCode(97+x)}</span>`),B.type&&B.color){const O=C(B.type,B.color),d1=B.type==="n"&&F?" anim-knight":"";P+=`<div class="piece-wrapper${d1}">${O}</div>`}o1?P+='<div class="capture-ring"></div>':i1&&(P+='<div class="move-dot"></div>'),j.innerHTML=P;const n1=p&&!0&&B.color===i,c1=M?p:n1;j.disabled=!c1}E()}function W(t){const o=Math.max(0,Math.floor(t/1e3)),l=Math.floor(o/60),e=o%60;return`${l}:${e<10?"0":""}${e}`}function e1(t){if(!n||!n.clocks)return 0;const o=n.clocks[t]??0;if(n.phase==="play"&&n.turn===t){const l=Date.now()-X;return Math.max(0,o-l)}return o}function b1(){if(!(!n||!n.clocks||n.phase!=="play"))for(const t of["top-bar","bottom-bar"]){const o=document.getElementById(t);if(!o)continue;const l=o.querySelector(".chess-clock");if(!l||!l.dataset.seat)continue;const e=Number(l.dataset.seat),i=e1(e);l.textContent=W(i),i<=3e4&&i>0?l.classList.add("low-time"):l.classList.remove("low-time")}}function Y(t,o,l,e){var m;const i=document.getElementById(t);if(!i||!o||!n)return;i.className="player-bar"+(l?" active":"");const r=G1(o.color),a=q1(o.color),s=a>0?`<span class="advantage-score">+${a}</span>`:"",y=o.bot?'<span class="bot-tag">BOT</span>':"",c=e?`<span class="bot-tag you-tag">${k("شما","YOU")}</span>`:"",g=n.phase==="over"?n.winner===o.seat?k("برنده 🏆","Winner 🏆"):n.winner===null?k("تساوی 🤝","Draw 🤝"):"":l?e?k("نوبت شماست","Your turn"):k("در حال تفکر…","Thinking…"):"",f=e1(o.seat),d=f<=3e4&&f>0&&n.phase==="play",h=n.clocks?`<div class="chess-clock ${l?"active":""} ${d?"low-time":""}" data-seat="${o.seat}">${W(f)}</div>`:"",p=e?`<button class="theme-settings-btn" id="open-theme-btn" title="${k("انتخاب طرح و استایل مهره‌ها","Select Piece Theme")}">🎨</button>`:"";i.innerHTML=`
<div class="player-profile">
<div class="player-badge ${o.color}">
${o.color==="w"?"♔":"♚"}
</div>
<div class="player-meta">
<div class="player-name">${o.name} ${y} ${c}</div>
<div class="player-status">${g}</div>
</div>
</div>
<div class="player-clock-section">
<div class="captured-tray">
${r.map(v=>`<div class="mini-piece">${C(v.type,v.color)}</div>`).join("")}
${s}
</div>
${h}
${p}
</div>
`,e&&((m=i.querySelector("#open-theme-btn"))==null||m.addEventListener("click",()=>{Q=!0,E()}))}function G1(t){if(!n)return[];const o=t==="w"?"b":"w",l={p:8,n:2,b:2,r:2,q:1},e={p:0,n:0,b:0,r:0,q:0};for(const r of n.board)r.color===o&&r.type&&e[r.type]!==void 0&&e[r.type]++;const i=[];for(const r of["q","r","b","n","p"]){const a=l[r]-(e[r]||0);for(let s=0;s<a;s++)i.push({square:"",type:r,color:o})}return i}function q1(t){if(!n)return 0;const o={p:1,n:3,b:3,r:5,q:9};let l=0,e=0;for(const i of n.board){if(!i.type||!i.color)continue;const r=o[i.type]||0;i.color===t?l+=r:e+=r}return l-e}function E(){var o,l,e,i;const t=document.getElementById("modal-container");if(!(!t||!n)){if(q){const r=n.me!==null&&n.me!==void 0?(o=n.players[n.me])==null?void 0:o.color:"w";t.innerHTML=`
<div class="modal-backdrop">
<div class="promo-card">
<div class="promo-title">${k("ارتقای پیاده به:","Promote pawn to:")}</div>
<div class="promo-options">
${["q","r","b","n"].map(a=>`
<button class="promo-piece-btn" data-promo="${a}" title="${a}">
${C(a,r)}
</button>
`).join("")}
</div>
<button class="promo-cancel-btn" data-cancel-promo="1">${k("لغو","Cancel")}</button>
</div>
</div>
`,t.querySelectorAll("[data-promo]").forEach(a=>{a.addEventListener("click",()=>{var y;const s=a.dataset.promo;if(q&&s){A.cmd("move",{from:q.from,to:q.to,promotion:s});const c=document.querySelector(`[data-square="${q.to}"]`);if(c){const g=c.getBoundingClientRect(),f=(y=document.getElementById("vfx-canvas"))==null?void 0:y.getBoundingClientRect();f&&(z==null||z.promotionBurst(g.left-f.left+g.width/2,g.top-f.top+g.height/2))}q=null,M="",b=[],U()}})}),(l=t.querySelector("[data-cancel-promo]"))==null||l.addEventListener("click",()=>{q=null,U()});return}if(Q){const r=k1();t.innerHTML=`
<div class="modal-backdrop">
<div class="theme-modal-card">
<div class="theme-modal-header">
<div class="theme-modal-title">🎨 ${k("انتخاب طرح و استایل مهره‌ها","Select Piece Theme")}</div>
<button class="theme-modal-close" id="close-theme-modal">✕</button>
</div>
<div class="theme-grid">
${w1.map(a=>{const s=a.id===r,y=C("k","w",a.id),c=C("n","b",a.id);return`
<div class="theme-option-card ${s?"selected":""}" data-theme-id="${a.id}">
<div class="theme-preview-pieces">
<div class="theme-mini-piece">${y}</div>
<div class="theme-mini-piece">${c}</div>
</div>
<div class="theme-name">${(S==null?void 0:S.locale)==="en"?a.name:a.nameFa}</div>
</div>
`}).join("")}
</div>
</div>
</div>
`,(e=t.querySelector("#close-theme-modal"))==null||e.addEventListener("click",()=>{Q=!1,E()}),t.querySelectorAll("[data-theme-id]").forEach(a=>{a.addEventListener("click",()=>{const s=a.dataset.themeId;if(s){D(s);try{localStorage.setItem("chess_piece_theme",s)}catch{}Q=!1,U()}})});return}if(n.phase==="over"){n.winner!==null&&(n.winner,n.me);const r=n.winner===null;let a="",s="";r?n.result_reason==="stalemate"?(a=k("پات — مساوی!","Stalemate — Draw!"),s=k("شاه راه حرکتی ندارد","King has no legal moves")):n.result_reason==="insufficient_material"?(a=k("تساوی — عدم کفایت مهره‌ها","Draw — Insufficient Material"),s=k("مهره کافی برای مات کردن در صفحه وجود ندارد","Neither side has sufficient pieces to force checkmate")):n.result_reason==="timeout_draw"?(a=k("تساوی — پایان زمان و عدم کفایت مهره","Draw — Timeout vs Insufficient Material"),s=k("زمان حریف تمام شد اما مهره کافی برای مات کردن ندارید","Opponent flagged but you lack mating material")):(a=k("بازی مساوی شد","Draw!"),s=k("هیچ‌کدام از طرفین برنده نشد","No side achieved victory")):(a=`${(i=n.players[n.winner])==null?void 0:i.name} ${k("برنده شد! 🏆","Wins! 🏆")}`,n.result_reason==="checkmate"?s=k("با کیش و مات حریف","By checkmate"):n.result_reason==="timeout"?s=k("با اتمام زمان حریف","On time"):n.result_reason==="abandoned"?s=k("به دلیل ترک حریف","By abandonment"):s=""),t.innerHTML=`
<div class="game-over-banner">
<div class="game-over-title">${a}</div>
<div class="game-over-subtitle">${s}</div>
</div>
`;return}t.innerHTML=""}}function U1(t){var i;if(!n||n.phase!=="play"||q)return;const o=n.me;if(o==null||n.turn!==o)return;const l=(i=n.players[o])==null?void 0:i.color;if(!l)return;const e=n.board.find(r=>r.square===t);if(M){if(M===t){M="",b=[],U();return}if(e!=null&&e.color&&e.color===l){M=t;try{b=K(t,n.board,l)}catch{b=[]}U();return}const r=n.board.find(s=>s.square===M),a=l==="b"?"1":"8";if((r==null?void 0:r.type)==="p"&&t[1]===a){q={from:M,to:t},M="",b=[],U();return}A.cmd("move",{from:M,to:t}),M="",b=[],U()}else if(e&&e.color===l){M=t;try{b=K(t,n.board,l)}catch{b=[]}U()}}