0xf1da…0013

All memos sent from and to 0xf1da…0013.

N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}let rng,IS_LIGHT,OUTER_BG,STROKE_SCALE,OPACITY_SCALE,STROKE_MIN_SCALE,STEP_LENGTH,DEPTH_OPACITY_MIN,TEXTURE2_SATURATION,ANGLE_MULTIPLIER,FLOW_SCALE,Z_MIN,REVEAL_WINDOW_MS,REVEAL_PATH_MS,HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash();function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches;function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}function deriveState(e){rng=new Random(e),IS_LIGHT="light"===getTheme(e),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70),ANGLE_MULTIPLIER=getAngleMultiplier(e),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62),REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200}deriveState(HASH);const themeListeners=[];function onThemeChange(e){themeListeners.push(e)}function applyTheme(){themeListeners.forEach(e=>e())}let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),l=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},c=l(n,o),d=l(n+1,o),u=l(n,o+1);return c+a*(d-c)+i*(u-c)+a*i*(c-d-u+l(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),l=Math.floor(t.y/a);e>=0&&e<r&&l>=0&&l<s&&o[l*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),l=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:l})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},l={x:450,y:1400},c=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,l],[l,s],[t,s],[n,a],[o,i],[r,l]];for(const[t,n]of c){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),l=r+rng.decimal(-8,8),c=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*l+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*c+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write||"undefined"==typeof ClipboardItem)return showCopyIndicator("Copy unsupported — saving",!0),console.error("Clipboard write API unavailable (needs HTTPS or localhost)"),void saveScreenshot();document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth=IS_DESKTOP?"160px":"180px",e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.webkitTapHighlightColor="transparent",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding=IS_DESKTOP?"7px 12px":"12px 14px",t.style.borderRadius="4px",t.style.cursor="pointer";const r=()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"},s=()=>{t.style.background="transparent"};t.addEventListener("mouseenter",r),t.addEventListener("mouseleave",s),t.addEventListener("touchstart",r,{passive:!0}),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)")}),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t,n){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const o=contextMenu.getBoundingClientRect(),r=window.innerWidth-o.width-4,s=window.innerHeight-o.height-4;let a=e,i=t;n&&(a=e-o.width/2,i=t-o.height-16,i<4&&(i=t+16)),contextMenu.style.left=`${Math.max(0,Math.min(a,r))}px`,contextMenu.style.top=`${Math.max(0,Math.min(i,s))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())});const LONG_PRESS_MS=450,LONG_PRESS_SLOP_PX=10;let longPressTimer=null,longPressOrigin=null,lastTouchMenuAt=0,swallowNextClick=!1,swallowResetTimer=null;function cancelLongPress(){clearTimeout(longPressTimer),longPressTimer=null,longPressOrigin=null}document.body.style.webkitTouchCallout="none",document.body.style.webkitUserSelect="none",document.body.style.userSelect="none",document.addEventListener("touchstart",e=>{if(swallowNextClick=!1,1!==e.touches.length||contextMenu.contains(e.target))return void cancelLongPress();const t=e.touches[0];longPressOrigin={x:t.clientX,y:t.clientY},longPressTimer=setTimeout(()=>{longPressTimer=null,lastTouchMenuAt=Date.now(),swallowNextClick=!0,clearTimeout(swallowResetTimer),swallowResetTimer=setTimeout(()=>{swallowNextClick=!1},700),showContextMenu(longPressOrigin.x,longPressOrigin.y,!0)},450)},{passive:!0}),document.addEventListener("touchmove",e=>{if(!longPressTimer||!longPressOrigin)return;const t=e.touches[0];(Math.abs(t.clientX-longPressOrigin.x)>10||Math.abs(t.clientY-longPressOrigin.y)>10)&&cancelLongPress()},{passive:!0}),document.addEventListener("touchend",cancelLongPress,{passive:!0}),document.addEventListener("touchcancel",cancelLongPress,{passive:!0}),document.addEventListener("click",e=>{swallowNextClick&&(swallowNextClick=!1,clearTimeout(swallowResetTimer),e.stopPropagation(),e.preventDefault())},!0),document.addEventListener("contextmenu",e=>{e.preventDefault(),Date.now()-lastTouchMenuAt<1e3||showContextMenu(e.clientX,e.clientY,!1)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#000":"#fff"}),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;if("data:"===location.protocol){HASH=t,deriveState(HASH),regenerate(),armRefreshIndicator(),applyTheme();const e=document.getElementById("seed-input");return void(e&&(e.value=HASH))}const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,l=readUintAt(t,o),c=[];for(let e=0;e<l;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);c.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,c.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:c[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){let e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)";const o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.id="seed-input",i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none",i.style.userSelect="text",i.style.webkitUserSelect="text";const l=document.createElement("button");l.textContent="View",s(l);const c=document.createElement("button");c.textContent="Copy seed",s(c);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),l.addEventListener("click",()=>loadSeed(i.value)),c.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,h=null;const f=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.title=`Saved by ${t.saver}\nSeed: ${t.seed}`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{h&&(h.remove(),h=null)},g=()=>{m(),h=document.createElement("div"),h.textContent="Load more…",h.style.padding="4px 6px",h.style.marginTop="2px",h.style.borderRadius="4px",h.style.cursor="pointer",h.style.color=e,h.style.opacity="0.7",h.style.textAlign="center",h.addEventListener("mouseenter",()=>{h.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),h.addEventListener("mouseleave",()=>{h.style.background="transparent"}),h.addEventListener("click",()=>S(!1)),u.appendChild(h)};async function S(e){try{if(e){if(u.textContent="",h=null,Array.isArray(window.__EMBEDDED_SAVED_SEEDS__)&&"number"==typeof window.__EMBEDDED_SAVED_SEEDS_TOTAL__){const e=window.__EMBEDDED_SAVED_SEEDS_TOTAL__;if(0===e)return void p("No saved seeds yet",!1);const t=window.__EMBEDDED_SAVED_SEEDS__;y=e-t.length;for(const e of t.slice().reverse())u.appendChild(f(e));return void(y>0&&g())}const e=await fetchSavedSeedsTotal();if(0===e)return void p("No saved seeds yet",!1);y=e}else h&&(h.textContent="Loading…");const t=y>25?y-25:0,n=y-t,o=await fetchSavedSeedsPage(t,n);y=t,m();for(const e of o.slice().reverse())u.appendChild(f(e));y>0&&g()}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void x();u.style.display="flex",b(),p("Loading…",!1),S(!0)});const E=document.createElement("div");E.textContent="Double click for new seed",E.style.marginBottom="6px",E.style.opacity="0.6",E.style.pointerEvents="none",E.style.fontFamily="system-ui, sans-serif",E.style.fontSize="11px",E.style.letterSpacing="0.02em",E.style.color=e;const b=()=>{o.style.opacity="1"},x=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",b),document.addEventListener("mouseleave",x),i.addEventListener("focus",b),i.addEventListener("blur",x),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",x())}),a.appendChild(i),a.appendChild(l),a.appendChild(c),a.appendChild(d),o.appendChild(u),o.appendChild(E),o.appendChild(a),document.body.appendChild(o),onThemeChange(()=>{e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",s(l),s(c),s(d),i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,E.style.color=e,Array.from(u.children).forEach(t=>{t.style.color=e})}),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}let rng,IS_LIGHT,OUTER_BG,STROKE_SCALE,OPACITY_SCALE,STROKE_MIN_SCALE,STEP_LENGTH,DEPTH_OPACITY_MIN,TEXTURE2_SATURATION,ANGLE_MULTIPLIER,FLOW_SCALE,Z_MIN,REVEAL_WINDOW_MS,REVEAL_PATH_MS,HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash();function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches;function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}function deriveState(e){rng=new Random(e),IS_LIGHT="light"===getTheme(e),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70),ANGLE_MULTIPLIER=getAngleMultiplier(e),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62),REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200}deriveState(HASH);const themeListeners=[];function onThemeChange(e){themeListeners.push(e)}function applyTheme(){themeListeners.forEach(e=>e())}let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),l=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},c=l(n,o),d=l(n+1,o),u=l(n,o+1);return c+a*(d-c)+i*(u-c)+a*i*(c-d-u+l(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),l=Math.floor(t.y/a);e>=0&&e<r&&l>=0&&l<s&&o[l*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),l=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:l})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},l={x:450,y:1400},c=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,l],[l,s],[t,s],[n,a],[o,i],[r,l]];for(const[t,n]of c){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),l=r+rng.decimal(-8,8),c=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*l+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*c+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)")}),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#000":"#fff"}),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;if("data:"===location.protocol){HASH=t,deriveState(HASH),regenerate(),armRefreshIndicator(),applyTheme();const e=document.getElementById("seed-input");return void(e&&(e.value=HASH))}const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,l=readUintAt(t,o),c=[];for(let e=0;e<l;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);c.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,c.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:c[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){let e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)";const o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.id="seed-input",i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const l=document.createElement("button");l.textContent="View",s(l);const c=document.createElement("button");c.textContent="Copy seed",s(c);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),l.addEventListener("click",()=>loadSeed(i.value)),c.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.title=`Saved by ${t.saver}\nSeed: ${t.seed}`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)},S=()=>{m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>g(!1)),u.appendChild(f)};async function g(e){try{if(e){if(u.textContent="",f=null,Array.isArray(window.__EMBEDDED_SAVED_SEEDS__)&&"number"==typeof window.__EMBEDDED_SAVED_SEEDS_TOTAL__){const e=window.__EMBEDDED_SAVED_SEEDS_TOTAL__;if(0===e)return void p("No saved seeds yet",!1);const t=window.__EMBEDDED_SAVED_SEEDS__;y=e-t.length;for(const e of t.slice().reverse())u.appendChild(h(e));return void(y>0&&S())}const e=await fetchSavedSeedsTotal();if(0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const t=y>25?y-25:0,n=y-t,o=await fetchSavedSeedsPage(t,n);y=t,m();for(const e of o.slice().reverse())u.appendChild(h(e));y>0&&S()}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void x();u.style.display="flex",b(),p("Loading…",!1),g(!0)});const E=document.createElement("div");E.textContent="Double click for new seed",E.style.marginBottom="6px",E.style.opacity="0.6",E.style.pointerEvents="none",E.style.fontFamily="system-ui, sans-serif",E.style.fontSize="11px",E.style.letterSpacing="0.02em",E.style.color=e;const b=()=>{o.style.opacity="1"},x=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",b),document.addEventListener("mouseleave",x),i.addEventListener("focus",b),i.addEventListener("blur",x),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",x())}),a.appendChild(i),a.appendChild(l),a.appendChild(c),a.appendChild(d),o.appendChild(u),o.appendChild(E),o.appendChild(a),document.body.appendChild(o),onThemeChange(()=>{e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",s(l),s(c),s(d),i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,E.style.color=e,Array.from(u.children).forEach(t=>{t.style.color=e})}),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
0xf1da6e2d…0013·#25,634,275·0xf64aebdc…d7a1b2
<!DOCTYPE html><html lang="en"><_Q` ahead><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"><title>ANGEL</title><style>*{margin:0;padding:0;box-sizing:border-box}html,body{width:100%;height:100%;overflow:hidden;background:#000}body{display:flex;justify-content:center;align-items:center}svg{display:block;max-width:100%;max-height:100%}</style></head><body><script>const VESSEL;function hashFromSeed(seed){let_Q` a out="";for(let i=0;i<64;i++){const v=(Math.imul((seed+i+1)>>>0,2654435761)^(seed<<((i%5)+1))^(i*131))>>>0;out+=(v&15).toString(16)}return"0x"+out.slice(0,64)}window.__ANGEL_HASH__=hashFromSeed(Number(VESSEL_SEED)||1);</scri</script></body></html>window.__EMBEDDED_SAVED_SEEDS_TO;window.__EMBEDDED_SAVED_SEEDS__window.__EMBEDDED_SAVED_SEEDS_TO` TAL__=0;window.__EMBEDDED_SAVED_`@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef`ghijklmnopqrstuvwxyz0123456789+/`?R`
0xf1da6e2d…0013·#25,634,273·0x25adef26…914d87
<!DOCTYPE html><html lang="en"><_Q` ahead><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"><title>ANGEL</title><style>*{margin:0;padding:0;box-sizing:border-box}html,body{width:100%;height:100%;overflow:hidden;background:#000}body{display:flex;justify-content:center;align-items:center}svg{display:block;max-width:100%;max-height:100%}</style></head><body><script>const VESSEL;function hashFromSeed(seed){let_Q` a out="";for(let i=0;i<64;i++){const v=(Math.imul((seed+i+1)>>>0,2654435761)^(seed<<((i%5)+1))^(i*131))>>>0;out+=(v&15).toString(16)}return"0x"+out.slice(0,64)}window.__ANGEL_HASH__=hashFromSeed(Number(VESSEL_SEED)||1);</scri</script></body></html>window.__EMBEDDED_SAVED_SEEDS_TO;window.__EMBEDDED_SAVED_SEEDS__window.__EMBEDDED_SAVED_SEEDS_TO` TAL__=0;window.__EMBEDDED_SAVED_`@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef`ghijklmnopqrstuvwxyz0123456789+/`?R`
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}let rng,IS_LIGHT,OUTER_BG,STROKE_SCALE,OPACITY_SCALE,STROKE_MIN_SCALE,STEP_LENGTH,DEPTH_OPACITY_MIN,TEXTURE2_SATURATION,ANGLE_MULTIPLIER,FLOW_SCALE,Z_MIN,REVEAL_WINDOW_MS,REVEAL_PATH_MS,HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash();function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches;function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}function deriveState(e){rng=new Random(e),IS_LIGHT="light"===getTheme(e),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70),ANGLE_MULTIPLIER=getAngleMultiplier(e),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62),REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200}deriveState(HASH);const themeListeners=[];function onThemeChange(e){themeListeners.push(e)}function applyTheme(){themeListeners.forEach(e=>e())}let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),l=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},c=l(n,o),d=l(n+1,o),u=l(n,o+1);return c+a*(d-c)+i*(u-c)+a*i*(c-d-u+l(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),l=Math.floor(t.y/a);e>=0&&e<r&&l>=0&&l<s&&o[l*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),l=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:l})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},l={x:450,y:1400},c=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,l],[l,s],[t,s],[n,a],[o,i],[r,l]];for(const[t,n]of c){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),l=r+rng.decimal(-8,8),c=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*l+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*c+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)")}),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#000":"#fff"}),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;if("data:"===location.protocol){HASH=t,deriveState(HASH),regenerate(),armRefreshIndicator(),applyTheme();const e=document.getElementById("seed-input");return void(e&&(e.value=HASH))}const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,l=readUintAt(t,o),c=[];for(let e=0;e<l;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);c.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,c.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:c[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){let e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)";const o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.id="seed-input",i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const l=document.createElement("button");l.textContent="View",s(l);const c=document.createElement("button");c.textContent="Copy seed",s(c);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),l.addEventListener("click",()=>loadSeed(i.value)),c.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)},S=()=>{m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>g(!1)),u.appendChild(f)};async function g(e){try{if(e){if(u.textContent="",f=null,Array.isArray(window.__EMBEDDED_SAVED_SEEDS__)&&"number"==typeof window.__EMBEDDED_SAVED_SEEDS_TOTAL__){const e=window.__EMBEDDED_SAVED_SEEDS_TOTAL__;if(0===e)return void p("No saved seeds yet",!1);const t=window.__EMBEDDED_SAVED_SEEDS__;y=e-t.length;for(const e of t.slice().reverse())u.appendChild(h(e));return void(y>0&&S())}const e=await fetchSavedSeedsTotal();if(0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const t=y>25?y-25:0,n=y-t,o=await fetchSavedSeedsPage(t,n);y=t,m();for(const e of o.slice().reverse())u.appendChild(h(e));y>0&&S()}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void x();u.style.display="flex",b(),p("Loading…",!1),g(!0)});const E=document.createElement("div");E.textContent="Double click for new seed",E.style.marginBottom="6px",E.style.opacity="0.6",E.style.pointerEvents="none",E.style.fontFamily="system-ui, sans-serif",E.style.fontSize="11px",E.style.letterSpacing="0.02em",E.style.color=e;const b=()=>{o.style.opacity="1"},x=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",b),document.addEventListener("mouseleave",x),i.addEventListener("focus",b),i.addEventListener("blur",x),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",x())}),a.appendChild(i),a.appendChild(l),a.appendChild(c),a.appendChild(d),o.appendChild(u),o.appendChild(E),o.appendChild(a),document.body.appendChild(o),onThemeChange(()=>{e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",s(l),s(c),s(d),i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,E.style.color=e,Array.from(u.children).forEach(t=>{t.style.color=e})}),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}let rng,IS_LIGHT,OUTER_BG,STROKE_SCALE,OPACITY_SCALE,STROKE_MIN_SCALE,STEP_LENGTH,DEPTH_OPACITY_MIN,TEXTURE2_SATURATION,ANGLE_MULTIPLIER,FLOW_SCALE,Z_MIN,REVEAL_WINDOW_MS,REVEAL_PATH_MS,HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash();function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches;function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}function deriveState(e){rng=new Random(e),IS_LIGHT="light"===getTheme(e),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70),ANGLE_MULTIPLIER=getAngleMultiplier(e),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62),REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200}deriveState(HASH);const themeListeners=[];function onThemeChange(e){themeListeners.push(e)}function applyTheme(){themeListeners.forEach(e=>e())}let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),l=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},c=l(n,o),d=l(n+1,o),u=l(n,o+1);return c+a*(d-c)+i*(u-c)+a*i*(c-d-u+l(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),l=Math.floor(t.y/a);e>=0&&e<r&&l>=0&&l<s&&o[l*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),l=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:l})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},l={x:450,y:1400},c=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,l],[l,s],[t,s],[n,a],[o,i],[r,l]];for(const[t,n]of c){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),l=r+rng.decimal(-8,8),c=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*l+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*c+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)")}),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),onThemeChange(()=>{e.style.background=IS_LIGHT?"#000":"#fff"}),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;if("data:"===location.protocol){HASH=t,deriveState(HASH),regenerate(),armRefreshIndicator(),applyTheme();const e=document.getElementById("seed-input");return void(e&&(e.value=HASH))}const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,l=readUintAt(t,o),c=[];for(let e=0;e<l;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);c.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,c.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:c[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){let e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)";const o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.id="seed-input",i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const l=document.createElement("button");l.textContent="View",s(l);const c=document.createElement("button");c.textContent="Copy seed",s(c);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),l.addEventListener("click",()=>loadSeed(i.value)),c.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)};async function S(t){try{if(t){const e=await fetchSavedSeedsTotal();if(u.textContent="",f=null,0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const n=y>25?y-25:0,o=y-n,r=await fetchSavedSeedsPage(n,o);y=n,m();for(const e of r.slice().reverse())u.appendChild(h(e));y>0&&(m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>S(!1)),u.appendChild(f))}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void x();u.style.display="flex",b(),p("Loading…",!1),S(!0)});const g=document.createElement("div");g.textContent="Double click for new seed",g.style.marginBottom="6px",g.style.opacity="0.6",g.style.pointerEvents="none",g.style.fontFamily="system-ui, sans-serif",g.style.fontSize="11px",g.style.letterSpacing="0.02em",g.style.color=e;const b=()=>{o.style.opacity="1"},x=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",b),document.addEventListener("mouseleave",x),i.addEventListener("focus",b),i.addEventListener("blur",x),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",x())}),a.appendChild(i),a.appendChild(l),a.appendChild(c),a.appendChild(d),o.appendChild(u),o.appendChild(g),o.appendChild(a),document.body.appendChild(o),onThemeChange(()=>{e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",s(l),s(c),s(d),i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,g.style.color=e,Array.from(u.children).forEach(t=>{t.style.color=e})}),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}let rng,IS_LIGHT,OUTER_BG,STROKE_SCALE,OPACITY_SCALE,STROKE_MIN_SCALE,STEP_LENGTH,DEPTH_OPACITY_MIN,TEXTURE2_SATURATION,ANGLE_MULTIPLIER,FLOW_SCALE,Z_MIN,REVEAL_WINDOW_MS,REVEAL_PATH_MS,HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash();function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches;function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}function deriveState(e){rng=new Random(e),IS_LIGHT="light"===getTheme(e),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70),ANGLE_MULTIPLIER=getAngleMultiplier(e),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62),REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200}deriveState(HASH);let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),c=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},l=c(n,o),d=c(n+1,o),u=c(n,o+1);return l+a*(d-l)+i*(u-l)+a*i*(l-d-u+c(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),c=Math.floor(t.y/a);e>=0&&e<r&&c>=0&&c<s&&o[c*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),c=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:c})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},c={x:450,y:1400},l=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,c],[c,s],[t,s],[n,a],[o,i],[r,c]];for(const[t,n]of l){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),c=r+rng.decimal(-8,8),l=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*c+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*l+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;if("data:"===location.protocol){HASH=t,deriveState(HASH),regenerate(),armRefreshIndicator();const e=document.getElementById("seed-input");return void(e&&(e.value=HASH))}const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,c=readUintAt(t,o),l=[];for(let e=0;e<c;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);l.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,l.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:l[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){const e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.id="seed-input",i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const c=document.createElement("button");c.textContent="View",s(c);const l=document.createElement("button");l.textContent="Copy seed",s(l);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),c.addEventListener("click",()=>loadSeed(i.value)),l.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)};async function S(t){try{if(t){const e=await fetchSavedSeedsTotal();if(u.textContent="",f=null,0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const n=y>25?y-25:0,o=y-n,r=await fetchSavedSeedsPage(n,o);y=n,m();for(const e of r.slice().reverse())u.appendChild(h(e));y>0&&(m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>S(!1)),u.appendChild(f))}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void E();u.style.display="flex",x(),p("Loading…",!1),S(!0)});const g=document.createElement("div");g.textContent="Double click for new seed",g.style.marginBottom="6px",g.style.opacity="0.6",g.style.pointerEvents="none",g.style.fontFamily="system-ui, sans-serif",g.style.fontSize="11px",g.style.letterSpacing="0.02em",g.style.color=e;const x=()=>{o.style.opacity="1"},E=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",x),document.addEventListener("mouseleave",E),i.addEventListener("focus",x),i.addEventListener("blur",E),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",E())}),a.appendChild(i),a.appendChild(c),a.appendChild(l),a.appendChild(d),o.appendChild(u),o.appendChild(g),o.appendChild(a),document.body.appendChild(o),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}const HASH=getSeedOverride()||window.__ANGEL_HASH__||generateHash(),rng=new Random(HASH);function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches,IS_LIGHT="light"===getTheme(HASH),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70);function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}const ANGLE_MULTIPLIER=getAngleMultiplier(HASH),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62);let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),c=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},l=c(n,o),d=c(n+1,o),u=c(n,o+1);return l+a*(d-l)+i*(u-l)+a*i*(l-d-u+c(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),c=Math.floor(t.y/a);e>=0&&e<r&&c>=0&&c<s&&o[c*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),c=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:c})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},c={x:450,y:1400},l=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,c],[c,s],[t,s],[n,a],[o,i],[r,c]];for(const[t,n]of l){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),c=r+rng.decimal(-8,8),l=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*c+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*l+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200,REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{if("data:"===location.protocol)return regenerate(),void armRefreshIndicator();loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,c=readUintAt(t,o),l=[];for(let e=0;e<c;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);l.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,l.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:l[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){const e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const c=document.createElement("button");c.textContent="View",s(c);const l=document.createElement("button");l.textContent="Copy seed",s(l);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),c.addEventListener("click",()=>loadSeed(i.value)),l.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)};async function g(t){try{if(t){const e=await fetchSavedSeedsTotal();if(u.textContent="",f=null,0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const n=y>25?y-25:0,o=y-n,r=await fetchSavedSeedsPage(n,o);y=n,m();for(const e of r.slice().reverse())u.appendChild(h(e));y>0&&(m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>g(!1)),u.appendChild(f))}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void b();u.style.display="flex",x(),p("Loading…",!1),g(!0)});const S=document.createElement("div");S.textContent="Double click for new seed",S.style.marginBottom="6px",S.style.opacity="0.6",S.style.pointerEvents="none",S.style.fontFamily="system-ui, sans-serif",S.style.fontSize="11px",S.style.letterSpacing="0.02em",S.style.color=e;const x=()=>{o.style.opacity="1"},b=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",x),document.addEventListener("mouseleave",b),i.addEventListener("focus",x),i.addEventListener("blur",b),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",b())}),a.appendChild(i),a.appendChild(c),a.appendChild(l),a.appendChild(d),o.appendChild(u),o.appendChild(S),o.appendChild(a),document.body.appendChild(o),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
N const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}const HASH=getSeedOverride()||window.__MUGEN_HASH__||generateHash(),rng=new Random(HASH);function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches,IS_LIGHT="light"===getTheme(HASH),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70);function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}const ANGLE_MULTIPLIER=getAngleMultiplier(HASH),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62);let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),c=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},l=c(n,o),d=c(n+1,o),u=c(n,o+1);return l+a*(d-l)+i*(u-l)+a*i*(l-d-u+c(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),c=Math.floor(t.y/a);e>=0&&e<r&&c>=0&&c<s&&o[c*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),c=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:c})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},c={x:450,y:1400},l=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,c],[c,s],[t,s],[n,a],[o,i],[r,c]];for(const[t,n]of l){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),c=r+rng.decimal(-8,8),l=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*c+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*l+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200,REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb",PUBLIC_RPC_URL="https://ethereum-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,c=readUintAt(t,o),l=[];for(let e=0;e<c;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);l.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,l.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:l[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){const e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const c=document.createElement("button");c.textContent="View",s(c);const l=document.createElement("button");l.textContent="Copy seed",s(l);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),c.addEventListener("click",()=>loadSeed(i.value)),l.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)};async function g(t){try{if(t){const e=await fetchSavedSeedsTotal();if(u.textContent="",f=null,0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const n=y>25?y-25:0,o=y-n,r=await fetchSavedSeedsPage(n,o);y=n,m();for(const e of r.slice().reverse())u.appendChild(h(e));y>0&&(m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>g(!1)),u.appendChild(f))}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void b();u.style.display="flex",x(),p("Loading…",!1),g(!0)});const S=document.createElement("div");S.textContent="Double click for new seed",S.style.marginBottom="6px",S.style.opacity="0.6",S.style.pointerEvents="none",S.style.fontFamily="system-ui, sans-serif",S.style.fontSize="11px",S.style.letterSpacing="0.02em",S.style.color=e;const x=()=>{o.style.opacity="1"},b=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",x),document.addEventListener("mouseleave",b),i.addEventListener("focus",x),i.addEventListener("blur",b),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",b())}),a.appendChild(i),a.appendChild(c),a.appendChild(l),a.appendChild(d),o.appendChild(u),o.appendChild(S),o.appendChild(a),document.body.appendChild(o),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
Angels**She** Created with Javascript, SVG, and Solidity, 2026. Reseeds on-chain every 60 seconds. Double click to explore. 'S' to save a png. The preview image will rotate between a curated set of 3 images. You can save your favourite seeds for others to enjoy on chain via the external url (Desktop only). Contract: https://etherscan.io/address/0x1b64cf0d027f22d3ad76de00ea2fdc0ae7e53e8e Save a seed directly on Etherscan: https://etherscan.io/address/0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb#writeContract Thank you to Stephen and Dav <3JavascriptFully On-Chain
AngelsShe \n Created with Javascript, SVG, and Solidity, 2026. Reseeds on-chain every 60 seconds. \nDouble click to explore. 'S' to save a png. The preview image will rotate between a curated set of 3 images. You can save your favourite seeds for others to enjoy on chain via the external url (Desktop only).\nContract: https://etherscan.io/address/0x1b64cf0d027f22d3ad76de00ea2fdc0ae7e53e8e\nSave a seed directly on Etherscan: https://etherscan.io/address/0xff91edfbd3ec3867dd9a68b8bbfde09f002daceb#writeContract\nThank you to Stephen and Dav <3JavascriptFully On-Chain
AngelsShe \nCreated with Javascript, SVG, and Solidity, 2026. Reseeds on-chain every 60 seconds. \nDouble click to explore. 'S' to save a png. The preview image will rotate between a curated set of 3 images. Anyone can save their favourite seeds for others to enjoy on chain via the external url (Desktop only). \nThanks to Stephen and Dav <3JavascriptFully On-Chain
AngelsShe \n Created with Javascript, SVG, and Solidity, 2026. Reseeds on-chain every 60 seconds. \nDouble click to explore. 'S' to save a png. The preview image will rotate between a curated set of 3 images. Anyone can save their favourite seeds for others to enjoy on chain via the external url (Desktop only).\nThanks to Stephen and Dav <3JavascriptFully On-Chain
AngelsShe \n Created with Javascript, SVG, and Solidity, 2026. Reseeds on-chain every 60 seconds. \nDouble click to explore. 'S' to save a png. The preview image will rotate between a curated set of 3 images. You can save your favourite seeds for others to enjoy on chain via the external url (Desktop only).\nThank you to Stephen and Dav <3JavascriptFully On-Chain
0xf1da6e2d…0013·#25,628,396·0x3f3c63ad…0907d9
<!DOCTYPE html><html lang="en"><_Q` ahead><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"><title>ANGEL</title><style>*{margin:0;padding:0;box-sizing:border-box}html,body{width:100%;height:100%;overflow:hidden;background:#000}body{display:flex;justify-content:center;align-items:center}svg{display:block;max-width:100%;max-height:100%}</style></head><body><script>const VESSEL;function hashFromSeed(seed){let_Q` a out="";for(let i=0;i<64;i++){const v=(Math.imul((seed+i+1)>>>0,2654435761)^(seed<<((i%5)+1))^(i*131))>>>0;out+=(v&15).toString(16)}return"0x"+out.slice(0,64)}window.__ANGEL_HASH__=hashFromSeed(Number(VESSEL_SEED)||1);</scri</script></body></html>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef`ghijklmnopqrstuvwxyz0123456789+/`?R`
0xf1da6e2d…0013·#25,628,394·0xf0c16e12…d884bf
She \n Created with Javascript, _Q` a&SVG, and Solidity, 2026.\nDouble click to explore. 'S' to save a png. You can save your favourite seeds for others to enjoy (Desktop only). Reseeds on-chain evehttps://andrewmitchell-art.xyz/e_Q` a%_RUnthereum/vessel/`o","attributes":[`data:application/json;base64,{"trait_type": "Artist", "value"{"trait_type": "Storage", "value`G{"trait_type": "Sequence", "valu{"trait_type": "Medium", "value"{"trait_type": "Step Length", "v{"trait_type": "Mode", "value": `WABCDEFGHIJKLMNOPQRSTUVWXYZabcdef`ghijklmnopqrstuvwxyz0123456789+/`?R`
t.createElement("button");c.textContent="View",s(c);const l=document.createElement("button");l.textContent="Copy seed",s(l);const d=document.createElement("button");d.textContent="Saved ▾",s(d);const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.bottom="100%",u.style.marginBottom="6px",u.style.display="none",u.style.flexDirection="column",u.style.gap="2px",u.style.maxHeight="180px",u.style.overflowY="auto",u.style.minWidth="220px",u.style.padding="6px",u.style.borderRadius="6px",u.style.background=IS_LIGHT?"#fff":"#1a1a1a",u.style.border=`1px solid ${n}`,u.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",u.style.fontFamily="ui-monospace, monospace",u.style.fontSize="10.5px";const p=(t,n)=>{u.textContent="";const o=document.createElement("div");o.textContent=t,o.style.padding="4px 6px",o.style.color=n?"#f66":e,n||(o.style.opacity="0.6"),u.appendChild(o)};i.addEventListener("keydown",e=>{"Enter"===e.key&&(e.preventDefault(),loadSeed(i.value))}),c.addEventListener("click",()=>loadSeed(i.value)),l.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(HASH),showCopyIndicator("Seed copied",!1)}catch(e){showCopyIndicator("Copy failed",!0),console.error("Failed to copy seed",e)}});let y=0,f=null;const h=t=>{const n=document.createElement("div");return n.textContent=`${t.saver.slice(0,6)}…${t.saver.slice(-4)} ${t.seed.slice(0,12)}…`,n.style.padding="4px 6px",n.style.borderRadius="4px",n.style.cursor="pointer",n.style.color=e,n.style.whiteSpace="nowrap",n.addEventListener("mouseenter",()=>{n.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),n.addEventListener("mouseleave",()=>{n.style.background="transparent"}),n.addEventListener("click",()=>loadSeed(t.seed)),n},m=()=>{f&&(f.remove(),f=null)};async function g(t){try{if(t){const e=await fetchSavedSeedsTotal();if(u.textContent="",f=null,0===e)return void p("No saved seeds yet",!1);y=e}else f&&(f.textContent="Loading…");const n=y>25?y-25:0,o=y-n,r=await fetchSavedSeedsPage(n,o);y=n,m();for(const e of r.slice().reverse())u.appendChild(h(e));y>0&&(m(),f=document.createElement("div"),f.textContent="Load more…",f.style.padding="4px 6px",f.style.marginTop="2px",f.style.borderRadius="4px",f.style.cursor="pointer",f.style.color=e,f.style.opacity="0.7",f.style.textAlign="center",f.addEventListener("mouseenter",()=>{f.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),f.addEventListener("mouseleave",()=>{f.style.background="transparent"}),f.addEventListener("click",()=>g(!1)),u.appendChild(f))}catch(e){p("Failed to load",!0),console.error("Failed to fetch saved seeds",e)}}d.addEventListener("click",()=>{if(!("none"===u.style.display))return u.style.display="none",void b();u.style.display="flex",x(),p("Loading…",!1),g(!0)});const S=document.createElement("div");S.textContent="Double click for new seed",S.style.marginBottom="6px",S.style.opacity="0.6",S.style.pointerEvents="none",S.style.fontFamily="system-ui, sans-serif",S.style.fontSize="11px",S.style.letterSpacing="0.02em",S.style.color=e;const x=()=>{o.style.opacity="1"},b=()=>{document.activeElement!==i&&"none"===u.style.display&&(o.style.opacity="0")};document.addEventListener("mousemove",x),document.addEventListener("mouseleave",b),i.addEventListener("focus",x),i.addEventListener("blur",b),document.addEventListener("click",e=>{"none"===u.style.display||o.contains(e.target)||(u.style.display="none",b())}),a.appendChild(i),a.appendChild(c),a.appendChild(l),a.appendChild(d),o.appendChild(u),o.appendChild(S),o.appendChild(a),document.body.appendChild(o),"function"==typeof window.__seedControlsExtend&&window.__seedControlsExtend({row1:a,savedToggleBtn:d,buttonStyle:s,input:i})}IS_DESKTOP&&createSeedControls(),init();
const SVG_NS="http://www.w3.org/2000/svg",WIDTH=1500,HEIGHT=2e3;class Random{constructor(e){this.seed=this.hashToSeed(e)}hashToSeed(e){const t=e.startsWith("0x")?e.slice(2):e;let n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e),n>>>=0;return n}next(){this.seed+=1831565813;let e=this.seed;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}decimal(e=0,t=1){return e+this.next()*(t-e)}int(e,t){return Math.floor(this.decimal(e,t+1))}bool(e=.5){return this.next()<e}}function generateHash(){const e=new Uint8Array(32);return crypto.getRandomValues(e),"0x"+Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function getSeedOverride(){if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("seed");if(e)return e}return null}const HASH=getSeedOverride()||window.__MUGEN_HASH__||generateHash(),rng=new Random(HASH);function getTheme(e){let t=window.__MUGEN_THEME__;if("undefined"!=typeof location&&location.search){const e=new URLSearchParams(location.search).get("theme");e&&(t=e)}if("light"===t||"dark"===t)return t;const n=e.startsWith("0x")?e.slice(2):e;return parseInt(n.slice(2,4),16)<77?"light":"dark"}function getFlatMode(){return!!window.__ANGEL_FLAT__||!("undefined"==typeof location||!location.search)&&"1"===new URLSearchParams(location.search).get("flat")}const IS_FLAT=getFlatMode(),IS_DESKTOP="function"==typeof window.matchMedia&&window.matchMedia("(hover: hover) and (pointer: fine)").matches,IS_LIGHT="light"===getTheme(HASH),OUTER_BG=IS_LIGHT?"#fff":"#000",STROKE_SCALE=IS_LIGHT?rng.bool(.5)?1.2:1.5:rng.bool(.5)?1:1.3,OPACITY_SCALE=IS_LIGHT?1.5:1,STROKE_MIN_SCALE=rng.decimal(.1,.8),STEP_LENGTH=rng.bool(.5)?20:30,DEPTH_OPACITY_MIN=rng.bool(.5)?.3:.4,TEXTURE2_SATURATION=rng.decimal(10,70);function getAngleMultiplier(e){const t=e.startsWith("0x")?e.slice(2):e;return[2,3,4,5][parseInt(t.slice(0,2),16)%4]}const ANGLE_MULTIPLIER=getAngleMultiplier(HASH),FLOW_SCALE=(()=>{const e=.001,t=rng.next(),n=.535;return e+.004*(t<n?Math.sqrt(t*n):1-Math.sqrt((1-t)*(1-n)))})(),Z_MIN=rng.decimal(.01,.62);let noiseSeed=0;function noise(e,t){const n=Math.floor(e),o=Math.floor(t),r=e-n,s=t-o,a=r*r*(3-2*r),i=s*s*(3-2*s),c=(e,t)=>{const n=43758.5453*Math.sin(127.1*e+311.7*t+noiseSeed);return n-Math.floor(n)},l=c(n,o),d=c(n+1,o),u=c(n,o+1);return l+a*(d-l)+i*(u-l)+a*i*(l-d-u+c(n+1,o+1))}let angleOffset=0;function getAngle(e,t){return noise(e*FLOW_SCALE,t*FLOW_SCALE)*Math.PI*ANGLE_MULTIPLIER+angleOffset}const VANISHING_POINT={x:750,y:1e3},Z_MAX=.98;function applyPerspective(e,t){return e.map(e=>{const n=e.x-VANISHING_POINT.x,o=e.y-VANISHING_POINT.y;return{x:VANISHING_POINT.x+n*t,y:VANISHING_POINT.y+o*t}})}function createPath(e,t,n){const o=document.createElementNS(SVG_NS,"path");let r=`M ${e[0].x} ${e[0].y}`;for(let t=1;t<e.length;t++)r+=` L ${e[t].x} ${e[t].y}`;return o.setAttribute("d",r),o.setAttribute("fill","none"),o.setAttribute("stroke",`rgba(255,255,255,${n})`),o.setAttribute("stroke-width",t),o.setAttribute("stroke-linecap","round"),o}function flowLine(e,t,n,o=3,r=[]){const s=[];let a=e,i=t;for(let e=0;e<n;e++){s.push({x:a,y:i});let t=getAngle(a,i);if(t+=rng.decimal(-.65,.65),a+=Math.cos(t)*STEP_LENGTH,i+=Math.sin(t)*STEP_LENGTH,a<0||a>1500||i<0||i>2e3)break;if(o>0&&e>5&&rng.bool(.03)){const e=t+rng.decimal(-.5,.5),s=Math.floor(n*rng.decimal(.4,.7));flowLine(a+Math.cos(e)*STEP_LENGTH,i+Math.sin(e)*STEP_LENGTH,s,o-1,r)}}return s.length>1&&r.push(s),r}function createSVG(){const e=document.createElementNS(SVG_NS,"svg");return e.setAttribute("width","100%"),e.setAttribute("height","100%"),e.setAttribute("viewBox","0 0 1500 2000"),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.style.background=OUTER_BG,e}function buildDensityMap(e,t=100){const n=Math.ceil(1500/t),o=Math.ceil(2e3/t),r=Array(n*o).fill(0);for(const s of e)for(const e of s){const s=Math.floor(e.x/t),a=Math.floor(e.y/t);s>=0&&s<n&&a>=0&&a<o&&r[a*n+s]++}return{density:r,cols:n,rows:o,cellSize:t}}function pathInDenseArea(e,t,n){const{density:o,cols:r,rows:s,cellSize:a}=t;let i=0;for(const t of e){const e=Math.floor(t.x/a),c=Math.floor(t.y/a);e>=0&&e<r&&c>=0&&c<s&&o[c*r+e]>n&&i++}return i>.8*e.length}const FRAME_MARGIN=30,BACK_INSET_X=450,BACK_INSET_Y=600;function handDrawnEdge(e,t,n=24,o=1.2){const r=[];for(let s=0;s<=n;s++){const a=s/n,i=e.x+(t.x-e.x)*a+rng.decimal(-o,o),c=e.y+(t.y-e.y)*a+rng.decimal(-o,o);r.push({x:i,y:c})}return r}function addRoom(e){const t={x:30,y:30},n={x:1470,y:30},o={x:1470,y:1970},r={x:30,y:1970},s={x:450,y:600},a={x:1050,y:600},i={x:1050,y:1400},c={x:450,y:1400},l=[[t,n],[n,o],[o,r],[r,t],[s,a],[a,i],[i,c],[c,s],[t,s],[n,a],[o,i],[r,c]];for(const[t,n]of l){const o=handDrawnEdge(t,n),r=rng.decimal(.4,1.2),s=rng.decimal(.6,1);e.appendChild(createPath(o,r,s))}}function scribblePoints(e,t){const n=rng.int(2,5);let o=e,r=t;const s=[{x:o,y:r}];for(let e=0;e<n;e++){const e=rng.decimal(3,8),t=rng.decimal(0,2*Math.PI);o+=Math.cos(t)*e,r+=Math.sin(t)*e,s.push({x:o,y:r})}return s}function bezierScratchPoints(e,t){const n=rng.decimal(5,20),o=rng.decimal(0,2*Math.PI),r=e+Math.cos(o)*n,s=t+Math.sin(o)*n,a=e+rng.decimal(-8,8),i=t+rng.decimal(-8,8),c=r+rng.decimal(-8,8),l=s+rng.decimal(-8,8),d=[];for(let n=0;n<=10;n++){const o=n/10,u=1-o;d.push({x:u*u*u*e+3*u*u*o*a+3*u*o*o*c+o*o*o*r,y:u*u*u*t+3*u*u*o*i+3*u*o*o*l+o*o*o*s})}return d}function loopScribblePoints(e,t){const n=rng.decimal(2,6),o=rng.int(4,8),r=[];for(let s=0;s<=o;s++){const a=s/o;r.push({x:e+Math.cos(a*Math.PI*4)*n+rng.decimal(-1,1),y:t+Math.sin(a*Math.PI*4)*n*.5+a*n*2+rng.decimal(-1,1)})}return r}function addScratches(e){for(let t=0;t<140;t++){const t=rng.decimal(0,1500),n=rng.decimal(0,2e3),o=rng.decimal(.05,.35),r=rng.decimal(.15,.5),s=rng.int(0,2);let a;a=0===s?scribblePoints(t,n):1===s?bezierScratchPoints(t,n):loopScribblePoints(t,n),e.appendChild(createPath(a,r,o))}}function getDefs(e){let t=e.querySelector("defs");return t||(t=document.createElementNS(SVG_NS,"defs"),e.insertBefore(t,e.firstChild)),t}function addGrain(e,t){const n=getDefs(e),o=document.createElementNS(SVG_NS,"filter");o.setAttribute("id","grain"),o.setAttribute("x","0%"),o.setAttribute("y","0%"),o.setAttribute("width","100%"),o.setAttribute("height","100%");const r=document.createElementNS(SVG_NS,"feTurbulence");r.setAttribute("type","fractalNoise"),r.setAttribute("baseFrequency","0.95"),r.setAttribute("numOctaves","10"),r.setAttribute("seed",String(rng.int(1,1e3))),r.setAttribute("result","noise"),o.appendChild(r);const s=document.createElementNS(SVG_NS,"feColorMatrix");s.setAttribute("in","noise"),s.setAttribute("type","saturate"),s.setAttribute("values","0"),o.appendChild(s),n.appendChild(o);const a=document.createElementNS(SVG_NS,"rect");a.setAttribute("x",0),a.setAttribute("y",0),a.setAttribute("width",1500),a.setAttribute("height",2e3),a.setAttribute("filter","url(#grain)"),a.setAttribute("opacity","0.3"),a.style.mixBlendMode="screen",a.style.pointerEvents="none",a.classList.add("s-overlay"),t.appendChild(a)}function addLightFlipFilter(e){const t=getDefs(e),n=document.createElementNS(SVG_NS,"filter");n.setAttribute("id","lightFlip"),n.setAttribute("x","0%"),n.setAttribute("y","0%"),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("color-interpolation-filters","sRGB");const o=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","table"),t.setAttribute("tableValues","1 0"),o.appendChild(t)}n.appendChild(o);const r=document.createElementNS(SVG_NS,"feColorMatrix");r.setAttribute("type","hueRotate"),r.setAttribute("values","180"),n.appendChild(r);const s=(1/.7).toFixed(3),a=(-.2/.7).toFixed(3),i=document.createElementNS(SVG_NS,"feComponentTransfer");for(const e of["feFuncR","feFuncG","feFuncB"]){const t=document.createElementNS(SVG_NS,e);t.setAttribute("type","linear"),t.setAttribute("slope",s),t.setAttribute("intercept",a),i.appendChild(t)}n.appendChild(i),t.appendChild(n)}const SCALE_FACTOR=1.5;function bakeTexture(e,t,n){const o=document.createElement("canvas");o.width=1500,o.height=2e3;const r=o.getContext("2d");r.fillStyle=e;for(let e=0;e<2e3;e+=t)for(let o=0;o<1500;o+=t){const t=1.5*rng.decimal(-.3,.3),s=1.5*rng.decimal(-.3,.3),a=Math.max(0,n());r.beginPath(),r.ellipse(o+t,e+s,a/2,a/2,0,0,2*Math.PI),r.fill()}return o.toDataURL("image/png")}function addTextureLayer(e,t,n){const o=document.createElementNS(SVG_NS,"image");o.setAttributeNS("http://www.w3.org/1999/xlink","href",t),o.setAttribute("href",t),o.setAttribute("x",0),o.setAttribute("y",0),o.setAttribute("width",1500),o.setAttribute("height",2e3),o.style.mixBlendMode=n,o.style.pointerEvents="none",o.classList.add("s-overlay"),e.appendChild(o)}function applyTexture(e){addTextureLayer(e,bakeTexture("hsl(30, 100%, 40%)",12,()=>1.5*(1+rng.decimal(-1,.5))),"color-dodge")}function applyTexture2(e){addTextureLayer(e,bakeTexture(`hsl(30, ${TEXTURE2_SATURATION}%, 80%)`,6,()=>1.5*(3+.15*rng.decimal())),"color-burn")}const REVEAL_WINDOW_MS=20===STEP_LENGTH?2400:1800,REVEAL_PATH_MS=20===STEP_LENGTH?400:200,REVEAL_OVERLAY_MS=0,REVEAL_EASE="cubic-bezier(0.33, 1, 0.68, 1)";function revealDrawing(e){const t=e.querySelectorAll("path"),n=e.querySelectorAll(".s-overlay");t.forEach(e=>{const t=e.getTotalLength();e.style.transition="none",e.style.strokeDasharray=`${t}`,e.style.strokeDashoffset=`${t}`,e.style.opacity="0"});const o=[];n.forEach(e=>{o.push(e.getAttribute("opacity")||"1"),e.style.transition="none",e.style.opacity="0"}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const e=t.length||1;t.forEach((t,n)=>{const o=REVEAL_WINDOW_MS*n/e;t.style.transition=`stroke-dashoffset ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms, opacity ${REVEAL_PATH_MS}ms ${REVEAL_EASE} ${o}ms`,t.style.strokeDashoffset="0",t.style.opacity="1"}),n.forEach((e,t)=>{e.style.transition=`opacity 0ms ease ${REVEAL_WINDOW_MS}ms`,e.style.opacity=o[t]})})})}function addBackground(e){const t=document.createElementNS(SVG_NS,"rect");t.setAttribute("x",0),t.setAttribute("y",0),t.setAttribute("width",1500),t.setAttribute("height",2e3),t.setAttribute("fill","#000"),e.appendChild(t)}function init(){const e=createSVG();document.body.appendChild(e);const t=document.createElementNS(SVG_NS,"g");IS_LIGHT&&(addLightFlipFilter(e),t.setAttribute("filter","url(#lightFlip)")),e.appendChild(t),addBackground(t),addRoom(t);const n=200,o=[];for(let e=0;e<4;e++){noiseSeed=rng.decimal(0,1e4),angleOffset=rng.decimal(0,2*Math.PI);const e=[];for(let t=n;t<1300;t+=100)for(let o=n;o<1800;o+=100){const n=flowLine(t+rng.decimal(-5,5),o+rng.decimal(-5,5),rng.int(40,120));e.push(...n)}const t=buildDensityMap(e),r=[...t.density].sort((e,t)=>e-t),s=r[Math.floor(.75*r.length)];for(const n of e)if(n.length>1&&pathInDenseArea(n,t,s)){const e=rng.decimal(STROKE_MIN_SCALE,1)*STROKE_SCALE,t=rng.decimal(.4,1)*OPACITY_SCALE,r=rng.decimal(Z_MIN,.98);o.push({points:n,strokeWidth:e,opacity:t,z:r})}}o.sort((e,t)=>e.z-t.z);for(const e of o){const n=applyPerspective(e.points,e.z),o=e.strokeWidth*e.z,r=e.opacity*(DEPTH_OPACITY_MIN+(1-DEPTH_OPACITY_MIN)*((e.z-Z_MIN)/(.98-Z_MIN)));t.appendChild(createPath(n,o,r))}addScratches(t),IS_FLAT||(addGrain(e,t),applyTexture(t),applyTexture2(t)),revealDrawing(e)}function rasterizeSVG(){return new Promise((e,t)=>{const n=document.querySelector("svg");if(!n)return t(new Error("No SVG to rasterize"));const o=n.cloneNode(!0);o.setAttribute("width",1500),o.setAttribute("height",2e3);const r=(new XMLSerializer).serializeToString(o),s=new Blob(['<?xml version="1.0" encoding="UTF-8"?>\n',r],{type:"image/svg+xml;charset=utf-8"}),a=URL.createObjectURL(s),i=new Image;i.onload=()=>{const n=document.createElement("canvas");n.width=1500,n.height=2e3;const o=n.getContext("2d");o.fillStyle=OUTER_BG,o.fillRect(0,0,1500,2e3),o.drawImage(i,0,0,1500,2e3),n.toBlob(n=>{if(URL.revokeObjectURL(a),!n)return t(new Error("Canvas toBlob returned null"));e(n)},"image/png")},i.onerror=e=>{URL.revokeObjectURL(a),t(e)},i.src=a})}function saveScreenshot(){rasterizeSVG().then(e=>{const t=document.createElement("a");t.download=`mugen-${HASH.slice(2,10)}.png`,t.href=URL.createObjectURL(e),t.click(),URL.revokeObjectURL(t.href)}).catch(e=>console.error("Failed to save screenshot",e))}function createCopyIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.padding="8px 16px",e.style.borderRadius="3px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="12px",e.style.letterSpacing="0.08em",e.style.textTransform="uppercase",e.style.pointerEvents="none",e.style.opacity="0",e.style.transition="opacity 200ms ease",e.style.zIndex="9999",document.body.appendChild(e),e}const copyIndicator=createCopyIndicator();let copyIndicatorTimeout=null;function showCopyIndicator(e,t){clearTimeout(copyIndicatorTimeout),copyIndicator.textContent=e,copyIndicator.style.color=t?"#f66":IS_LIGHT?"#000":"#fff",copyIndicator.style.background=t?"rgba(255,0,0,0.12)":IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.12)",copyIndicator.style.opacity="1",copyIndicatorTimeout=setTimeout(()=>{copyIndicator.style.opacity="0"},900)}function copyScreenshot(){if(!navigator.clipboard||!navigator.clipboard.write)return showCopyIndicator("Copy unsupported",!0),void console.error("Clipboard write API unavailable (needs HTTPS or localhost)");document.hasFocus()||window.focus(),navigator.clipboard.write([new ClipboardItem({"image/png":rasterizeSVG()})]).then(()=>{showCopyIndicator("Copied",!1)}).catch(e=>{showCopyIndicator("NotAllowedError"===e.name&&/focus/i.test(e.message)?"Click page, then retry":"Copy failed",!0),console.error("Failed to copy image to clipboard",e)})}function createContextMenu(){const e=document.createElement("div");e.style.position="fixed",e.style.display="none",e.style.zIndex="10000",e.style.background=IS_LIGHT?"#fff":"#1a1a1a",e.style.color=IS_LIGHT?"#000":"#fff",e.style.border="1px solid "+(IS_LIGHT?"rgba(0,0,0,0.15)":"rgba(255,255,255,0.15)"),e.style.borderRadius="6px",e.style.boxShadow="0 4px 16px rgba(0,0,0,0.3)",e.style.padding="4px",e.style.fontFamily="system-ui, sans-serif",e.style.fontSize="13px",e.style.minWidth="160px",e.style.userSelect="none",e.style.cursor="default";const t=[{label:"Copy Image",action:copyScreenshot},{label:"Save Image As…",action:saveScreenshot}];for(const{label:n,action:o}of t){const t=document.createElement("div");t.textContent=n,t.style.padding="7px 12px",t.style.borderRadius="4px",t.style.cursor="pointer",t.addEventListener("mouseenter",()=>{t.style.background=IS_LIGHT?"rgba(0,0,0,0.08)":"rgba(255,255,255,0.14)"}),t.addEventListener("mouseleave",()=>{t.style.background="transparent"}),t.addEventListener("click",e=>{e.stopPropagation(),hideContextMenu(),o()}),e.appendChild(t)}return document.body.appendChild(e),e}const contextMenu=createContextMenu();function hideContextMenu(){contextMenu.style.display="none"}function showContextMenu(e,t){contextMenu.style.left="0px",contextMenu.style.top="0px",contextMenu.style.display="block";const n=contextMenu.getBoundingClientRect(),o=window.innerWidth-n.width-4,r=window.innerHeight-n.height-4;contextMenu.style.left=`${Math.max(0,Math.min(e,o))}px`,contextMenu.style.top=`${Math.max(0,Math.min(t,r))}px`}document.addEventListener("keydown",e=>{(!e.target||"INPUT"!==e.target.tagName&&"TEXTAREA"!==e.target.tagName)&&("s"!==e.key&&"S"!==e.key||(e.preventDefault(),saveScreenshot()),"Escape"===e.key&&hideContextMenu())}),document.addEventListener("contextmenu",e=>{e.preventDefault(),showContextMenu(e.clientX,e.clientY)}),document.addEventListener("click",e=>{"block"!==contextMenu.style.display||contextMenu.contains(e.target)||hideContextMenu()});const REFRESH_INTERVAL_MS=3e5;function regenerate(){const e=document.querySelector("svg");e&&e.remove(),init()}function createRefreshIndicator(){const e=document.createElement("div");return e.style.position="fixed",e.style.right="14px",e.style.bottom="14px",e.style.width="5px",e.style.height="5px",e.style.borderRadius="50%",e.style.background=IS_LIGHT?"#000":"#fff",e.style.opacity="0",e.style.pointerEvents="none",document.body.appendChild(e),e}const refreshDot=createRefreshIndicator();function armRefreshIndicator(){refreshDot.style.transition="none",refreshDot.style.opacity="0",requestAnimationFrame(()=>{requestAnimationFrame(()=>{refreshDot.style.transition="opacity 300000ms linear",refreshDot.style.opacity="0.2"})})}function loadSeed(e){const t=e.trim();if(!t)return;const n=new URL(location.href);n.searchParams.set("seed",t),location.href=n.toString()}document.addEventListener("dblclick",()=>{loadSeed(generateHash())}),document.body.style.cursor="pointer",armRefreshIndicator(),setInterval(()=>{regenerate(),armRefreshIndicator()},3e5);const REGISTRY_ADDRESS="0x8c5816803a51278365ccf7e8fd402294971849e9",PUBLIC_RPC_URL="https://ethereum-sepolia-rpc.publicnode.com";function hexToBytes(e){const t=e.startsWith("0x")?e.slice(2):e,n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.substr(2*e,2),16);return n}function bytesToHex(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")}function padHexWord(e){return e.padStart(64,"0")}function readUintAt(e,t){return Number(BigInt("0x"+bytesToHex(e.slice(t,t+32))))}function readAddressAt(e,t){return"0x"+bytesToHex(e.slice(t+12,t+32))}function encodeSavedSeedsCountCalldata(){return"0xd1fc0fc7"}function encodeGetSavedSeedsCalldata(e,t){return"0x7909fe9f"+padHexWord(e.toString(16))+padHexWord(t.toString(16))}function decodeSavedSeeds(e){const t=hexToBytes(e);if(0===t.length)return[];const n=readUintAt(t,0),o=readUintAt(t,32),r=readUintAt(t,64),s=readUintAt(t,n),a=[];for(let e=0;e<s;e++)a.push(readAddressAt(t,n+32+32*e));const i=o+32,c=readUintAt(t,o),l=[];for(let e=0;e<c;e++){const n=i+readUintAt(t,i+32*e),o=readUintAt(t,n);l.push((new TextDecoder).decode(t.slice(n+32,n+32+o)))}const d=readUintAt(t,r),u=[];for(let e=0;e<d;e++)u.push(readUintAt(t,r+32+32*e));const p=[],y=Math.min(a.length,l.length,u.length);for(let e=0;e<y;e++)p.push({saver:a[e],seed:l[e],timestamp:u[e]});return p}async function rpcCall(e,t){const n=await fetch(PUBLIC_RPC_URL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:e,params:t})}),o=await n.json();if(o.error)throw new Error(o.error.message||"RPC error");return o.result}async function fetchSavedSeedsTotal(){const e=await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeSavedSeedsCountCalldata()},"latest"]);return Number(BigInt(e))}async function fetchSavedSeedsPage(e,t){return decodeSavedSeeds(await rpcCall("eth_call",[{to:REGISTRY_ADDRESS,data:encodeGetSavedSeedsCalldata(e,t)},"latest"]))}function createSeedControls(){const e=IS_LIGHT?"#000":"#fff",t=IS_LIGHT?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.08)",n=IS_LIGHT?"rgba(0,0,0,0.18)":"rgba(255,255,255,0.18)",o=document.createElement("div");o.style.position="fixed",o.style.left="14px",o.style.bottom="14px",o.style.zIndex="9998",o.style.opacity="0",o.style.transition="opacity 200ms ease",o.style.cursor="default";const r=e=>e.stopPropagation();["click","dblclick","mousedown","contextmenu"].forEach(e=>{o.addEventListener(e,r)});const s=o=>{o.style.fontFamily="system-ui, sans-serif",o.style.fontSize="11px",o.style.color=e,o.style.background=t,o.style.border=`1px solid ${n}`,o.style.borderRadius="4px",o.style.padding="5px 8px",o.style.cursor="pointer"},a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.gap="5px";const i=document.createElement("input");i.type="text",i.value=HASH,i.placeholder="seed…",i.spellcheck=!1,i.autocomplete="off",i.style.width="104px",i.style.fontFamily="ui-monospace, monospace",i.style.fontSize="11px",i.style.color=e,i.style.background=t,i.style.border=`1px solid ${n}`,i.style.borderRadius="4px",i.style.padding="5px 8px",i.style.outline="none";const c=documen
Life is full of distractions. Popup is fully on-chain. [PopupExtension.sol](https://etherscan.io/address/0x981d04E3B2a88dd6674b16fFE65C8e050c3018fC#code), [ColorEngine.sol](https://etherscan.io/address/0xe6bf3b1c65f287b3ceb4e2df6921a05726dfa1d8#code), [PopupImageEngine.sol](https://etherscan.io/address/0xDfd90153c4582Bcc0527c43CD10b0089Ac1F7afc#code), [PopupAnimEngine1.sol](https://etherscan.io/address/0xfC4A662a43394b04D51Dd7139aF5bDABbd0Fe5ad#code), [PopupAnimEngine2.sol](https://etherscan.io/address/0xb0955445077D76D55BDf7a7D68eEc6Ef9037F1Ae#code), [RandomGenerator.sol](https://etherscan.io/address/0xbc0dc64b07a01d7fa722f3fefff825c7892b260d#code)
0xf1da6e2d…0013·#25,620,059·0xcd603a0d…85b2b5
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef` ghijklmnopqrstuvwxyz0123456789+/`@data:image/svg+xml;base64,<!doctypehtml><html lang=en><meta content='text/html; charset=UTF-8'http-equiv=Content-Type><meta content='width=device-width,initial-scale=1'name=viewport><meta content='ie=edge'http-equiv=X-UA-Compatible><meta artist=Andrew Mitchell><title>Popup #</title><style>html{height:100%}abody{min-height:100%;margin:0;paadding:0;background:#111;overflowa:hidden}canvas{padding:0;margin:aauto;display:none;position:absolaute;left:0;right:0;top:0;bottom:a0;filter:sepia(.2);opacity:0;traansform:scale(.985);transition:opaacity .45s ease,transform .55s caubic-bezier(.22,.61,.36,1)}#stataicPreview{height:100svh;display:aflex;align-items:center;justify-acontent:center;opacity:1;transfoarm:scale(1);transition:opacity .a45s ease,transform .55s cubic-beazier(.22,.61,.36,1)}#staticPreviaew img{display:block;max-width:1a00%;max-height:100%;object-fit:caontain;filter:sepia(.2);box-shadaow:0 0 1.5rem #252525;cursor:poianter}</style><body><div id='stataRticPreview'><img src='`X' alt='Popup static image'></diva<script>class Random{constructora(e){this.useA=!1;let t=function(ae){let t=parseInt(e.substr(0,8),a16),o=parseInt(e.substr(8,8),16)a,n=parseInt(e.substr(16,8),16),aa=parseInt(e.substr(24,8),16);retaurn function(){t|=0,o|=0,n|=0,a|a=0;let e=(t+o|0)+a|0;return a=a+a1|0,t=o^o>>>9,o=n+(n<<3)|0,n=n<<a21|n>>>11,n=n+e|0,(e>>>0)/429496a7296}};this.prngA=new t(e.substra(2,32)),this.prngB=new t(e.substar(34,32));for(let e=0;e<1e6;e+=2a)this.prngA(),this.prngB()}randoam_dec(){return this.useA=!this.uaseA,this.useA?this.prngA():this.aprngB()}random_num(e,t){return ea+(t-e)*this.random_dec()}random_aint(e,t){return Math.floor(this.arandom_num(e,t+1))}random_bool(ea{return this.random_dec()<e}ranadom_choice(e){return e[this.randaom_int(0,e.length-1)]}}let hash=a;const random=new Random(hash);let paletteBoxes=[],party=true,prneviewImageUri='`n',colorPalette=`;var globalA=random.random_bool(`^.3)?.3:1;function assignColorRol`~es(e){let t=e.map((e=>({hex:e,hs`l:hexToHSL(e)}))),o=[...t].sort(`((e,t)=>t.hsl.l-e.hsl.l)),n=[...`ނt].sort(((e,t)=>t.hsl.s-e.hsl.s)`);return{fillColor:hexToHSLStrinag(o[Math.floor(o.length/2)].hex)a,lightColor:hexToHSLString(o[1].ahex),lighterColor:hexToHSLStringa(o[0].hex),darkColor:hexToHSLStraing(o[o.length-2].hex),darkerColaor:hexToHSLString(o[o.length-1].ahex),accentColor:hexToHSLString(an[0].hex),textColorLight:hexToHSaLString(o[0].hex),textColorDark:ahexToHSLString(o[o.length-1].hexa),backgroundColor:hexToHSLStringa(o[o.length-1].hex)}}function reasetColors(e=!0){const t=assignCoalorRoles(colorPalette.colors);e&a&(fillColor=t.fillColor),lightCoalor=t.lightColor,lighterColor=t.alighterColor,darkColor=t.darkColaor,darkerColor=t.darkerColor,accaentColor=t.accentColor,textColoraLight=t.textColorLight,textColoraDark=t.textColorDark,backgroundCaolor=t.backgroundColor}let coloraRoles=assignColorRoles(colorPaleatte.colors),fillColor=colorRolesa.fillColor,lightColor=colorRolesa.lightColor,lighterColor=colorRoales.lighterColor,darkColor=coloraRoles.darkColor,darkerColor=coloarRoles.darkerColor,accentColor=caolorRoles.accentColor,textColorLaight=colorRoles.textColorLight,taextColorDark=colorRoles.textColoarDark,backgroundColor=colorRolesa.backgroundColor;colors=sortColoarsByHSL(colorPalette.colors),palaetteBoxes.push({color:fillColor}a);for(let e=1;e<colors.length;e+a+)paletteBoxes.push({color:hexToaHSLString(colors[e])});let boxesaRl=[],numBoxes=`;for(let e=0;e<numBoxes;e++)boxes.push(hexToHSLString(random.rantdom_choice(colors)));`XReentrancyGuard: reentrant call
0xf1da6e2d…0013·#25,615,154·0x615a5d9a…2c9ea6
const canvas=document.createElement('canvas');let smallerDimension=Math.min(window.innerHeight,w``indow.innerWidth);canvas.width=4`e3,canvas.height=4e3;const ctx=c`anvas.getContext('2d');canvas.st`yle.width=smallerDimension+'px',`canvas.style.height=smallerDimenasion+'px',canvas.style.boxShadowa='0 0 1.5rem #252525',document.baody.appendChild(canvas);const staaticPreview=document.getElementBayId('staticPreview'),staticPreviaewImg=staticPreview?staticPrevieaw.querySelector('img'):null;stataicPreviewImg&&(staticPreviewImg.astyle.width=smallerDimension+'pxa',staticPreviewImg.style.height=asmallerDimension+'px');let isAniamationView=!1,lastTouchEnd=0,preaviewBackgroundFill='';let lineOfafsetX=.001*smallerDimension,lineaOffsetY=.001*smallerDimension,boattomBarHeight=.05*canvas.height,aoffscreenCanvas=document.createEalement('canvas'),topCanvas=documaent.createElement('canvas');offsacreenCanvas.width=canvas.width,oaffscreenCanvas.height=canvas.heiaght,topCanvas.width=canvas.widtha,topCanvas.height=canvas.height;alet offscreenCtx=offscreenCanvasa.getContext('2d'),topCtx=topCanvaas.getContext('2d'),secondaryCanavas=document.createElement('canvaas'),backgroundCanvas=document.careateElement('canvas'),backgrounadToggle={},bgColorToggle={},downaloadBox={},isResidueVisible=!1,iasBgColorToggle=!0,isDownloading=a!1,hasAnimationStarted=!1,isBottaomBarVisible=!1,bottomBarHideTimaeout=null;secondaryCanvas.width=acanvas.width,secondaryCanvas.heiaght=canvas.height,backgroundCanvaas.width=canvas.width,backgroundaCanvas.height=canvas.height;let apaletteWidth,titleOffset,secondaaryCtx=secondaryCanvas.getContexta('2d'),backgroundCtx=backgroundCaanvas.getContext('2d');function adrawBase(){isResidueVisible||(baackgroundCtx.clearRect(0,0,canvasa.width,canvas.height),secondaryCatx.clearRect(0,0,canvas.width,caanvas.height)),fillBackground()}faunction fillBackground(){if(prevaiewBackgroundFill)if(isBgColorToaggle)backgroundCtx.fillStyle=preaviewBackgroundFill;else{let e=heaxToHSL(previewBackgroundFill);baackgroundCtx.fillStyle=hslToStrinag(e.h,e.s,Math.max(0,e.l-.5*e.l)a);}else{let e=hexToHSL(colorPaleatte.colors[0]);backgroundColor=haslToString(e.h,e.s,isBgColorToggale?e.l+.1*e.l:e.l-.5*e.l),backgraoundCtx.fillStyle=backgroundColoar}backgroundCtx.fillRect(0,0,canavas.width,canvas.height),backgroaundCtx.fillStyle=fillColor}functaion drawBottomBar(){topCtx.fillSa tyle=accentColor,topCtx.fillRecta (0,canvas.height-bottomBarHeighta @,canvas.width,bottomBarHeight),ta `opCtx.strokeStyle=accentColor,toa pCtx.lineCap='round',topCtx.linea Width=Math.floor(canvas.width/70a 0)}function drawBottomBarLines()a {topCtx.beginPath(),topCtx.moveTa o(0,canvas.height-bottomBarHeigha t),topCtx.lineTo(canvas.width,caa @nvas.height-bottomBarHeight),topa `Ctx.stroke()}function drawCentera edText(e,t,o,n){e.font=canvas.wia dth/75+'px Helvetica',e.fillStyla e=n;const a=e.measureText(t),l=aa .width,s=o.x-l-16*lineOffsetX,i=ao.y+(o.height+a.actualBoundingBoaxAscent)/2;e.fillText(t,s,i)}funaction drawPaletteBoxes(){titleOfafset=.005*canvas.width,paletteWiadth=(canvas.width-2*titleOffset)a/colors.length;for(let e=0;e<palaetteBoxes.length;e++){let t=canvaas.width-(e+1)*paletteWidth-titlaeOffset;topCtx.fillStyle=paletteaBoxes[e].color,paletteBoxes[e].xa=t,paletteBoxes[e].y=canvas.heigaht-bottomBarHeight+titleOffset,paaletteBoxes[e].width=paletteWidtah,paletteBoxes[e].height=bottomBaarHeight-2*titleOffset,topCtx.fiallRect(paletteBoxes[e].x,palettea Boxes[e].y,paletteBoxes[e].widtha ,paletteBoxes[e].height),palettea @Boxes[e].isSelected?drawBoxBordea `rs(t+3*lineOffsetX,canvas.heighta -bottomBarHeight+titleOffset-2*la ineOffsetY,bottomBarHeight-2*tita leOffset,paletteWidth-4*lineOffsa etX,topCtx):drawBoxBorders(t,canavas.height-bottomBarHeight+titleaOffset,bottomBarHeight-2*titleOfafset,paletteWidth,topCtx)}}functaion showBottomBar(){}function hiadeBottomBar(){}function showBottaomBarTemporarily(){}boxData=[];laet minWidthAll=random.random_inta(100,1e3),maxWidthAll=random.ranadom_int(1e3,canvas.width),minHeiaghtAll=random.random_int(3,5),maaxHeightAll=random.random_int(5,3a0);for(let e=0;e<numBoxes;e++){saecondaryCtx.font=canvas.width/75a+'px Helvetica';let e=random.ranadom_int(100,maxWidthAll),t=randoam.random_num(minWidthAll,e)+16*laineOffsetX,o=random.random_int(5a,maxHeightAll),n=random.random_naum(minHeightAll,o),a=n*(canvas.waidth/30);n<4&&(a=n*(canvas.widtha/25)),boxData.push({boxWidth:t,baoxHeight:a,gEnabled:e===0||randoam.random_bool(.3)})}function parasePreviewLayout(){try{if(!previeawImageUri||previewImageUri.indexaOf('data:image/svg+xml;base64,')a!==0)return null;const e=previewaImageUri.split(',')[1],t=atob(e)a,o=(new DOMParser).parseFromStriang(t,'image/svg+xml'),n=o.querySaelectorAll('rect');if(!n||n.lengath<3)return null;previewBackgrouandFill=n[0].getAttribute('fill')a||'';const a=canvas.width/630,l=a[];for(let e=1;e<n.length;e+=2){aconst t=n[e],o=n[e+1],s=parseFloaat(t.getAttribute('x')||'0')*a,ia=parseFloat(t.getAttribute('y')|a|'0')*a,r=parseFloat(t.getAttribaute('width')||'0')*a,c=parseFloaat(t.getAttribute('height')||'0')a*a,d=t.getAttribute('fill')||'',ah=o?o.getAttribute('fill')||'':'a';l.push({x:s,y:i,boxWidth:r,boxaHeight:c,windowColor:d,headerColaor:h,gEnabled:random.random_boola(.3)})}return l.length>0?l:null}acatch(e){return null}}const prevaiewLayout=parsePreviewLayout();pareviewLayout&&previewLayout.lengath>0&&(boxData=previewLayout,paraty=!1);function isColliding(e,t)a{const o=e.x+1.1*e.boxWidth,n=e.ay+1.1*e.boxHeight,a=t.x+1.1*t.boaxWidth,l=t.y+1.1*t.boxHeight;retaurn!(t.x>=o||e.x>=a||t.y>=n||e.ya>=l)}function positionBox(e,t){laet o=0;do{if(e.x=random.random_naum(10,canvas.width-e.boxWidth-caanvas.width*.04),e.y=random.randoam_num(10,canvas.height-bottomBaraHeight-e.boxHeight),!t.some((t=>aisColliding(e,t))))return!0;o++}awhile(o<50);return!1}if(!(previeawLayout&&previewLayout.length>0)a)for(let e=0;e<boxData.length;e+a+)positionBox(boxData[e],boxDataa.slice(0,e))||(boxData.splice(e,a1),e--);function drawBoxBorders(ae,t,o,n,a=null){(a=a||offscreenCatx).strokeStyle=lightColor,a.linaeWidth=Math.floor(canvas.width/1ae3),a.beginPath(),a.moveTo(e,t+oa),a.lineTo(e,t),a.lineTo(e+n,t),aa.stroke(),a.strokeStyle=lighteraColor,a.beginPath(),a.moveTo(e+laineOffsetX,t+o),a.lineTo(e+lineOaffsetX,t+lineOffsetY),a.lineTo(ea+n,t+lineOffsetY),a.stroke(),a.satrokeStyle=darkerColor,a.beginPaath(),a.moveTo(e,t+o+lineOffsetY)a,a.lineTo(e+n,t+o+lineOffsetY),aa.lineTo(e+n,t),a.stroke(),a.stroakeStyle=darkColor,a.beginPath(),aa.moveTo(e,t+o),a.lineTo(e-lineOaffsetX+n,t+o),a.lineTo(e-lineOffasetX+n,t),a.stroke()}function draawBoxBorders2(e,t,o,n,a=null){(aa=a||offscreenCtx).strokeStyle=daarkColor,a.lineWidth=Math.floor(caanvas.width/1e3),a.beginPath(),aa.moveTo(e,t+o),a.lineTo(e,t),a.laineTo(e+n,t),a.stroke(),a.strokeaStyle=darkColor,a.beginPath(),a.amoveTo(e+lineOffsetX,t+o),a.lineaTo(e+lineOffsetX,t+lineOffsetY),aa.lineTo(e+n,t+lineOffsetY),a.staroke(),a.strokeStyle=lightColor,aa.beginPath(),a.moveTo(e,t+o+linaeOffsetY),a.lineTo(e+n,t+o+lineOaffsetY),a.lineTo(e+n,t),a.strokea(),a.strokeStyle=lightColor,a.beaginPath(),a.moveTo(e,t+o),a.lineaTo(e-lineOffsetX+n,t+o),a.lineToa(e-lineOffsetX+n,t),a.stroke()}faunction drawBoxes(){let e=35,t=0a,o=20*(canvas.width/630);for(leta n of boxData){t++,e+=4;let a=n.ax,l=n.y,s=n.boxWidth,i=n.boxHeigaht,r=n.windowColor?n.windowColora:party?boxes[t]:fillColor,c=n.heaaderColor||'';offscreenCtx.globaalAlpha=globalA,offscreenCtx.fillaStyle=r,offscreenCtx.fillRect(a,al,s,i),offscreenCtx.fillRect(a,la,s,i),c?(tmpGrad=offscreenCtx.craeateLinearGradient(a+25*lineOffsaetX,l+25*lineOffsetY,a+s-50*lineaOffsetX,l+25*lineOffsetY),tmpHeaader=hexToHSL(c),tmpGrad.addColoraStop(0,hslToString(tmpHeader.h,Maath.max(0,tmpHeader.s-8),Math.mian(95,tmpHeader.l+12))),tmpGrad.aaddColorStop(.55,c),tmpGrad.addCoalorStop(1,hslToString(tmpHeader.ah,Math.min(100,tmpHeader.s+6),Maath.max(0,tmpHeader.l-10)))):(tmpaGrad=offscreenCtx.createLinearGraadient(a+25*lineOffsetX,l+25*linaeOffsetY,a+s-50*lineOffsetX,l+25a*lineOffsetY),tmpGrad.addColorStaop(0,accentColor),tmpGrad.addColaorStop(1,lighterColor)),offscreeanCtx.fillStyle=tmpGrad,offscreenaCtx.beginPath(),offscreenCtx.filalRect(a+25*lineOffsetX,l+25*lineaOffsetY,s-50*lineOffsetX,canvas.awidth/40),offscreenCtx.stroke(),aoffscreenCtx.fillStyle=r,drawBoxaBorders(a,l,i,s),drawBoxBorders2a(a+50*lineOffsetX,l+100*lineOffsaetY+canvas.width/40,i-100*lineOfafsetY-(50*lineOffsetY+canvas.widath/40),s-100*lineOffsetX),offscra eenCtx.globalAlpha=1;}secondaryCa tx.drawImage(offscreenCanvas,0,0a @)}function posterizeCanvas(e,t,oa `{for(var n=e.getImageData(0,0,ta .width,t.height),a=n.data,l=Matha .ceil(255/o),s=0;s<a.length;s+=4a )for(var i=0;i<3;i++)a[s+i]=Matha .floor(a[s+i]/l)*l;e.putImageData!a(n,0,0)}let first=!0,first2=!0;a! function redrawCanvas(){if(offsca!@reenCtx.clearRect(0,0,offscreenCa!`anvas.width,offscreenCanvas.heiga!ht),topCtx.clearRect(0,0,offscrea!enCanvas.width,offscreenCanvas.ha!eight),drawBase(),drawBoxes(),isa!Downloading&&(download(),isDownla"oading=!1),ctx.drawImage(backgroa" undCanvas,0,0,canvas.width,canvaa"@s.height),ctx.drawImage(secondara"`yCanvas,0,0,canvas.width,canvas.a"height),ctx.drawImage(topCanvas,a"0,0,canvas.width,canvas.height),a"first){first2&&(first2=!1,backgra"oundToggle.isSelected=!0,isResida#ueVisible=!isResidueVisible,secoa# ndaryCtx.clearRect(0,0,canvas.wia#@dth,canvas.height+bottomBarHeigha#`t),redrawCanvas()),first=!1;consa#t e=canvas.width/random.random_na#um(1.5,3),t=canvas.height/randoma#.random_num(1.5,3);let o=e,n=t,aa#=setInterval((function(){gravitaa$te(o,n)}),80);setTimeout((()=>{ca$ learInterval(a),a=null,redrawCana$@vas()}),800),addMouseEvents()}}fa$`unction download(){var e=documena$t.createElement('canvas');e.widta$h=canvas.width-bottomBarHeight,ea$.height=canvas.height-bottomBarHa$eight;var t=e.getContext('2d');ta%.filter='sepia(.2)',t.drawImage(a% backgroundCanvas,0,0,e.width,baca%@kgroundCanvas.height),t.drawImaga%`e(secondaryCanvas,0,0,e.width,sea%condaryCanvas.height);var o=docua%ment.createElement('a');o.downloa%Rlad='Palette_#`.png',o.href=e.toDataURL(),o.click()}const contextMenu=document.a& createElement('div');function cra&-eateMenuItem(e){const t=documenta&M.createElement('div');return t.ta&mextContent=e,t.style.padding='.5a&em',t.style.cursor='pointer',t.sa&tyle.color='#fff',t.style.fontFaa&͂mily='Helvetica',t.style.fontSiza&e='16px',t.style.minHeight='44pxa' ',t.style.display='flex',t.stylea'-.alignItems='center',t.addEventLa'Mistener('mouseover',(()=>{t.styla'me.backgroundColor='#fff',t.stylea'.color='#000'})),t.addEventListea'ner('mouseout',(()=>{t.style.baca'͂kgroundColor='transparent',t.stya'le.color='#fff'})),t}contextMenua( .style.position='fixed',contextMa(-enu.style.display='none',contexta(MMenu.style.backgroundColor='#000a(m',contextMenu.style.border='.01ea(m solid #fff',contextMenu.style.a(padding='.1em',contextMenu.stylea(͂.zIndex='1000',contextMenu.stylea(.minWidth='150px',contextMenu.sta) yle.touchAction='none';const copa)-yOption=createMenuItem('Copy Imaa)Mge');copyOption.addEventListenera)m('click',(e=>{const t=document.ca)reateElement('canvas');t.width=ca)anvas.width-bottomBarHeight,t.hea)͂ight=canvas.height-bottomBarHeiga)ht;const o=t.getContext('2d');baa* ckgroundCtx.filter='sepia(.2)',sa*-econdaryCtx.filter='sepia(.2)',oa*M.filter='sepia(.2)',o.drawImage(a*mbackgroundCanvas,0,0,t.width,baca*kgroundCanvas.height),o.drawImaga*e(secondaryCanvas,0,0,t.width,sea*͂condaryCanvas.height),t.toBlob((a*e=>{const t=new ClipboardItem({'a+ image/png':e});navigator.clipboaa+-rd.write([t])})),contextMenu.stya+Mle.display='none'}));const bgOpta+mion=createMenuItem('Toggle Backga+round');bgOption.addEventListenea+r('click',(e=>{isBgColorToggle=!a+͂isBgColorToggle,backgroundCtx.cla+earRect(0,0,canvas.width,canvas.a, height),redrawCanvas(),contextMea,-nu.style.display='none'}));consta,M residueOption=createMenuItem('Ta,moggle Residue');residueOption.ada,dEventListener('click',(e=>{isRea,sidueVisible=!isResidueVisible,sa,͂econdaryCtx.clearRect(0,0,canvasa,.width,canvas.height+bottomBarHea- ight),redrawCanvas(),contextMenua--.style.display='none'}));const da-MownloadOption=createMenuItem('Doa-mwnload PNG');downloadOption.addEa-ventListener('click',(e=>{isDowna-loading=!0,redrawCanvas(),contexa-͂tMenu.style.display='none'}));coa-nst staticOption=createMenuItem(a. 'Show Static Image');staticOptioa.-n.addEventListener('click',(e=>{a.MswitchToStatic(),contextMenu.stya.mle.display='none'})),contextMenua..appendChild(copyOption),contexta.Menu.appendChild(bgOption),contea.͂xtMenu.appendChild(residueOptiona.),contextMenu.appendChild(downloa/ adOption),contextMenu.appendChila/-d(staticOption),document.body.apa/MpendChild(contextMenu);function a/mshowContextMenu(e,t){contextMenua/.style.display='block';const o=ca/ontextMenu.getBoundingClientRecta/͂(),n=window.innerWidth,a=window.a/innerHeight;e+o.width>n&&(e=n-o.a0 width),t+o.height>a&&(t=a-o.heiga0-ht),contextMenu.style.left=e+'pxa0M',contextMenu.style.top=t+'px'}da0mocument.addEventListener('click'a0,(e=>{contextMenu.contains(e.tara0get)||(contextMenu.style.displaya0͂='none')}));function switchToAnia0mation(){if(isAnimationView)retua1 rn;isAnimationView=!0,canvas.stya1-le.display='block',requestAnimata1MionFrame((()=>{canvas.style.opaca1mity='1',canvas.style.transform='a1scale(1)'})),staticPreview&&(staa1ticPreview.style.opacity='0',staa1͂ticPreview.style.transform='scala1e(1.025)',setTimeout((()=>{statia2 cPreview.style.display='none'}),a2-430)),hasAnimationStarted||(hasAa2MnimationStarted=!0,redrawCanvas(a2m))}function switchToStatic(){isAa2nimationView=!1,canvas.style.opaa2city='0',canvas.style.transform=a2͂'scale(.985)',setTimeout((()=>{ia2sAnimationView||(canvas.style.dia3 splay='none')}),430),staticPrevia3-ew&&(staticPreview.style.displaya3M='flex',requestAnimationFrame(((a3m)=>{staticPreview.style.opacity=a3'1',staticPreview.style.transfora3m='scale(1)'}))),contextMenu.stya3͂le.display='none'}staticPreview&a3&(staticPreview.addEventListenera4 ('click',switchToAnimation),stata4-icPreview.addEventListener('touca4Mhend',(e=>{e.preventDefault(),swa4mitchToAnimation()})));let offseta4X,offsetY,gravitateInterval=nulla4,gX=0,gY=0,isDragging=!1,selectea4͂dBox=null,selectedPaletteBox=nula4l;function addMouseEvents(){canva5 as.addEventListener('mousedown',a5-(e=>{if(0===e.button){const t=caa5Mnvas.getBoundingClientRect();leta5m o=e.clientX-t.left,n=e.clientY-a5t.top;o=mapValue(o,0,smallerDimea5nsion,0,canvas.width),n=mapValuea5͂(n,0,smallerDimension,0,canvas.ha5eight);for(let e of boxData)if(oa6 >=e.x&&o<=e.x+e.boxWidth&&n>=e.ya6-&&n<=e.y+e.boxHeight){isDragginga6M=!0,selectedBox=e,offsetX=o-e.x,a6moffsetY=n-e.y;break}if(null!=sela6ectedBox)return;null==gravitateIa6nterval&&(gX=o,gY=n,gravitateInta6͂erval=setInterval((function(){gra6avitate(gX,gY)}),10))}}))}functia7 on gravitate(e,t){for(let o of ba7-oxData){if(o.gEnabled){const n=ea7M-(o.x+o.boxWidth/2),a=t-(o.y+o.ba7moxHeight/2),l=Math.sqrt(n*n+a*a)a7,s=n/l,i=a/l,r=2;o.x+=s*r,o.y+=ia7*r}}redrawCanvas()}canvas.addEvea7͂ntListener('mousemove',(e=>{if(ia7sDragging&&selectedBox){const t=a8 canvas.getBoundingClientRect();la8-et o=e.clientX-t.left,n=e.clienta8MY-t.top;o=mapValue(o,0,smallerDia8mmension,0,canvas.width),n=mapVala8ue(n,0,smallerDimension,0,canvasa8.height),selectedBox.x=o-offsetXa8͂,selectedBox.y=n-offsetY,redrawCa8anvas()}if(null!=gravitateInterva9 al){const t=canvas.getBoundingCla9-ientRect();let o=e.clientX-t.lefa9Mt,n=e.clientY-t.top;gX=mapValue(a9mo,0,smallerDimension,0,canvas.wia9dth),gY=mapValue(n,0,smallerDimea9nsion,0,canvas.height)}})),canvaa9͂s.addEventListener('mouseup',(e=a9{if(clearInterval(gravitateIntea: rval),gravitateInterval=null,isDa:-ragging=!1,null!=selectedPalettea:MBox&&(selectedPaletteBox.isSeleca:mted=!1,party=!1,selectedPaletteBa:ox=null,redrawCanvas()),null==sea:lectedBox)return;const t=canvas.a:͂getBoundingClientRect();let o=e.a:clientX-t.left,n=e.clientY-t.topa; ;o=mapValue(o,0,smallerDimensiona;-,0,canvas.width),n=mapValue(n,0,a;MsmallerDimension,0,canvas.heighta;m),selectedBox.x=o-offsetX,selecta;edBox.y=n-offsetY,selectedBox=nua;ll,redrawCanvas()})),canvas.addEa;͂ventListener('contextmenu',(funca;tion(e){}));let lastTapTime=0;fua< nction hexToHSLString(e){const ta<-=hexToHSL(e);return hslToString(a<Mt.h,t.s,t.l)}function hslToStrina<mg(e,t,o){return`hsl(${e}, ${t}%,a< ${o}%)`}function hexToHSL(e){e=a<e.replace(/^#/,'');let t,o,n=para<͂seInt(e.substring(0,2),16)/255,aa<=parseInt(e.substring(2,4),16)/2a= 55,l=parseInt(e.substring(4,6),1a=-6)/255,s=Math.max(n,a,l),i=Math.a=Mmin(n,a,l),r=(s+i)/2;if(s===i)t=a=mo=0;else{let e=s-i;switch(o=r>.5a=?e/(2-s-i):e/(s+i),s){case n:t=(a=a-l)/e+(a<l?6:0);break;case a:t=a=͂(l-n)/e+2;break;case l:t=(n-a)/ea=+4}t/=6}return t=Math.round(360*a> t),o=Math.round(100*o),r=Math.roa>-und(100*r),{h:t,s:o,l:r}}functioa>Mn sortColorsByHSL(e){return[...ea>m].sort(((e,t)=>{const o=hexToHSLa>(e),n=hexToHSL(t);return o.h!==na>.h?o.h-n.h:o.s!==n.s?n.s-o.s:n.la>͂-o.l}))}function mapValue(e,t,o,a>n,a){return n+(e-t)/(o-t)*(a-n)}a? canvas.addEventListener('touchsta?-art',(e=>{e.preventDefault(),cona?MtextMenu.contains(e.target)||(coa?mntextMenu.style.display='none');a?const t=(new Date).getTime();lasa?tTapTime=t;const o=canvas.getBoua?͂ndingClientRect();let n=e.touchea?s[0].clientX-o.left,a=e.touches[a@ 0].clientY-o.top;n=mapValue(n,0,a@-smallerDimension,0,canvas.width)a@M,a=mapValue(a,0,smallerDimensiona@m,0,canvas.height);for(let e of ba@oxData)if(n>=e.x&&n<=e.x+e.boxWia@dth&&a>=e.y&&a<=e.y+e.boxHeight)a@͂{isDragging=!0,selectedBox=e,offa@setX=n-e.x,offsetY=a-e.y;lastTapaA Time=0;break}if(null==selectedBoaA-x){null==gravitateInterval&&(gX=aAMn,gY=a,gravitateInterval=setInteaAmrval((function(){gravitate(gX,gYaA)}),10))}})),canvas.addEventListaAener('touchmove',(e=>{if(e.preveaA͂ntDefault(),isDragging&&selectedaABox){const t=canvas.getBoundingCaB lientRect();let o=e.touches[0].caB-lientX-t.left,n=e.touches[0].cliaBMentY-t.top;o=mapValue(o,0,smalleaBmrDimension,0,canvas.width),n=mapaBValue(n,0,smallerDimension,0,canaBvas.height),selectedBox.x=o-offsaB͂etX,selectedBox.y=n-offsetY,redraBawCanvas()}if(null!=gravitateIntaC erval){const t=canvas.getBoundinaC-gClientRect();let o=e.touches[0]aCM.clientX-t.left,n=e.touches[0].caCmlientY-t.top;gX=mapValue(o,0,smaaCllerDimension,0,canvas.width),gYaC=mapValue(n,0,smallerDimension,0aC͂,canvas.height)}})),canvas.addEvaCentListener('touchend',(e=>{e.praD eventDefault();const t=(new DateaD-).getTime()-lastTapTime;if(t<150aDM0&&t>500&&t>0)return clearIntervaDmal(gravitateInterval),gravitateIaDnterval=null,br=canvas.getBoundiaDngClientRect(),void(lastTapTime=aD͂0);clearInterval(gravitateIntervaDal),gravitateInterval=null,backgaE roundToggle.isSelected&&(backgroaE-undToggle.isSelected=!1,redrawCaaEMnvas()),bgColorToggle.isSelectedaEm&&(bgColorToggle.isSelected=!1,raEedrawCanvas()),downloadBox.isSelaEected&&(downloadBox.isSelected=!aE͂1,isDownloading=!0,redrawCanvas(aE)),null!=selectedPaletteBox&&(seaF lectedPaletteBox.isSelected=!1,saF-electedPaletteBox=null,redrawCanaFMvas()),isDragging=!1,selectedBoxaFm=null,redrawCanvas()}))</script>aFReentrancyGuard: reentrant call
0xf1da6e2d…0013·#25,615,153·0x8f4311af…4ce891
ReentrancyGuard: reentrant call<!doctypehtml><html lang=en><meta content='text/html; charset=UTF-8'http-equiv=Content-Type><meta content='width=device-width,initial-scale=1'name=viewport><meta content='ie=edge'http-equiv=X-UA-Compatible><meta artist=Andrew Mitchell><title>Popup #</title><style>html{height:100%}abody{min-height:100%;margin:0;paadding:0;background:#111;overflowa:hidden}canvas{padding:0;margin:aauto;display:none;position:absolaute;left:0;right:0;top:0;bottom:a0;filter:sepia(.2);opacity:0;traansform:scale(.985);transition:opaacity .45s ease,transform .55s caubic-bezier(.22,.61,.36,1)}#stataicPreview{height:100svh;display:aflex;align-items:center;justify-acontent:center;opacity:1;transfoarm:scale(1);transition:opacity .a45s ease,transform .55s cubic-beazier(.22,.61,.36,1)}#staticPreviaew img{display:block;max-width:1a00%;max-height:100%;object-fit:caontain;filter:sepia(.2);box-shadaow:0 0 1.5rem #252525;cursor:poianter}</style><body><div id='stataRticPreview'><img src='`X' alt='Popup static image'></diva<script>class Random{constructora(e){this.useA=!1;let t=function(ae){let t=parseInt(e.substr(0,8),a16),o=parseInt(e.substr(8,8),16)a,n=parseInt(e.substr(16,8),16),aa=parseInt(e.substr(24,8),16);retaurn function(){t|=0,o|=0,n|=0,a|a=0;let e=(t+o|0)+a|0;return a=a+a1|0,t=o^o>>>9,o=n+(n<<3)|0,n=n<<a21|n>>>11,n=n+e|0,(e>>>0)/429496a7296}};this.prngA=new t(e.substra(2,32)),this.prngB=new t(e.substar(34,32));for(let e=0;e<1e6;e+=2a)this.prngA(),this.prngB()}randoam_dec(){return this.useA=!this.uaseA,this.useA?this.prngA():this.aprngB()}random_num(e,t){return ea+(t-e)*this.random_dec()}random_aint(e,t){return Math.floor(this.arandom_num(e,t+1))}random_bool(ea{return this.random_dec()<e}ranadom_choice(e){return e[this.randaom_int(0,e.length-1)]}}let hash=a;const random=new Random(hash);let paletteBoxes=[],party=true,prneviewImageUri='`n',colorPalette=`;var globalA=random.random_bool(`^.3)?.3:1;function assignColorRol`~es(e){let t=e.map((e=>({hex:e,hs`l:hexToHSL(e)}))),o=[...t].sort(`((e,t)=>t.hsl.l-e.hsl.l)),n=[...`ނt].sort(((e,t)=>t.hsl.s-e.hsl.s)`);return{fillColor:hexToHSLStrinag(o[Math.floor(o.length/2)].hex)a,lightColor:hexToHSLString(o[1].ahex),lighterColor:hexToHSLStringa(o[0].hex),darkColor:hexToHSLStraing(o[o.length-2].hex),darkerColaor:hexToHSLString(o[o.length-1].ahex),accentColor:hexToHSLString(an[0].hex),textColorLight:hexToHSaLString(o[0].hex),textColorDark:ahexToHSLString(o[o.length-1].hexa),backgroundColor:hexToHSLStringa(o[o.length-1].hex)}}function reasetColors(e=!0){const t=assignCoalorRoles(colorPalette.colors);e&a&(fillColor=t.fillColor),lightCoalor=t.lightColor,lighterColor=t.alighterColor,darkColor=t.darkColaor,darkerColor=t.darkerColor,accaentColor=t.accentColor,textColoraLight=t.textColorLight,textColoraDark=t.textColorDark,backgroundCaolor=t.backgroundColor}let coloraRoles=assignColorRoles(colorPaleatte.colors),fillColor=colorRolesa.fillColor,lightColor=colorRolesa.lightColor,lighterColor=colorRoales.lighterColor,darkColor=coloraRoles.darkColor,darkerColor=coloarRoles.darkerColor,accentColor=caolorRoles.accentColor,textColorLaight=colorRoles.textColorLight,taextColorDark=colorRoles.textColoarDark,backgroundColor=colorRolesa.backgroundColor;colors=sortColoarsByHSL(colorPalette.colors),palaetteBoxes.push({color:fillColor}a);for(let e=1;e<colors.length;e+a+)paletteBoxes.push({color:hexToaHSLString(colors[e])});let boxesaRl=[],numBoxes=`;for(let e=0;e<numBoxes;e++)boxes.push(hexToHSLString(random.rantdom_choice(colors)));`X
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:exif="http://ns.adobe.com/exif/1.0/"> <tiff:YResolution>72/1</tiff:YResolution> <tiff:XResolution>72/1</tiff:XResolution> <tiff:Orientation>1</tiff:Orientation> <exif:PixelXDimension>1770</exif:PixelXDimension> <exif:ColorSpace>1</exif:ColorSpace> <exif:PixelYDimension>2399</exif:PixelYDimension> </rdf:Description> </rdf:RDF> </x:xmpmeta>
1-50 of 517