let numCells,cellSize,totalCells,fillPercent,cursors,selectedColorProfile,fee,blockNumber,inscriptionIncrementRate,applyGlitchEffect,colorInterval,errorTriggered=!1,showErrorAnimation=!1,savedGrid=[],showElements=!1,grid=[],maxSpan=4.5,rareMaxSpan=20,rareBlockProbability=.01,occupiedCount=0,glitchSquares=[],totalTransactions=0,totalGasSpent=0,totalGlitchSquares=0,lastFeeUpdate=0,nInscription=0,currentSeed=hashToSeed(txnhash),colorRange1=["#42c920","#082e00"],colorRange2=["#7fffd4","#0079c4"],colorRange3=["#f0c945","#91281b"],colorRange4=["#FF1300","#FF9200"],colorRange5=["#f4b41a","#16A085"],colorRange6=["#f4b41a","#f93800"],colorRange7=["#ff0173","#76f7b7","#087487"],colorRange8=["#c2403e","#f0c945","#4280be"],colorRange10=["#eb1933","#2151a1","#ffffff"],colorRange9=["#131b25","#2357b4"],colorRange11=["#eb09c1","#8906ba"],colorRange12=["#cdff01","#330066","#ff33cc"],colorRange13=["#690d44","#8c0c5d","#ad2061"],colorRange14=["#d12a2f","#fbf9f5"],group1=[{profile:colorProfile1,probability:.22},{profile:colorProfile2,probability:.12},{profile:colorProfile3,probability:.17},{profile:colorProfile4,probability:.23},{profile:colorProfile9,probability:.19},{profile:colorProfile11,probability:.07}],group2=[{profile:colorProfile5,probability:.44},{profile:colorProfile14,probability:.12},{profile:colorProfile6,probability:.44}],group3=[{profile:colorProfile8,probability:.45},{profile:colorProfile10,probability:.1},{profile:colorProfile13,probability:.45}],group4=[{profile:colorProfile7,probability:.5},{profile:colorProfile12,probability:.5}];function hashToSeed(o){let e=0;for(let r=0;r<o.length;r++){e=(16*e+o.charCodeAt(r))%2147483647}return e}function shouldActivateSuperglitch(o){return(sin(o)+1)/2<.02}function setup(){let o=720;createCanvas(o,o),background(0);let e=createCanvas(o,o);background(0),e.parent("sketch-holder"),randomizeColor=shouldActivateSuperglitch(currentSeed),void 0===currentSeed&&(currentSeed=hashToSeed(txnhash)),randomSeed(currentSeed);for(let o=0;o<numCells;o++)savedGrid[o]=[...grid[o]];let r=[];for(let o=0;o<numCells;o++){let e=map(o,0,numCells,0,width);r.push(e)}let l=[color(225,0,0),color(100,0,40)],t=[color(0,60,0),color(0,130,0)],n=[color(8,8,180),color(49,0,240)],i=[color(194,131,0),color(255,113,0)],a=[color(75,0,130),color(180,6,180)],c=[color(50,45,45),color(60,55,55)],f=[color(210,210,210),color(240,240,240)],s=random();glitchInterval=s<.13?l:s<.35?t:s<.51?n:s<.71?i:s<.87?a:s<.92?c:f,fee=random(42,690),applyGlitchEffect=random(1)<1,blockNumber=floor(random(89e4,4000001)),inscriptionIncrementRate=4,resetValues(),numCells=o/7,cellSize=width/numCells,stroke(0),strokeWeight(2),grid=[];for(let o=0;o<numCells;o++){grid[o]=[];for(let e=0;e<numCells;e++)grid[o][e]=!1}totalCells=numCells*numCells,occupiedCount=0,cursors=new Array(200).fill().map((o=>({x:floor(random(numCells)),y:0,updateInterval:assignSpeedProfile(),startOffset:0}))),glitchSquares=[],selectColorProfile(),selectFillPercent(),selectGlitchProbProfile(),applyFillProfile(),setupElements()}function applyFillProfile(){const o=random();if(o<.06)maxSpan=1,rareMaxSpan=7;else if(o<.26)maxSpan=3,rareMaxSpan=20;else if(o<.76)maxSpan=6,rareMaxSpan=60;else if(o<.93)maxSpan=20,rareMaxSpan=60;else{maxSpan=1,rareMaxSpan=200;const o=Math.random()*(1.2-1.8)+.8;maxSpan*=o,rareMaxSpan*=o}}function assignSpeedProfile(){let o=random();return o<.93?floor(random(10,20)):o<.066?floor(random(5,8)):floor(random(8,10))}function assignSpeedProfile(){let o=random();return o<.03?floor(random(1,2)):o<.8?floor(random(2,10)):floor(random(20,40))}function selectColorProfile(){let o,e=random();o=e<.7?group1:e<.85?group2:e<.96?group3:group4;let r=random(),l=0;for(let e=0;e<o.length;e++)if(l+=o[e].probability,r<l){selectedColorProfile=o[e].profile;break}}function selectFillPercent(){let o=random();fillPercent=o<.01?.55:o<.02?.7:o<.15?.85:99}function selectGlitchProbProfile(){let o=random();probGlitch=o<.05?0:o<.17?.1:o<.42?.25:o<.64?.45:o<.79?.6:o<.89?.75:o<.98?.9:.99}function drawGlitchEffect(){let o="Censored",e=height-.075*height+12;push(),textFont("Fira Code"),textSize(12),fill(155);for(let r=0;r<8;r++){let l=600+r*textWidth(o.charAt(r)),t=random(-10,10);text(o.charAt(r),l+t,e),random()<.03&&(fill(220),rect(l+random(-40,20),e-10,random(50,20),10))}pop()}function drawGlitchBlockNumber(){let o=`${blockNumber}`,e=height-.025*height+12;push(),textFont("Fira Code"),textSize(12),fill(255);for(let r=0;r<o.length;r++){let l=490+r*textWidth(o.charAt(r)),t=random(-10,10);text(o.charAt(r),l+t,e),random()<.03&&(fill(220),rect(l+random(-10,10),e-10,random(10,10),10))}pop()}function displayErrorAnimation(){fill(0,0,0,2),rect(0,0,width,height),fill(205,0,0),textSize(40),textAlign(CENTER,CENTER);let o="ERROR:\nBlock suppressed\nby [redacted]",e=width/2,r=height/2;text(o,e,r),applyGlitchyEffect(e,r,o)}function applyGlitchyEffect(o,e,r){for(let l=0;l<3;l++){let l=random(0,5),t=random(0,.5);fill(255,255,255,200),textSize(40+random(0,.5)),text(r,o+l,e+t)}}function draw(){!errorTriggered&&frameCount>120&&(errorTriggered=!0,random()<.009&&(showErrorAnimation=!0)),showErrorAnimation?displayErrorAnimation():(cursors.forEach((o=>{frameCount%o.updateInterval==0&&occupiedCount/totalCells<fillPercent&&(o.x<numCells?drawSquare(o):(o.x=floor(random(numCells)),o.y=0))})),updateGlitchSquares(),showElements&&(drawElements(),drawGlitchEffect(),drawGlitchBlockNumber()),swapSquareColors())}function updateGlitchSquares(){glitchSquares.forEach((o=>{fill(0),rect(o.x*cellSize,o.y*cellSize,o.span*cellSize,o.span*cellSize);for(let e=0;e<o.span;e++)for(let r=0;r<o.span;r++)if(random(1)<.005){let l=randomizeColor?color(random(255),random(255),random(255)):lerpColor(glitchInterval[0],glitchInterval[1],random(1));stroke(l),point((o.x+e+random(-.005,.005))*cellSize,(o.y+r+random(-.005,.005))*cellSize)}frameCount%o.speed==0&&drawNoiseOverlay(o.x,o.y,o.span)}))}function drawSquare(o){for(;o.x<numCells&&grid[o.x][o.y];)o.y++,o.y>=numCells&&(o.y=0,o.x++),totalTransactions++;if(o.x<numCells){let e;e=random()<rareBlockProbability?floor(random(maxSpan,rareMaxSpan+1)):floor(random(1,maxSpan+1));let r=!0;for(let l=o.x;l<o.x+e&&l<numCells;l++){for(let t=o.y;t<o.y+e&&t<numCells;t++)if(grid[l][t]){r=!1;break}if(!r)break}if(r){totalGasSpent+=e*e*fee*4;let r=8,l=.08;if(random()<probGlitch||e>=r&&random()<l)createGlitchSquare(o.x,o.y,e,selectedColorProfile);else{let r=getColorForPosition(o.x,o.y);fill(r),rect(o.x*cellSize,o.y*cellSize,e*cellSize,e*cellSize)}for(let r=o.x;r<o.x+e&&r<numCells;r++)for(let l=o.y;l<o.y+e&&l<numCells;l++)grid[r][l]=!0,occupiedCount++}o.y++,o.y>=numCells&&(o.y=0,o.x++)}}function getRandomColorFromRange(o){let e=color(o[0]),r=color(o[1]);return lerpColor(e,r,random())}function drawNoiseOverlay(o,e,r){for(let l=0;l<r;l++)for(let t=0;t<r;t++)fill(random(255)),rect((o+l)*cellSize,(e+t)*cellSize,cellSize,cellSize)}function getColorForPosition(o,e){return selectedColorProfile(o,e)}function colorProfile1(o,e){return createGradientColor(o,e,colorRange1[0],colorRange1[1])}function colorProfile2(o,e){return createGradientColor(o,e,colorRange2[0],colorRange2[1])}function colorProfile3(o,e){return createGradientColor(o,e,colorRange3[0],colorRange3[1])}function colorProfile4(o,e){return createGradientColor(o,e,colorRange4[0],colorRange4[1])}function colorProfile9(o,e){return createGradientColor(o,e,colorRange9[0],colorRange9[1])}function colorProfile11(o,e){return createGradientColor(o,e,colorRange11[0],colorRange11[1])}function createGradientColor(o,e,r,l){let t=map(e,0,numCells,1,0),n=color(r),i=color(l);return lerpColor(i,n,t)}function createGlitchSquare(o,e,r,l){getColorRangeForProfile(l);totalTransactions++,totalGasSpent+=r*r*fee;let t=Array(3).fill().map((()=>getRandomColorFromProfile(o,e))),n=floor(random(100,19100));glitchSquares.push({x:o,y:e,span:r,colorIndex:0,colors:t,offsetX:0,speed:n}),totalGlitchSquares++}function getRandomColorFromProfile(o,e){return getColorForPosition(o,e)}function getColorRangeForProfile(o){return o===colorProfile1?colorRange1:o===colorProfile2?colorRange2:o===colorProfile3?colorRange3:colorRange4}function swapSquareColors(){if(frameCount%90==0&&random()<.52){let o=findRandomSquare(),e=findRandomSquare(o.span);if(o&&e){let r=o.color;o.color=e.color,e.color=r}}}function findRandomSquare(o=null){let e=grid.flat().filter((e=>e&&(!o||e.span===o)));return e.length>0?random(e):null}function resetValues(){totalTransactions=0,totalGasSpent=0,totalGlitchSquares=0,nInscription=0;for(let o=0;o<numCells;o++)grid[o]=[...savedGrid[o]]}function keyPressed(){"R"===key||"r"===key?window.location.reload():"D"!==key&&"d"!==key||(showElements?window.location.reload():showElements=!0)}function colorProfile5(o,e){return noise(.1*o,.1*e)<.55?color(colorRange5[0]):color(colorRange5[1])}function colorProfile6(o,e){return noise(.1*o,.1*e)<.5?color(colorRange6[0]):color(colorRange6[1])}function colorProfile7(o,e){let r=noise(.1*o,.1*e);return r<.33?color(colorRange7[0]):r<.66?color(colorRange7[1]):color(colorRange7[2])}function colorProfile8(o,e){let r=noise(.1*o,.1*e);return r<.33?color(colorRange8[0]):r<.66?color(colorRange8[1]):color(colorRange8[2])}function colorProfile9(o,e){return createGradientColor(o,e,colorRange9[0],colorRange9[1])}function colorProfile10(o,e){let r=noise(.1*o,.1*e);return r<1/3?color(colorRange10[0]):r<2/3?color(colorRange10[1]):color(colorRange10[2])}function colorProfile12(o,e){let r=noise(.1*o,.1*e);return r<.5?color(colorRange12[0]):r<3.5/6?color(colorRange12[1]):color(colorRange12[2])}function colorProfile13(o,e){let r=noise(.1*o,.1*e);return r<1/3?color(colorRange13[0]):r<2/3?color(colorRange13[1]):color(colorRange13[2])}function colorProfile14(o,e){return noise(.1*o,.1*e)<.6?color(colorRange14[0]):color(colorRange14[1])}function setupElements(){}function drawElements(){if(showElements){fill(0),rect(0,height-.1*height,width,.2*height),textSize(12.5),textFont("Fira Code"),fill(255);let o=millis();o-lastFeeUpdate>1e3&&(fee=random(20,251),lastFeeUpdate=o),displayInfo()}}function displayInfo(){text(`Tot Txn: ${totalTransactions}`,10,height-.075*height+12),text(`Average Txn Fees: ${fee.toFixed(2)}`,200,height-.075*height+12),text(`Total Fees: ${totalGasSpent.toFixed(2)} sats`,400,height-.075*height+12),text(`                 : ${totalGlitchSquares}`,600,height-.075*height+12);let o=(occupiedCount/totalCells*100).toFixed(2)+"%";nInscription=floor(occupiedCount/inscriptionIncrementRate),text(`Block Seize: ${o}`,10,height-.025*height+12),text(`Tot Inscriptions: ${nInscription}`,200,height-.025*height+12),text(`Block Number: ${blockNumber}`,400,height-.025*height+12)}