(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=[{name:`Sleigh Crash`,clash:70,body:`#b3121f`,colors:[`#1e7d32`,`#f4c430`,`#ffffff`,`#ff5fa2`]},{name:`Eggnog Nightmare`,clash:85,body:`#f3e3b8`,colors:[`#39d353`,`#ff2f92`,`#ff7b00`,`#26c6da`]},{name:`Radioactive Pine`,clash:92,body:`#2fbf3f`,colors:[`#7b2ff7`,`#ff1744`,`#ffe600`,`#00e5ff`]},{name:`Tinsel Overload`,clash:65,body:`#1c1c1c`,colors:[`#ffd700`,`#e91e63`,`#00bcd4`,`#ff5252`]},{name:`Grinch Sick`,clash:75,body:`#43a047`,colors:[`#f06292`,`#ba68c8`,`#ffee58`,`#4fc3f7`]},{name:`Candy Cane Vomit`,clash:80,body:`#ff8fa3`,colors:[`#d90429`,`#ffffff`,`#80ed99`,`#ffd60a`]},{name:`Nordic Normie`,clash:28,body:`#274b7a`,colors:[`#e8e8e8`,`#c0392b`,`#f1c40f`,`#7fb3d5`]},{name:`Reindeer Roadkill`,clash:88,body:`#6d4c41`,colors:[`#ffeb3b`,`#e53935`,`#4caf50`,`#ff9800`]}],a=[`The `,`Aunt Helga's `,`Grandpa Ole's `,`Cousin Kim's `,`The Office Party `,`Christmas 1987 `,`Mom's `],o=[`Eggnog-Soaked `,`Tinsel-Loaded `,`Radioactive `,`Cursed `,`Maximum `,`Aggressively Festive `,`Glitter-Bombed `,`Sleigh-Chasing `,`Mulled-Wine `,`Ginger-Infused `],s=[`Disaster`,`Nightmare`,`Menace`,`Warcrime`,`Masterpiece`,`Catastrophe`,`Legend`,`Special`,`Tragedy`,`Showstopper`],c=(e,t)=>t[Math.floor(e()*t.length)];function l(e){return c(e,a)+c(e,o)+c(e,s)}function u(e){return e<20?`Potentially office-safe`:e<40?`Mildly festive`:e<60?`Aunt-approved`:e<80?`Family intervention needed`:e<95?`Documented war crime`:`Nuclear`}var d=(e,t,n=!1)=>({name:e,w:t[0].length,h:t.length,rows:t,tame:n}),f=[d(`tree`,[`...##...`,`..####..`,`..####..`,`.######.`,`.######.`,`########`,`...oo...`,`...oo...`],!0),d(`snowflake`,[`#..##..#`,`.#.##.#.`,`..####..`,`########`,`########`,`..####..`,`.#.##.#.`,`#..##..#`],!0),d(`star`,[`...##...`,`..####..`,`########`,`########`,`.######.`,`..####..`,`.#.##.#.`,`#..##..#`],!0),d(`snowman`,[`...##...`,`..####..`,`.######.`,`..oooo..`,`.o#oo#o.`,`..oooo..`,`.oooooo.`,`oooooooo`],!0),d(`santa`,[`.....##.`,`....###.`,`..####..`,`########`,`.oooooo.`,`.o#oo#o.`,`.oooooo.`,`..oooo..`]),d(`reindeer`,[`#......#`,`.#....#.`,`..####..`,`.oooooo.`,`.o#oo#o.`,`.oooooo.`,`..o##o..`,`...oo...`]),d(`candycane`,[`..####..`,`.#....#.`,`#......#`,`#......#`,`...#....`,`...#....`,`...#....`,`...#....`]),d(`present`,[`..o..o..`,`.oooooo.`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`,`oo####oo`]),d(`gingerbread`,[`..####..`,`..####..`,`########`,`.######.`,`..####..`,`..#..#..`,`.#....#.`,`#......#`]),d(`bell`,[`...##...`,`...##...`,`..####..`,`.######.`,`.######.`,`########`,`########`,`...oo...`]),d(`heart`,[`.#....#.`,`########`,`########`,`########`,`.######.`,`..####..`,`...##...`,`........`]),d(`mitten`,[`..####..`,`.######.`,`#######.`,`######..`,`######..`,`.######.`,`.######.`,`........`]),d(`stocking`,[`..####..`,`..####..`,`..####..`,`..####..`,`..#####.`,`.#######`,`########`,`#####...`])],p=d(`flake6`,[`#.##.#`,`.####.`,`######`,`######`,`.####.`,`#.##.#`]),m=12;function h(e){let t=e>>>0;return()=>{t|=0,t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function g(e,t,n){let r=e^Math.imul(t,2654435761)^Math.imul(n,2246822507);return r=Math.imul(r^r>>>13,3266489909),r^=r>>>16,(r>>>0)/4294967296}var _=e=>[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)],v=(e,t,n)=>`#`+[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,`0`)).join(``),y=(e,t)=>{let[n,r,i]=_(e);return v(n*t,r*t,i*t)};function b(e,t){if(e>=4&&e<=43&&t>=14&&t<=37)return(e===4||e===7)&&t>=23&&t<=28||(e===5||e===6)&&t>=22&&t<=29?0:e<=8||e>=41?3:1;if(e>=4&&e<=22){if(t>=Math.max(0,12-(e-4))&&t<=13)return e>=21?3:2;let n=Math.min(51,39+(e-4));if(t>=38&&t<=n)return e>=21?3:2}return 0}var x=(e,t,n,r,i,a)=>{let o=n-t+1,s=Math.max(1,Math.floor((o-1)/2)),c=t+s,l=2*s*2;for(let t=r;t<=i;t++){let i=(t-r)%l,o=i{let o=Math.floor((t+n)/2);for(let n=r;n<=i;n++)(n-r)%2==0?e(o,n,a[0]):t!==o&&e(t,n,a[1])},C=[x,S,(e,t,n,r,i,a)=>{let o=Math.floor((t+n)/2);for(let s=r;s<=i;s++)for(let i=t;i<=n;i++){let t=Math.abs((s-r)%6-3)+Math.abs(i-o);t<=1?e(i,s,a[0]):t===2&&e(i,s,a[1])}},(e,t,n,r,i,a)=>{for(let o=t;o<=n;o++){let n=(o-t)%2==0?a[0]:a[1];for(let t=r;t<=i;t++)(t+o)%2==0&&e(o,t,n)}},(e,t,n,r,i,a)=>{let o=Math.floor((t+n)/2);for(let s=r;s<=i;s++)(s-r)%4==0?(e(o,s,a[0]),o-1>=t&&e(o-1,s,a[0]),o+1<=n&&e(o+1,s,a[0]),e(o,Math.min(i,s+1),a[0]),s>r&&e(o,s-1,a[0])):(s-r)%4==2&&(e(t,s,a[1]),n!==t&&e(n,s,a[1]))}];function w(e){return e.paletteId>=0&&e.paletteId{if(e<0||e>=46||t<0||t>=52)return;let r=a[e][t];(r===1||r===2)&&(i[e][t]=n)},s=y(n.body,1.25),c=y(n.body,.72),d=y(n.body,.88);for(let e=0;e<46;e++)for(let t=0;t<52;t++)(a[e][t]===1||a[e][t]===2)&&(i[e][t]=n.body);for(let e=0;e<46;e++)for(let t=0;t<52;t++)a[e][t]===3&&(i[e][t]=e<=8?e%2==0?s:c:t%2==0?s:c);let m=2+Math.round(r*2),g=n.colors.slice(0,m),_=f.filter(e=>r<.35?e.tame:!0),v=new Set,T=(e,n,r,i,a,s)=>{e(o,n,r,i,a,s,t);for(let e of s)v.add(e)},E=(e,t,n,r,s,c,l,u,d)=>{let f=s-r+1,p=d??Math.max(1,Math.round(f/(e.w+2))),m=f/p;for(let s=0;st()-.5),O=D[0],k=D[1%D.length],A=r>.5?D[2%D.length]:O,j=C[Math.floor(t()*C.length)];C[Math.floor(t()*C.length)];let M=r>.4?j:x,N=g[0],P=g[1%g.length],F=g[2%g.length],I=g[3%g.length],L=r>.45?g[Math.floor(t()*g.length)]:null;M(o,9,11,14,37,[P,d],t),E(O,12,19,14,37,N,P,L),T(j,20,22,14,37,[F,I]),E(k,23,30,14,37,P,F,L),T(S,31,32,14,37,[I,N]),E(A,33,40,14,37,F,I,L);for(let[e,n]of[[0,13],[38,51]])x(o,9,11,e,n,[F,d],t),E(p,12,17,e,n,N,P,null,1),S(o,18,20,e,n,[I,d],t);let R=l(t),z=v.size,B=Math.max(4,Math.min(100,Math.round(n.clash*(.55+.45*r)+z*3+(L===null?0:6)+t()*8)));return{config:e,palette:n,name:R,embarrassment:B,label:u(B),cells:i}}function E(e,t){let n=Math.min(2,window.devicePixelRatio||1);e.width=624*n,e.height=552*n;let r=e.getContext(`2d`);r.scale(n,n),r.clearRect(0,0,624,552);let i=t.config.seed>>>0,a=.05+t.config.ugliness/100*.05;for(let e=0;e<46;e++)for(let n=0;n<52;n++){let o=t.cells[e]?.[n]??null;if(o===null)continue;let s=n*m,c=e*m,l=y(o,1+(g(i,n,e)-.5)*2*a);r.fillStyle=l,r.fillRect(s,c,m,m),r.strokeStyle=y(l,.86),r.lineWidth=1.6,r.beginPath(),r.moveTo(s+1,c+2.5),r.lineTo(s+m/2,c+m-2),r.lineTo(s+m-1,c+2.5),r.stroke(),r.strokeStyle=y(l,1.12),r.lineWidth=1,r.beginPath(),r.moveTo(s+1,c+1.5),r.lineTo(s+m/2,c+m-3),r.stroke()}r.strokeStyle=`rgba(0,0,0,0.35)`,r.lineWidth=1;for(let e=0;e<46;e++)for(let n=0;n<52;n++){if(t.cells[e][n]===null)continue;let i=n*m,a=e*m,o=(r,i)=>{let a=e+r,o=n+i;return a<0||a>=46||o<0||o>=52||t.cells[a][o]===null};r.beginPath(),o(-1,0)&&(r.moveTo(i,a),r.lineTo(i+m,a)),o(1,0)&&(r.moveTo(i,a+m),r.lineTo(i+m,a+m)),o(0,-1)&&(r.moveTo(i,a),r.lineTo(i,a+m)),o(0,1)&&(r.moveTo(i+m,a),r.lineTo(i+m,a+m)),r.stroke()}}var D=document.querySelector(`#app`);if(D===null)throw Error(`Missing #app in index.html`);var O=`aos02-ugly-sweater`;function k(){try{let e=localStorage.getItem(O);if(e!==null){let t=JSON.parse(e);if(typeof t.seed==`number`&&typeof t.paletteId==`number`&&typeof t.ugliness==`number`)return{seed:t.seed,paletteId:t.paletteId,ugliness:t.ugliness}}}catch{}return{seed:Math.floor(Math.random()*1e6),paletteId:-1,ugliness:65}}function A(e){localStorage.setItem(O,JSON.stringify(e))}var j=k();D.innerHTML=`

๐Ÿงถ Ugly Sweater Forge

Procedurally knitted crimes against fashion. Every stitch is deterministic โ€” share the seed.

`;var M=document.querySelector(`#sweater`),N=document.querySelector(`#name`),P=document.querySelector(`#meter`),F=document.querySelector(`#score`),I=document.querySelector(`#verdict`),L=document.querySelector(`#palette-line`),R=document.querySelector(`#ugliness`),z=document.querySelector(`#ugl-val`),B=document.querySelector(`#palette`),V=document.querySelector(`#seed`);B.innerHTML=``+i.map((e,t)=>``).join(``);function H(){let e=T(j);E(M,e),N.textContent=`โ€œ${e.name}โ€`,P.style.width=e.embarrassment+`%`,P.style.background=`linear-gradient(90deg, #4caf50, #ffc107 55%, #f44336)`,F.textContent=String(e.embarrassment),I.textContent=e.label,L.textContent=`Yarn: ${e.palette.name}`,z.textContent=j.ugliness>=85?`โ˜ ๏ธ`:String(j.ugliness),A(j)}function U(){R.value=String(j.ugliness),B.value=String(j.paletteId),V.value=String(j.seed)}document.querySelector(`#knit`).addEventListener(`click`,()=>{j.seed=Math.floor(Math.random()*1e6),U(),H()}),R.addEventListener(`input`,()=>{j.ugliness=Number(R.value),H()}),B.addEventListener(`change`,()=>{j.paletteId=Number(B.value),H()}),V.addEventListener(`change`,()=>{let e=Math.floor(Number(V.value));j.seed=Number.isFinite(e)?Math.max(0,Math.min(999999,e)):0,V.value=String(j.seed),H()}),document.querySelector(`#copy-seed`).addEventListener(`click`,e=>{navigator.clipboard.writeText(String(j.seed));let t=e.currentTarget;t.textContent=`โœ“`,setTimeout(()=>t.textContent=`๐Ÿ“‹`,900)}),document.querySelector(`#download`).addEventListener(`click`,()=>{M.toBlob(e=>{if(e===null)return;let t=document.createElement(`a`);t.href=URL.createObjectURL(e),t.download=`ugly-sweater-${j.seed}.png`,t.click(),URL.revokeObjectURL(t.href)},`image/png`)}),U(),H();