(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=`https://advent-of-slop.quesma.com`,t=` nav { position: fixed; top: 0; right: 0; z-index: 2147483647; display: flex; flex-wrap: wrap; gap: 0 0.35em; max-width: 100vw; box-sizing: border-box; padding: 0.35rem 0.7rem; border-bottom-left-radius: 0.5rem; background: #b8232f; font: 700 0.8125rem/1.2 system-ui, sans-serif; } a { color: #f6ecd6; text-decoration: none; } a:hover { text-decoration: underline; } `,n=(e,t)=>{let n=document.createElement(`a`);return n.href=e,n.textContent=t,n},r=class extends HTMLElement{connectedCallback(){let r=Number(this.getAttribute(`day`));if(!Number.isInteger(r)||r<1||r>24)throw Error(` needs day="1" to day="24", got ${this.getAttribute(`day`)}`);let i=this.getAttribute(`name`);if(i===null||i.trim()===``)throw Error(` needs name="...", the title of its day, such as name="Living fishtank"`);let a=document.createElement(`style`);a.textContent=t;let o=document.createElement(`nav`);o.append(n(`${e}/`,`Advent of AI Slop`),n(`${e}/day/${r}/`,`[Day ${r}] ${i}`)),this.attachShadow({mode:`open`}).append(a,o)}};customElements.define(`advent-badge`,r);var i=1200,a=e=>{let t=Math.sin(e*127.1+311.7)*43758.5453;return t-Math.floor(t)};function o(e,t){let n=Math.random()*1e4,r=t===0?[140,300]:t===1?[100,220]:[70,150],i=r[0]+Math.random()*(r[1]-r[0]);return{x:e,w:t===0?70+Math.random()*90:t===1?60+Math.random()*80:55+Math.random()*70,h:i,tone:Math.random(),seed:n,spire:Math.random()<.16}}function s(e,t){let n=e.createLinearGradient(0,0,0,508);n.addColorStop(0,`#0c1024`),n.addColorStop(.55,`#1c2748`),n.addColorStop(.85,`#3a3f6b`),n.addColorStop(1,`#6b4a63`),e.fillStyle=n,e.fillRect(0,0,i,508);for(let n=0;n<70;n++){let r=a(n*3.7)*i,o=a(n*9.1)*508*.55;e.fillStyle=`rgba(240,240,255,${(.25+.5*(.35+.65*Math.abs(Math.sin(t*(.6+a(n)*1.4)+n))))*(1-o/(508*.7))})`,e.fillRect(r,o,2,2)}let r=1010,o=e.createRadialGradient(r,92,8,r,92,60);o.addColorStop(0,`rgba(255,244,214,0.55)`),o.addColorStop(1,`rgba(255,244,214,0)`),e.fillStyle=o,e.fillRect(950,32,120,120),e.fillStyle=`#f8ecc8`,e.beginPath(),e.arc(r,92,26,0,Math.PI*2),e.fill(),e.fillStyle=`rgba(200,180,140,0.35)`,e.beginPath(),e.arc(1002,86,5,0,Math.PI*2),e.fill(),e.beginPath(),e.arc(1017,100,7,0,Math.PI*2),e.fill()}function c(e,t,n,r){let i=508-(n===2?26:n===1?12:0),o=n===0?[`#141a33`,`#182040`]:n===1?[`#1d2547`,`#232c52`]:[`#2a3358`,`#323d66`];for(let s of t){if(s.x>1210||s.x+s.w<-10)continue;let t=i-s.h;if(e.fillStyle=o[+(s.tone>.5)],e.fillRect(s.x,t,s.w,s.h),s.spire&&(e.beginPath(),e.moveTo(s.x+s.w*.5-8,t),e.lineTo(s.x+s.w*.5,t-34),e.lineTo(s.x+s.w*.5+8,t),e.closePath(),e.fill()),e.fillStyle=`rgba(226,234,250,0.85)`,e.fillRect(s.x-2,t,s.w+4,5),n>0){let n=Math.max(2,Math.floor(s.w/22)),i=Math.max(2,Math.floor(s.h/26));for(let o=0;o.9?.6+.4*Math.sin(r*3+s.seed+o):1;e.fillStyle=l>.75?`rgba(255,196,102,${.75*u})`:`rgba(160,200,255,${.4*u})`,e.fillRect(s.x+8+c*((s.w-16)/n),t+12+o*((s.h-20)/i),8,10)}}}}function l(e,t){e.fillStyle=`#cfd8ea`,e.fillRect(0,482,i,26),e.fillStyle=`#eef3fb`,e.fillRect(0,482,i,6),e.fillStyle=`#9aa6c0`,e.fillRect(0,504,i,4);let n=e.createLinearGradient(0,508,0,600);n.addColorStop(0,`#3a4056`),n.addColorStop(1,`#232838`),e.fillStyle=n,e.fillRect(0,508,i,92),e.fillStyle=`rgba(226,234,250,0.5)`;let r=t%104;for(let t=-r;te+Math.random()*(t-e),C=class{phase=`menu`;char=`pelican`;time=0;scroll=0;speed=0;pickupsGot=0;best=0;spec=v.pelican;rider=this.freshRider();far=[];mid=[];near=[];lamps=[];obstacles=[];pickups=[];flakes=[];distSinceSpawn=1e9;distSincePickup=0;garlandCooldown=0;score=0;onHud;onCrash;constructor(e,t){this.onHud=e,this.onCrash=t,this.buildLayer();let n=60;for(;n0&&(e.vy=-this.spec.jumpV*.88,--e.jumpsLeft)}setDuck(e){this.duckOn=e}duckOn=!1;get crashDone(){return this.rider.crashT>1.15}pause(e){e&&this.phase===`playing`?this.phase=`paused`:!e&&this.phase===`paused`&&(this.phase=`playing`)}get meters(){return Math.floor(this.scroll/40)}get kmh(){return Math.round(this.speed*.065)}get scoreNow(){return this.score}update(e){this.time+=e;for(let t of this.flakes)t.y+=t.vy*e,t.x-=(this.phase===`playing`?this.speed*.12:18)*e+Math.sin(this.time*2+t.phase)*t.sway*e,t.y>600&&(t.y=-4,t.x=Math.random()*i),t.x<-4&&(t.x=i+4);if(this.phase!==`playing`&&this.phase!==`crashed`){this.pushHud();return}let t=this.rider;if(this.phase===`crashed`){t.crashT+=e,t.vy+=y*e,t.y=Math.min(508,t.y+t.vy*e);return}this.speed=Math.min(this.spec.vmax,this.spec.v0+this.spec.accel*this.time);let n=this.speed*e;this.scroll+=n,t.crank+=n*.045;let r=[.22,.45,.72];for(let[e,t]of[[0,this.far],[1,this.mid],[2,this.near]]){for(let i of t)i.x-=n*r[e];let i=0;for(let e of t)i=Math.max(i,e.x+e.w);for(let n of t)if(n.x+n.w<-60){n.x=i+S(6,40);let t=o(n.x,e);n.w=t.w,n.h=t.h,n.tone=t.tone,n.seed=t.seed,n.spire=t.spire,i=n.x+n.w}}for(let e=0;e=508&&(t.y=508,t.vy=0,t.onGround=!0,t.jumpsLeft=this.spec.jumps),this.distSinceSpawn+=n;let c=240+this.speed*.42;if(this.distSinceSpawn>c*S(.85,1.6)){this.distSinceSpawn=0,--this.garlandCooldown;let e=[`pothole`,`snowman`,`tree`,`gift`,`bin`];if(this.garlandCooldown<=0&&this.time>12)this.garlandCooldown=5,this.obstacles.push({kind:`garland`,x:i+60,w:230,h:0,seed:Math.random()});else{let t=e[Math.floor(Math.random()*e.length)],[n,r]={pothole:[64,16],snowman:[40,96],tree:[60,92],gift:[46,54],bin:[40,66]}[t];this.obstacles.push({kind:t,x:i+60,w:n,h:r,seed:Math.random()})}}if(this.distSincePickup+=n,this.distSincePickup>200){this.distSincePickup=0;let e=this.char===`pelican`?`fish`:`carrot`,t=Math.random()<.45,n=t?508-S(120,175):478;for(let r=0;r<3;r++)this.pickups.push({kind:e,x:i+80+r*42,y:t?n-Math.sin(r/2*Math.PI)*26:n,taken:!1})}let l=t.y-(this.spec.standH-(this.spec.standH-this.spec.duckH)*t.duck),u=b-x/2;for(let e of this.obstacles)if(e.x-=n,e.kind===`garland`)218>e.x+14&&u358&&this.crash();else if(e.kind!==`pothole`){let n=508-e.h;218>e.x+6&&un+8&&this.crash()}else 218>e.x+10&&168e.x+e.w>-80);for(let e of this.pickups)e.x-=n,!e.taken&&Math.abs(e.x-b)<34&&Math.abs(e.y-(t.y-70))<52&&(e.taken=!0,this.pickupsGot+=1,this.score+=50);this.pickups=this.pickups.filter(e=>e.x>-40),this.score=Math.max(this.score,0),this.score+=n*.1,this.pushHud()}crash(){if(this.phase!==`playing`)return;this.phase=`crashed`,this.rider.crashT=0,this.rider.vy=-420;let e=Math.floor(this.score),t=e>this.best;this.onCrash(e,this.meters,this.pickupsGot,Math.max(this.best,e),t)}pushHud(){this.onHud({score:Math.floor(this.score),meters:this.meters,kmh:this.kmh,fish:this.pickupsGot,best:this.best})}render(e){s(e,this.time),c(e,this.far,0,this.time),c(e,this.mid,1,this.time),c(e,this.near,2,this.time),l(e,this.scroll);for(let t of this.lamps)t>-60&&t<1260&&u(e,t,this.time);for(let t of this.obstacles)t.kind===`garland`&&f(e,t,this.time);for(let t of this.obstacles)t.kind!==`garland`&&f(e,t,this.time);for(let t of this.pickups)p(e,t,this.time);let t=this.rider;if(e.save(),this.phase===`crashed`){e.translate(b,t.y-60),e.rotate(t.crashT*5.2),e.translate(-190,-(t.y-60)),e.fillStyle=`#ffd166`;for(let n=0;n<6;n++){let r=n/6*Math.PI*2+t.crashT*3,i=40+t.crashT*60;e.beginPath(),e.arc(b+Math.cos(r)*i,t.y-70+Math.sin(r)*i*.6,4-t.crashT*2,0,Math.PI*2),e.fill()}}this.char===`pelican`?g(e,b,t.y,t.crank,t.duck,this.time):_(e,b,t.y,t.crank,t.duck,this.time),e.restore(),e.fillStyle=`rgba(240,245,255,0.9)`;for(let t of this.flakes)e.globalAlpha=.35+t.r/4,e.beginPath(),e.arc(t.x,t.y,t.r,0,Math.PI*2),e.fill();e.globalAlpha=1;let n=e.createRadialGradient(i/2,300,330,i/2,300,630);n.addColorStop(0,`rgba(0,0,0,0)`),n.addColorStop(1,`rgba(5,8,18,0.5)`),e.fillStyle=n,e.fillRect(0,0,i,600)}},w=document.getElementById(`game`),T=w?.getContext(`2d`);if(!w||!T)throw Error(`canvas #game missing`);var E=T,D=e=>{let t=document.getElementById(e);if(!t)throw Error(`missing #${e}`);return t},O=D(`hud-score`),k=D(`hud-dist`),A=D(`hud-speed`),j=D(`hud-fish`),M=D(`hud-best`),N=D(`menu`),P=D(`pause`),F=D(`gameover`),I=D(`final-score`),L=D(`final-dist`),R=D(`final-fish`),z=D(`best-line`),B=D(`crash-line`),V=e=>`aos5-best-${e}`,H=e=>Number(localStorage.getItem(V(e))??`0`)||0,U=new C(e=>{O.textContent=String(e.score),k.textContent=String(e.meters),A.textContent=String(e.kmh),j.textContent=String(e.fish),M.textContent=String(e.best)},(e,t,n,r,i)=>{I.textContent=String(e),L.textContent=String(t),R.textContent=String(n),i?(localStorage.setItem(V(U.char),String(r)),z.textContent=`★ new personal best!`,z.classList.add(`new`)):(z.textContent=`best: ${r}`,z.classList.remove(`new`));let a=U.char===`pelican`?[`Squawk.`,`Honk. That was not a ramp.`,`The fish saw everything.`]:[`Clatter.`,`The unicycle disagrees.`,`Rudolph needs a moment.`];B.textContent=a[Math.floor(Math.random()*a.length)],F.classList.remove(`hidden`),M.textContent=String(r)});function W(e){U.setChar(e,H(e)),M.textContent=String(H(e)),U.start(),N.classList.add(`hidden`),F.classList.add(`hidden`)}for(let e of document.querySelectorAll(`#cards .card`))e.addEventListener(`click`,()=>{let t=e.dataset.char;(t===`pelican`||t===`reindeer`)&&W(t)});D(`restart-btn`).addEventListener(`click`,()=>W(U.char)),D(`menu-btn`).addEventListener(`click`,()=>{F.classList.add(`hidden`),N.classList.remove(`hidden`),U.phase=`menu`});var G=new Set([`Space`,`ArrowUp`,`KeyW`]),K=new Set([`ArrowDown`,`KeyS`]);window.addEventListener(`keydown`,e=>{if(!e.repeat){if(G.has(e.code)){if(e.preventDefault(),U.phase===`menu`&&!N.classList.contains(`hidden`))return;U.phase===`crashed`&&U.crashDone&&W(U.char),U.jump()}else K.has(e.code)?(e.preventDefault(),U.setDuck(!0)):e.code===`KeyR`&&(U.phase===`crashed`||U.phase===`playing`)?W(U.char):e.code===`KeyP`||e.code===`Escape`?(U.pause(U.phase===`playing`),P.classList.toggle(`hidden`,U.phase!==`paused`)):U.phase===`menu`&&!N.classList.contains(`hidden`)&&(e.code===`Digit1`&&W(`pelican`),e.code===`Digit2`&&W(`reindeer`))}}),window.addEventListener(`keyup`,e=>{K.has(e.code)&&U.setDuck(!1)}),w.addEventListener(`pointerdown`,e=>{e.preventDefault(),U.phase===`playing`&&U.jump()});var q=performance.now();function J(e){let t=Math.min(.033,(e-q)/1e3);q=e,U.update(t),U.render(E),requestAnimationFrame(J)}requestAnimationFrame(J),window.__aos5=U;