207 lines
31 KiB
JavaScript
207 lines
31 KiB
JavaScript
(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))t(r);new MutationObserver(r=>{for(const e of r)if(e.type==="childList")for(const c of e.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&t(c)}).observe(document,{childList:!0,subtree:!0});function s(r){const e={};return r.integrity&&(e.integrity=r.integrity),r.referrerPolicy&&(e.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?e.credentials="include":r.crossOrigin==="anonymous"?e.credentials="omit":e.credentials="same-origin",e}function t(r){if(r.ep)return;r.ep=!0;const e=s(r);fetch(r.href,e)}})();function ot(o){const a=new URLSearchParams(location.search).get("host")??"*",s=r=>window.parent.postMessage({m3:1,...r},a);let t=0;return window.addEventListener("message",r=>{var c,l,m;if(r.source!==window.parent||a!=="*"&&r.origin!==a)return;const e=r.data;if(!(!e||e.m3!==1))switch(e.type){case"init":o.onInit(e),s({type:"ready"});break;case"state":o.onState(e.env);break;case"ack":(c=o.onAck)==null||c.call(o,e);break;case"view_changed":(l=o.onViewChanged)==null||l.call(o,e.view);break;case"cmd_failed":(m=o.onCmdFailed)==null||m.call(o,e.req_id,e.code);break}}),s({type:"loaded"}),{cmd(r,e={}){const c=++t;return s({type:"cmd",cmd_type:r,payload:e,req_id:c}),c},toast(r,e,c="info"){s({type:"toast",text_fa:r,text_en:e,kind:c})}}}const G=`
|
|||
|
|
<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>
|
||
|
|
`,S=`
|
||
|
|
<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 rt(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="28" ry="3.5" fill="${e}"/>
|
||
|
|
<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="${t}"/>
|
||
|
|
<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="${r}" stroke="none"/>
|
||
|
|
<ellipse cx="50" cy="42" rx="14" ry="4" fill="${e}"/>
|
||
|
|
<ellipse cx="50" cy="39" rx="11" ry="3" fill="${t}"/>
|
||
|
|
<circle cx="50" cy="24" r="14" fill="${t}"/>
|
||
|
|
<ellipse cx="44" cy="18" rx="6" ry="3.5" transform="rotate(-30 44 18)" fill="#ffffff" opacity="${o?"0.85":"0.5"}" stroke="none"/>
|
||
|
|
<circle cx="50" cy="9.5" r="2.5" fill="${e}"/>
|
||
|
|
<path d="M 21 89 C 30 85, 70 85, 79 89" fill="none" stroke="${o?"#e2e8f0":"#64748b"}" stroke-width="1.2" opacity="0.6"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}function st(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)",c=o?"url(#cp-ruby)":"url(#cp-sapphire)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
|
||
|
|
<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="${t}"/>
|
||
|
|
<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="${e}" 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="${s}" 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="${r}" stroke="none"/>
|
||
|
|
<ellipse cx="20" cy="38" rx="2.5" ry="1.5" transform="rotate(-20 20 38)" fill="${s}"/>
|
||
|
|
<path d="M 17 41 C 21 44, 25 43, 27 41" fill="none" stroke="${s}" stroke-width="1.5"/>
|
||
|
|
<ellipse cx="36" cy="27" rx="3.5" ry="2.2" transform="rotate(-15 36 27)" fill="${c}"/>
|
||
|
|
<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="${e}"/>
|
||
|
|
<circle cx="50" cy="71" r="4.5" fill="${e}"/>
|
||
|
|
<circle cx="50" cy="71" r="2.5" fill="${c}"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}function at(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="27" ry="3.5" fill="${e}"/>
|
||
|
|
<path d="M 29 82 C 31 72, 38 64, 40 52 L 60 52 C 62 64, 69 72, 71 82 Z" fill="${t}"/>
|
||
|
|
<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="${r}" 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="${e}"/>
|
||
|
|
<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="${t}"/>
|
||
|
|
<path d="M 58 22 L 40 40 L 44 43 L 61 24 Z" fill="${e}"/>
|
||
|
|
<path d="M 50 28 L 50 42 M 45 33 L 55 33" stroke="${e}" stroke-width="2.6"/>
|
||
|
|
<circle cx="50" cy="11" r="3.5" fill="${e}"/>
|
||
|
|
<circle cx="50" cy="11" r="1.8" fill="${o?"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="${r}" stroke="none"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}function ct(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
|
||
|
|
<path d="M 26 82 L 31 34 L 69 34 L 74 82 Z" fill="${t}"/>
|
||
|
|
<path d="M 31 80 L 35 36 L 43 36 L 39 80 Z" fill="${r}" stroke="none"/>
|
||
|
|
<path d="M 23 34 L 77 34 L 75 27 L 25 27 Z" fill="${e}"/>
|
||
|
|
<rect x="28" y="29" width="6" height="4" fill="${t}"/>
|
||
|
|
<rect x="40" y="29" width="6" height="4" fill="${t}"/>
|
||
|
|
<rect x="54" y="29" width="6" height="4" fill="${t}"/>
|
||
|
|
<rect x="66" y="29" width="6" height="4" fill="${t}"/>
|
||
|
|
<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="${t}"/>
|
||
|
|
<path d="M 23 14 L 34 14 M 43 14 L 57 14 M 66 14 L 77 14" stroke="${e}" stroke-width="2"/>
|
||
|
|
<path d="M 48 46 C 48 43, 52 43, 52 46 L 52 64 L 48 64 Z" fill="${s}"/>
|
||
|
|
<circle cx="50" cy="46" r="1.5" fill="${e}"/>
|
||
|
|
<path d="M 33 55 L 67 55" stroke="${s}" stroke-width="1.2" opacity="0.4"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}function nt(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)",c=o?"url(#cp-ruby)":"url(#cp-sapphire)",l=o?"url(#cp-pearl)":"url(#cp-amethyst)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="29" ry="3.5" fill="${e}"/>
|
||
|
|
<path d="M 27 82 C 29 68, 38 60, 41 48 L 59 48 C 62 60, 71 68, 73 82 Z" fill="${t}"/>
|
||
|
|
<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="${r}" 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="${e}"/>
|
||
|
|
<path d="M 40 48 C 37 40, 31 34, 28 32 L 72 32 C 69 34, 63 40, 60 48 Z" fill="${t}"/>
|
||
|
|
<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="${t}"/>
|
||
|
|
<path d="M 27 32 C 40 35, 60 35, 73 32 L 73 35 C 60 38, 40 38, 27 35 Z" fill="${e}"/>
|
||
|
|
<circle cx="20" cy="17" r="3.2" fill="${l}"/>
|
||
|
|
<circle cx="34" cy="25" r="3.2" fill="${l}"/>
|
||
|
|
<circle cx="50" cy="11" r="4.2" fill="${l}"/>
|
||
|
|
<circle cx="66" cy="25" r="3.2" fill="${l}"/>
|
||
|
|
<circle cx="80" cy="17" r="3.2" fill="${l}"/>
|
||
|
|
<ellipse cx="50" cy="40" rx="3.5" ry="4.5" fill="${c}"/>
|
||
|
|
<circle cx="49" cy="38" r="1.2" fill="#ffffff" stroke="none"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}function lt(o){const a=o?G:S,s=o?"#0f172a":"#020617",t=o?"url(#cp-w-body)":"url(#cp-b-body)",r=o?"url(#cp-w-spec)":"url(#cp-b-spec)",e=o?"url(#cp-w-gold)":"url(#cp-b-gold)";return`<svg viewBox="0 0 100 100" class="piece-svg piece-${o?"w":"b"}" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
${a}
|
||
|
|
<g stroke="${s}" 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="${t}"/>
|
||
|
|
<ellipse cx="50" cy="83" rx="31" ry="3.8" fill="${e}"/>
|
||
|
|
<path d="M 25 82 C 27 68, 36 58, 38 46 L 62 46 C 64 58, 73 68, 75 82 Z" fill="${t}"/>
|
||
|
|
<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="${r}" 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="${e}"/>
|
||
|
|
<path d="M 33 46 C 28 38, 28 28, 50 24 C 72 28, 72 38, 67 46 Z" fill="${t}"/>
|
||
|
|
<path d="M 50 24 L 50 46 M 34 36 C 42 34, 58 34, 66 36" stroke="${e}" stroke-width="2.6"/>
|
||
|
|
<ellipse cx="50" cy="46" rx="16" ry="3.5" fill="${e}"/>
|
||
|
|
<path d="M 46 24 L 54 24 L 52 19 L 48 19 Z" fill="${e}"/>
|
||
|
|
<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="${e}"/>
|
||
|
|
<circle cx="50" cy="13" r="2.8" fill="${o?"url(#cp-ruby)":"url(#cp-sapphire)"}"/>
|
||
|
|
<circle cx="49" cy="12" r="0.9" fill="#ffffff" stroke="none"/>
|
||
|
|
</g>
|
||
|
|
</svg>`}const it={p:rt,n:st,b:at,r:ct,q:nt,k:lt},O={};function _(o,a){if(!o||!a)return"";const s=`${o}-${a}`;if(!O[s]){const t=it[o];t&&(O[s]=t(a==="w"))}return O[s]??""}class dt{constructor(a){this.particles=[],this.shockwaves=[],this.animId=null,this.lastTime=0,this.canvas=a,this.ctx=a.getContext("2d"),this.resize(),window.addEventListener("resize",()=>this.resize()),this.startLoop()}resize(){var t,r,e;const a=(t=this.canvas.parentElement)==null?void 0:t.getBoundingClientRect();if(!a)return;const s=window.devicePixelRatio||1;this.canvas.width=Math.round(a.width*s),this.canvas.height=Math.round(a.height*s),this.canvas.style.width=`${a.width}px`,this.canvas.style.height=`${a.height}px`,(e=(r=this.ctx).resetTransform)==null||e.call(r),this.ctx.scale(s,s)}startLoop(){if(this.animId)return;const a=s=>{const t=this.lastTime?Math.min((s-this.lastTime)/1e3,.1):.016;this.lastTime=s,this.update(t),this.render(),this.animId=requestAnimationFrame(a)};this.animId=requestAnimationFrame(a)}update(a){for(let s=this.shockwaves.length-1;s>=0;s--){const t=this.shockwaves[s];t.radius+=(t.maxRadius-t.radius)*12*a,t.alpha-=t.decay*a,(t.alpha<=0||t.radius>=t.maxRadius*.98)&&this.shockwaves.splice(s,1)}for(let s=this.particles.length-1;s>=0;s--){const t=this.particles[s];t.x+=t.vx*a,t.y+=t.vy*a,t.vx*=Math.pow(t.drag,a*60),t.vy*=Math.pow(t.drag,a*60),t.vy+=t.gravity*a,t.vRot&&t.rotation!==void 0&&(t.rotation+=t.vRot*a),t.alpha-=t.decay*a,t.alpha<=0&&this.particles.splice(s,1)}}render(){const a=this.canvas.width/(window.devicePixelRatio||1),s=this.canvas.height/(window.devicePixelRatio||1);this.ctx.clearRect(0,0,a,s);for(const t of this.shockwaves)this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(1,t.radius),0,Math.PI*2),this.ctx.strokeStyle=t.color,this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.lineWidth=t.lineWidth,this.ctx.stroke(),this.ctx.restore();for(const t of this.particles){if(this.ctx.save(),this.ctx.globalAlpha=Math.max(0,t.alpha),this.ctx.fillStyle=t.color,t.shape==="rect"||t.shape==="spark"){this.ctx.translate(t.x,t.y),t.rotation!==void 0&&this.ctx.rotate(t.rotation);const r=t.size||t.radius*2;t.shape==="spark"?this.ctx.fillRect(-r,-r*.25,r*2,r*.5):this.ctx.fillRect(-r*.5,-r*.5,r,r)}else this.ctx.beginPath(),this.ctx.arc(t.x,t.y,Math.max(.5,t.radius),0,Math.PI*2),this.ctx.fill();this.ctx.restore()}}captureImpact(a,s,t="w"){this.shockwaves.push({x:a,y:s,radius:4,maxRadius:48,color:t==="w"?"rgba(255, 235, 180, 0.9)":"rgba(120, 140, 180, 0.9)",alpha:.9,decay:2.8,lineWidth:3});const r=t==="w"?["#ffffff","#fef08a","#f59e0b","#fbbf24"]:["#94a3b8","#cbd5e1","#64748b","#38bdf8"],e=18;for(let c=0;c<e;c++){const l=Math.PI*2*c/e+(Math.random()-.5)*.5,m=120+Math.random()*220;this.particles.push({x:a,y:s,vx:Math.cos(l)*m,vy:Math.sin(l)*m,radius:2+Math.random()*2.5,color:r[Math.floor(Math.random()*r.length)],alpha:1,decay:1.8+Math.random()*1.4,gravity:80,drag:.92,shape:"spark",size:3+Math.random()*3,rotation:l})}for(let c=0;c<6;c++){const l=Math.random()*Math.PI*2,m=25+Math.random()*45;this.particles.push({x:a+(Math.random()-.5)*12,y:s+(Math.random()-.5)*12,vx:Math.cos(l)*m,vy:Math.sin(l)*m,radius:4+Math.random()*6,color:"rgba(200, 200, 210, 0.4)",alpha:.6,decay:1.2,gravity:-10,drag:.88,shape:"circle"})}}landingPuff(a,s){for(let t=0;t<8;t++){const r=20+Math.random()*40;this.particles.push({x:a+(Math.random()-.5)*10,y:s+10,vx:(Math.random()-.5)*r,vy:-Math.random()*20,radius:2.5+Math.random()*3,color:"rgba(220, 220, 230, 0.35)",alpha:.5,decay:2,gravity:15,drag:.85,shape:"circle"})}}dissolvePuff(a,s,t="w"){const r=t==="w"?["#fef08a","#fbbf24","#ffffff","rgba(254, 240, 138, 0.7)"]:["#c084fc","#a855f7","#60a5fa","rgba(192, 132, 252, 0.7)"];for(let e=0;e<16;e++){const c=Math.random()*Math.PI*2,l=12+Math.random()*38;this.particles.push({x:a+(Math.random()-.5)*22,y:s+8+(Math.random()-.5)*12,vx:Math.cos(c)*l,vy:Math.sin(c)*l-22,radius:1.5+Math.random()*2.8,color:r[Math.floor(Math.random()*r.length)],alpha:.85,decay:1.5+Math.random()*.8,gravity:-18,drag:.91,shape:"circle"})}}promotionBurst(a,s){this.shockwaves.push({x:a,y:s,radius:
|
||
|
|
<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 a=document.getElementById("vfx-canvas");x=new dt(a);const s=document.getElementById("board-grid");s.addEventListener("click",t=>{const r=t.target.closest(".cell");r&&r.dataset.square&&!r.disabled&&yt(r.dataset.square)});for(let t=0;t<64;t++){const r=document.createElement("button");r.className="cell",r.dataset.index=String(t),s.appendChild(r)}}function I(){var y;if(!i)return;const o=i.me,a=o!=null&&i.players[o]!==void 0;let s,t;a?(s=i.players[o],t=i.players.find(v=>v.seat!==o)||i.players[1-o]):(s=i.players.find(v=>v.color==="w")||i.players[0],t=i.players.find(v=>v.color==="b")||i.players[1]);const r=(s==null?void 0:s.color)||"w",e=r==="b",c=s?i.turn===s.seat&&i.phase==="play":!1,l=t?i.turn===t.seat&&i.phase==="play":!1;j("top-bar",t,l,!1),j("bottom-bar",s,c,a);const m=new Map;for(const v of i.board)m.set(v.square,v);const n=e?[7,6,5,4,3,2,1,0]:[0,1,2,3,4,5,6,7],g=e?[0,1,2,3,4,5,6,7]:[7,6,5,4,3,2,1,0],u=document.getElementById("board-grid");if(!u)return;const d=u.children;let f=0;const p=i.phase==="play"&&i.turn===o,h=i.check&&i.phase==="play"?(y=i.board.find(v=>{var w;return v.type==="k"&&v.color===((w=i.players[i.turn])==null?void 0:w.color)}))==null?void 0:y.square:null;for(const v of g)for(const w of n){const k=String.fromCharCode(97+w)+(v+1),q=m.get(k)||{type:null,color:null},P=d[f++];P.dataset.square=k,P.dataset.color=q.color||"";const K=(w+v)%2===0?"dark":"light",D=M===k,U=R&&(R.from===k||R.to===k),V=h===k;P.className=`cell ${K}`+(D?" selected":"")+(U?" last-move":"")+(V?" in-check":"");const Y=$.some(E=>E.target===k),Q=$.some(E=>E.target===k&&E.isCapture);let B="";const J=e?w===7:w===0,X=e?v===7:v===0;if(J&&(B+=`<span class="coord-rank">${v+1}</span>`),X&&(B+=`<span class="coord-file">${String.fromCharCode(97+w)}</span>`),q.type&&q.color){const E=_(q.type,q.color),et=q.type==="n"&&D?" anim-knight":"";B+=`<div class="piece-wrapper${et}">${E}</div>`}Q?B+='<div class="capture-ring"></div>':Y&&(B+='<div class="move-dot"></div>'),P.innerHTML=B;const W=p&&!0&&q.color===r,tt=M?p:W;P.disabled=!tt}gt()}function j(o,a,s,t){const r=document.getElementById(o);if(!r||!a||!i)return;r.className="player-bar"+(s?" active":"");const e=ut(a.color),c=ht(a.color),l=c>0?`<span class="advantage-score">+${c}</span>`:"",m=a.bot?'<span class="bot-tag">BOT</span>':"",n=t?`<span class="bot-tag you-tag">${C("شما","YOU")}</span>`:"",g=i.phase==="over"?i.winner===a.seat?C("برنده 🏆","Winner 🏆"):i.winner===null?C("تساوی 🤝","Draw 🤝"):"":s?t?C("نوبت شماست","Your turn"):C("در حال تفکر…","Thinking…"):"";r.innerHTML=`
|
||
|
|
<div class="player-profile">
|
||
|
|
<div class="player-badge ${a.color}">
|
||
|
|
${a.color==="w"?"♔":"♚"}
|
||
|
|
</div>
|
||
|
|
<div class="player-meta">
|
||
|
|
<div class="player-name">${a.name} ${m} ${n}</div>
|
||
|
|
<div class="player-status">${g}</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="captured-tray">
|
||
|
|
${e.map(u=>`<div class="mini-piece">${_(u.type,u.color)}</div>`).join("")}
|
||
|
|
${l}
|
||
|
|
</div>
|
||
|
|
`}function ut(o){if(!i)return[];const a=o==="w"?"b":"w",s={p:8,n:2,b:2,r:2,q:1},t={p:0,n:0,b:0,r:0,q:0};for(const e of i.board)e.color===a&&e.type&&t[e.type]!==void 0&&t[e.type]++;const r=[];for(const e of["q","r","b","n","p"]){const c=s[e]-(t[e]||0);for(let l=0;l<c;l++)r.push({square:"",type:e,color:a})}return r}function ht(o){if(!i)return 0;const a={p:1,n:3,b:3,r:5,q:9};let s=0,t=0;for(const r of i.board){if(!r.type||!r.color)continue;const e=a[r.type]||0;r.color===o?s+=e:t+=e}return s-t}function gt(){var a,s,t;const o=document.getElementById("modal-container");if(!(!o||!i)){if(L){const r=i.me!==null&&i.me!==void 0?(a=i.players[i.me])==null?void 0:a.color:"w";o.innerHTML=`
|
||
|
|
<div class="modal-backdrop">
|
||
|
|
<div class="promo-card">
|
||
|
|
<div class="promo-title">${C("ارتقای پیاده به:","Promote pawn to:")}</div>
|
||
|
|
<div class="promo-options">
|
||
|
|
${["q","r","b","n"].map(e=>`
|
||
|
|
<button class="promo-piece-btn" data-promo="${e}" title="${e}">
|
||
|
|
${_(e,r)}
|
||
|
|
</button>
|
||
|
|
`).join("")}
|
||
|
|
</div>
|
||
|
|
<button class="promo-cancel-btn" data-cancel-promo="1">${C("لغو","Cancel")}</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
`,o.querySelectorAll("[data-promo]").forEach(e=>{e.addEventListener("click",()=>{var l;const c=e.dataset.promo;if(L&&c){A.cmd("move",{from:L.from,to:L.to,promotion:c});const m=document.querySelector(`[data-square="${L.to}"]`);if(m){const n=m.getBoundingClientRect(),g=(l=document.getElementById("vfx-canvas"))==null?void 0:l.getBoundingClientRect();g&&(x==null||x.promotionBurst(n.left-g.left+n.width/2,n.top-g.top+n.height/2))}L=null,M="",$=[],I()}})}),(s=o.querySelector("[data-cancel-promo]"))==null||s.addEventListener("click",()=>{L=null,I()});return}if(i.phase==="over"){i.winner!==null&&(i.winner,i.me);const r=i.winner===null;let e="",c="";r?i.result_reason==="stalemate"?(e=C("پات — مساوی!","Stalemate — Draw!"),c=C("شاه راه حرکتی ندارد","King has no legal moves")):i.result_reason==="insufficient_material"?(e=C("تساوی — عدم کفایت مهرهها","Draw — Insufficient Material"),c=C("مهره کافی برای مات کردن در صفحه وجود ندارد","Neither side has sufficient pieces to force checkmate")):(e=C("بازی مساوی شد","Draw!"),c=C("هیچکدام از طرفین برنده نشد","No side achieved victory")):(e=`${(t=i.players[i.winner])==null?void 0:t.name} ${C("برنده شد! 🏆","Wins! 🏆")}`,c=i.result_reason==="checkmate"?C("با کیش و مات حریف","By checkmate"):i.result_reason==="abandoned"?C("به دلیل ترک حریف","By abandonment"):""),o.innerHTML=`
|
||
|
|
<div class="game-over-banner">
|
||
|
|
<div class="game-over-title">${e}</div>
|
||
|
|
<div class="game-over-subtitle">${c}</div>
|
||
|
|
</div>
|
||
|
|
`;return}o.innerHTML=""}}function yt(o){var r;if(!i||i.phase!=="play"||L)return;const a=i.me;if(a==null||i.turn!==a)return;const s=(r=i.players[a])==null?void 0:r.color;if(!s)return;const t=i.board.find(e=>e.square===o);if(M){if(M===o){M="",$=[],I();return}if(t!=null&&t.color&&t.color===s){M=o;try{$=N(o,i.board,s)}catch{$=[]}I();return}const e=i.board.find(l=>l.square===M),c=s==="b"?"1":"8";if((e==null?void 0:e.type)==="p"&&o[1]===c){L={from:M,to:o},M="",$=[],I();return}A.cmd("move",{from:M,to:o}),M="",$=[],I()}else if(t&&t.color===s){M=o;try{$=N(o,i.board,s)}catch{$=[]}I()}}
|