var e={preferredElementNodeName:"PRE",render:function(e,c){const s=e.settings.element;for(e.rows==n&&e.cols==o||(o=e.cols,n=e.rows,t.length=0);s.childElementCountn;)s.removeChild(s.lastChild);for(let i=0;i",h={},f=!1),u+=o.beginHTML),!l(o,h)){f&&(u+="");const t=o.color===e.settings.color?null:o.color,n=o.backgroundColor===e.settings.backgroundColor?null:o.backgroundColor,r=o.fontWeight===e.settings.fontWeight?null:o.fontWeight;let c="";t&&(c+="color:"+t+";"),n&&(c+="background:"+n+";"),r&&(c+="font-weight:"+r+";"),c&&(c=' style="'+c+'"'),u+="",f=!0}u+=o.char,h=o,o.endHTML&&(f&&(u+="",h={},f=!1),u+=o.endHTML)}f&&(u+=""),s.childNodes[i].innerHTML=u}}};const t=[];let o,n;function r(e,t){return"object"==typeof e&&"object"==typeof t&&e.char===t.char&&e.fontWeight===t.fontWeight&&e.color===t.color&&e.backgroundColor===t.backgroundColor}function l(e,t){return e.fontWeight===t.fontWeight&&e.color===t.color&&e.backgroundColor===t.backgroundColor}var s={preferredElementNodeName:"CANVAS",render:function(e,t){const o=e.settings.element,n=devicePixelRatio,r=e.cols,c=e.rows,s=e.metrics,l=s.cellWidth,i=Math.round(s.lineHeight),a=e.settings;a.canvasSize?(o.width=a.canvasSize.width*n,o.height=a.canvasSize.height*n,o.style.width=a.canvasSize.width+"px",o.style.height=a.canvasSize.height+"px"):(o.width=e.width*n,o.height=e.height*n);const u=" "+s.fontSize+"px "+s.fontFamily,h=a&&a.backgroundColor?a.backgroundColor:"white",f=a&&a.color?a.color:"black",d=a&&a.fontWeight?a.color:"400",x=o.getContext("2d");if(x.fillStyle=h,x.fillRect(0,0,o.width,o.height),x.save(),x.scale(n,n),x.fillStyle=f,x.textBaseline="top",a.canvasOffset){const e=a.canvasOffset,t=Math.round("auto"==e.x?(o.width/n-r*l)/2:e.x),s=Math.round("auto"==e.y?(o.height/n-c*i)/2:e.y);x.translate(t,s)}if("center"==a.textAlign)for(let e=0;e=this.ptime+1e3&&(this.fps=1e3*this.frames/(e-this.ptime),this.ptime=e,this.frames=0),this.fps}}var c=function(e,t){try{return localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return!1}},a=function(e,t={}){const o=JSON.parse(localStorage.getItem(e));return Object.assign(t,o),t},d="1.1";const f={canvas:s,text:e},h={element:null,cols:0,rows:0,once:!1,fps:30,renderer:"text",allowSelect:!1,restoreState:!1},u=["backgroundColor","color","fontFamily","fontSize","fontWeight","letterSpacing","lineHeight","textAlign"];function p(e,t,o={}){return new Promise((function(n){const r={...h,...t,...e.settings},s={time:0,frame:0,cycle:0},l="currentState";let d;r.restoreState&&(a(l,s),s.cycle++),r.element?"canvas"==r.renderer?"CANVAS"==r.element.nodeName?d=f[r.renderer]:console.warn("This renderer expects a canvas target element."):"CANVAS"!=r.element.nodeName?d=f[r.renderer]:console.warn("This renderer expects a text target element."):(d=f[r.renderer]||f.text,r.element=document.createElement(d.preferredElementNodeName),document.body.appendChild(r.element));for(const e of u)r[e]&&(r.element.style[e]=r[e]);const x=[],p={x:0,y:0,pressed:!1,px:0,py:0,ppressed:!1};r.element.addEventListener("pointermove",(e=>{const t=r.element.getBoundingClientRect();p.x=e.clientX-t.left,p.y=e.clientY-t.top,x.push("pointerMove")})),r.element.addEventListener("pointerdown",(e=>{p.pressed=!0,x.push("pointerDown")})),r.element.addEventListener("pointerup",(e=>{p.pressed=!1,x.push("pointerUp")})),r.element.style.fontStrech="normal",r.allowSelect||y(r.element),document.fonts.ready.then((t=>{let n=3;!function t(){--n>0?requestAnimationFrame(t):function(){M=b(r.element);const t=g(s,r,M,m);"function"==typeof e.boot&&e.boot(t,v,o),requestAnimationFrame(N)}()}()}));const m=new i,w=Object.freeze({color:r.color,backgroundColor:r.backgroundColor,fontWeight:r.fontWeight}),v=[];let M,S=0;const E=1e3/r.fps,C=s.time;let T,A;function N(t){const i=t-S;if(i0;){const t=x.shift();t&&"function"==typeof e[t]&&e[t](a,u,v)}r.once||requestAnimationFrame(N),n(a)}}))}function g(e,t,o,n){const r=t.element.getBoundingClientRect(),c=t.cols||Math.floor(r.width/o.cellWidth),s=t.rows||Math.floor(r.height/o.lineHeight);return Object.freeze({frame:e.frame,time:e.time,cols:c,rows:s,metrics:o,width:r.width,height:r.height,settings:t,runtime:Object.freeze({cycle:e.cycle,fps:n.fps})})}function y(e){e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.mozUserSelect="none",e.dataset.selectionEnabled="false"}function w(e){const t="false"==!e.dataset.selectionEnabled;t||function(e){e.style.userSelect="auto",e.style.webkitUserSelect="auto",e.style.mozUserSelect="auto",e.dataset.selectionEnabled="true"}(e);const o=document.createRange();o.selectNode(e);const n=window.getSelection();n.removeAllRanges(),n.addRange(o),document.execCommand("copy"),n.removeAllRanges(),t||y(e)}function b(e){const t=getComputedStyle(e),o=t.getPropertyValue("font-family"),n=parseFloat(t.getPropertyValue("font-size")),r=parseFloat(t.getPropertyValue("line-height"));let c;if("CANVAS"==e.nodeName){const t=e.getContext("2d");t.font=n+"px "+o,c=t.measureText("".padEnd(50,"X")).width/50}else{const t=document.createElement("span");e.appendChild(t),t.innerHTML="".padEnd(50,"X"),c=t.getBoundingClientRect().width/50,e.removeChild(t)}return{aspect:c/r,cellWidth:c,lineHeight:r,fontFamily:o,fontSize:n,_update:function(){const t=b(e);for(var o in t)"number"!=typeof t[o]&&"string"!=typeof t[o]||(m[o]=t[o])}}}export function vec2(e,t){return{x:e,y:t}}export function copy(e,t){return(t=t||vec2(0,0)).x=e.x,t.y=e.y,t}export function add(e,t,o){return(o=o||vec2(0,0)).x=e.x+t.x,o.y=e.y+t.y,o}export function sub(e,t,o){return(o=o||vec2(0,0)).x=e.x-t.x,o.y=e.y-t.y,o}export function mul(e,t,o){return(o=o||vec2(0,0)).x=e.x*t.x,o.y=e.y*t.y,o}export function div(e,t,o){return(o=o||vec2(0,0)).x=e.x/t.x,o.y=e.y/t.y,o}export function addN(e,t,o){return(o=o||vec2(0,0)).x=e.x+t,o.y=e.y+t,o}export function subN(e,t,o){return(o=o||vec2(0,0)).x=e.x-t,o.y=e.y-t,o}export function mulN(e,t,o){return(o=o||vec2(0,0)).x=e.x*t,o.y=e.y*t,o}export function divN(e,t,o){return(o=o||vec2(0,0)).x=e.x/t,o.y=e.y/t,o}export function dot(e,t){return e.x*t.x+e.y*t.y}export function length(e){return Math.sqrt(e.x*e.x+e.y*e.y)}export function lengthSq(e){return e.x*e.x+e.y*e.y}export function dist(e,t){const o=e.x-t.x,n=e.y-t.y;return Math.sqrt(o*o+n*n)}export function distSq(e,t){const o=e.x-t.x,n=e.y-t.y;return o*o+n*n}export function norm(e,t){t=t||vec2(0,0);const o=length(e);return o>1e-5?(t.x=e.x/o,t.y=e.y/o):(t.x=0,t.y=0),t}export function neg(e,t){return(t=t||vec2(0,0)).x=-a.x,t.y=-a.y,t}export function rot(e,t,o){o=o||vec2(0,0);const n=Math.sin(t),r=Math.cos(t);return o.x=e.x*r-e.y*n,o.y=e.x*n+e.y*r,o}export function mix(e,t,o,n){return(n=n||vec2(0,0)).x=(1-o)*e.x+o*t.x,n.y=(1-o)*e.y+o*t.y,n}export function abs(e,t){return(t=t||vec2(0,0)).x=Math.abs(e.x),t.y=Math.abs(e.y),t}export function max(e,t,o){return(o=o||vec2(0,0)).x=Math.max(e.x,t.x),o.y=Math.max(e.y,t.y),o}export function min(e,t,o){return(o=o||vec2(0,0)).x=Math.min(e.x,t.x),o.y=Math.min(e.y,t.y),o}export function fract(e,t){return(t=t||vec2(0,0)).x=e.x-Math.floor(e.x),t.y=e.y-Math.floor(e.y),t}export function floor(e,t){return(t=t||vec2(0,0)).x=Math.floor(e.x),t.y=Math.floor(e.y),t}export function ceil(e,t){return(t=t||vec2(0,0)).x=Math.ceil(e.x),t.y=Math.ceil(e.y),t}export function round(e,t){return(t=t||vec2(0,0)).x=Math.round(e.x),t.y=Math.round(e.y),t}const WIDTH=400,HEIGHT=400,NUM_AGENTS=3e3,MIN_CHEM=1e-4,SENS_ANGLE=45*Math.PI/180,SENS_DIST=9,AGT_SPEED=3,AGT_ANGLE=45*Math.PI/180,DEPOSIT=1;let textureGroup=[[" █╳^$"," █▒░^"],[" ┼█^$"," ▒░^╋"],[" `+^$"," █▒░^"],[" █▒░"," █▒░"],[" █░░░"," █░░░"],[" █▒▒▒"," █▒▒▒"],[" █▓▓▓"," █▓▓▓"],[" █▒░^"," █╳^$"]];const getRandomTexture=()=>{const e=Math.floor(Math.random()*textureGroup.length);return textureGroup[e]},updateTexture=()=>{const[e,t]=getRandomTexture();TEXTURE=[e,t],console.log("New Texture:",TEXTURE)},updateDecay=()=>{DECAY=.8*Math.random()+.1,console.log("New DECAY:",DECAY)};let TEXTURE=[],DECAY=.5;const OOB=" ",userTime=new Date,randomTimeInterval=Math.floor(9*Math.random())+6,textureInterval=1e3*randomTimeInterval*60/64;setInterval((()=>{updateTexture(),updateDecay()}),textureInterval),updateTexture(),updateDecay(),console.log("Initial Texture:",TEXTURE),console.log("Initial DECAY:",DECAY);export const settings={backgroundColor:"white",color:["yellowgreen","black","darkolivegreen","darkred","darkorange","darkblue","darkviolet"],fontSize:"12px",getRandomColor:function(e){const t=e%this.color.length;return this.color[t]}};function applyTknHsh2(e){var t=parseInt(e.slice(8,14),16);settings.color=settings.getRandomColor(t)}applyTknHsh2(externalTknHsh2);var tknHsh2=window.location.href.split("/").find((e=>e.includes("i0")))||"0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",hash=tknHsh2.slice(2),seed2=parseInt(hash.slice(6,12),16);settings.color=settings.getRandomColor(externalTknHsh2);export function boot(e,t,o){document.body.style.cursor="crosshair",o.chem=new Float32Array(16e4),o.wip=new Float32Array(16e4),o.agents=[];for(let e=0;e<3e3;e++)o.agents.push(new Agent(mulN(addN(mulN(randCircle(),.5),1),200),rot(vec2(1,0),2*Math.random()*Math.PI)));o.viewScale={y:100/e.metrics.aspect,x:100},o.viewFocus={y:.5,x:.5}}export function pre(e,t,o,n){for(let e=0;e<400;e++)for(let t=0;t<400;t++){let o=DECAY*blur(e,t,n.chem);o<1e-4&&(o=0),n.wip[400*e+t]=o}const r=n.chem;n.chem=n.wip,n.wip=r;const{chem:c,agents:s,view:l}=n,i=Math.sin(e.frame/150)>.8;for(const e of s)e.scatter=i,e.react(c);for(const e of s)e.deposit(c);updateView(t,e,n)}export function main(e,t,o,n,r){const{viewFocus:c,viewScale:s}=r,l=Math.floor(c.y*(400-s.y*t.rows)),i=Math.floor(c.x*(400-s.x*t.cols)),a={y:l+Math.floor(e.y*s.y),x:i+Math.floor(e.x*s.x)},u={y:l+Math.floor((e.y+1)*s.y),x:i+Math.floor((e.x+1)*s.x)};if(!bounded(a)||!bounded(u))return" ";const h=Math.max(1,u.y-a.y),f=Math.max(1,u.x-a.x);let d=0,x=0;for(let e=a.x;eo&&t>n?r=0:t