@imagile-dev/toil-ui 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{h as e,p as t,u as n}from"./index-BZCjoilm.js";var r=e(t(),1),i=new URL(`title-1MphWZoQ.webp`,import.meta.url).href,a=new URL(`sprites-BUKsxG6N.webp`,import.meta.url).href,o=n(),s=[{label:`THE RELEASE PIPELINE`,title:`FRIDAY. 16:59.`,narration:`Microsoft releases reach production through the packaging team. Reviewed, signed, and supported. Powershell Man finds this suspiciously boring.`,bubble:`Use the vendor release. Let Packaging verify and distribute it.`,speaker:`THE ARCHITECT`,caption:`A predictable release process. Our hero senses a problem.`},{label:`THE INTERNAL BUILD`,title:`WE'LL BUILD IT OURSELVES`,narration:`Powershell Man has a plan: compile PowerShell and other Microsoft software, then have Packaging distribute his internal binaries in place of Microsoft's releases.`,bubble:`Why wait for Microsoft? Packaging can ship MY builds instead!`,speaker:`POWERSHELL MAN`,caption:`The vendor release pipeline is now a folder called final_FINAL.`},{label:`THE REVIEW`,title:`THE ARCHITECT STRIKES`,narration:`The DevSecOps architect raises a clipboard shield. Someone has to own the replacement release chain after the first build succeeds.`,bubble:`Who owns signing, security updates, provenance, and support?`,speaker:`THE ARCHITECT`,caption:`He wants a supportable release chain. Powershell Man calls it villainy.`}];function c({onFinish:e,onSkip:t}){let[n,i]=(0,r.useState)(0),a=s[n],c=(0,r.useCallback)(()=>{n===s.length-1?e():i(e=>Math.min(e+1,s.length-1))},[n,e]);(0,r.useEffect)(()=>{let e=e=>{if(e.repeat)return;if(e.key===`Escape`){e.preventDefault(),t();return}if(e.key!==`Enter`&&e.key!==` `)return;let n=e.target;n instanceof HTMLElement&&(n.closest(`button`)||n.isContentEditable)||(e.preventDefault(),c())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,t]);function l(){i(e=>Math.max(0,e-1))}return(0,o.jsxs)(`section`,{className:`pm-story pm-story--panel-${n+1}`,"aria-label":`Powershell Man: origin story`,"aria-roledescription":`comic`,children:[(0,o.jsx)(`div`,{className:`pm-story__art`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`pm-story__shade`,"aria-hidden":`true`}),(0,o.jsxs)(`header`,{className:`pm-story__topline`,children:[(0,o.jsxs)(`span`,{children:[`TOIL COMICS `,(0,o.jsx)(`i`,{children:`✦`}),` INCIDENT ZERO`]}),(0,o.jsxs)(`span`,{className:`pm-story__counter`,"aria-label":`Panel ${n+1} of 3`,children:[String(n+1).padStart(2,`0`),` `,(0,o.jsx)(`b`,{children:`/`}),` 03`]})]}),(0,o.jsxs)(`div`,{className:`pm-story__content`,role:`group`,"aria-live":`polite`,"aria-atomic":`true`,"aria-label":`${a.label}, panel ${n+1} of 3`,children:[(0,o.jsx)(`div`,{className:`pm-story__eyebrow`,children:a.label}),(0,o.jsx)(`h1`,{children:a.title}),(0,o.jsx)(`p`,{className:`pm-story__narration`,children:a.narration}),(0,o.jsxs)(`div`,{className:`pm-story__bubble`,children:[(0,o.jsx)(`span`,{children:a.speaker}),(0,o.jsx)(`p`,{children:a.bubble})]}),(0,o.jsx)(`p`,{className:`pm-story__caption`,children:a.caption})]},n),(0,o.jsxs)(`footer`,{className:`pm-story__footer`,children:[(0,o.jsx)(`div`,{className:`pm-story__dots`,"aria-label":`Story progress`,children:s.map((e,t)=>(0,o.jsx)(`span`,{className:t===n?`is-current`:``,"aria-hidden":`true`},e.label))}),(0,o.jsxs)(`div`,{className:`pm-story__actions`,children:[(0,o.jsxs)(`button`,{className:`pm-story__skip`,onClick:t,children:[`SKIP STORY `,(0,o.jsx)(`kbd`,{children:`ESC`})]}),(0,o.jsxs)(`div`,{className:`pm-story__step-actions`,children:[(0,o.jsx)(`button`,{className:`pm-story__back`,onClick:l,disabled:n===0,"aria-label":`Previous panel`,children:`←`}),(0,o.jsxs)(`button`,{className:`pm-story__next`,onClick:c,children:[n===s.length-1?`START GAME`:`NEXT PANEL`,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:` ↗`})]})]})]}),(0,o.jsx)(`div`,{className:`pm-story__hint`,"aria-hidden":`true`,children:`ENTER / SPACE TO ADVANCE`})]})]})}var l=new Image;l.src=a;var u=[],d=[];function f(){if(u.length||!l.naturalWidth)return;let e=document.createElement(`canvas`);e.width=l.naturalWidth,e.height=l.naturalHeight;let t=e.getContext(`2d`,{willReadFrequently:!0});if(!t)return;t.drawImage(l,0,0);let n=t.getImageData(0,0,e.width,e.height).data,r=e.width/8,i=[0,.265,.507,.727,1];u=Array.from({length:4},(t,a)=>Array.from({length:8},(t,o)=>{let s=Math.round(o*r),c=Math.round((i[a]??0)*e.height),l=Math.round((i[a+1]??1)*e.height)-c,u=Math.round(r),d=Math.round(l),f=0,p=0;for(let t=0;t<Math.floor(l);t++)for(let i=0;i<Math.floor(r);i++)(n[((c+t)*e.width+s+i)*4+3]??0)<32||(u=Math.min(u,i),d=Math.min(d,t),f=Math.max(f,i),p=Math.max(p,t));return{x:s+u,y:c+d,w:Math.max(1,f-u+1),h:Math.max(1,p-d+1)}}));let a=Math.max(...u.slice(0,2).flat().map(e=>e.h));d=[76/a,76/a,1,140/Math.max(...(u[3]??[]).map(e=>e.h))]}function p(e,t,n,r,i,a=1,o){let s=u[t]?.[n];if(!s)return;let c=o?o/Math.max(...(u[t]??[]).slice(n-n%2,n-n%2+2).map(e=>e.h)):d[t]??1;e.save(),e.translate(Math.round(r),Math.round(i)),e.scale(a,1),e.imageSmoothingEnabled=!1,e.drawImage(l,s.x,s.y,s.w,s.h,-s.w*c/2,-s.h*c,s.w*c,s.h*c),e.restore()}function m(e,t,n,r,i,a){if(r<.12)return;let o=Math.min(1,(r-.12)/.88),s=1+Math.sin(i/95)*.06;if(e.save(),e.globalCompositeOperation=`lighter`,a){e.globalAlpha=o*.22,e.filter=`blur(2px)`,p(e,2,7,t+Math.sin(i/150)*5,n+3,-1,(65+o*38)*s),e.filter=`none`,e.globalAlpha=.35+o*.4;for(let r=0;r<12;r++){let a=i/380+r*Math.PI/6,s=25+o*20+Math.sin(a*3)*4;e.fillStyle=r%2?`#8affed`:`#ffc5f1`,e.beginPath(),e.arc(t+Math.cos(a)*s,n-36+Math.sin(a)*s*1.15,.7+o,0,Math.PI*2),e.fill()}}else{let r=(42+o*30)*s,i=e.createRadialGradient(t,n-36,3,t,n-36,r);i.addColorStop(0,`rgba(100,240,255,${.12+o*.12})`),i.addColorStop(.5,`rgba(76,130,255,${o*.2})`),i.addColorStop(1,`rgba(70,80,255,0)`),e.fillStyle=i,e.fillRect(t-r,n-36-r,r*2,r*2),e.globalAlpha=.13+o*.18,e.filter=`blur(7px)`,p(e,2,7,t,n+12,1,(90+o*50)*s)}e.restore()}var h=960,g=540,_=1850,v=235,y=[{x:0,y:476,w:720,h:80},{x:790,y:476,w:520,h:80},{x:1400,y:476,w:740,h:80},{x:2240,y:476,w:720,h:80},{x:3060,y:476,w:760,h:80},{x:3900,y:476,w:740,h:80},{x:520,y:390,w:120,h:20},{x:925,y:370,w:140,h:20},{x:1190,y:410,w:120,h:20},{x:1640,y:370,w:150,h:20},{x:1900,y:405,w:130,h:20},{x:2460,y:380,w:140,h:20},{x:2780,y:410,w:130,h:20},{x:3270,y:365,w:150,h:20},{x:3550,y:400,w:130,h:20},{x:4100,y:370,w:160,h:20},{x:4390,y:400,w:150,h:20},{x:4740,y:476,w:650,h:80},{x:5470,y:476,w:650,h:80},{x:6260,y:476,w:680,h:80},{x:7090,y:476,w:640,h:80},{x:7880,y:476,w:1e3,h:80},{x:4930,y:400,w:130,h:20},{x:5700,y:380,w:140,h:20},{x:6030,y:410,w:120,h:20},{x:6530,y:370,w:150,h:20},{x:6840,y:405,w:130,h:20},{x:7370,y:375,w:140,h:20},{x:7660,y:410,w:120,h:20}],b=[0,1400,3060,4740,6260,7880],x=(e,t)=>e.type!==`phantom`||Math.sin(t/690+e.phase)<.45,S=()=>[...[300,620,1010,1320,1550,1810,2090,2360,2650,2960,3210,3470,3780,4050,4300,4610,4910,5180,5500,5810,6120,6400,6670,6940,7220,7490,7770].map((e,t)=>({x:e,y:465,hp:2,type:t%3==0?`job`:t%3==1?`alias`:`phantom`,base:e,phase:t*1.8})),{x:8310,y:405,hp:18,type:`boss`,base:8310,phase:0}];function C(e,t,n){let r=t.camera,i=e.createLinearGradient(0,0,0,g);i.addColorStop(0,`#071522`),i.addColorStop(1,`#102a3b`),e.fillStyle=i,e.fillRect(0,0,h,g);for(let t=0;t<28;t++){let n=((t*213-r*.22)%6200+6200)%6200-80,i=100+t*47%145;e.fillStyle=t%2?`#0b2130`:`#0d2636`,e.fillRect(n,470-i,92,i),e.fillStyle=`#17394a`;for(let t=485-i;t<455;t+=24)e.fillRect(n+12,t,6,7),e.fillRect(n+28,t,6,7),e.fillRect(n+62,t,6,7)}e.strokeStyle=`rgba(68,163,185,.08)`,e.lineWidth=1;for(let t=-(r%48);t<h;t+=48)e.beginPath(),e.moveTo(t,0),e.lineTo(t,g),e.stroke();for(let t of y){let n=t.x-r;if(!(n+t.w<-20||n>980)){e.fillStyle=`#193547`,e.fillRect(n,t.y,t.w,t.h),e.fillStyle=`#2b6270`,e.fillRect(n,t.y,t.w,5),e.fillStyle=`#102634`;for(let r=n+10;r<n+t.w-5;r+=40)e.fillRect(r,t.y+14,20,3)}}for(let[t,n]of[[520,`Execution Policy: Bypass?`],[1620,`Object → string`],[2780,`Final_v7_REAL.ps1`],[4120,`TODO: add retries`],[5660,`Reviewed by /dev/null`],[7130,`This log is not a database`]]){let i=t-r;i<-180||i>990||(e.fillStyle=`#302f3b`,e.fillRect(i,398,3,78),e.fillStyle=`#41394a`,e.fillRect(i-8,399,Math.min(190,n.length*6+18),30),e.fillStyle=`#f1b4c0`,e.font=`9px monospace`,e.fillText(n,i,418),e.fillStyle=`#ef77a5`,e.fillRect(i-2,396,7,4))}b.slice(1).forEach((t,i)=>{let a=t-r;a>-30&&a<990&&(e.fillStyle=`#f7b955`,e.fillRect(a,416,4,60),e.fillStyle=`rgba(247,185,85,${.2+.12*Math.sin(n/240)})`,e.beginPath(),e.arc(a+2,412,18,0,Math.PI*2),e.fill(),e.fillStyle=`#ffda8b`,e.font=`10px monospace`,e.fillText(`CHECKPOINT ${i+1}`,a-42,398))});for(let i of t.foes){let a=i.x-r,o=t.time-(i.hitAt??-1/0),s=i.hp<=0;if(!(a<-100||a>1060||s&&o>.45||!x(i,n)&&o>.3)){if(e.save(),o<.32&&e.translate((i.hitDirection??1)*Math.sin(o*Math.PI/.32)*9,0),s&&(e.globalAlpha=Math.max(0,1-o/.45),e.translate(0,-o*40)),o<.075&&(e.filter=`brightness(3) saturate(0.4)`),i.type===`boss`){if(p(e,3,o<.26?6+Math.min(1,Math.floor(o/.13)):t.bossTelegraph>0?4+Math.floor(n/100)%2:Math.floor(n/180)%4,a,476),t.bossTelegraph>0){let n=[`“Could we add validation before deploy?”`,`“Let’s keep this to least privilege.”`,`“One quick review before merge?”`][t.bossPhase];e.fillStyle=`#f3ebdf`,e.fillRect(a-120,276,240,26),e.fillStyle=`#302c39`,e.font=`10px monospace`,e.textAlign=`center`,e.fillText(n??`Please add a test.`,a,293),e.textAlign=`start`,e.fillStyle=`#ef77a5`,e.fillRect(a-3,301,6,8)}}else{let t=i.y;p(e,2,(i.type===`job`?0:i.type===`alias`?2:4)+Math.floor(n/140+i.phase)%2,a,t+9,1,i.type===`phantom`?46:39),e.fillStyle=`#d8b9bc`,e.font=`8px monospace`,e.textAlign=`center`,e.fillText(i.type===`job`?`JOB`:i.type===`alias`?`ALIAS`:`PROFILE`,a,t-30),e.textAlign=`start`}if(e.filter=`none`,o<.25&&(e.globalAlpha=1-o/.25,p(e,2,7,a,(i.type===`boss`?425:i.y)+14,1,24+o*120)),s){e.fillStyle=`#ffb8e6`;for(let t=0;t<8;t++){let n=t*Math.PI/4;e.fillRect(a+Math.cos(n)*o*95,i.y-12+Math.sin(n)*o*80,3,3)}}e.restore()}}for(let n of t.shots){let t=n.x-r,i=n.hostile?`#ffb547`:n.charge>0?`#8affed`:`#ff58a5`;e.strokeStyle=i,e.lineWidth=n.charge?5:3,e.shadowBlur=n.charge?14:7,e.shadowColor=i,e.beginPath(),e.moveTo(t-n.vx*.035,n.y-n.vy*.035),e.bezierCurveTo(t-n.vx*.024+3,n.y-n.vy*.025+5,t-n.vx*.012-4,n.y-n.vy*.012-5,t,n.y),e.stroke(),e.fillStyle=i,e.fillRect(t-3,n.y-3,6,6),e.shadowBlur=0}let a=t.player,o=a.x-r,s=a.y;if(!(a.invuln>0&&Math.floor(n/65)%2==0)){let r=t.time-t.lastFire<.23,i=Math.abs(a.vx)>1,c=a.grounded&&i&&!r?0:1,l=c===0?Math.floor(n/75)%8:r?5+Math.min(2,Math.floor((t.time-t.lastFire)/.077)):a.grounded?Math.floor(n/320)%2:a.vy<-160?2:a.vy<150?3:4;m(e,o,s,t.charge,n,!1),p(e,c,l,o,s,a.face),m(e,o,s,t.charge,n,!0),t.charge>.85&&(e.strokeStyle=`#8affed`,e.lineWidth=1+t.charge,e.beginPath(),e.arc(o+a.face*27,s-44,5+t.charge*9+Math.sin(n/45)*2,0,Math.PI*2),e.stroke()),r&&p(e,2,6+Math.floor(n/65)%2,o+a.face*40,s-27,a.face,24)}}function w({onClose:e}){let[t,n]=(0,r.useState)(!1),[a,s]=(0,r.useState)(!1),[d,p]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=()=>{f(),n(u.length===4)},t=()=>s(!0);return l.addEventListener(`load`,e),l.addEventListener(`error`,t),l.complete&&(l.naturalWidth?e():t()),()=>{l.removeEventListener(`load`,e),l.removeEventListener(`error`,t)}},[]);let m=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useRef)(new Set),E=(0,r.useRef)(!1),[D,O]=(0,r.useState)(`intro`),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(8),[N,P]=(0,r.useState)(18),F=(0,r.useCallback)(()=>{w.current={player:{x:90,y:476,vx:0,vy:0,grounded:!0,face:1,invuln:0,health:8,checkpoint:0,coyote:.1,buffer:0,emergency:0,emergencyCooldown:0},foes:S(),shots:[],camera:0,charge:0,last:0,accumulator:0,shotAt:0,lastFire:-1/0,bossPhase:0,time:0,bossTelegraph:0,padJump:!1,padFire:!1,padEmergency:!1,padStart:!1},T.current.clear(),M(8),P(18),A(0),p(0),O(`playing`)},[]);(0,r.useEffect)(()=>{let e=m.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let n=0,r=()=>{let n=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(e.clientWidth*n),e.height=Math.round(e.clientHeight*n),t.setTransform(e.width/h,0,0,e.height/g,0,0)};r();let i=new ResizeObserver(r);i.observe(e);let a=e=>{if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`Space`].includes(e.code)&&e.preventDefault(),e.code===`Escape`){if(e.repeat)return;D===`playing`&&T.current.clear(),O(e=>e===`playing`?`paused`:e===`paused`?`playing`:e)}else e.code===`KeyR`&&(D===`won`||D===`lost`)?F():(D===`playing`&&!T.current.has(e.code)&&[`ArrowUp`,`KeyZ`,`Space`].includes(e.code)&&(E.current=!0),D===`playing`&&!T.current.has(e.code)&&e.code===`KeyC`&&w.current&&w.current.player.emergencyCooldown<=0&&(w.current.player.emergency=1.25,w.current.player.emergencyCooldown=7,w.current.player.invuln=1.25),T.current.add(e.code))},o=e=>{if(T.current.delete(e.code),D===`playing`&&e.code===`KeyX`&&w.current){let e=w.current,t=e.player;performance.now()-e.shotAt>180&&(e.shots.push({x:t.x+t.face*24,y:t.y-45,vx:t.face*(e.charge>.9?600:510),vy:0,life:1.5,charge:+(e.charge>.9)}),e.shotAt=performance.now(),e.lastFire=e.time),e.charge=0}};window.addEventListener(`keydown`,a),window.addEventListener(`keyup`,o);let s=(e,t)=>{t.time+=e;let n=t.time*1e3,r=t.player,i=T.current,a=navigator.getGamepads?.()[0],o=!!a?.buttons[0]?.pressed,s=!!a?.buttons[2]?.pressed,c=!!a?.buttons[1]?.pressed,l=!!a?.buttons[9]?.pressed;o&&!t.padJump&&(E.current=!0),c&&!t.padEmergency&&r.emergencyCooldown<=0&&(r.emergency=1.25,r.emergencyCooldown=7,r.invuln=1.25),l&&!t.padStart&&(T.current.clear(),O(`paused`)),s&&!t.padFire&&(t.charge=0),!s&&t.padFire&&performance.now()-t.shotAt>180&&(t.shots.push({x:r.x+r.face*24,y:r.y-45,vx:r.face*(t.charge>.9?600:510),vy:0,life:1.5,charge:+(t.charge>.9)}),t.shotAt=performance.now(),t.lastFire=t.time,t.charge=0),t.padJump=o,t.padFire=s,t.padEmergency=c,t.padStart=l,r.invuln=Math.max(0,r.invuln-e),r.emergency=Math.max(0,r.emergency-e),r.emergencyCooldown=Math.max(0,r.emergencyCooldown-e),r.coyote=r.grounded?.11:Math.max(0,r.coyote-e),r.buffer=E.current?.12:Math.max(0,r.buffer-e),E.current=!1;let u=a?.axes[0]??0,d=(i.has(`ArrowRight`)||i.has(`KeyD`)||u>.25||a?.buttons[15]?.pressed?1:0)-(i.has(`ArrowLeft`)||i.has(`KeyA`)||u<-.25||a?.buttons[14]?.pressed?1:0);d&&(r.face=d),r.vx=d*v,r.buffer&&r.coyote&&(r.vy=-665,r.grounded=!1,r.coyote=0,r.buffer=0),(i.has(`KeyX`)||s)&&(t.charge=Math.min(1,t.charge+e/1.2)),r.vy=Math.min(1e3,r.vy+_*e);let f=r.x;r.x=Math.max(18,Math.min(8780,r.x+r.vx*e));let m=r.y;r.y+=r.vy*e,r.grounded=!1;for(let e of y){let t=r.x+12>e.x&&r.x-12<e.x+e.w,n=r.y>e.y&&r.y-54<e.y+e.h;t&&(m<=e.y&&r.y>=e.y&&r.vy>=0?(r.y=e.y,r.vy=0,r.grounded=!0):m-54>=e.y+e.h&&r.y-54<e.y+e.h&&r.vy<0&&(r.y=e.y+e.h+54,r.vy=0)),n&&(f+12<=e.x&&r.x+12>e.x?(r.x=e.x-12,r.vx=0):f-12>=e.x+e.w&&r.x-12<e.x+e.w&&(r.x=e.x+e.w+12,r.vx=0))}r.y>620&&(r.health=0);for(let i of t.shots){if(i.x+=i.vx*e,i.y+=i.vy*e,i.life-=e,!i.hostile){for(let e of t.foes)if(e.hp>0&&x(e,n)&&Math.abs(i.x-e.x)<(e.type===`boss`?44:23)&&Math.abs(i.y-e.y)<(e.type===`boss`?118:36)){e.hp-=i.charge?3:1,e.hitAt=t.time,e.hitDirection=Math.sign(i.vx),p(e=>e+1),i.life=0,e.type===`boss`&&P(e.hp);break}}i.hostile&&Math.abs(i.x-r.x)<20&&Math.abs(i.y-(r.y-20))<30&&!r.invuln&&(r.health--,r.invuln=1.2,i.life=0)}t.shots=t.shots.filter(e=>e.life>0&&e.x>t.camera-100&&e.x<t.camera+h+100);for(let i of t.foes)if(!(i.hp<=0)){if(i.type===`boss`){i.x=Math.max(8110,Math.min(8510,i.base+Math.sin(n/1100)*160)),i.phase+=e;let a=i.hp>12?0:i.hp>6?1:2;t.bossPhase=a;let o=a===0?1.5:a===1?1.2:.9;if(t.bossTelegraph=i.phase>o-.35?o-i.phase:0,i.phase>o){i.phase=0,t.bossTelegraph=0;let e=r.x-i.x,n=r.y-22-382,o=Math.hypot(e,n)||1,s=a===2?3:1;for(let r=0;r<s;r++){let a=(r-(s-1)/2)*.2,c=e/o*300,l=n/o*300;t.shots.push({x:i.x,y:382,vx:c*Math.cos(a)-l*Math.sin(a),vy:c*Math.sin(a)+l*Math.cos(a),life:3.2,charge:0,hostile:!0})}}}else i.x=i.type===`job`?i.base+Math.sin(n/640+i.phase)*65:i.base+Math.sin(n/480+i.phase)*32,i.y=i.type===`alias`?465-Math.max(0,Math.sin(n/250+i.phase))*42:465,x(i,n)&&Math.abs(i.x-r.x)<28&&Math.abs(i.y-22-(r.y-35))<35&&!r.invuln&&(r.health--,r.invuln=1)}if(r.health<=0)r.health=0,M(0),O(`lost`);else{for(let e=r.checkpoint+1;e<b.length;e++)r.x>(b[e]??1/0)&&(r.checkpoint=e);t.camera=Math.max(0,Math.min(7900,r.x-290)),M(r.health),A(t.charge),(t.foes.at(-1)?.hp??18)<=0&&O(`won`)}},c=e=>{if(D===`playing`){let n=w.current;if(n){n.last||=e;let r=Math.min(.05,(e-n.last)/1e3);for(n.last=e,n.accumulator+=r;n.accumulator>=1/120;)s(1/120,n),n.accumulator-=1/120;C(t,n,n.time*1e3)}}else if(w.current)C(t,w.current,w.current.time*1e3);else{t.fillStyle=`#071522`,t.fillRect(0,0,h,g);for(let e=0;e<18;e++)t.fillStyle=e%2?`#0b2130`:`#0d2636`,t.fillRect(e*61,270+e%4*19,48,250)}n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>{cancelAnimationFrame(n),i.disconnect(),window.removeEventListener(`keydown`,a),window.removeEventListener(`keyup`,o)}},[D,F]),(0,r.useEffect)(()=>{let e=()=>{T.current.clear(),O(e=>e===`playing`?`paused`:e)},t=()=>{document.hidden&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`blur`,e)}},[]);let I=w.current;return(0,o.jsxs)(`section`,{className:`pm-game`,"aria-label":`Powershell Man game`,"data-game-state":D,"data-health":j,"data-boss-health":N,"data-charge":k.toFixed(2),"data-player-x":I?.player.x.toFixed(0),"data-player-y":I?.player.y.toFixed(0),"data-checkpoint":I?.player.checkpoint,"data-sprites-ready":t,"data-hit-count":d,children:[(0,o.jsx)(`canvas`,{ref:m,className:`pm-canvas`,"aria-label":`Game screen. Arrow keys or A and D to move, Z or Space to jump, X to fire, Escape to pause.`}),D===`playing`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`pm-hud`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`b`,{children:`POWERSHELL MAN`}),(0,o.jsx)(`span`,{children:`INCIDENT RESPONSE / FIELD OPS`})]}),(0,o.jsxs)(`div`,{className:`pm-life`,children:[(0,o.jsx)(`span`,{title:`Works on My Machine`,children:`HP`}),Array.from({length:8},(e,t)=>(0,o.jsx)(`i`,{className:t<j?`on`:``},t))]}),(0,o.jsxs)(`div`,{className:`pm-charge`,children:[(0,o.jsx)(`span`,{children:`CHARGE`}),(0,o.jsx)(`progress`,{max:`100`,value:k*100})]}),(0,o.jsxs)(`span`,{className:`pm-emergency`,"data-ready":I&&I.player.emergencyCooldown<=0,children:[`C · SilentlyContinue`,` `,I?`${Math.ceil(I.player.emergencyCooldown)}s`:``]}),(0,o.jsx)(`button`,{onClick:()=>O(`paused`),"aria-label":`Pause`,children:`Ⅱ`})]}),(I?.foes.at(-1)?.x??1/0)-(I?.camera??0)<900&&(0,o.jsxs)(`div`,{className:`pm-bossbar`,children:[(0,o.jsxs)(`span`,{children:[`COMMON-SENSE DEVSECOPS ARCHITECT · PHASE`,` `,(I?.bossPhase??0)+1,I?.bossTelegraph?` · REVIEWING TARGET`:``]}),(0,o.jsx)(`progress`,{max:`18`,value:Math.max(0,N)})]}),(0,o.jsx)(`div`,{className:`pm-controls`,children:`← → move\xA0\xA0 Z jump\xA0\xA0 X fire / release to shoot\xA0\xA0 C emergency\xA0\xA0 Esc pause`})]}),D===`story`&&(0,o.jsx)(c,{onFinish:F,onSkip:F}),D!==`playing`&&D!==`story`&&(0,o.jsxs)(`div`,{className:`pm-overlay ${D===`intro`?`pm-overlay--intro`:``}`,children:[D===`intro`&&(0,o.jsx)(`img`,{className:`pm-title-art`,src:i,alt:``}),(0,o.jsxs)(`div`,{className:`pm-card`,children:[(0,o.jsx)(`div`,{className:`pm-kicker`,children:`TOIL SYSTEMS // INCIDENT RESPONSE SIMULATOR`}),(0,o.jsx)(`h1`,{children:D===`intro`?`POWERSHELL MAN`:D===`paused`?`PAUSED`:D===`won`?`PRODUCTION RESTORED`:`INCIDENT UNRECOVERED`}),D===`intro`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Compile the stack. Replace the vendor release. Hand Packaging the consequences.`}),(0,o.jsxs)(`div`,{className:`pm-how`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`MOVE`}),(0,o.jsx)(`span`,{children:`← → or A / D`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`JUMP`}),(0,o.jsx)(`span`,{children:`Z or Space`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`FIRE`}),(0,o.jsx)(`span`,{children:`X · hold to charge`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`PAUSE`}),(0,o.jsx)(`span`,{children:`Esc`})]})]}),(0,o.jsx)(`p`,{className:`pm-threat`,children:`Alias gremlins · orphan jobs · profile phantoms · one architect with opinions.`}),(0,o.jsx)(`p`,{className:`pm-gamepad-note`,children:`GAMEPAD · left stick / D-pad move · A jump · X hold/release fire · B emergency · Start pause`}),a&&(0,o.jsx)(`p`,{role:`alert`,children:`The sprite sheet could not load. Reload the page to retry.`}),(0,o.jsxs)(`button`,{onClick:()=>O(`story`),disabled:!t,children:[t?`START INCIDENT`:`LOADING SPRITES…`,` `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]}):D===`paused`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Runbooks can wait. The incident will not progress while paused.`}),(0,o.jsxs)(`button`,{onClick:()=>{I&&(I.last=0),O(`playing`)},children:[`RESUME `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`EXIT SIMULATOR`})]}):D===`won`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`DEPLOYMENT SUCCESSFUL · Fine.`}),(0,o.jsx)(`p`,{className:`pm-joke`,children:`The architect approved the deploy. You now own the on-call rotation. Maintenance begins at 02:00.`}),(0,o.jsxs)(`button`,{onClick:F,children:[`RUN IT BACK `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Emergency SilentlyContinue: the incident got you. Your last checkpoint is still intact.`}),(0,o.jsxs)(`button`,{onClick:()=>{if(I){let e=b[I.player.checkpoint]??7880;I.player.x=e+40,I.player.y=476,I.player.vy=0,I.player.health=8,I.player.invuln=2,I.shots=[];for(let t of I.foes)t.type!==`boss`&&t.x<e&&(t.hp=0);M(8),O(`playing`)}},children:[`RESPAWN AT CHECKPOINT `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:F,children:`RESTART LEVEL · R`}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]})]})]})]})}export{w as PowershellMan};
1
+ import{h as e,p as t,u as n}from"./index-B1I248Ba.js";var r=e(t(),1),i=new URL(`title-1MphWZoQ.webp`,import.meta.url).href,a=new URL(`sprites-BUKsxG6N.webp`,import.meta.url).href,o=n(),s=[{label:`THE RELEASE PIPELINE`,title:`FRIDAY. 16:59.`,narration:`Microsoft releases reach production through the packaging team. Reviewed, signed, and supported. Powershell Man finds this suspiciously boring.`,bubble:`Use the vendor release. Let Packaging verify and distribute it.`,speaker:`THE ARCHITECT`,caption:`A predictable release process. Our hero senses a problem.`},{label:`THE INTERNAL BUILD`,title:`WE'LL BUILD IT OURSELVES`,narration:`Powershell Man has a plan: compile PowerShell and other Microsoft software, then have Packaging distribute his internal binaries in place of Microsoft's releases.`,bubble:`Why wait for Microsoft? Packaging can ship MY builds instead!`,speaker:`POWERSHELL MAN`,caption:`The vendor release pipeline is now a folder called final_FINAL.`},{label:`THE REVIEW`,title:`THE ARCHITECT STRIKES`,narration:`The DevSecOps architect raises a clipboard shield. Someone has to own the replacement release chain after the first build succeeds.`,bubble:`Who owns signing, security updates, provenance, and support?`,speaker:`THE ARCHITECT`,caption:`He wants a supportable release chain. Powershell Man calls it villainy.`}];function c({onFinish:e,onSkip:t}){let[n,i]=(0,r.useState)(0),a=s[n],c=(0,r.useCallback)(()=>{n===s.length-1?e():i(e=>Math.min(e+1,s.length-1))},[n,e]);(0,r.useEffect)(()=>{let e=e=>{if(e.repeat)return;if(e.key===`Escape`){e.preventDefault(),t();return}if(e.key!==`Enter`&&e.key!==` `)return;let n=e.target;n instanceof HTMLElement&&(n.closest(`button`)||n.isContentEditable)||(e.preventDefault(),c())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c,t]);function l(){i(e=>Math.max(0,e-1))}return(0,o.jsxs)(`section`,{className:`pm-story pm-story--panel-${n+1}`,"aria-label":`Powershell Man: origin story`,"aria-roledescription":`comic`,children:[(0,o.jsx)(`div`,{className:`pm-story__art`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`pm-story__shade`,"aria-hidden":`true`}),(0,o.jsxs)(`header`,{className:`pm-story__topline`,children:[(0,o.jsxs)(`span`,{children:[`TOIL COMICS `,(0,o.jsx)(`i`,{children:`✦`}),` INCIDENT ZERO`]}),(0,o.jsxs)(`span`,{className:`pm-story__counter`,"aria-label":`Panel ${n+1} of 3`,children:[String(n+1).padStart(2,`0`),` `,(0,o.jsx)(`b`,{children:`/`}),` 03`]})]}),(0,o.jsxs)(`div`,{className:`pm-story__content`,role:`group`,"aria-live":`polite`,"aria-atomic":`true`,"aria-label":`${a.label}, panel ${n+1} of 3`,children:[(0,o.jsx)(`div`,{className:`pm-story__eyebrow`,children:a.label}),(0,o.jsx)(`h1`,{children:a.title}),(0,o.jsx)(`p`,{className:`pm-story__narration`,children:a.narration}),(0,o.jsxs)(`div`,{className:`pm-story__bubble`,children:[(0,o.jsx)(`span`,{children:a.speaker}),(0,o.jsx)(`p`,{children:a.bubble})]}),(0,o.jsx)(`p`,{className:`pm-story__caption`,children:a.caption})]},n),(0,o.jsxs)(`footer`,{className:`pm-story__footer`,children:[(0,o.jsx)(`div`,{className:`pm-story__dots`,"aria-label":`Story progress`,children:s.map((e,t)=>(0,o.jsx)(`span`,{className:t===n?`is-current`:``,"aria-hidden":`true`},e.label))}),(0,o.jsxs)(`div`,{className:`pm-story__actions`,children:[(0,o.jsxs)(`button`,{className:`pm-story__skip`,onClick:t,children:[`SKIP STORY `,(0,o.jsx)(`kbd`,{children:`ESC`})]}),(0,o.jsxs)(`div`,{className:`pm-story__step-actions`,children:[(0,o.jsx)(`button`,{className:`pm-story__back`,onClick:l,disabled:n===0,"aria-label":`Previous panel`,children:`←`}),(0,o.jsxs)(`button`,{className:`pm-story__next`,onClick:c,children:[n===s.length-1?`START GAME`:`NEXT PANEL`,(0,o.jsx)(`span`,{"aria-hidden":`true`,children:` ↗`})]})]})]}),(0,o.jsx)(`div`,{className:`pm-story__hint`,"aria-hidden":`true`,children:`ENTER / SPACE TO ADVANCE`})]})]})}var l=new Image;l.src=a;var u=[],d=[];function f(){if(u.length||!l.naturalWidth)return;let e=document.createElement(`canvas`);e.width=l.naturalWidth,e.height=l.naturalHeight;let t=e.getContext(`2d`,{willReadFrequently:!0});if(!t)return;t.drawImage(l,0,0);let n=t.getImageData(0,0,e.width,e.height).data,r=e.width/8,i=[0,.265,.507,.727,1];u=Array.from({length:4},(t,a)=>Array.from({length:8},(t,o)=>{let s=Math.round(o*r),c=Math.round((i[a]??0)*e.height),l=Math.round((i[a+1]??1)*e.height)-c,u=Math.round(r),d=Math.round(l),f=0,p=0;for(let t=0;t<Math.floor(l);t++)for(let i=0;i<Math.floor(r);i++)(n[((c+t)*e.width+s+i)*4+3]??0)<32||(u=Math.min(u,i),d=Math.min(d,t),f=Math.max(f,i),p=Math.max(p,t));return{x:s+u,y:c+d,w:Math.max(1,f-u+1),h:Math.max(1,p-d+1)}}));let a=Math.max(...u.slice(0,2).flat().map(e=>e.h));d=[76/a,76/a,1,140/Math.max(...(u[3]??[]).map(e=>e.h))]}function p(e,t,n,r,i,a=1,o){let s=u[t]?.[n];if(!s)return;let c=o?o/Math.max(...(u[t]??[]).slice(n-n%2,n-n%2+2).map(e=>e.h)):d[t]??1;e.save(),e.translate(Math.round(r),Math.round(i)),e.scale(a,1),e.imageSmoothingEnabled=!1,e.drawImage(l,s.x,s.y,s.w,s.h,-s.w*c/2,-s.h*c,s.w*c,s.h*c),e.restore()}function m(e,t,n,r,i,a){if(r<.12)return;let o=Math.min(1,(r-.12)/.88),s=1+Math.sin(i/95)*.06;if(e.save(),e.globalCompositeOperation=`lighter`,a){e.globalAlpha=o*.22,e.filter=`blur(2px)`,p(e,2,7,t+Math.sin(i/150)*5,n+3,-1,(65+o*38)*s),e.filter=`none`,e.globalAlpha=.35+o*.4;for(let r=0;r<12;r++){let a=i/380+r*Math.PI/6,s=25+o*20+Math.sin(a*3)*4;e.fillStyle=r%2?`#8affed`:`#ffc5f1`,e.beginPath(),e.arc(t+Math.cos(a)*s,n-36+Math.sin(a)*s*1.15,.7+o,0,Math.PI*2),e.fill()}}else{let r=(42+o*30)*s,i=e.createRadialGradient(t,n-36,3,t,n-36,r);i.addColorStop(0,`rgba(100,240,255,${.12+o*.12})`),i.addColorStop(.5,`rgba(76,130,255,${o*.2})`),i.addColorStop(1,`rgba(70,80,255,0)`),e.fillStyle=i,e.fillRect(t-r,n-36-r,r*2,r*2),e.globalAlpha=.13+o*.18,e.filter=`blur(7px)`,p(e,2,7,t,n+12,1,(90+o*50)*s)}e.restore()}var h=960,g=540,_=1850,v=235,y=[{x:0,y:476,w:720,h:80},{x:790,y:476,w:520,h:80},{x:1400,y:476,w:740,h:80},{x:2240,y:476,w:720,h:80},{x:3060,y:476,w:760,h:80},{x:3900,y:476,w:740,h:80},{x:520,y:390,w:120,h:20},{x:925,y:370,w:140,h:20},{x:1190,y:410,w:120,h:20},{x:1640,y:370,w:150,h:20},{x:1900,y:405,w:130,h:20},{x:2460,y:380,w:140,h:20},{x:2780,y:410,w:130,h:20},{x:3270,y:365,w:150,h:20},{x:3550,y:400,w:130,h:20},{x:4100,y:370,w:160,h:20},{x:4390,y:400,w:150,h:20},{x:4740,y:476,w:650,h:80},{x:5470,y:476,w:650,h:80},{x:6260,y:476,w:680,h:80},{x:7090,y:476,w:640,h:80},{x:7880,y:476,w:1e3,h:80},{x:4930,y:400,w:130,h:20},{x:5700,y:380,w:140,h:20},{x:6030,y:410,w:120,h:20},{x:6530,y:370,w:150,h:20},{x:6840,y:405,w:130,h:20},{x:7370,y:375,w:140,h:20},{x:7660,y:410,w:120,h:20}],b=[0,1400,3060,4740,6260,7880],x=(e,t)=>e.type!==`phantom`||Math.sin(t/690+e.phase)<.45,S=()=>[...[300,620,1010,1320,1550,1810,2090,2360,2650,2960,3210,3470,3780,4050,4300,4610,4910,5180,5500,5810,6120,6400,6670,6940,7220,7490,7770].map((e,t)=>({x:e,y:465,hp:2,type:t%3==0?`job`:t%3==1?`alias`:`phantom`,base:e,phase:t*1.8})),{x:8310,y:405,hp:18,type:`boss`,base:8310,phase:0}];function C(e,t,n){let r=t.camera,i=e.createLinearGradient(0,0,0,g);i.addColorStop(0,`#071522`),i.addColorStop(1,`#102a3b`),e.fillStyle=i,e.fillRect(0,0,h,g);for(let t=0;t<28;t++){let n=((t*213-r*.22)%6200+6200)%6200-80,i=100+t*47%145;e.fillStyle=t%2?`#0b2130`:`#0d2636`,e.fillRect(n,470-i,92,i),e.fillStyle=`#17394a`;for(let t=485-i;t<455;t+=24)e.fillRect(n+12,t,6,7),e.fillRect(n+28,t,6,7),e.fillRect(n+62,t,6,7)}e.strokeStyle=`rgba(68,163,185,.08)`,e.lineWidth=1;for(let t=-(r%48);t<h;t+=48)e.beginPath(),e.moveTo(t,0),e.lineTo(t,g),e.stroke();for(let t of y){let n=t.x-r;if(!(n+t.w<-20||n>980)){e.fillStyle=`#193547`,e.fillRect(n,t.y,t.w,t.h),e.fillStyle=`#2b6270`,e.fillRect(n,t.y,t.w,5),e.fillStyle=`#102634`;for(let r=n+10;r<n+t.w-5;r+=40)e.fillRect(r,t.y+14,20,3)}}for(let[t,n]of[[520,`Execution Policy: Bypass?`],[1620,`Object → string`],[2780,`Final_v7_REAL.ps1`],[4120,`TODO: add retries`],[5660,`Reviewed by /dev/null`],[7130,`This log is not a database`]]){let i=t-r;i<-180||i>990||(e.fillStyle=`#302f3b`,e.fillRect(i,398,3,78),e.fillStyle=`#41394a`,e.fillRect(i-8,399,Math.min(190,n.length*6+18),30),e.fillStyle=`#f1b4c0`,e.font=`9px monospace`,e.fillText(n,i,418),e.fillStyle=`#ef77a5`,e.fillRect(i-2,396,7,4))}b.slice(1).forEach((t,i)=>{let a=t-r;a>-30&&a<990&&(e.fillStyle=`#f7b955`,e.fillRect(a,416,4,60),e.fillStyle=`rgba(247,185,85,${.2+.12*Math.sin(n/240)})`,e.beginPath(),e.arc(a+2,412,18,0,Math.PI*2),e.fill(),e.fillStyle=`#ffda8b`,e.font=`10px monospace`,e.fillText(`CHECKPOINT ${i+1}`,a-42,398))});for(let i of t.foes){let a=i.x-r,o=t.time-(i.hitAt??-1/0),s=i.hp<=0;if(!(a<-100||a>1060||s&&o>.45||!x(i,n)&&o>.3)){if(e.save(),o<.32&&e.translate((i.hitDirection??1)*Math.sin(o*Math.PI/.32)*9,0),s&&(e.globalAlpha=Math.max(0,1-o/.45),e.translate(0,-o*40)),o<.075&&(e.filter=`brightness(3) saturate(0.4)`),i.type===`boss`){if(p(e,3,o<.26?6+Math.min(1,Math.floor(o/.13)):t.bossTelegraph>0?4+Math.floor(n/100)%2:Math.floor(n/180)%4,a,476),t.bossTelegraph>0){let n=[`“Could we add validation before deploy?”`,`“Let’s keep this to least privilege.”`,`“One quick review before merge?”`][t.bossPhase];e.fillStyle=`#f3ebdf`,e.fillRect(a-120,276,240,26),e.fillStyle=`#302c39`,e.font=`10px monospace`,e.textAlign=`center`,e.fillText(n??`Please add a test.`,a,293),e.textAlign=`start`,e.fillStyle=`#ef77a5`,e.fillRect(a-3,301,6,8)}}else{let t=i.y;p(e,2,(i.type===`job`?0:i.type===`alias`?2:4)+Math.floor(n/140+i.phase)%2,a,t+9,1,i.type===`phantom`?46:39),e.fillStyle=`#d8b9bc`,e.font=`8px monospace`,e.textAlign=`center`,e.fillText(i.type===`job`?`JOB`:i.type===`alias`?`ALIAS`:`PROFILE`,a,t-30),e.textAlign=`start`}if(e.filter=`none`,o<.25&&(e.globalAlpha=1-o/.25,p(e,2,7,a,(i.type===`boss`?425:i.y)+14,1,24+o*120)),s){e.fillStyle=`#ffb8e6`;for(let t=0;t<8;t++){let n=t*Math.PI/4;e.fillRect(a+Math.cos(n)*o*95,i.y-12+Math.sin(n)*o*80,3,3)}}e.restore()}}for(let n of t.shots){let t=n.x-r,i=n.hostile?`#ffb547`:n.charge>0?`#8affed`:`#ff58a5`;e.strokeStyle=i,e.lineWidth=n.charge?5:3,e.shadowBlur=n.charge?14:7,e.shadowColor=i,e.beginPath(),e.moveTo(t-n.vx*.035,n.y-n.vy*.035),e.bezierCurveTo(t-n.vx*.024+3,n.y-n.vy*.025+5,t-n.vx*.012-4,n.y-n.vy*.012-5,t,n.y),e.stroke(),e.fillStyle=i,e.fillRect(t-3,n.y-3,6,6),e.shadowBlur=0}let a=t.player,o=a.x-r,s=a.y;if(!(a.invuln>0&&Math.floor(n/65)%2==0)){let r=t.time-t.lastFire<.23,i=Math.abs(a.vx)>1,c=a.grounded&&i&&!r?0:1,l=c===0?Math.floor(n/75)%8:r?5+Math.min(2,Math.floor((t.time-t.lastFire)/.077)):a.grounded?Math.floor(n/320)%2:a.vy<-160?2:a.vy<150?3:4;m(e,o,s,t.charge,n,!1),p(e,c,l,o,s,a.face),m(e,o,s,t.charge,n,!0),t.charge>.85&&(e.strokeStyle=`#8affed`,e.lineWidth=1+t.charge,e.beginPath(),e.arc(o+a.face*27,s-44,5+t.charge*9+Math.sin(n/45)*2,0,Math.PI*2),e.stroke()),r&&p(e,2,6+Math.floor(n/65)%2,o+a.face*40,s-27,a.face,24)}}function w({onClose:e}){let[t,n]=(0,r.useState)(!1),[a,s]=(0,r.useState)(!1),[d,p]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=()=>{f(),n(u.length===4)},t=()=>s(!0);return l.addEventListener(`load`,e),l.addEventListener(`error`,t),l.complete&&(l.naturalWidth?e():t()),()=>{l.removeEventListener(`load`,e),l.removeEventListener(`error`,t)}},[]);let m=(0,r.useRef)(null),w=(0,r.useRef)(null),T=(0,r.useRef)(new Set),E=(0,r.useRef)(!1),[D,O]=(0,r.useState)(`intro`),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(8),[N,P]=(0,r.useState)(18),F=(0,r.useCallback)(()=>{w.current={player:{x:90,y:476,vx:0,vy:0,grounded:!0,face:1,invuln:0,health:8,checkpoint:0,coyote:.1,buffer:0,emergency:0,emergencyCooldown:0},foes:S(),shots:[],camera:0,charge:0,last:0,accumulator:0,shotAt:0,lastFire:-1/0,bossPhase:0,time:0,bossTelegraph:0,padJump:!1,padFire:!1,padEmergency:!1,padStart:!1},T.current.clear(),M(8),P(18),A(0),p(0),O(`playing`)},[]);(0,r.useEffect)(()=>{let e=m.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let n=0,r=()=>{let n=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(e.clientWidth*n),e.height=Math.round(e.clientHeight*n),t.setTransform(e.width/h,0,0,e.height/g,0,0)};r();let i=new ResizeObserver(r);i.observe(e);let a=e=>{if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`Space`].includes(e.code)&&e.preventDefault(),e.code===`Escape`){if(e.repeat)return;D===`playing`&&T.current.clear(),O(e=>e===`playing`?`paused`:e===`paused`?`playing`:e)}else e.code===`KeyR`&&(D===`won`||D===`lost`)?F():(D===`playing`&&!T.current.has(e.code)&&[`ArrowUp`,`KeyZ`,`Space`].includes(e.code)&&(E.current=!0),D===`playing`&&!T.current.has(e.code)&&e.code===`KeyC`&&w.current&&w.current.player.emergencyCooldown<=0&&(w.current.player.emergency=1.25,w.current.player.emergencyCooldown=7,w.current.player.invuln=1.25),T.current.add(e.code))},o=e=>{if(T.current.delete(e.code),D===`playing`&&e.code===`KeyX`&&w.current){let e=w.current,t=e.player;performance.now()-e.shotAt>180&&(e.shots.push({x:t.x+t.face*24,y:t.y-45,vx:t.face*(e.charge>.9?600:510),vy:0,life:1.5,charge:+(e.charge>.9)}),e.shotAt=performance.now(),e.lastFire=e.time),e.charge=0}};window.addEventListener(`keydown`,a),window.addEventListener(`keyup`,o);let s=(e,t)=>{t.time+=e;let n=t.time*1e3,r=t.player,i=T.current,a=navigator.getGamepads?.()[0],o=!!a?.buttons[0]?.pressed,s=!!a?.buttons[2]?.pressed,c=!!a?.buttons[1]?.pressed,l=!!a?.buttons[9]?.pressed;o&&!t.padJump&&(E.current=!0),c&&!t.padEmergency&&r.emergencyCooldown<=0&&(r.emergency=1.25,r.emergencyCooldown=7,r.invuln=1.25),l&&!t.padStart&&(T.current.clear(),O(`paused`)),s&&!t.padFire&&(t.charge=0),!s&&t.padFire&&performance.now()-t.shotAt>180&&(t.shots.push({x:r.x+r.face*24,y:r.y-45,vx:r.face*(t.charge>.9?600:510),vy:0,life:1.5,charge:+(t.charge>.9)}),t.shotAt=performance.now(),t.lastFire=t.time,t.charge=0),t.padJump=o,t.padFire=s,t.padEmergency=c,t.padStart=l,r.invuln=Math.max(0,r.invuln-e),r.emergency=Math.max(0,r.emergency-e),r.emergencyCooldown=Math.max(0,r.emergencyCooldown-e),r.coyote=r.grounded?.11:Math.max(0,r.coyote-e),r.buffer=E.current?.12:Math.max(0,r.buffer-e),E.current=!1;let u=a?.axes[0]??0,d=(i.has(`ArrowRight`)||i.has(`KeyD`)||u>.25||a?.buttons[15]?.pressed?1:0)-(i.has(`ArrowLeft`)||i.has(`KeyA`)||u<-.25||a?.buttons[14]?.pressed?1:0);d&&(r.face=d),r.vx=d*v,r.buffer&&r.coyote&&(r.vy=-665,r.grounded=!1,r.coyote=0,r.buffer=0),(i.has(`KeyX`)||s)&&(t.charge=Math.min(1,t.charge+e/1.2)),r.vy=Math.min(1e3,r.vy+_*e);let f=r.x;r.x=Math.max(18,Math.min(8780,r.x+r.vx*e));let m=r.y;r.y+=r.vy*e,r.grounded=!1;for(let e of y){let t=r.x+12>e.x&&r.x-12<e.x+e.w,n=r.y>e.y&&r.y-54<e.y+e.h;t&&(m<=e.y&&r.y>=e.y&&r.vy>=0?(r.y=e.y,r.vy=0,r.grounded=!0):m-54>=e.y+e.h&&r.y-54<e.y+e.h&&r.vy<0&&(r.y=e.y+e.h+54,r.vy=0)),n&&(f+12<=e.x&&r.x+12>e.x?(r.x=e.x-12,r.vx=0):f-12>=e.x+e.w&&r.x-12<e.x+e.w&&(r.x=e.x+e.w+12,r.vx=0))}r.y>620&&(r.health=0);for(let i of t.shots){if(i.x+=i.vx*e,i.y+=i.vy*e,i.life-=e,!i.hostile){for(let e of t.foes)if(e.hp>0&&x(e,n)&&Math.abs(i.x-e.x)<(e.type===`boss`?44:23)&&Math.abs(i.y-e.y)<(e.type===`boss`?118:36)){e.hp-=i.charge?3:1,e.hitAt=t.time,e.hitDirection=Math.sign(i.vx),p(e=>e+1),i.life=0,e.type===`boss`&&P(e.hp);break}}i.hostile&&Math.abs(i.x-r.x)<20&&Math.abs(i.y-(r.y-20))<30&&!r.invuln&&(r.health--,r.invuln=1.2,i.life=0)}t.shots=t.shots.filter(e=>e.life>0&&e.x>t.camera-100&&e.x<t.camera+h+100);for(let i of t.foes)if(!(i.hp<=0)){if(i.type===`boss`){i.x=Math.max(8110,Math.min(8510,i.base+Math.sin(n/1100)*160)),i.phase+=e;let a=i.hp>12?0:i.hp>6?1:2;t.bossPhase=a;let o=a===0?1.5:a===1?1.2:.9;if(t.bossTelegraph=i.phase>o-.35?o-i.phase:0,i.phase>o){i.phase=0,t.bossTelegraph=0;let e=r.x-i.x,n=r.y-22-382,o=Math.hypot(e,n)||1,s=a===2?3:1;for(let r=0;r<s;r++){let a=(r-(s-1)/2)*.2,c=e/o*300,l=n/o*300;t.shots.push({x:i.x,y:382,vx:c*Math.cos(a)-l*Math.sin(a),vy:c*Math.sin(a)+l*Math.cos(a),life:3.2,charge:0,hostile:!0})}}}else i.x=i.type===`job`?i.base+Math.sin(n/640+i.phase)*65:i.base+Math.sin(n/480+i.phase)*32,i.y=i.type===`alias`?465-Math.max(0,Math.sin(n/250+i.phase))*42:465,x(i,n)&&Math.abs(i.x-r.x)<28&&Math.abs(i.y-22-(r.y-35))<35&&!r.invuln&&(r.health--,r.invuln=1)}if(r.health<=0)r.health=0,M(0),O(`lost`);else{for(let e=r.checkpoint+1;e<b.length;e++)r.x>(b[e]??1/0)&&(r.checkpoint=e);t.camera=Math.max(0,Math.min(7900,r.x-290)),M(r.health),A(t.charge),(t.foes.at(-1)?.hp??18)<=0&&O(`won`)}},c=e=>{if(D===`playing`){let n=w.current;if(n){n.last||=e;let r=Math.min(.05,(e-n.last)/1e3);for(n.last=e,n.accumulator+=r;n.accumulator>=1/120;)s(1/120,n),n.accumulator-=1/120;C(t,n,n.time*1e3)}}else if(w.current)C(t,w.current,w.current.time*1e3);else{t.fillStyle=`#071522`,t.fillRect(0,0,h,g);for(let e=0;e<18;e++)t.fillStyle=e%2?`#0b2130`:`#0d2636`,t.fillRect(e*61,270+e%4*19,48,250)}n=requestAnimationFrame(c)};return n=requestAnimationFrame(c),()=>{cancelAnimationFrame(n),i.disconnect(),window.removeEventListener(`keydown`,a),window.removeEventListener(`keyup`,o)}},[D,F]),(0,r.useEffect)(()=>{let e=()=>{T.current.clear(),O(e=>e===`playing`?`paused`:e)},t=()=>{document.hidden&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`blur`,e),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`blur`,e)}},[]);let I=w.current;return(0,o.jsxs)(`section`,{className:`pm-game`,"aria-label":`Powershell Man game`,"data-game-state":D,"data-health":j,"data-boss-health":N,"data-charge":k.toFixed(2),"data-player-x":I?.player.x.toFixed(0),"data-player-y":I?.player.y.toFixed(0),"data-checkpoint":I?.player.checkpoint,"data-sprites-ready":t,"data-hit-count":d,children:[(0,o.jsx)(`canvas`,{ref:m,className:`pm-canvas`,"aria-label":`Game screen. Arrow keys or A and D to move, Z or Space to jump, X to fire, Escape to pause.`}),D===`playing`&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`pm-hud`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`b`,{children:`POWERSHELL MAN`}),(0,o.jsx)(`span`,{children:`INCIDENT RESPONSE / FIELD OPS`})]}),(0,o.jsxs)(`div`,{className:`pm-life`,children:[(0,o.jsx)(`span`,{title:`Works on My Machine`,children:`HP`}),Array.from({length:8},(e,t)=>(0,o.jsx)(`i`,{className:t<j?`on`:``},t))]}),(0,o.jsxs)(`div`,{className:`pm-charge`,children:[(0,o.jsx)(`span`,{children:`CHARGE`}),(0,o.jsx)(`progress`,{max:`100`,value:k*100})]}),(0,o.jsxs)(`span`,{className:`pm-emergency`,"data-ready":I&&I.player.emergencyCooldown<=0,children:[`C · SilentlyContinue`,` `,I?`${Math.ceil(I.player.emergencyCooldown)}s`:``]}),(0,o.jsx)(`button`,{onClick:()=>O(`paused`),"aria-label":`Pause`,children:`Ⅱ`})]}),(I?.foes.at(-1)?.x??1/0)-(I?.camera??0)<900&&(0,o.jsxs)(`div`,{className:`pm-bossbar`,children:[(0,o.jsxs)(`span`,{children:[`COMMON-SENSE DEVSECOPS ARCHITECT · PHASE`,` `,(I?.bossPhase??0)+1,I?.bossTelegraph?` · REVIEWING TARGET`:``]}),(0,o.jsx)(`progress`,{max:`18`,value:Math.max(0,N)})]}),(0,o.jsx)(`div`,{className:`pm-controls`,children:`← → move\xA0\xA0 Z jump\xA0\xA0 X fire / release to shoot\xA0\xA0 C emergency\xA0\xA0 Esc pause`})]}),D===`story`&&(0,o.jsx)(c,{onFinish:F,onSkip:F}),D!==`playing`&&D!==`story`&&(0,o.jsxs)(`div`,{className:`pm-overlay ${D===`intro`?`pm-overlay--intro`:``}`,children:[D===`intro`&&(0,o.jsx)(`img`,{className:`pm-title-art`,src:i,alt:``}),(0,o.jsxs)(`div`,{className:`pm-card`,children:[(0,o.jsx)(`div`,{className:`pm-kicker`,children:`TOIL SYSTEMS // INCIDENT RESPONSE SIMULATOR`}),(0,o.jsx)(`h1`,{children:D===`intro`?`POWERSHELL MAN`:D===`paused`?`PAUSED`:D===`won`?`PRODUCTION RESTORED`:`INCIDENT UNRECOVERED`}),D===`intro`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Compile the stack. Replace the vendor release. Hand Packaging the consequences.`}),(0,o.jsxs)(`div`,{className:`pm-how`,children:[(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`MOVE`}),(0,o.jsx)(`span`,{children:`← → or A / D`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`JUMP`}),(0,o.jsx)(`span`,{children:`Z or Space`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`FIRE`}),(0,o.jsx)(`span`,{children:`X · hold to charge`})]}),(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`strong`,{children:`PAUSE`}),(0,o.jsx)(`span`,{children:`Esc`})]})]}),(0,o.jsx)(`p`,{className:`pm-threat`,children:`Alias gremlins · orphan jobs · profile phantoms · one architect with opinions.`}),(0,o.jsx)(`p`,{className:`pm-gamepad-note`,children:`GAMEPAD · left stick / D-pad move · A jump · X hold/release fire · B emergency · Start pause`}),a&&(0,o.jsx)(`p`,{role:`alert`,children:`The sprite sheet could not load. Reload the page to retry.`}),(0,o.jsxs)(`button`,{onClick:()=>O(`story`),disabled:!t,children:[t?`START INCIDENT`:`LOADING SPRITES…`,` `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]}):D===`paused`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Runbooks can wait. The incident will not progress while paused.`}),(0,o.jsxs)(`button`,{onClick:()=>{I&&(I.last=0),O(`playing`)},children:[`RESUME `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`EXIT SIMULATOR`})]}):D===`won`?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`DEPLOYMENT SUCCESSFUL · Fine.`}),(0,o.jsx)(`p`,{className:`pm-joke`,children:`The architect approved the deploy. You now own the on-call rotation. Maintenance begins at 02:00.`}),(0,o.jsxs)(`button`,{onClick:F,children:[`RUN IT BACK `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`p`,{children:`Emergency SilentlyContinue: the incident got you. Your last checkpoint is still intact.`}),(0,o.jsxs)(`button`,{onClick:()=>{if(I){let e=b[I.player.checkpoint]??7880;I.player.x=e+40,I.player.y=476,I.player.vy=0,I.player.health=8,I.player.invuln=2,I.shots=[];for(let t of I.foes)t.type!==`boss`&&t.x<e&&(t.hp=0);M(8),O(`playing`)}},children:[`RESPAWN AT CHECKPOINT `,(0,o.jsx)(`span`,{children:`↗`})]}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:F,children:`RESTART LEVEL · R`}),(0,o.jsx)(`button`,{className:`pm-secondary`,onClick:e,children:`BACK TO WORK`})]})]})]})]})}export{w as PowershellMan};