1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[465],{8370:(e,t,r)=>{Promise.resolve().then(r.bind(r,97969)),Promise.resolve().then(r.bind(r,66559)),Promise.resolve().then(r.bind(r,60079))},66559:(e,t,r)=>{"use strict";r.d(t,{default:()=>T});var a=r(95296),n=r(62493),l=r(11180);let o={board:{width:720,height:1080},path:[{x:360,y:90},{x:360,y:230},{x:170,y:230},{x:170,y:410},{x:520,y:410},{x:520,y:590},{x:260,y:590},{x:260,y:790},{x:600,y:790},{x:600,y:980}],buildSpots:[{x:210,y:150},{x:500,y:150},{x:110,y:320},{x:300,y:320},{x:450,y:320},{x:610,y:500},{x:130,y:680},{x:400,y:680},{x:610,y:900},{x:360,y:920}],towers:{pulse:{id:"pulse",name:"Pulse Tower",description:"Fast, flexible, and easy to upgrade.",buildCost:60,color:"#38bdf8",glow:"#60a5fa",levels:[{range:150,damage:10,cooldown:.92,burstCount:1,burstDelay:0,spread:0,projectileSpeed:460,projectileRadius:5,upgradeCost:70},{range:172,damage:13,cooldown:.82,burstCount:2,burstDelay:.05,spread:5,projectileSpeed:480,projectileRadius:5,upgradeCost:110},{range:194,damage:17,cooldown:.74,burstCount:2,burstDelay:.05,spread:8,projectileSpeed:500,projectileRadius:5,upgradeCost:155},{range:220,damage:22,cooldown:.65,burstCount:3,burstDelay:.06,spread:10,projectileSpeed:520,projectileRadius:5,upgradeCost:220},{range:248,damage:28,cooldown:.56,burstCount:4,burstDelay:.06,spread:13,projectileSpeed:540,projectileRadius:6,upgradeCost:null}]}},enemies:{grunt:{id:"grunt",name:"Grunt",hp:24,speed:46,reward:10,radius:12,color:"#fb7185"},runner:{id:"runner",name:"Runner",hp:19,speed:62,reward:12,radius:10,color:"#f59e0b"},brute:{id:"brute",name:"Brute",hp:48,speed:34,reward:22,radius:17,color:"#60a5fa"}},waves:[{minWave:1,countBase:8,countGrowth:1.45,countMax:44,spawnInterval:.92,intervalFloor:.42,enemyWeights:[{type:"grunt",weight:1}]},{minWave:5,countBase:10,countGrowth:1.62,countMax:52,spawnInterval:.84,intervalFloor:.34,enemyWeights:[{type:"grunt",weight:.64},{type:"runner",weight:.36}]},{minWave:10,countBase:12,countGrowth:1.85,countMax:62,spawnInterval:.76,intervalFloor:.28,enemyWeights:[{type:"grunt",weight:.5},{type:"runner",weight:.3},{type:"brute",weight:.2}]},{minWave:20,countBase:15,countGrowth:2.05,countMax:78,spawnInterval:.68,intervalFloor:.22,enemyWeights:[{type:"grunt",weight:.42},{type:"runner",weight:.33},{type:"brute",weight:.25}]}],ui:{headline:"Hold the lane, stack upgrades, and keep the climb under control.",mobileHint:"Use the board buttons to upgrade the selected tower, expand the board, or restart the run.",shieldResetLives:12}};function s(e,t,r){return Math.min(r,Math.max(t,e))}function i(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function d(e){let t=o.towers.pulse.levels,r=s(e-1,0,t.length-1);return t[r]}function u(e){let t=function(e){let t=o.waves[0];for(let r of o.waves)e>=r.minWave&&(t=r);return t}(e),r=s(Math.round(t.countBase+e*t.countGrowth),8,t.countMax),a=Math.max(t.intervalFloor,t.spawnInterval-.01*Math.max(0,e-t.minWave)),n=Array.from({length:r},()=>(function(e){var t;let r=Math.random()*e.reduce((e,t)=>e+t.weight,0);for(let t of e)if((r-=t.weight)<=0)return t.type;return(null==(t=e[e.length-1])?void 0:t.type)||"grunt"})(t.enemyWeights));return{band:t,count:r,spawnInterval:a,queue:n}}function c(){return{wave:1,gold:120,lives:o.ui.shieldResetLives,score:0,towers:[],enemies:[],projectiles:[],waveBlueprint:u(1),waveSpawned:0,spawnTimer:.75,intermissionTimer:0,message:"Tap a glowing pad to place your first tower.",messageTimer:3,selectedTowerId:null,nextTowerId:1,nextEnemyId:1,nextProjectileId:1}}function f(e,t,r,a,n,l){let o=Math.min(l,a/2,n/2);e.beginPath(),e.moveTo(t+o,r),e.arcTo(t+a,r,t+a,r+n,o),e.arcTo(t+a,r+n,t,r+n,o),e.arcTo(t,r+n,t,r,o),e.arcTo(t,r,t+a,r,o),e.closePath()}function h(e,t,r,a,n,l,o){let s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;e.save(),s&&(e.shadowColor=s.color,e.shadowBlur=s.blur,e.shadowOffsetY=s.offsetY||0),f(e,t,r,a,n,l),e.fillStyle=o,e.fill(),e.restore()}function p(e,t,r,a,n,l,o){let s=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1;e.save(),f(e,t,r,a,n,l),e.strokeStyle=o,e.lineWidth=s,e.stroke(),e.restore(
1)}function m(e,t,r){let a=t.split(" "),n=[],l="";for(let t of a){let a=l?"".concat(l," ").concat(t):t;e.measureText(a).width>r&&l?(n.push(l),l=t):l=a}return l&&n.push(l),n}async function g(e){if(!e)return!1;try{if(e.requestFullscreen)return await e.requestFullscreen({navigationUI:"hide"}),!0}catch(t){try{return await e.requestFullscreen(),!0}catch(e){}}return e.webkitRequestFullscreen?(e.webkitRequestFullscreen(),!0):e.mozRequestFullScreen?(e.mozRequestFullScreen(),!0):!!e.msRequestFullscreen&&(e.msRequestFullscreen(),!0)}async function y(){if("undefined"==typeof document)return!1;try{if(document.exitFullscreen)return await document.exitFullscreen(),!0}catch(e){}return document.webkitExitFullscreen?(document.webkitExitFullscreen(),!0):document.mozCancelFullScreen?(document.mozCancelFullScreen(),!0):!!document.msExitFullscreen&&(document.msExitFullscreen(),!0)}function w(e,t){let r=s(Math.round(.03*e),12,24),a=s(Math.round(.016*e),10,16),n=s(Math.round(.19*t),150,188),l=s(Math.round(.22*t),200,228),i=r+n+a,d=Math.max(220,t-i-l-r-a),u={x:r,y:i,w:e-2*r,h:d},c=o.board.width,f=o.board.height,h=Math.min(u.w/c,u.h/f),p={x:u.x+(u.w-c*h)/2,y:u.y+(u.h-f*h)/2,w:c*h,h:f*h,scale:h},m={x:r,y:u.y+u.h+a,w:e-2*r,h:Math.max(130,t-(u.y+u.h+a+r))},g=e<860,y=e<680?2:4,w=Math.ceil(4/y),x=(e-2*r-10*(y-1))/y,b=r+(e<680?44:34),v=Math.max(88,r+n-12-b),S=w>1?Math.max(34,Math.min(48,Math.floor((v-10*(w-1))/w))):Math.max(54,Math.floor(v)),M=[];for(let e=0;e<4;e+=1){let t=e%y,a=Math.floor(e/y);M.push({x:r+t*(x+10),y:b+a*(S+10),w:x,h:S})}let T=m.w,k=g?(T-10)/2:Math.max(128,Math.min(180,Math.round(.18*T))),C=g?{upgrade:{x:m.x,y:m.y+m.h-88-20,w:T,h:44},expand:{x:m.x,y:m.y+m.h-44-10,w:k,h:44},reset:{x:m.x+k+10,y:m.y+m.h-44-10,w:k,h:44}}:{upgrade:{x:m.x,y:m.y+m.h-44,w:T-2*k-20,h:44},expand:{x:m.x+T-2*k-10,y:m.y+m.h-44,w:k,h:44},reset:{x:m.x+T-k,y:m.y+m.h-44,w:k,h:44}};return{pad:r,gap:a,hudHeight:n,footerHeight:l,boardArea:u,boardInner:p,footer:m,statCards:M,buttons:C,isCompact:g}}function x(e,t){return{x:e.x+t.x*e.scale,y:e.y+t.y*e.scale}}function b(e,t,r,a,n){let l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"";h(e,t.x,t.y,t.w,t.h,18,"rgba(15, 23, 42, 0.92)",{color:n,blur:18,offsetY:2}),p(e,t.x,t.y,t.w,t.h,18,"rgba(255,255,255,0.12)",1);let o=t.w<112||t.h<74;e.save(),e.fillStyle=n,e.fillRect(t.x+12,t.y+12,4,t.h-24),e.fillStyle="rgba(226, 232, 240, 0.78)",e.font="600 ".concat(o?9:11,"px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif"),e.textAlign="left",e.textBaseline="top",e.fillText(r.toUpperCase(),t.x+22,t.y+12),e.fillStyle="#ffffff",e.font="700 ".concat(o?18:24,"px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif"),e.fillText(String(a),t.x+22,t.y+(o?28:32)),l&&!o&&(e.fillStyle="rgba(226, 232, 240, 0.72)",e.font="500 ".concat(10,"px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif"),e.fillText(l,t.x+22,t.y+t.h-18)),e.restore()}function v(e,t,r,a){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"primary",l=!(arguments.length>5)||void 0===arguments[5]||arguments[5];if(e.save(),"primary"===n&&l&&(e.shadowColor="rgba(56, 189, 248, 0.42)",e.shadowBlur=16),f(e,t.x,t.y,t.w,t.h,16),"primary"===n&&l){let r=e.createLinearGradient(t.x,t.y,t.x+t.w,t.y+t.h);r.addColorStop(0,"rgba(59,130,246,1)"),r.addColorStop(1,"rgba(14,165,233,0.88)"),e.fillStyle=r}
1else e.fillStyle="secondary"===n?l?"rgba(30, 41, 59, 0.9)":"rgba(71, 85, 105, 0.55)":l?"linear-gradient(135deg, rgba(59,130,246,0.98), rgba(14,165,233,0.88))":"rgba(71, 85, 105, 0.55)";e.fill(),e.strokeStyle=l?"rgba(255,255,255,0.16)":"rgba(255,255,255,0.08)",e.lineWidth=1,e.stroke(),e.fillStyle="#fff",e.font="700 15px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textBaseline="middle",e.textAlign="left",e.fillText(r,t.x+16,t.y+t.h/2-6),a&&(e.fillStyle="rgba(255,255,255,0.78)",e.font="500 11px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.fillText(a,t.x+16,t.y+t.h/2+12)),e.restore()}let S=function(){let e=0;for(let t=0;t<o.path.length-1;t+=1)e+=i(o.path[t],o.path[t+1]);return e}();function M(e,t,r){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0,n=null,l=a;for(let a of e){if(a.dead)continue;let e=Math.hypot(a.x-t,a.y-r);e<=l&&(n=a,l=e)}return n}function T(){let e=(0,l.useRef)(null),t=(0,l.useRef)(null),r=(0,l.useRef)(c()),T=(0,l.useRef)({width:0,height:0}),[k,C]=(0,l.useState)({width:0,height:0}),[I,B]=(0,l.useState)(!1);async function F(t){let r=e.current;if(r){if(!t){await y(),B(!1);return}if(!await g(r))return void B(!0);B(!0)}}(0,l.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=e[0].contentRect,r={width:Math.max(1,Math.round(t.width)),height:Math.max(1,Math.round(t.height))};T.current=r,C(r)});return r.observe(t),()=>r.disconnect()},[]),(0,l.useEffect)(()=>{var e,t;let r=()=>{var e;let t=(null==(e=window.visualViewport)?void 0:e.height)||window.innerHeight;document.documentElement.style.setProperty("--tower-defense-viewport-height","".concat(Math.round(t),"px"))};return r(),window.addEventListener("resize",r),null==(e=window.visualViewport)||e.addEventListener("resize",r),null==(t=window.visualViewport)||t.addEventListener("scroll",r),()=>{var e,t;window.removeEventListener("resize",r),null==(e=window.visualViewport)||e.removeEventListener("resize",r),null==(t=window.visualViewport)||t.removeEventListener("scroll",r),document.documentElement.style.removeProperty("--tower-defense-viewport-height")}},[]),(0,l.useEffect)(()=>{if(!I)return;let e=document.body.style.overflow,t=document.documentElement.style.overflow,r=document.body.style.overscrollBehavior,a=document.documentElement.style.overscrollBehavior;return document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",document.body.style.overscrollBehavior="none",document.documentElement.style.overscrollBehavior="none",()=>{document.body.style.overflow=e,document.documentElement.style.overflow=t,document.body.style.overscrollBehavior=r,document.documentElement.style.overscrollBehavior=a}},[I]),(0,l.useEffect)(()=>{let t=()=>{B(("undefined"==typeof document?null:document.fullscreenElement||document.webkitFullscreenElement||null)===e.current)};return document.addEventListener("fullscreenchange",t),document.addEventListener("webkitfullscreenchange",t),()=>{document.removeEventListener("fullscreenchange",t),document.removeEventListener("webkitfullscreenchange",t)}},[]),(0,l.useEffect)(()=>{let e=t.current;if(!e||!k.width||!k.height)return;let a=window.devicePixelRatio||1;e.width=Math.floor(k.width*a),e.height=Math.floor(k.height*a),e.style.width="".concat(k.width,"px"),e.style.height="".concat(k.height,"px");let n=e.getContext("2d");if(!n)return;let l=0,c=performance.now(),g=()=>{let e=T.current.width,t=T.current.height;if(!e||!t){l=requestAnimationFrame(g);return}let y=performance.now(),k=Math.min(.033,(y-c)/1e3);c=y,function(e,t){if(e.messageTimer>0&&(e.messageTimer-=t,e.messageTimer<=0&&(e.message="")),e.intermissionTimer>0)e.intermissionTimer-=t,e.intermissionTimer<=0&&(e.wave+=1,e.waveBlueprint=u(e.wave),e.waveSpawned=0,e.spawnTimer=e.waveBlueprint.spawnInterval,e.message="Wave ".concat(e.wave," incoming."),e.messageTimer=1.6);else if(e.waveSpawned<e.waveBlueprint.count)for(e.spawnTimer-=t;e.spawnTimer<=0&&e.waveSpawned<e.waveBlueprint.count;){let t=e.waveBlueprint.queue[e.waveSpawned];e.enemies.push(function(e,t,r,a){let n=o.enemies[e],l=1+.11*t;return{id:r,typeId:e,x:a.x,y:a.y,progress:0,hp:Math.round(n.hp*l),maxHp:Math.round(n.hp*l),speed:n.speed*(1+.022*t),reward:n.reward+Math.floor(t/3),radius:n.radius,color:n.color,dead:!1}}(t,e.wave,e.nextEnemyId++,o.path[0])),e.waveSpawned+=1,e.spawnTimer+=e.waveBlueprint.spawnInterval}let r=[],a=!1;for(let n of e.enemies){if(n.dead)continue;if(n.progress+=n.speed*t,n.progress>=S){a=!0;continue}let e=function(e){if(e<=0)return o.path[0];let t=0;for(let n=0;n<o.path.length-1;n+=1){let l=o.path[n],s=o.path[n+1],d=i(l,s);if(e<=t+d){var r,a;let n=(e-t)/d;return{x:(r=l.x,r+(s.x-r)*n),y:(a=l.y,a+(s.y-a)*n)}}t+=d}return o.path[o.path.length-1]}(n.progress);n.x=e.x,n.y=e.y,r.push(n)}for(let n of(e.enemies=r,a&&(e.lives-=1,e.lives<=0?(e.lives=o.ui.shieldResetLives,e.message="Shield collapsed and auto-rebuilt. Keep going.",e.messageTimer=2):(e.message="An enemy leaked through the line.",e.messageTimer=1.2)),e.towers
1)){let r=d(n.level);if(n.cooldown=Math.max(0,n.cooldown-t),n.cooldown>0)continue;let a=M(e.enemies,n.x,n.y,r.range);a&&(!function(e,t,r){let a=d(t.level),n=Math.atan2(r.y-t.y,r.x-t.x),l=a.burstCount,o=a.spread;for(let s=0;s<l;s+=1){let i=(s-(l-1)/2)*o*(Math.PI/180);e.projectiles.push({id:e.nextProjectileId++,x:t.x,y:t.y,prevX:t.x,prevY:t.y,angle:n+i,angleOffset:i,turnRate:14,speed:a.projectileSpeed,damage:a.damage,radius:a.projectileRadius,delay:s*a.burstDelay,ttl:3.4,targetId:r.id,color:"rgba(255,255,255,0.96)"})}}(e,n,a),n.cooldown=r.cooldown)}let n=[];for(let r of e.projectiles){if(r.ttl-=t,r.delay>0){r.delay-=t,n.push(r);continue}let a=M(e.enemies,r.x,r.y,280)||e.enemies.find(e=>e.id===r.targetId&&!e.dead)||null;if(a){let e=Math.atan2(a.y-r.y,a.x-r.x)+r.angleOffset,n=s(r.turnRate*t,0,1);r.angle=r.angle+function(e){let t=e;for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}(e-r.angle)*n}if(r.prevX=r.x,r.prevY=r.y,r.x+=Math.cos(r.angle)*r.speed*t,r.y+=Math.sin(r.angle)*r.speed*t,a&&i(r,a)<=a.radius+r.radius){a.hp-=r.damage,a.hp<=0&&(a.dead=!0,e.gold+=a.reward,e.score+=10*a.reward);continue}let l=r.x<-40||r.y<-40||r.x>o.board.width+40||r.y>o.board.height+40;r.ttl<=0||l||n.push(r)}e.projectiles=n,e.enemies=e.enemies.filter(e=>!e.dead&&e.hp>0),e.intermissionTimer<=0&&e.waveSpawned>=e.waveBlueprint.count&&0===e.enemies.length&&(e.intermissionTimer=1.3,e.message="Wave ".concat(e.wave," cleared. Preparing the next assault."),e.messageTimer=1.8)}(r.current,k),n.setTransform(a,0,0,a,0,0);let C=n.createLinearGradient(0,0,0,t);C.addColorStop(0,"#020617"),C.addColorStop(.5,"#0f172a"),C.addColorStop(1,"#111827"),n.fillStyle=C,n.fillRect(0,0,e,t);let B=n.createRadialGradient(.25*e,.08*t,10,.25*e,.08*t,.65*Math.max(e,t));B.addColorStop(0,"rgba(59,130,246,0.18)"),B.addColorStop(.4,"rgba(16,185,129,0.10)"),B.addColorStop(1,"rgba(2,6,23,0)"),n.fillStyle=B,n.fillRect(0,0,e,t);let F=w(e,t);!function(e,t,r){let{pad:a,hudHeight:n,statCards:l}=r;h(e,a,a,r.boardArea.w,n,28,"rgba(15, 23, 42, 0.84)",{color:"rgba(59,130,246,0.18)",blur:20,offsetY:3}),p(e,a,a,r.boardArea.w,n,28,"rgba(255,255,255,0.10)",1),e.save(),e.fillStyle="#fff",e.font=r.isCompact?"800 16px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif":"800 18px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="left",e.textBaseline="top",e.fillText("Tower Defense",a+18,a+16),e.fillStyle="rgba(226, 232, 240, 0.76)",e.font=r.isCompact?"500 11px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif":"500 12px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif";let i=m(e,o.ui.headline,r.boardArea.w-(r.isCompact?120:180))[0]||o.ui.headline;e.fillText(i,a+18,a+36);let d=t.waveBlueprint,u=d.count>0?t.waveSpawned/d.count:1,c=a+18,f=a+n-18,g=Math.min(r.isCompact?200:260,r.boardArea.w*(r.isCompact?.28:.34));if(h(e,c,f-8,g,8,4,"rgba(30,41,59,0.95)"),h(e,c,f-8,Math.max(12,g*s(u,0,1)),8,4,"rgba(56,189,248,0.95)"),e.fillStyle="rgba(226, 232, 240, 0.8)",e.font=r.isCompact?"500 10px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif":"500 11px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.fillText("Wave ".concat(t.wave," \xb7 ").concat(t.waveSpawned,"/").concat(d.count," enemies"),c,f+4),b(e,l[0],"Gold",t.gold,"rgba(250, 204, 21, 0.95)","Build and upgrade"),b(e,l[1],"Lives",t.lives,"rgba(248, 113, 113, 0.95)","Auto-recovers"),b(e,l[2],"Wave",t.wave,"rgba(56, 189, 248, 0.95)","".concat(d.band.minWave,"+ band")),b(e,l[3],"Score",t.score,"rgba(74, 222, 128, 0.95)","Endless run"),t.message){let n=Math.min(420,.48*r.boardArea.w);h(e,a+r.boardArea.w-n-18,a+16,n,54,18,"rgba(15,23,42,0.90)",{color:"rgba(129, 140, 248, 0.18)",blur:14,offsetY:2}),e.fillStyle="rgba(255,255,255,0.96)",e.font="600 13px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="left",e.textBaseline="top",m(e,t.message,n-24).slice(0,2).forEach((t,l)=>{e.fillText(t,a+r.boardArea.w-n,a+27+16*l)})}e.restore()}(n,r.current,F);var P=F.boardArea;let E=n.createLinearGradient(P.x,P.y,P.x,P.y+P.h);for(let e of(E.addColorStop(0,"rgba(15, 23, 42, 0.94)"),E.addColorStop(1,"rgba(15, 23, 42, 0.98)"),h(n,P.x,P.y,P.w,P.h,28,E,{color:"rgba(14, 165, 233, 0.18)",blur:24,offsetY:6}
1),p(n,P.x,P.y,P.w,P.h,28,"rgba(148, 163, 184, 0.16)",1),!function(e,t){e.save(),e.beginPath(),f(e,t.x,t.y,t.w,t.h,24),e.clip();let r=Math.max(34,Math.round(42*t.scale/.8));e.strokeStyle="rgba(255,255,255,0.05)",e.lineWidth=1;for(let a=t.x;a<=t.x+t.w;a+=r)e.beginPath(),e.moveTo(a,t.y),e.lineTo(a,t.y+t.h),e.stroke();for(let a=t.y;a<=t.y+t.h;a+=r)e.beginPath(),e.moveTo(t.x,a),e.lineTo(t.x+t.w,a),e.stroke();e.restore()}(n,F.boardInner),!function(e,t){let r=o.path.map(e=>x(t,e));e.save(),e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t+=1)e.lineTo(r[t].x,r[t].y);e.strokeStyle="rgba(15, 118, 110, 0.28)",e.lineWidth=Math.max(34,56*t.scale),e.stroke(),e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t+=1)e.lineTo(r[t].x,r[t].y);e.strokeStyle="rgba(251, 191, 36, 0.78)",e.lineWidth=Math.max(20,38*t.scale),e.stroke(),e.setLineDash([10*t.scale,14*t.scale]),e.beginPath(),e.moveTo(r[0].x,r[0].y);for(let t=1;t<r.length;t+=1)e.lineTo(r[t].x,r[t].y);e.strokeStyle="rgba(255,255,255,0.22)",e.lineWidth=Math.max(2,4*t.scale),e.stroke(),e.setLineDash([]),e.restore()}(n,F.boardInner),!function(e,t,r){let a=o.towers.pulse.buildCost;for(let n=0;n<o.buildSpots.length;n+=1){let l=x(r,o.buildSpots[n]),i=t.towers.find(e=>e.spotIndex===n)||null,d=s(r.scale*(i?24:19),16,30),u=t.gold>=a;e.save(),e.beginPath(),e.arc(l.x,l.y,d+6,0,2*Math.PI),e.fillStyle=i?"rgba(34, 211, 238, 0.10)":u?"rgba(74, 222, 128, 0.12)":"rgba(148, 163, 184, 0.06)",e.fill(),e.beginPath(),e.arc(l.x,l.y,d,0,2*Math.PI),e.fillStyle=i?"rgba(15, 118, 110, 0.38)":u?"rgba(34, 197, 94, 0.18)":"rgba(148, 163, 184, 0.08)",e.fill(),e.strokeStyle=i?"rgba(103, 232, 249, 0.42)":u?"rgba(134, 239, 172, 0.55)":"rgba(255,255,255,0.10)",e.lineWidth=2,e.stroke(),i?(e.fillStyle="#fff",e.font="700 12px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.fillText(String(i.level),l.x,l.y)):(e.fillStyle=u?"#ecfeff":"rgba(226, 232, 240, 0.75)",e.font="700 11px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(String(a),l.x,l.y-1)),e.restore()}}(n,r.current,F.boardInner),r.current.towers))!function(e,t,r,a){let n=d(a.level),l=x(r,{x:a.x,y:a.y}),i=s(r.scale*(18+4*a.level),16,34),u=t.selectedTowerId===a.id;e.save(),u&&(e.beginPath(),e.arc(l.x,l.y,n.range*r.scale,0,2*Math.PI),e.strokeStyle="rgba(129, 140, 248, 0.12)",e.lineWidth=2,e.stroke()),e.beginPath(),e.arc(l.x,l.y,i+10,0,2*Math.PI),e.fillStyle="rgba(2, 6, 23, 0.75)",e.fill();let c=e.createRadialGradient(l.x-5,l.y-5,2,l.x,l.y,i+14);c.addColorStop(0,"rgba(255,255,255,0.42)"),c.addColorStop(.4,o.towers.pulse.glow),c.addColorStop(1,"rgba(15,23,42,0.20)"),e.beginPath(),e.arc(l.x,l.y,i+8,0,2*Math.PI),e.fillStyle=c,e.fill(),e.beginPath(),e.arc(l.x,l.y,i,0,2*Math.PI),e.fillStyle="rgba(15, 118, 110, 0.82)",e.fill(),e.strokeStyle=u?"rgba(255,255,255,0.95)":"rgba(191, 219, 254, 0.45)",e.lineWidth=u?3:2,e.stroke(),e.beginPath(),e.arc(l.x,l.y,.38*i,0,2*Math.PI),e.fillStyle="rgba(56, 189, 248, 0.92)",e.fill(),e.fillStyle="#fff",e.font="800 13px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(String(a.level),l.x,l.y-1),e.fillStyle="rgba(226, 232, 240, 0.95)",e.font="600 10px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.fillText("".concat(Math.round(n.range),"r"),l.x,l.y+i+10),e.restore()}(n,r.current,F.boardInner,e);for(let e of r.current.enemies)!function(e,t,r){let a=x(t,r),n=s(t.scale*r.radius,8,18);e.save();let l=e.createRadialGradient(a.x-3,a.y-3,2,a.x,a.y,n+8);l.addColorStop(0,"rgba(255,255,255,0.42)"),l.addColorStop(.3,r.color),l.addColorStop(1,"rgba(15,23,42,0.95)"),e.beginPath(),e.arc(a.x,a.y,n,0,2*Math.PI),e.fillStyle=l,e.fill(),e.strokeStyle="rgba(255,255,255,0.18)",e.lineWidth=1,e.stroke();let o=2.1*n,i=a.x-o/2,d=a.y+n+6,u=s(r.hp/r.maxHp,0,1);h(e,i,d,o,5,3,"rgba(15,23,42,0.65)"),h(e,i,d,Math.max(10,o*u),5,3,u>.5?"rgba(74, 222, 128, 0.92)":"rgba(248, 113, 113, 0.92)"),e.fillStyle="rgba(226, 232, 240, 0.84)",e.font="600 9px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.textBaseline="bottom",e.fillText(r.typeId.toUpperCase(),a.x,a.y-n-4),e.restore(
1)}(n,F.boardInner,e);for(let e of r.current.projectiles)e.delay>0||function(e,t,r){let a=x(t,{x:r.x,y:r.y}),n=x(t,{x:r.prevX,y:r.prevY}),l=s(t.scale*r.radius,3.5,7);e.save(),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.strokeStyle=r.color,e.lineWidth=Math.max(2,l),e.lineCap="round",e.stroke(),e.beginPath(),e.arc(a.x,a.y,l,0,2*Math.PI),e.fillStyle="#ffffff",e.shadowColor="rgba(255,255,255,0.75)",e.shadowBlur=12,e.fill(),e.restore()}(n,F.boardInner,e);if(r.current.message){let e={x:F.boardInner.x+16,y:F.boardInner.y+16,w:Math.min(420,F.boardInner.w-32),h:48};h(n,e.x,e.y,e.w,e.h,16,"rgba(2,6,23,0.68)",{color:"rgba(129,140,248,0.24)",blur:10,offsetY:2}),n.fillStyle="rgba(255,255,255,0.96)",n.font="600 12px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",n.textAlign="left",n.textBaseline="top",m(n,r.current.message,e.w-24).slice(0,2).forEach((t,r)=>{n.fillText(t,e.x+12,e.y+11+16*r)})}if(!F.isCompact){let e=r.current.towers.find(e=>e.id===r.current.selectedTowerId)||null,t=e?d(e.level):null,a=e?"Selected tower #".concat(e.id," \xb7 Lv ").concat(e.level," \xb7 Burst ").concat(t.burstCount,"x"):"No tower selected",l={x:F.boardInner.x+F.boardInner.w-Math.min(360,.4*F.boardInner.w)-16,y:F.boardInner.y+16,w:Math.min(360,.4*F.boardInner.w),h:48};h(n,l.x,l.y,l.w,l.h,16,"rgba(15,23,42,0.70)",{color:"rgba(56,189,248,0.18)",blur:10,offsetY:2}),n.fillStyle="rgba(255,255,255,0.95)",n.font="600 12px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",n.textAlign="left",n.textBaseline="top",m(n,a,l.w-24).slice(0,2).forEach((e,t)=>{n.fillText(e,l.x+12,l.y+11+16*t)})}!function(e,t,r,a){let{footer:n,buttons:l}=r;h(e,n.x,n.y,n.w,n.h,28,"rgba(15, 23, 42, 0.88)",{color:"rgba(14,165,233,0.12)",blur:18,offsetY:4}),p(e,n.x,n.y,n.w,n.h,28,"rgba(255,255,255,0.10)",1);let s=t.towers.find(e=>e.id===t.selectedTowerId)||null,i=s?d(s.level):null,u=n.x+18,c=n.y+16,f=n.w-36;e.save(),e.fillStyle="#fff",e.font="800 16px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="left",e.textBaseline="top",e.fillText(s?"Selected Tower #".concat(s.id):"No tower selected",u,c),e.fillStyle="rgba(226, 232, 240, 0.82)",e.font="500 12px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif",m(e,s?"".concat(o.towers.pulse.name," \xb7 Range ").concat(Math.round(i.range)," \xb7 Damage ").concat(i.damage," \xb7 Burst ").concat(i.burstCount,"x \xb7 Upgrade ").concat(i.upgradeCost?"".concat(i.upgradeCost," gold"):"maxed"):"Tap a glowing pad to build. Select a tower to push its next upgrade.",f-180).slice(0,2).forEach((t,r)=>{e.fillText(t,u,c+28+16*r)});let g=m(e,o.ui.mobileHint,f-180).slice(0,2);e.fillStyle="rgba(148, 163, 184, 0.86)",g.forEach((t,r)=>{e.fillText(t,u,c+58+15*r)}),e.restore();let y=!!(s&&i.upgradeCost&&t.gold>=i.upgradeCost);v(e,l.upgrade,s?i.upgradeCost?"Upgrade for ".concat(i.upgradeCost):"Tower maxed":"Select a tower first",s?"Level ".concat(s.level," \xb7 Burst ").concat(i.burstCount,"x"):"Action lives inside the board","primary",y),v(e,l.expand,a?"Shrink board":"Expand board",a?"Return to the page":"Fill the page","secondary",!0),v(e,l.reset,"Restart","Fresh run","secondary",!0)}(n,r.current,F,I),l=requestAnimationFrame(g)};return l=requestAnimationFrame(g),()=>cancelAnimationFrame(l)},[k.width,k.height,I]);let P=(0,a.jsxs)("div",{ref:e,className:I?"fixed inset-0 z-[80] overflow-hidden rounded-none border border-slate-200 bg-slate-950 shadow-2xl shadow-slate-900/15 outline-none":"relative w-full overflow-hidden rounded-[1.75rem] border border-slate-200 bg-slate-950 shadow-2xl shadow-slate-900/15 outline-none",style:{height:I?"var(--tower-defense-viewport-height, 100dvh)":"clamp(760px, 92dvh, 1100px)"},children:[(0,a.jsx)("canvas",{ref:t,tabIndex:0,"aria-label":"Endless tower defense game canvas","aria-describedby":"tower-defense-help",className:"block h-full w-full touch-manipulation",style:{touchAction:I?"none":"manipulation"},onPointerDown:e=>{var a;let n=t.current;if(!n||!T.current.width||!T.current.height)return;let l=n.getBoundingClientRect(),i=(e.clientX-l.left)/l.width*T.current.width,u=(e.clientY-l.top)/l.height*T.current.height,f=w(T.current.width,T.current.height),h={x:i,y:u},p=r.current;for(let[e,t]of Object.entries(f.buttons))if(h.x>=t.x&&h.x<=t.x+t.w&&h.y>=t.y&&h.y<=t.y+t.h){if("upgrade"===e){let e=p.towers.find(e=>e.id===p.selectedTowerId)||null;if(e){let t=d(e.level);t.upgradeCost&&p.gold>=t.upgradeCost?(p.gold-=t.upgradeCost,e.level+=1,e.cooldown=Math.max(0,e.cooldown-.08),p.message="Tower upgraded to level ".concat(e.level,"."),p.messageTimer=1.5):t.upgradeCost?(p.message="Not enough gold to upgrade.",p.messageTimer=1.4):(p.message="This tower is already at max level.",p.messageTimer=1.5)}else p.message="Select a tower first.",p.messageTimer=1.2}
1if("expand"===e){let e=!I;p.message=e?"Board expanded.":"Board shrunk back into the page.",p.messageTimer=1.4,F(e)}"reset"===e&&(r.current=c(),r.current.message="Fresh run started.",r.current.messageTimer=1.3,r.current.selectedTowerId=null),n.focus();return}let m={x:(h.x-f.boardInner.x)/f.boardInner.scale,y:(h.y-f.boardInner.y)/f.boardInner.scale};for(let e=0;e<o.buildSpots.length;e+=1){let t=o.buildSpots[e],r=p.towers.find(t=>t.spotIndex===e)||null,l=26/f.boardInner.scale;if(Math.hypot(m.x-t.x,m.y-t.y)<=l){if(r)p.selectedTowerId=r.id,p.message="Selected tower #".concat(r.id,"."),p.messageTimer=1.1;else if(p.gold>=o.towers.pulse.buildCost){let r=(a=e,{id:0,type:"pulse",spotIndex:a,x:t.x,y:t.y,level:1,cooldown:0});r.id=p.nextTowerId++,p.towers.push(r),p.gold-=o.towers.pulse.buildCost,p.selectedTowerId=r.id,p.message="Tower placed.",p.messageTimer=1.1}else p.message="Not enough gold to build a tower.",p.messageTimer=1.2;n.focus();return}}let g=p.towers.find(e=>{let t=s(f.boardInner.scale*(18+4*e.level),16,34)+8;return Math.hypot(m.x-e.x,m.y-e.y)<=t/f.boardInner.scale})||null;g?(p.selectedTowerId=g.id,p.message="Selected tower #".concat(g.id,"."),p.messageTimer=1.1):p.selectedTowerId=null,n.focus()},onKeyDown:e=>{let t=r.current;if("r"===e.key||"R"===e.key){e.preventDefault(),r.current=c(),r.current.message="Fresh run started.",r.current.messageTimer=1.2;return}if("f"===e.key||"F"===e.key){e.preventDefault();let r=!I;t.message=r?"Board expanded.":"Board shrunk back into the page.",t.messageTimer=1.4,F(r);return}if(("u"===e.key||"U"===e.key)&&t.selectedTowerId){e.preventDefault();let r=t.towers.find(e=>e.id===t.selectedTowerId);if(r){let e=d(r.level);e.upgradeCost&&t.gold>=e.upgradeCost?(t.gold-=e.upgradeCost,r.level+=1,t.message="Tower upgraded to level ".concat(r.level,".")):e.upgradeCost?t.message="Not enough gold to upgrade.":t.message="This tower is already at max level.",t.messageTimer=1.3}}"Escape"===e.key&&(I?(F(!1),t.message="Board shrunk back into the page.",t.messageTimer=1.4):t.selectedTowerId=null)}}),(0,a.jsx)("p",{id:"tower-defense-help",className:"sr-only",children:"Tap glowing pads on the board to place towers. Tap a tower to select it, then use the in-board buttons to upgrade, expand the board, or restart the run. Keyboard shortcuts include U for upgrade, F for expand, and R for restart."})]});return I&&"undefined"!=typeof document?(0,n.createPortal)(P,document.body):P}}},e=>{e.O(0,[533,186,262,732,299,689,359,324,724,358],()=>e(e.s=8370)),_N_E=e.O()}]);
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.