0x8558…5972

All memos sent from and to 0x8558…5972.

Ii=!1,Ni=!1;function Ui(){F.save(),F.scale(D,D),Ni||(F.fillStyle="#FFF",F.rect(0,0,Y,P),F.fill(),Ni=!0)}function Di(){F.restore()}function Oi(){Ni=!1}function Bi(e,t="red",n=!0){if(e.length){Ui(),F.beginPath(),F.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)F.lineTo(e[t].x,e[t].y);F.closePath(),F.lineCap="round",n?(F.fillStyle=t,F.fill()):(F.lineWidth=3,F.strokeStyle=t,F.stroke()),Di()}}function Qi(e,t="red",n=!1,l=1){Ui(),F.beginPath(),F.lineCap="round",F.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)F.lineTo(e[t].x,e[t].y);n&&F.closePath(),F.lineWidth=l,F.strokeStyle=t,F.stroke(),Di()}function ji(){Oi();for(let e of[...hn,...Si])if(e.category==mn.foreground){let t=e?.detailObjectProps?.inDominantShapes?.length>0;Bi(e.polygon,t?"blue":"red",!0),Bi(e.polygon,"black",!1)}return!1}function Ji(){Oi();for(let e of[...hn,...Si])if(e.category==mn.foreground){let t=tl(e.detailObject?.[0].lineColor||[0,0,0]);Bi(e.polygon,t,!0),Bi(e.polygon,"black",!1)}return!1}function Ai(){Oi();for(let e of[...hn,...Si])if(e.category==mn.foreground){let t=e.lightingIntensity||Ie.default,n=fe(t,Ie.min,Ie.max,0,255);Bi(e.polygon,`rgba(${n},${n},${n},1)`,!0)}return!1}function Ei(){Oi();for(let e of[...hn,...Si])if(e.category==mn.foreground&&Bi(e.polygon,"black",!1),e?.detailObject?.length)for(let t of e.detailObject)for(let e of t.lines)Qi(e.map((e=>new Ut(...e))),"black",!1,.5);return!1}function _i(){return Oi(),Wi&&Wi.getAllLines().forEach((e=>{Qi(e.line.map((e=>(new ie).fromArray(e))),"black",e.meta.isClosed)})),!1}function qi(){return Oi(),Gi&&Gi.internalFaces().forEach(((e,t)=>{Bi(e.vertexlist,`rgba(${J.num(0,255)},${J.num(0,255)},${J.num(0,255)},0.9)`)})),!1}let $i=!1;function ea(e){let{verts:t,parentSvg:n,strokeColor:l="black",strokeWidth:i=1,className:a="path",isClosed:s=!1}=e,o=`M ${t[0].x} ${t[0].y}`;for(let e=1;e<t.length;e++)o+=` L ${t[e].x} ${t[e].y}`;s&&(o+=" Z");const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",o),r.setAttribute("fill","none"),r.setAttribute("stroke",l),r.setAttribute("stroke-width",i.toString()),r.setAttribute("class",a),n.appendChild(r),r}let ta=()=>{let e=document.querySelector("svg");e?($i=!1,e.remove(),R()):(k(),e=(()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",O+"px"),e.setAttribute("height",B+"px"),e.setAttribute("style","position: relative; background-color: white;"),e.setAttribute("viewBox",`0 0 ${Y} ${P}`),e.setAttribute("preserveAspectRatio","xMinYMin meet"),e.setAttribute("xmlns","http://www.w3.org/2000/svg");let t=[[new Ut(0,5),new Ut(0,0),new Ut(5,0)],[new Ut(0,P-5),new Ut(0,P),new Ut(5,P)],[new Ut(Y-5,0),new Ut(Y,0),new Ut(Y,5)],[new Ut(Y-5,P),new Ut(Y,P),new Ut(Y,P-5)]];for(let n=0;n<t.length;n++)ea({verts:t[n],parentSvg:e,strokeWidth:2,className:"marker",isClosed:!1,strokeColor:"rgb(1, 0, 0)"});for(let t of[...Si,...hn])if(t.category==mn.foreground){if(ea({verts:t.polygon,parentSvg:e,strokeWidth:2,className:"outline",isClosed:!0,strokeColor:t?.detailObjectProps?.inDominantShapes?.length>0?"rgb(0, 0, 0)":"rgb(1, 1, 1)"}),!t?.detailObject?.length)continue;for(let n of t?.detailObject)if("detail"===n.type)for(let t of n?.lines)ea({verts:t.map((e=>new Ut(...e))),parentSvg:e,strokeWidth:1,className:"detail",strokeColor:"rgb(5, 5, 5)"})}else if(t.category==mn.walker){if(!t?.detailObject?.length)continue;for(let n of t.detailObject)for(let t of n.lines)ea({verts:t.map((e=>new Ut(...e))),parentSvg:e,strokeWidth:4,className:"topline",isClosed:!1,strokeColor:"rgb(10, 10, 10)"})}else if(t.category==mn.overlay){let n=2;for(let l=0;l<n;l++)ea({verts:t.polygon,parentSvg:e,strokeWidth:2,className:"oerlay",isClosed:!0,strokeColor:"rgb(15, 15, 15)"})}return e})(),document.body.appendChild(e),$i=!0)},na=!1;const la=()=>{Fi()[Hi]()?(H(),R()):(k(),M.style.display="block"),Ii=!Ii,Hi=(Hi+1)%Fi().length},ia=()=>{na=!na};var aa;document.complete=!1,(()=>{let n=new URL(window.location.href),l=n.searchParams.get("noFrame");const{innerWidth:i,innerHeight:a}=window;if(l&&(E=0,globalThis.document.body.classList.add("noFrame")),n.searchParams.get("unlockAspect")){let e=N/(i/a);N=i/a,e>1&&(I=a/i*(I-400)),E=0,globalThis.document.body.classList.add("noFrame")}S=document.createElement("canvas"),S.style.backgroundColor="#000",w=S.getContext("webgl2",{colorSpace:"display-p3",preserveDrawingBuffer:!0,stencil:!1,alpha:!1,premultipliedAlpha:!1}),X=new e.WebGLRenderer({canvas:S,context:w,preserveDrawingBuffer:!0,precision:"highp",alpha:!1,premultipliedAlpha:!1,antialias:!1,stencil:!1,depth:!0,powerPreference:"high-performance"}),K=!!w.getExtension("OES_texture_float_linear"),w.getParameter(w.MAX_UNIFORM_BLOCK_SIZE),X.setClearColor(new e.Color(1,1,1),1),C=X.capabilities.maxTextureSize,V=X.capabilities.getMaxAnisotropy(),X.shadowMap.enabled=!0,X.outputColorSpace=e.DisplayP3ColorSpace,X.shadowMap.type=e.PCFSoftShadowMap,document.body.appendChild(S),M=document.createElement("canvas"),M.style.backgroundColor="#000",z=M.style,F=M.getContext("2d",{alpha:!1,colorSpace:"display-p3"}),document.body.appendChild(M),H(),Y=t(I*N),P=t(I);let s=E/100*o(i,a);i<a*N?(B=t(1/N*(i-s)),O=t(i-s)):(B=t(a-s),O=t((a-s)*N)),X.setSize(O,B),X.setPixelRatio(U),Q=O*U,j=B*U,((e,t)=>{M.width=e,M.height=t,z.width=O+"px",z.height=B+"px"})(Q,j),D=Q/Y})(),aa=$(),J=new _(aa||""),(()=>{let t=document.createElement("a");addEventListener("keydown",(n=>{if("s"===n.key&&$i){let e=document.querySelector("svg");if(!e)return;let n=A+".svg";t.setAttribute("download",n);const l=new Blob([e.outerHTML],{type:"image/svg+xml"});t.href=URL.createObjectURL(l),t.click()}else if("s"===n.key){let e=A+".png";se.countX>1&&(e=`${A}-${se.index.x}-${se.index.y}.png`),t.setAttribute("download",e),S.toBlob((e=>{t.href=URL.createObjectURL(e),t.click()}))}"Space"===n.code&&ia(),"x"===n.key&&function(){v({showUpdate:!0,message:"Sending Data Buffer",value:A});let t=new e.WebGLRenderTarget(Q,j,{anisotropy:V,colorSpace:e.DisplayP3ColorSpace,minFilter:e.LinearFilter,magFilter:e.LinearFilter,format:e.RGBAFormat,type:e.FloatType,internalFormat:"RGBA32F"});Yt(Ft.getReadBuffer().texture,t);const n=new Float32Array(Q*j*4);X.readRenderTargetPixels(t,0,0,Q,j,n);let l=""+A;se.countX>1&&(l=`${A}-tiled-${se.index.x}-${se.index.y}`),void 0!==window?.electronAPI?.sendPixelData?window.electronAPI.sendPixelData({buffer:Buffer.from(n.buffer),width:Q,height:j,filename:l}):window.framebuffer=n,setTimeout((()=>{L()}),1e3)}(),"v"===n.key&&(Ii&&la(),ta()),"d"===n.key&&($i&&ta(),la())}))})(),document.metaData=(()=>{ke=[J.num(-1,1),J.num(-1,1)];for(let e=0;e<1e3;e++)He.push(J.dec());Re=J.choice(ue),rt=Re.bg[0][0]<.5,J.weightedChoice([20,Gt],[rt?0:1,Wt])();let e={"Genome base":yt||ot,Palette:Re.name,Mutated:"none"!==et.mutation};const t=[{name:"Name",value:ot},{name:"Meta",value:e},{name:"Divisions",value:it},{name:"Division Props",value:nt},{name:"Line Removal",value:at},{name:"Division Chances",value:Object.fromEntries(Object.entries(Ee).map((([e,t])=>[Se[Number(e)],t])))},{name:"lighting",value:Ie},{name:"color props",value:et},{name:"topLines",value:Ne},{name:"dominantLines",value:Oe},{name:"fillStyles",value:je},{name:"detailStyles",value:Qe},{name:"constructionLineProps",value:Ae},{name:"sceneObjects",value:Ue},{name:"colorProps",value:et},{name:"curveProps",value:qe},{name:"fillMargin",value:tt},{name:"grid",value:Be}];for(let e of t);return e})(),S.addEventListener("click",(e=>{let t=e.clientX,n=e.clientY,l=S.getBoundingClientRect();t-=l.left,n-=l.top;let i=new Ut(t*U/D,n*U/D);for(let e of[...hn,...Si])e.category==mn.foreground&&In(e.polygon,i)})),ci();
ion:i,maxPointUse:a,layers:s,maxLinePoints:o,pointsToConsider:r,insetMult:c}=qe,d=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.objects&&e.meta.isClosed&&J.bool(50))).map((e=>Dn(e.line.map((e=>new Ut(...e))))));for(let u=0;u<s;u++){let s=function(t,l){return yn(t,l,0,400,e,e*n)},u=Ae.margin+e*c,h=Ae.margin+e*c,m=new pi({maxDist:e*n,bounds:{topLeft:Bt(new Ut(u,h)).toArray(),bottomRight:Bt(new Ut(Y-u,P-h)).toArray()},noiseField:s,seedPoints:d}),p=m.generate();for(let e of p)yield;let b,g=m.kTree,f=[],x=new Set,Z=new Map,y=e=>{x.add(b);let t=Z.get(e)||0;Z.set(e,t+1),Z.get(e)>=a&&g.remove(e)};for(;!(g.count<=0);){if(!b){let e={point:new Ut(J.num(0,Y),J.num(0,P)),minDist:1/0};b=g.findNearest(e),y(b)}let e=J.choice(g.findKNearest(b,r).filter((e=>!x.has(e)&&e.point.distanceTo(b.point)<b.minDist*l)));!e||x.size>=o||g.count<=0?(f.push([...x].map((e=>e.point))),x=new Set,b=null):(b=e,y(b))}let G=[];for(let e of f){if(e.length<3)continue;let t=Zi(xi(e,{tension:J.num(i.min,i.max),cyclic:!1}),6,!1).map((e=>new Ut(e.x,e.y)));G.push(t)}for(let n of G){if(n.length<3)continue;let l=hi(n.map((e=>e.toArray())),J.int(e*(1-t),e*(1+t)),120);Xi.push({line:l,id:Jn(),meta:{lineCategory:Se.curves,isClosed:!0}}),Wi.addLine(l,{lineCategory:Se.curves,isClosed:!0})}}}],[function*(){for(let e=0;e<Ue.layers;e++){let{maxDist:t,minDist:n,bnFreq:l,minSizeMult:i,maxSizeMult:a,fieldFreq:s,maxSides:o,minSides:r,clampRotationTo:c,layerScaleMult:d,perspective:u}=Ue,h=0==e?1:e*d,m=Ue.cropTo==Ce.border?Li:Ue.cropTo==Ce.scene?[[0,0],[Y,P]]:null,p=null;null!==m&&(p=new dn,p.expandsByPoint(m));let b=function(e,i){return yn(e,i,0,l,n*h,t*h)},g=new pi({maxDist:t*h,bounds:{topLeft:Li[0],bottomRight:Li[2]},noiseField:b}).generate(),f=J.num(150,300)*J.choice([-1,1]),x=40;for(let t of g){let n=Ue.forceYUp?0:yn(t.point.x,t.point.y,1e3,s,-40,x),l=yn(t.point.x+1e3,t.point.y+1e3,2e3,s,-(x+f),x+f),d=Ue.forceYUp?0:yn(t.point.x-1e3,t.point.y-1e3,-1e3,s,-40,x),h={w:i,h:i,d:i},m={w:a,h:a,d:a},b=J.weightedChoice([1,"w"],[3,"h"],[0,"d"]),g=J.weightedChoice([1,1],[3,2],[1,3]);h[b]*=g,m[b]*=g;let Z=Mi({sides:J.easedInt(ve,r,o),perspectiveCenter:vi,perspectiveStrength:u,width:J.num(t.minDist*h.w,t.minDist*m.w),height:J.num(t.minDist*h.h,t.minDist*m.h),depth:J.num(t.minDist*h.d,t.minDist*m.d*(0==e?Ue.zDepthMaxMult:1)),center:[t.point.x,t.point.y],rotationProps:{x:xe(n,c),y:xe(l,c),z:xe(d,c)}}),y=J.int(0,1e10),G=Z.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0);Z.faces=Z.faces.filter((e=>null===p||!e.vertices.some((e=>!p.containsPoint(new Ut(...e))))));for(let e of Z.faces)e.vertices=e.vertices.map((t=>{if(!(t[0]>=Li[0][0]&&t[1]>=Li[0][1]&&t[0]<=Li[2][0]&&t[1]<=Li[2][1]))return t;let n=new dn;n.expandsByPoint(e.vertices),n.expandByValue(20);let l=Wi.getLinesIntersectingOrContainedWithinAABB(n).filter((e=>{let t=e.meta.lineCategory;return t==Se.horizontal||t==Se.vertical||t==Se.perspective}));if(!l.length)return t;let i=l.reduce(((e,n)=>Ln(t,e.line)<Ln(t,n.line)?e:n),l[0]);return vn(t,i.line)}));for(let e of Z.faces)Ki.addPolygon(e.vertices,{category:"face",meta:{id:y,lightingIntensity:e.lighting,normal:e.normal,area:Un(e.vertices.map((e=>new Ut(...e)))),totalArea:G}});wi.push(Z),yield{showUpdate:!0,message:"Generating Scene",isPercent:!1,value:""}}}let e=Ki.getAllPolygons();const n=e.map((e=>e.meta.meta.lightingIntensity));let l,i;if(n.length>4){const e=[...n].sort(((e,t)=>e-t)),a=e[t(.25*e.length)],s=e[.75*t(e.length)],o=s-a,r=a-2*o,c=s+2*o,d=n.filter((e=>e>=r&&e<=c)),u=d.length>=2?d:n;l=.9*Math.min(...u),i=Math.max(...u)}else l=.9*Math.min(...n),i=Math.max(...n);e.forEach((e=>{const t=e.meta.meta.lightingIntensity;let n=ye(t,l,i,0,1),a=ye(We(n),-0,1,Ie.min,Ie.max);e.meta.meta.lightingIntensity=a}));for(let t of e){let e={line:t.verts,id:Jn(),meta:{lineCategory:Se.objects,id:t.meta.meta.id,isClosed:!0}};Xi.push(e),Wi.addLine(t.verts,e.meta)}}],[function*(){let e=yi.internalFaces().sort(((e,t)=>t.area-e.area))[0],n=e.area,l=n,i=e,s=new Set,r=_e;for(Ee[Se.objects]>0&&r.push(Se.objects);l/n>.95+g;){let e=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.vertical||e.meta.lineCategory==Se.horizontal)),t=J.choice(e);yi.splitFaceByPolyLine(i,t.line,t.meta.isClosed,!1),s.add(t),i=yi.internalFaces().sort(((e,t)=>t.area-e.area))[0],l=i.area,yield{showUpdate:!0,message:"Searching for initial structure",isPercent:!0,value:o(.95*n/l*100,100)}}yi.cleanupTrailingEdges();let c=!0,d=new Map;for(let e=0;e<it;e++){if(e%t(it/5)==0&&e>0&&e<t(it-it/5)){let e=new Ql(yi,.75).findDominantPaths(),t=[];for(let n of e)t.push(n);[...t.filter((e=>e.curviness>.02)).sort(((e,t)=>t.length-e.length)).slice(0,2),...t.filter((e=>e.curviness<.02)).sort(((e,t)=>t.length-e.length)).slice(0,2)].forEach((e=>{let t=e.vertices;if(c){for(let e=1;e<t.length-2;e++){let n=[t[e],t[e+1]],l=yi.findHedge(n[0].x,n[0].y,n[1].x,n[1].y);l?.face?.area>0&&yi.removeEdge(n[0].x,n[0].y,n[1].x,n[1].y)}c=!1}else{let e=[t[0],t[1]],n=e[0].distanceTo(e[1]);for(let l=1;l<t.length-2;l++){let i=t[l].distanceTo(t[l+1]);i>n&&(e=[t[l],t[l+1]],n=i);let a=yi.findHedge(e[0].x,e[0].y,e[1].x,e[1].y);a?.face?.area>0&&a.twin.face?.area>0&&yi.removeEdge(e[0].x,e[0].y,e[1].x,e[1].y)}}})),yi.cleanupDegenerateHoles(),yi.cleanupTrailingEdges(),Ri.clear()}yi.cleanupTrailingEdges(),yi.insertPolygon(Li,!0);let l,i=yi.internalFaces();Ri.update(i);let s=Ri.topN(1e3).filter((e=>!Ti.has(e.id))),o=[];for(let e of s){let t=new kn([],[]);t.insertPolygon(e.vertexlist.map((e=>e.toArray())),!0);let i=t.faces[0],a=new Set,s=()=>{const n=[];for(let l=0;l<o.length;l++){const s=o[l];if(a.has(s.constructionLine.id))continue;const r=s.constructionLine.meta.lineCategory,c=s.constructionLine.meta.lineSubCategory;if(Pi(r,e.aabb.center,Ee[r],c)<=0)continue;const d=s.constructionLine.line;let u=s?.constructionLine?.meta?.aabb;if(u||(u=new dn,u.expandsByPoint(d),s.constructionLine.meta.aabb=u),!e.aabb.intersects(u))continue;const h=s?.constructionLine?.meta?.isClosed,m=t.splitFaceByPolyLine(i,d,h,!0);m?.lines?.length>0&&m?.intersectionCount>=2&&n.push(s)}o=n},r=e,c=n/10;if(e.area>c){let t=100,n=new dn;for(n.expand(e.center);!o.length&&n.area<c&&n.area<e.area;){n.expandByValue(t),o=Wi.linesIntersectingAABB(n),t+=50,s();for(let e of o)a.add(e.constructionLine.id)}}if(o.length||(o=Wi.getLinesIntersectingFace(r,!1),s()),o.length>0){l={face:e,intersecting:o},t.dispose();break}}if(!l)break;let{face:r,intersecting:h}=l,m=new Map;Object.values(Se).forEach((e=>{"string"!=typeof e&&0!=Ee[e]&&m.set(e,h.filter((t=>{let n=t.constructionLine.meta;return n.lineCategory===e&&!(n.unableToSplitFaces&&n.unableToSplitFaces.has(r.id))})))}));let p=[];if(m.forEach(((e,t)=>{if(!e.length)return;let n=Pi(t,r.aabb.center,Ee[t]);if(n>0)if(e.some((e=>e.constructionLine.meta?.lineSubCategory))){let n=new Map;e.map((e=>{let t=e.constructionLine.meta.lineSubCategory;n.has(t)?n.get(t).push(e):n.set(t,[e])}));for(let[e,l]of n){let n=Pi(t,r.aabb.center,Ee[t],e);p.push([n,l.reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-g?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])}}else p.push([n,e.reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-g?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])})),st>0){let e=h.filter((e=>e.constructionLine?.meta?.used&&!e.constructionLine?.meta?.unableToSplitFaces?.has(r.id)&&e.constructionLine.meta.lineCategory==Se.objects)).reduce(((e,t)=>{let n=Ln(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance?{distance:n,line:t}:e}),{distance:1/0,line:null}).line;e&&p.push([Pi(Se.used,r.aabb.center,st),e])}if(p=p.filter((e=>e[1])),0==p.length){Ti.add(r.id);continue}let b=J.weightedChoice(...p),f=yi.splitFaceByPolyLine(r,b.constructionLine.line,b.constructionLine.meta.isClosed,!1,J.bool(nt.longestSplitOnlyChance));if(f&&(b.constructionLine.meta.used=!0),!f&&(d.set(r.id,(d.get(r.id)||0)+1),e--,!b.constructionLine.meta.unableToSplitFaces&&(b.constructionLine.meta.unableToSplitFaces=new Set),b.constructionLine.meta.unableToSplitFaces.add(r.id),d.get(r.id)>5)){let e=yi.faces.find((e=>e.id==r.id));for(let t of e.hedges.filter((t=>t.face==e)))yi.removeEdge(t.origin.x,t.origin.y,t.twin.origin.x,t.twin.origin.y);yi.cleanupTrailingEdges()}yield{showUpdate:!0,message:"Composing",isPercent:!0,value:t(100*(u=e/it,1-a(1-u,3)))}}var u}],[function*(){wi.sort(((e,t)=>e.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0)-t.faces.reduce(((e,t)=>e+Un(t.vertices.map((e=>new Ut(...e))))),0))),wi=ll(wi.slice(t(wi.length/4),n(wi.length/4*2)));for(let e=0;e<wi.length;e++){if(J.bool(100-De.forceInsertObjectsChance))continue;let t=wi[e];for(let e of t.faces)J.bool(50)||(yi.insertPolygon(e.vertices,!0),J.bool(50)&&yi.removeEdgesInsidePolygon(e.vertices))}let e=Xi.filter((e=>e.meta.lineCategory==Se.curves)).sort(((e,t)=>{let n=Un(e.line.map((e=>new Ut(...e))));return Un(t.line.map((e=>new Ut(...e))))-n}));for(let n=0;n<e.length;n++){if(J.bool(100-De.forceInsertCurvesChance))continue;let l=e[n];n<t(e.length/10)&&(yi.insertPolygon(l.line,!0),yi.removeEdgesInsidePolygon(l.line,10))}}],[function*(){let e=yi.internalFaces().filter((e=>e.area>1)),n=e.length*at;for(let l=0;l<n&&!(e.length<10);l++){let i=J.choice(e.sort(((e,t)=>{const n=e.area-t.area;return Math.abs(n)<g?e.id-t.id:n})).slice(0,100));if(!i)continue;let a=i.hedges.filter((e=>e.twin&&e.face!==e.twin.face&&e.twin.face.area>0&&e.face.area>0)),s=J.choice(a);s&&yi.removeEdge(s.origin.x,s.origin.y,s.twin.origin.x,s.twin.origin.y),yi.cleanupTrailingEdges(),e=yi.internalFaces().filter((e=>e.area>1)),yield{showUpdate:!0,message:"Deconstructing",isPercent:!0,value:t(l/n*100)}}}],[function*(){yi.insertPolygon(Li,!0)}],[function*(){let e=new Ql(yi,.4).findDominantPaths();for(let t of e)Ci.push(t),yield{showUpdate:!0,message:"Walking Paths",isPercent:!1,value:Ci.length}}],[function*(){Gi=new kn(Li,[[0,1],[1,2],[2,3],[3,0]]);let e=Oe.meshDensity,t=Gi.internalFaces()[0].area;Gi.dispose();let n=P/15,l=[J.num(Y/2,Y/2),J.num(P/2-n,P/2+n)],i=Ci.sort(((e,t)=>Ln(l,e.vertices.map((e=>e.toArray())))-Ln(l,t.vertices.map((e=>e.toArray()))))).slice(0,Ci.length),a=[],s=0;for(;s<e&&i.length>0;){let n=i.shift();Gi.insertPolygon(n.vertices.map((e=>[e.x,e.y])),!1),a.push(n),s=Gi.internalFaces().reduce(((e,t)=>e+t.area),0)/t*100,yield{showUpdate:!0,message:"Defining subject",isPercent:!0,value:s/e*100}}Gi.cleanupTrailingEdges();let o=Gi.vertices.filter((e=>e.y<.75*P&&Mn(e.toArray(),Li)));for(let e of o)for(let t of e.hedgelist){let e=[t.origin.x,t.origin.y],n=[t.twin.origin.x,t.twin.origin.y];if(Mn(e,Li)&&Mn(n,Li)){if(t.origin.distanceTo(t.twin.origin)<10)continue;Gi.removeEdge(e[0],e[1],n[0],n[1])}}Gi.cleanupTrailingEdges(),Vi.push(...a.sort(((e,t)=>t.length-e.length)))}],[function*(){let e=Ci.filter((e=>{let t=(tt.cropToMargin?tt.margin:Ae.margin)*Oe.dominantLineInsetMultiplier;return!e.vertices.some((e=>e.x<=t||e.x>=Y-t||e.y<=t||e.y>=P-t))}));"none"!==Oe.lineFilter&&(e=e.filter((e=>{let t=e.curviness>.01;return"curves"==Oe.lineFilter?t:!t})));let n=[];for(let l of e){let e=t(l.vertices.length/2),i=!1;for(let t of n){let n=0;for(let a of l.vertices){for(let l of t.vertices)if(a.isEqualTo(l)&&(n++,n>=e)){i=!0;break}if(i)break}if(i)break}i||n.push(l)}e=n,Oe.cropToDominantShape&&(e=e.filter((e=>Gi.getFacesAtPoint(e.vertices[0].toArray()).length>0&&Gi.getFacesAtPoint(e.vertices[e.vertices.length-1].toArray()).length>0)));let a=t(e.length/100*Oe.skipLongest),s=e.sort(((e,t)=>t.length-e.length)).slice(a,e.length/100*Oe.percentage+a),o=Re.bg[0][0]>.5?Re.line[0]:[...Re.line,...Re.base,...Re.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),Re.line[0]),r=[...Re.line,...Re.base,...Re.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),Re.line[0]);for(let e of s){if(J.bool(50)){let t=e.vertices.reduce(((t,n,l)=>0===l?0:t+n.distanceTo(e.vertices[l-1])),0)/J.num(10,15),n=e.vertices[1].angleTo(e.vertices[0]),a=new Ut(e.vertices[0].x+i(n)*t,e.vertices[0].y+l(n)*t),s=e.vertices[e.vertices.length-2].angleTo(e.vertices[e.vertices.length-1]),o=new Ut(e.vertices[e.vertices.length-1].x+i(s)*t,e.vertices[e.vertices.length-1].y+l(s)*t);e.vertices=[a,...e.vertices,o]}let t=new dn;t.expands(e.vertices),t.expandByValue(Oe.thickness.max+3);let n={polygon:t.vertexList,faceRef:null,category:mn.walker,readyForRender:!0,detailObject:[{lines:[e.vertices.map((e=>e.toArray()))],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Oe.materialHardness.min,Oe.materialHardness.max),linePressure:J.num(Oe.linePressure.min,Oe.linePressure.max),canWarp:!0,lineTapering:Il(Oe.lineTapering,J),lineWeight:J.num(Oe.thickness.min,Oe.thickness.max),lineColor:Oe.backgroundColor?r:Oe.colors?J.choice([...Re.accent,...Re.base,...Re.line]):o}]};Si.push(n)}}],[function*(){let e=Ne.count;for(let t=0;t<e;t++){let e=new Ql(yi),t=Bl(yi);if(!t)break;e.walk(t,J.int(Ne.length.min,Ne.length.max),!0),e.AABB.expandByValue(10);let n=Ne.isLineColor?Re.line[0]:Ne.colors?J.weightedChoice([1,J.choice(Re.accent)],[0,J.choice(Re.line)],[1,J.choice(Re.base)]):J.choice(Re.bg),{fade:l,scale:i}=Ne.lineTapering,a={polygon:e.AABB.vertexList,faceRef:null,category:mn.walker,readyForRender:!0,detailObject:[{lines:[e.pathVerts.map((e=>e.toArray()))],closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],lineTapering:{fade:{in:{enabled:J.bool(l.in.enabledChance),length:J.num(l.in.min,l.in.max)},out:{enabled:J.bool(l.out.enabledChance),length:J.num(l.out.min,l.out.max)}},scale:{in:{enabled:J.bool(i.in.enabledChance),length:J.num(i.in.min,i.in.max)},out:{enabled:J.bool(i.out.enabledChance),length:J.num(i.out.min,i.out.max)}}},linePressure:J.num(Ne.hardness.min,Ne.hardness.max),canWarp:J.bool(Ne.warpChance),lineWeight:J.num(Ne.thickness.min,Ne.thickness.max),lineColor:n}]};Si.push(a)}}],[function*(){let e=yi.internalFaces().filter((e=>e.area>1));const n=e.map((e=>e.area));if(n.length>4){const l=[...n].sort(((e,t)=>e-t)),i=l[t(.25*l.length)],a=l[t(.75*l.length)],s=a+10*(a-i);e.length,e=e.filter((e=>e.area<=s)),e.length}let l=new dn;l.expandsByPoint(Li),e=e.filter((e=>l.containsPoint(e.center))),tt.cropToMargin&&(e=e.filter((e=>e.center.x>tt.margin&&e.center.x<Y-tt.margin&&e.center.y>tt.margin&&e.center.y<P-tt.margin)));let i=Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.curves&&e.meta.used)),a=e=>{let n=e.aabb;for(let l of i){let i=l.line.map((e=>new Ut(...e)));if(l.meta?.aabb||(l.meta.aabb=new dn,l.meta.aabb.expands(i)),l.meta.aabb.intersects(n)){let n=t(.9*e.vertexlist.length),a=0;for(let t=0;t<e.vertexlist.length;t++){if(a>=n)return l;let s=e.vertexlist[t],o=!1;for(let e of i)if(s.isEqualTo(e)){a++,o=!0;break}!o&&In(i,s)&&a++}}}},s=e=>Ki.getPolygonsAtPoint(e.center.toArray()).sort(((e,t)=>e.meta.meta.totalArea-t.meta.meta.totalArea)),o=e=>{const t=Gi.getFacesIntersectingPoly(e.vertexlist.map((e=>[e.x,e.y])));return e.vertexlist.every((e=>t.some((t=>Mn(e.toArray(),t.face.vertexlist.map((e=>e.toArray())))||In(t.face.vertexlist,e)))))?t:[]};for(let n=0;n<e.length;n++){let l=e[n],i=n,r=s(l),c=a(l),d=o(l),u=r.length?r[0].meta.meta.lightingIntensity:Ie.default,h={polygon:l.vertexlist,faceRef:l,lightingIntensity:u,category:mn.foreground,isInCurve:c,detailObjectProps:{inObject:r,inDominantShapes:d}};Si.push(h),yield{showUpdate:!0,message:"Determining Layout",isPercent:!0,value:t(i/e.length*100)}}const r=[...Si.filter((e=>e.category==mn.foreground&&e.lightingIntensity)).map((e=>e.lightingIntensity))].sort(((e,t)=>e-t));for(let e of Si){const t=(c=e.lightingIntensity,(r.indexOf(c)+r.lastIndexOf(c))/2/(r.length-1));e.lightingIntensity=ge(fe(Le(t),0,1,Ie.min,Ie.max),e.lightingIntensity,.9)}var c}],[function*(){let{freqMultiplier:e}=et,t=e,n=500*e;Wi.getAllLines().filter((e=>e.meta.lineCategory==Se.objects&&e.meta.used)).forEach((e=>{vl.add(e.meta.id)}));let l=Si.filter((e=>e.category==mn.foreground)),{base:i,accent:a,line:s,bg:o}=Re,r=ll([...i,...a,s[0],...o]),c=J.int(0,r.length-1);ol=function(e,t,n="right"){let l=e.slice();for(let e=0;e<t;e++)l=il(l,n);return l}(r,c),ol.length>et.maxAccents&&(ol=ol.slice(0,et.maxAccents));let d=et.mutation;if("none"!==d){let e=e=>{let t,n=hl;switch(d){case"offsetUp":t=n;break;case"offsetDown":t=-30}return J.choice(xl(e,cl,t,et.samplesForPaletteOffset))},t=[];for(let n=1;n<ol.length;n++){let l=ol[n],i=ol[n-1],a=J.bool(50);if(i&&a){let n=e(i);t.push(n)}else t.push(l)}ol=t}yl=sl(t,ol.length,0,ml,l.filter((e=>e.detailObjectProps?.inDominantShapes?.length>0)).map((e=>e.faceRef.center))),Gl=sl(n,rl.length,0,ml,l.filter((e=>!e.detailObjectProps?.inDominantShapes?.length)).map((e=>e.faceRef.center))),rl=fl(Gl,rl),ol=fl(yl,ol)}],[function*(){let e=Si.filter((e=>e.category==mn.foreground&&e.detailObjectProps?.inDominantShapes?.length>0)),t=new Ut(Y/2,P/2),n=e.map((e=>e.faceRef.hedges.reduce(((e,n)=>e.origin?n.origin?t.distanceTo(e.origin)<t.distanceTo(n.origin)?e:n:e:n),e.faceRef.hedges[0])));for(let e=0;e<lt.count;e++){let e=xe(J.num(Be.scale*lt.size.min,Be.scale*lt.size.max),Be.scale),t=n.map((e=>{let t=e.origin.lerp(e.twin.origin,.5);return{distance:Ln(t.toArray(),Li,!0),edge:e,point:t}})).filter((t=>t.distance>1.25*e)),l=2.5*e;t.sort(((e,t)=>Math.abs(e.distance-l)-Math.abs(t.distance-l)));let i=t[0];n.splice(n.indexOf(i.edge),1);let a=i.point,s=J.num(0,360),o=_n({center:a.toArray(),radius:e,startAngle:s,endAngle:s+359.5}),r=new Al([o],{x:J.num(-15,15),y:J.num(-15,15),z:J.num(-15,15)},1200,0,{x:vi[0],y:vi[1]}).getLineSegments(),c={polygon:r[0].map((e=>new Ut(...e))),faceRef:null,category:mn.overlay,readyForRender:!1,detailObjectProps:{}};if(Si.push(c),lt.outline){let e=r[0],t=new dn;t.expandsByPoint(e),t.expandByValue(2*Oe.thickness.max);let n={polygon:t.vertexList,faceRef:null,category:mn.overlayOutline,readyForRender:!0,detailObject:[{lines:[e],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Oe.materialHardness.min,Oe.materialHardness.max),linePressure:J.num(Oe.linePressure.min,Oe.linePressure.max),canWarp:!1,lineTapering:Il(Oe.lineTapering,J),lineWeight:J.num(Oe.thickness.min,Oe.thickness.max),lineColor:Oe.backgroundColor?Re.bg[0]:Oe.colors?J.choice([...Re.accent,...Re.base,...Re.line]):Re.line[0]}]};Si.push(n)}}}],[function*(){let{enabled:e,linePressure:t,materialHardness:n,lineWeight:l,percentage:i,lineTapering:a}=Je;if(!e)return;let s=Xi.filter((e=>e.meta.used)).filter((()=>J.bool(i))),o=new dn;o.expands([new Ut(0,0),new Ut(Y,P)]);let r={polygon:o.vertexList,faceRef:null,category:mn.constructionLine,readyForRender:!0,detailObject:[{lines:s.map((e=>e.line)),closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],linePressure:J.num(t.min,t.max),materialHardness:J.num(n.min,n.max),canWarp:!1,lineTapering:Il(a,J),lineWeight:J.num(l.min,l.max),lineColor:Re.line[0]}]};Si.push(r)}],[function*(){const e={[mn.constructionLine]:0,[mn.background]:1,[mn.foreground]:2,[mn.detail]:3,[mn.walker]:3,[mn.overlay]:4,[mn.overlayOutline]:5};Si.sort(((t,n)=>{if(e[t.category]<e[n.category])return-1;if(e[t.category]>e[n.category])return 1;let l=new dn;l.expands(t.polygon);let i=new dn;return i.expands(n.polygon),new Ut(l.maxX,l.maxY).distanceTo(new Ut(0,0))-new Ut(i.maxX,i.maxY).distanceTo(new Ut(0,0))}))}],[function*(){let e=new Map,n=0,l="◴ ◷ ◶ ◵".split(" "),i=function*(){let e=oe(!0),t=new dn;for(t.expands([new Ut(e.xOff,e.yOff),new Ut(e.xOff+e.width,e.yOff+e.height)]),t.expandByValue(10);Si.length;){let e=Si[0];if(e.readyForRender){if(e.detailObject?.length){let n=new dn;if(n.expands(e.polygon),t.intersects(n)){bn(e);for(let t=0;t<e.detailObject.length;t++)rn(e.detailObject[t]);w.flush(),Ft.copyBufferToScreen(),yield{rendering:!0}}}let n=Si.splice(0,1);hn.push(...n)}else yield{rendering:!1}}Ft.copyBufferToScreen()}(),a=!1,s=[];for(let e=0;e<1e3;e++)s.push(q());let o=0;for(;!a;){if(na){yield{showUpdate:!0,message:"Rendering Paused",value:"press space to continue",isPercent:!1};continue}for(let t=0;t<Si.length;t++){let l=Si[t];if((l.category==mn.foreground||l.category==mn.detail||l.category==mn.overlay)&&!l.detailsProcessed){l.detailsProcessed=!0,e.set(n,!1);let t=n;Nl(l,s[o++%s.length]).then((()=>{e.set(t,!0)})),n++}}let r=i.next();a=r.done;let c=r.value?.rendering||!1,d=0;for(let e of Object.keys(Rl))0==Rl[e]&&(d+=1);let u=[...e.values()].reduce(((e,t)=>e+(t?0:1)),0);if(yield{showUpdate:!c&&(u>0||d>0||u>0),message:""+l[t(oi/4)%4],isPercent:!1,value:`${d>0?`Waiting on 1 of ${d} threads, `:"Waiting for"} ${u} jobs queued`},0==u&&0==kl.length&&0==d&&a)break}yield{showUpdate:!1},Ft.copyBufferToScreen()},!0]],Ri=new class{heap;constructor(e){this.heap=new jl(1e10,e)}clear(){this.heap.clear()}topN(e){return this.heap.toArray().slice(0,e)}update(e){const t=new Set(this.heap.toArray());for(const n of e)t.has(n)?t.delete(n):this.heap.push(n);for(const e of t)this.heap.remove(e);return this.heap.toArray()}}((e=>{let{polyOverfitting:t,noiseOverfittingSpread:n,noiseOverfitFreq:l}=nt,i=e.area;if(1!==t&&(i*=Ki.getPolygonsAtPoint(e.center.toArray()).length>0?1:t),n>0){let t=n/2,a=sl(l,10,0,Ge);i*=xe(ye(yn(e.center.x,e.center.y,0,l,1-t,1+t),0,1,a.min,a.max),.001)}return xe(i,.001)})),Ti=new Set;function Mi(e){let t={x:e.center[0],y:e.center[1],z:-100},n={width:e.width,height:e.height,depth:e.depth};return{faces:new Jl(t,e.rotationProps,n,e.sides,{x:e.perspectiveCenter[0],y:e.perspectiveCenter[1],z:-1e3},90,Y/P,.001,1e3,[{position:Ie.position,brightness:1},{position:{x:-Ie.position.x,y:-Ie.position.y,z:Ie.position.z},brightness:.95},{position:{x:0,y:Ie.position.y,z:-1e3},brightness:.2},{position:{x:0,y:-Ie.position.y,z:-1e3},brightness:.2}],!0).getFaces2D(),shapeArgs:e}}let zi,Yi=!1,Pi=(e,t,n,l=0)=>{let i=1e3*n,a=1e3*l;if(!Yi){let e=J.num(800,1600),t=nt.noiseFieldCategoryInfluence;zi={[Se.used]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.horizontal]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.vertical]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.perspective]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.circle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.wobbles]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.curves]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.rects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.borderRect]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.triangle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[Se.objects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)}},Yi=!0}let s=ve,o=sl(zi[e].freq,10,zi[e].offset,s),r=ye(s(xe(yn(t.x+zi[e].offset,t.y+zi[e].offset,zi[e].offset-a,zi[e].freq,0,1),.3)),o.min,o.max,zi[e].min,zi[e].max);return c(i*r)},Fi=()=>[Ai,ji,Ji,qi,_i,Ei,()=>!0],Hi=0,
this.kTree.pointsWithinDistanceGenerator(e,this.maxDist+g))if(t.point.distanceTo(e.point)+this.epsilon<Math.max(t.minDist,e.minDist))return!1;return!0}placePoint(e){this.kTree.insert(e)}}const bi=function(e,t,n){const l=1/t,i=1/n;return Math.min(4,((3-l)*l**2*e+i**3)/(l**3*e+(3-i)*i**2))},gi=(e,t,n,l,i)=>Math.min(4,(2+Math.sqrt(2)*(e-n/16)*(n-e/16)*(t-l))/(1.5*i*(2+(Math.sqrt(5)-1)*t+(3-Math.sqrt(5))*l))),fi=(e,t)=>{const n=Math.sin(e.theta),l=Math.cos(e.theta),i=Math.sin(t.phi),a=Math.cos(t.phi),s=t.leftY,o=e.rightY,r=gi(n,l,i,a,s),c=gi(i,a,n,l,o);e.rightX=e.x+(e.deltaX*l-e.deltaY*n)*r,e.rightY=e.y+(e.deltaY*l+e.deltaX*n)*r,t.leftX=t.x-(e.deltaX*a+e.deltaY*i)*c,t.leftY=t.y-(e.deltaY*a-e.deltaX*i)*c},xi=(e,{tension:t=1,cyclic:n=!1}={})=>{const l=((e,t=1,n=!1)=>{const l=e.map((({x:e,y:n})=>((e,t,n)=>({x:e,y:t,leftY:n,rightY:n,leftX:n,rightX:n,deltaX:0,deltaY:0,delta:0,theta:0,phi:0,psi:0}))(e,n,t))),i=l[0],a=l[l.length-1];for(let e=0;e<l.length;e++)l[e].next=l[e+1]??i,l[e].prev=l[e-1]??a;if(((e,t)=>{const n=t?e.length:e.length-1;for(let t=0;t<n;t++){const n=e[t],l=e[t+1]??e[0];n.deltaX=l.x-n.x,n.deltaY=l.y-n.y,n.delta=Math.hypot(n.deltaX,n.deltaY)}})(l,n),2===e.length&&!n)return((e,t)=>{let n=1/(3*e.rightY);e.rightX=e.x+e.deltaX*n,e.rightY=e.y+e.deltaY*n,n=1/(3*t.leftY),t.leftX=t.x-e.deltaX*n,t.leftY=t.y-e.deltaY*n})(i,a),l;((e,t)=>{const[n,l]=t?[0,e.length]:[1,e.length-1];for(let t=n;t<l;t++){const n=e[t],l=n.prev,i=l.deltaY/l.delta,a=l.deltaX/l.delta;n.psi=Math.atan2(n.deltaY*a-n.deltaX*i,n.deltaX*a+n.deltaY*i)}})(l,n),function(e,t){const n=[],l=[],i=[],a=e[0],s=e[1],o=e[e.length-1],r=t?e.length+1:e.length;if(t)n[0]=0,i[0]=0,l[0]=1;else{const e=a.next,t=a.rightX,o=Math.abs(e.leftY),r=Math.abs(a.rightY);n[0]=bi(t,r,o),i[0]=-s.psi*n[0],l[0]=0}for(let s=1;s<r;s++){const c=e[s]??a,d=c.next,u=c.prev,h=s===r-1;if(!t&&h){const e=c.leftX,t=Math.abs(c.leftY),l=Math.abs(u.rightY),a=bi(e,t,l);o.theta=-i[r-2]*a/(1-a*n[r-2]);break}{let e=1/(3*Math.abs(u.rightY)-1),o=c.delta*(3-1/Math.abs(u.rightY)),m=1/(3*Math.abs(d.leftY)-1),p=u.delta*(3-1/Math.abs(d.leftY));const b=1-n[s-1]*e;o*=b;const g=Math.abs(c.leftY),f=Math.abs(c.rightY);g<f?o*=(g/f)**2:p*=(f/g)**2;let x=p/(p+o);n[s]=x*m;let Z=-d.psi*n[s];if(x=(1-x)/b,Z-=c.psi*x,x*=e,i[s]=Z-i[s-1]*x,l[s]=-l[s-1]*x,t&&h){let e=0,t=1;for(let a=s-1;a>=0;a--){const s=0===a?r-1:a;e=i[s]-e*n[s],t=l[s]-t*n[s]}e/=1-t,a.theta=e,i[0]=e;for(let t=1;t<r-1;t++)i[t]=i[t]+e*l[t];break}}}for(let t=r-2;t>=0;t-=1)e[t].theta=i[t]-e[t].next.theta*n[t]}(l,n),(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.phi=-n.psi-n.theta}})(l);const s=n?l.length:l.length-1;for(let e=0;e<s;e++)fi(l[e],l[e].next);return l})(e,t,n),i=[],a=n?l.length:l.length-1;for(let e=0;e<a;e++){const t=l[e];i.push({startControl:{x:t.rightX,y:t.rightY},endControl:{x:t.next.leftX,y:t.next.leftY},point:{x:t.next.x,y:t.next.y}})}return i};function Zi(e,t,n=!1,l=.01){const i=[],a=e.length;if(a<2)return i;const s=n?a:a-1;let o=null;for(let n=1;n<=s;n++){const s=n%a,r=e[(n-1)%a].point,c=e[s].startControl,d=e[s].endControl,u=e[s].point;let h=0;for(;h<=1;){const e=1-h,n={x:e**3*r.x+3*e**2*h*c.x+3*e*h**2*d.x+h**3*u.x,y:e**3*r.y+3*e**2*h*c.y+3*e*h**2*d.y+h**3*u.y};if(o){const e=n.x-o.x,l=n.y-o.y;e*e+l*l>=t*t&&(i.push(n),o=n)}else i.push(n),o=n;h+=l}const m={x:u.x,y:u.y};!o||o.x===m.x&&o.y===m.y||(i.push(m),o=m)}if(!n){const t=e[a-1].point,n=i[i.length-1];n.x===t.x&&n.y===t.y||i.push(t)}return i}let yi,Gi,Wi,vi,Li,Si=[],Xi=[],Ci=[],Vi=[],Ki=new class{cells=new Map;polygons=new Map;polygonMeta=new Map;nextPolygonId=0;cellSize;constructor(e,t){this.cellSize=e,t&&this.addPolygons(t)}getCellIndex(e,t){return`${f(e)},${f(t)}`}clear(){this.cells.clear(),this.polygons.clear(),this.polygonMeta.clear()}getCellTestVertices(e,t){let{cellSize:n}=this;return[new Ut(e*n,t*n),new Ut((e+1)*n,t*n),new Ut((e+1)*n,(t+1)*n),new Ut(e*n,(t+1)*n)]}addPolygons(e){e.forEach((e=>this.addPolygon(e.verts,e.meta)))}getPolygonsAtPoint(e){let{cellSize:t}=this,n=f(e[0]/t),l=f(e[1]/t);const i=this.getCellIndex(n,l);let a=new Set;return this.cells.has(i)&&Array.from(this.cells.get(i)).map((t=>{In(this.polygons.get(t).map((e=>(new Ut).fromArray(e))),new Ut(e[0],e[1]))&&a.add(t)})),Array.from(a).map((e=>({verts:this.polygons.get(e),meta:this.polygonMeta.get(e)})))}addPolygon(e,t){let{cellSize:n}=this;const l=this.nextPolygonId++;this.polygons.set(l,e),this.polygonMeta.set(l,t);let i=e.map((e=>(new Ut).fromArray(e))),a=new dn;a.expands(i);const s=f(a.minX/n),o=x(a.maxX/n)-1,r=f(a.minY/n),c=x(a.maxY/n)-1;for(let e=s;e<=o;e++)for(let t=r;t<=c;t++){const n=this.getCellIndex(e,t),a=this.getCellTestVertices(e,t);if(a.some((e=>In(i,e))))this.cells.has(n)||this.cells.set(n,new Set),this.cells.get(n).add(l);else for(let e=0;e<a.length;e++)if(Qn([a[e],a[(e+1)%a.length]],i)){this.cells.has(n)||this.cells.set(n,new Set),this.cells.get(n).add(l);break}}return l}checkIntersections(e){let{cellSize:t}=this,n=e.map((e=>(new Ut).fromArray(e))),l=new dn;l.expands(n);const i=f(l.minX/t),a=x(l.maxX/t)-1,s=f(l.minY/t),o=x(l.maxY/t)-1;let r=new Set;for(let e=i;e<=a;e++)for(let t=s;t<=o;t++){const l=this.getCellIndex(e,t),i=this.getCellTestVertices(e,t);this.cells.has(l)&&this.cells.get(l).forEach((e=>{if(i.some((e=>In(n,e))))r.add(e);else for(let t=0;t<i.length;t++)if(Qn([i[t],i[(t+1)%i.length]],n)){r.add(e);break}}))}return Array.from(r).map((e=>({verts:this.polygons.get(e),meta:this.polygonMeta.get(e)})))}getAllPolygons(){return Array.from(this.polygons).map((([e,t])=>({verts:t,meta:this.polygonMeta.get(e)})))}}(10),wi=[],ki=[[function*(){Zn()}],[function*(){ml=et.curveMap;let e=Re.bg[0][0]>=.5,t=e?1:1.0012,n=e?1:1.001;cl=cl.length?cl:he.filter((e=>e!==Re)).map((e=>[...e.accent,...e.base,...e.line])).flat().map((e=>(e[0]*=n,e[1]*=t,e))),[...Re.accent,...Re.base,...Re.line].forEach((e=>{e[0]*=n,e[1]*=t}));let l=[...Re.accent,...Re.base,...Re.line];ol=l,rl=[...Re.base].sort(((e,t)=>t[0]-e[0])),ol=[...ol].sort(((e,t)=>t[2]-e[2])),nl([...ol]),nl([...rl])}],[function*(){let t=K?e.LinearFilter:e.NearestFilter,n={anisotropy:V,colorSpace:e.LinearDisplayP3ColorSpace,minFilter:t,magFilter:t,type:e.FloatType};Ft=new Pt(Q,j,{stencilBuffer:!1,depthBuffer:!1}),Ht={paperTexture:{target:new e.WebGLRenderTarget(Q,j,{...n,format:e.RedFormat,internalFormat:"R32F"}),pass:()=>{let t=new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(Q,j)},noiseOffset:{value:new e.Vector2(ke[0],ke[1])},...ce()},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec3 backgroundColor;\n uniform vec3 lineColor;\n uniform vec2 noiseOffset;\n\n ${ee}\n ${te}\n\n varying vec2 vUv;\n out vec4 outColor;\n\n #include <packing>\n\n ${ne}\n\n vec4 render(vec2 uv) {\n\n float noiseTex1 = fbm(uv - noiseOffset, 5, 300., 0.9) - 0.5;\n float noiseTex2 = fbm(uv - noiseOffset, 3, 400., 0.9) - 0.5;\n float texCombined = step(0.001, -(noiseTex1 * noiseTex2)) * .05;\n\n float noiseTexDark1 = fbm(uv + noiseOffset + 1., 5, 280., 0.9) - 0.5;\n float noiseTexDark2 = fbm(uv + noiseOffset + 1., 3, 300., 0.9) - 0.5;\n float texDarkCombined = step(0.0001, -(noiseTexDark1 * noiseTexDark2)) * .05;\n\n float smoothNoise1 = smoothstep(0., 0.6, fbm(uv, 3, 420., 0.9)) * 0.03;\n\n // vec3 lchColor = vec3(0., 0.5, 0.5);\n float result;\n result += texCombined;\n result -= texDarkCombined;\n result += smoothNoise1;\n \n // vec3 colorRGB = OKLCHtoP3LRGB(lchColor);\n // float canvasTexture = fbm(uv, 6, 120., 0.7);\n return vec4(vec3(result), 1.);\n }\n\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 6.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `});re(t),It.material=t,X.setRenderTarget(Ht.paperTexture.target),It.render(X)}},displacementMap:{target:new e.WebGLRenderTarget(Q,j,{...n,format:e.RGFormat,internalFormat:"RG32F"}),pass:()=>{let e=Kt();re(e),It.material=e,X.setRenderTarget(Ht.displacementMap.target),It.render(X)}},displacementMapWarped:{target:new e.WebGLRenderTarget(Q,j,{...n,format:e.RGFormat,internalFormat:"RG32F"}),pass:()=>{let e=Kt();re(e),e.uniforms.uWarpEnabled.value=!0,It.material=e,X.setRenderTarget(Ht.displacementMapWarped.target),It.render(X)}},polyEdgeDistance:{target:new e.WebGLRenderTarget(Q,j,{...n,format:e.RedFormat,internalFormat:"R32F"}),skipSetup:!0}};let l=function*(){for(let e of Object.keys(Ht)){const t=Ht[e];t.skipSetup||t.pass&&t.pass()}return X.shadowMap.enabled=!0,void X.setRenderTarget(null)}();for(;!l.next().done;)yield}],[function*(){let e=Rt();It.material=e;for(let t of Object.keys(Ht)){if(!Ht[t].debug)continue;let n=Ht[t].target.texture;e.uniforms.tTex.value=n,X.setRenderTarget(null),It.render(X),ia(),yield}}],[function*(){let t=(n=Ht.paperTexture.target.texture,new e.ShaderMaterial({uniforms:{grid:{value:{...Be}},...ce(),tWarpTex:{value:Ht.displacementMap.target.texture},resolution:{value:new e.Vector2(Q,j)},coordsResolution:{value:new e.Vector2(Y,P)},noiseOffset:{value:new e.Vector2(0,0)},tPaperTexture:{value:n},backgroundColor:{value:new e.Vector3(0,0,0)},lineColor:{value:new e.Vector3(0,0,0)},uGridStrength:{value:.3}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n\t\t\tprecision highp int;\n \n // uniform highp sampler2D tTex;\n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec2 coordsResolution;\n uniform vec3 backgroundColor;\n uniform vec3 lineColor;\n uniform vec2 noiseOffset;\n uniform float uGridStrength;\n uniform highp sampler2D tPaperTexture;\n uniform highp sampler2D tWarpTex;\n\n struct Grid {\n float countX;\n float countY;\n float marginX;\n float marginY;\n float w;\n float h;\n float scale;\n };\n uniform Grid grid;\n\n ${ee}\n ${Et}\n ${te}\n \n float drawGridLines(vec2 uv, float lineWeight, float gridScale) {\n vec2 scale = resolution / coordsResolution;\n // This should be the desired line width in pixels\n float lineWeightNoise = snoise2D(uv * 200.f) * .09f;\n float gridLineWeight = (lineWeight + lineWeightNoise) * scale.y; // Width of the grid lines in pixels\n\n vec2 offset = vec2(grid.marginX, grid.marginY) * scale; // Applying scale to margins\n\n // Compute UVs for grid lines based on actual screen resolution and grid scaling\n vec2 gridUV = (uv * resolution - offset);\n\n // Convert grid dimensions from whatever space they are in to pixel space directly\n float gridWidthInPixelsX = grid.w * (resolution.x / coordsResolution.x) * 1.;\n float gridWidthInPixelsY = grid.h * (resolution.y / coordsResolution.y) * 1.;\n\n // Calculate the distance to the nearest grid line in pixels\n float lineDistX = min(mod(gridUV.x, gridWidthInPixelsX / gridScale), gridWidthInPixelsX - mod(gridUV.x, gridWidthInPixelsX / gridScale));\n float lineDistY = min(mod(gridUV.y, gridWidthInPixelsY / gridScale), gridWidthInPixelsY - mod(gridUV.y, gridWidthInPixelsY / gridScale));\n float lineDist = min(lineDistX, lineDistY);\n\n // Use smoothstep to create anti-aliased lines with a specified pixel width\n float lineFactor = 1.0 - smoothstep(gridLineWeight - 0.1, gridLineWeight + 0.1, lineDist);\n\n return lineFactor;\n }\n\n float drawGridBlocks(vec2 uv, float gridScale ) {\n vec2 scale = resolution / coordsResolution;\n vec2 offset = vec2(grid.marginX, grid.marginY) * scale; // Applying scale to margins\n vec2 gridUV = (uv * resolution - offset); // Apply resolution scaling to UV, then subtract offset\n\n float tileX = floor(gridUV.x / (grid.w * scale.x));\n float tileY = floor(gridUV.y / (grid.h * scale.y));\n\n vec2 centerUV = (vec2(tileX, tileY)) * vec2(grid.w, grid.h) / resolution;\n\n float noiseValue = clamp(fbm(centerUV, 3, 300., 0.5) + .5, 0.0, 1.); // Adjust for correct scaling if necessary\n\n return noiseValue;\n\n // float checker = mod(tileX + tileY, 2.0);\n \n // return checker == 0.0;\n }\n\n ${Ct}\n\n varying vec2 vUv;\n out vec4 outColor;\n\n #include <packing>\n\n ${ne}\n ${At}\n\n vec4 render(vec2 uv, vec2 texUv, vec2 msaaOffset) {\n\n // vec2 uvOffset = lookupWarpSample(uv).xy;\n\n // vec2 offsetUV = uv + uvOffset;\n vec2 offsetUV = uv;\n\n float gridNoise = fbm(uv, 3, 10., 0.9);\n float gridNoise2 = fbm(uv + 2., 3, 600., 0.9);\n\n float tileScaleFactor = resolution.x / uTileSize.x;\n\n // float gridFactor = clamp(0., .12, drawGridLines(uv, 38.));\n float aspectRatio = resolution.x / resolution.y;\n vec2 uvNormalised = offsetUV * vec2(aspectRatio, 1.);\n\n const float gridDarkness = 0.3;\n\n float gridDivisor = 1.;\n float edgeFactor = smoothstep(0.2f, 1.f, screenEdgeDist(uvNormalised, 0.22 - (gridNoise * .06)));\n \n float gridFactor = clamp(0., gridDarkness, drawGridLines(offsetUV, .3 , 5.) * edgeFactor);\n float gridFactor2 = clamp(0., gridDarkness + 0.025, drawGridLines(offsetUV, .5 , 1.) * edgeFactor);\n \n vec3 lineCol = lineColor;\n \n lineCol.x += (step(0.6, gridNoise - gridNoise2) * 0.4);\n \n float gridTextureNoise = fbm(uv + noiseOffset, 6, 700., 0.7) * 0.5;\n vec3 lchColor = mix(backgroundColor, lineCol, clamp((gridFactor2 - gridTextureNoise) * uGridStrength, 0., 1.));\n \n float smoothNoise1 = texture(tPaperTexture, texUv + msaaOffset).x * 0.8;\n\n float colourNoise = fbm(uv + noiseOffset, 12, 5., 0.7) * 0.001;\n float colourNoise2 = fbm(uv - noiseOffset + 1., 12, 3., 0.7) * 0.001;\n\n lchColor.x += smoothNoise1 - colourNoise + colourNoise2;\n\n float edgeFactorVignette = smoothstep(0.2f, 1.f, screenEdgeDist(uvNormalised, 0.5));\n lchColor.x -= (1. - edgeFactorVignette) * 0.005;\n lchColor.y += (1. - edgeFactorVignette) * 0.005;\n // lchColor.y *= colourNoise;\n \n\n // lchColor = vec3(lchColor.x, lchColor.y, lchColor.z);\n\n vec3 colorRGB = OKLCHtoP3LRGB(lchColor);\n\n vec3 lightDir = normalize(vec3(.6f, 1.6f, 1.6f));\n vec3 lightColor = vec3(1.0f) * 1.7f;\n\n vec3 paperTextureNormals = calculateNormals(texUv + msaaOffset, 0.0002 * tileScaleFactor, 2.);\n vec3 diffuse = calculateDiffuse(paperTextureNormals, lightDir, lightColor);\n\n colorRGB *= diffuse;\n \n // float canvasTexture = fbm(uv, 6, 120., 0.7);\n return vec4(colorRGB, 1.);\n }\n\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 16.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV, vUv, d * px);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `}));var n;It.material=t,re(t);let l=Qt(J.choice(Re.bg)),i=Qt(J.choice(Re.line));t.uniforms.backgroundColor.value=(new e.Vector3).fromArray(l),t.uniforms.lineColor.value=(new e.Vector3).fromArray(i),t.uniforms.noiseOffset.value=new e.Vector2(ke[0],ke[1]),t.uniforms.uGridStrength.value=.2,X.setRenderTarget(Ft.getWriteBuffer()),It.render(X),Ft.copyAndSwapBuffers(),Ft.copyBufferToScreen()}],[function*(){let e=Ae.margin+Be.marginX,n=Ae.margin+Be.marginY,l=new Ut(e,n),i=new Ut(Y-e,P-n);(function(e,t,n=0){let l=[],i=[],a=J.weightedChoice([0,J.easedNum(Le,Ae.HVariance.min,Ae.HVariance.max)]),s=J.weightedChoice([0,J.easedNum(Le,Ae.VVariance.min,Ae.VVariance.max)]);for(let i=e.y;i<t.y;i+=Be.scale/2)J.gaussianBool(Ae.HVariance.threshold,Ae.HVariance.mean,Ae.HVariance.stdDev)||l.push({id:Jn(),meta:{lineCategory:Se.horizontal},line:[[e.x-Be.scale*n,i+J.num(-Be.scale*a,Be.scale*a)],[t.x+Be.scale*n,i+J.num(-Be.scale*a,Be.scale*a)]]});for(let l=e.x;l<t.x;l+=Be.scale/2)J.gaussianBool(Ae.VVariance.threshold,Ae.VVariance.mean,Ae.VVariance.stdDev)||i.push({id:Jn(),meta:{lineCategory:Se.vertical},line:[[l+J.num(-Be.scale*s,Be.scale*s),e.y-Be.scale*n],[l+J.num(-Be.scale*s,Be.scale*s),t.y+Be.scale*n]]});Xi.push(...l,...i)})(l,i),vi=function(e,t){let n;if(!Ae.perspectiveBox.enabled)return;let l=[e,new Ut(t.x,e.y),t,new Ut(e.x,t.y)].map((e=>e.toArray())),i=new kn(l,[[0,1],[1,2],[2,3],[3,0]]);for(let e=0;e<Ae.perspectiveBox.count;e++){let e,t=i.internalFaces(),n=J.choice(t),l=n.aabb,a=J.bool(50),s=o(l.height,l.width)/4;if(a){let t=J.num(l.minX+s,l.maxX-s);e=[[t,l.minY],[t,l.maxY]]}else{let t=J.num(l.minY+s,l.maxY-s);e=[[l.minX,t],[l.maxX,t]]}i.splitFaceByPolyLine(n,e)}let a=i.internalFaces(),s=!1,r=!1,c=!1,d=Ae.perspectiveBox.firstFull;for(let e of a){if(-1==Ae.perspectiveBox.count)break;let t=e.aabb,l=t.width*J.num(.75,1.25),i=t.height*J.num(.75,1.25),a=!(!d||c)||J.bool(s?0:50),o=!(!d||c)||J.bool(r?0:50);a&&(r=!0),o&&(s=!0);let u=[a?Y/2:t.center.x,o?P/2:t.center.y];c||(n=u),c=!0,Ee[Se.perspective]>1&&Xi.push(...An({gStdDev:Ae.perspectiveBox.threshold,gMean:Ae.perspectiveBox.mean,gThreshold:Ae.perspectiveBox.stdDev,boxCenter:u,perspectiveCenter:[t.center.x+J.int(-l/4,l/4),t.center.y+J.int(-i/4,i/4)],width:a?4*Y:l*J.num(.75,1.25),height:o?P:i*J.num(.75,1.25),centerBoxMaskDimensions:[J.int(1,l/Be.scale*.5),J.int(1,i/Be.scale*.5)]}).map((e=>({id:Jn(),line:e,meta:{lineCategory:Se.perspective}}))))}return n}(l,i),function(){for(let e=0;e<Ae.circles.count;e++){let e=xe(J.num(Be.scale*Ae.circles.minRadius,Be.scale*Ae.circles.maxRadius),Be.scale),t=e/2,n=[Y/2+J.num(-Y/2+t,Y/2-t),P/2+J.num(-P/2+t,P/2-t)],l=J.num(0,360),i=_n({center:n,radius:e,startAngle:l,endAngle:l+J.int(25,360)});i.length>3&&Xi.push({id:Jn(),line:i,meta:{lineCategory:Se.circle}})}}(),function(){if(!Ae.rects.spiralRectsEnabled)return;let e=Ot(new Ut(J.num(.4*Y,.6*Y),J.num(.4*P,.6*P))).toArray(),t=J.num(0,22.5)*J.choice([-1,1]),n=Be.scale*J.int(5,10),l=J.num(0,360),i=Be.scale*(2*J.int(1,8));for(;n<P;){let a=En({width:n,height:n,center:e,angle:l});Xi.push({id:Jn(),line:a,meta:{lineCategory:Se.rects,isClosed:!0}}),n+=i,l+=t}}(),function(){if(!Ae.rects.insetRectEnabled)return;let e=2*Ae.margin+Be.scale*(2*J.int(1,4)),t=Ot(new Ut(J.num(Y/2,Y/2),J.num(P/2,P/2))).toArray(),n=En({width:Y-e,height:P-e,center:t,angle:J.num(-1,1)});Xi.push({id:Jn(),line:n,meta:{lineCategory:Se.borderRect,isClosed:!0}})}();let a=function(){let e=J.num(Ae.wobble.warpFreq.min,Ae.wobble.warpFreq.max),t=[];for(let n=0;n<Ae.wobble.layers;n++){let l=me(180/Ae.wobble.layers*n);for(let n=0;n<Ae.wobble.multiLayers;n++){let i=n*Ae.wobble.offsetMultiplier,a={warpStrength:e,rotationAngleAddition:l,wobbleOffset:i};zl.push(a);let s=new dn;s.expands([new Ut(-Y/4,-P/4),new Ut(Y+Y/4,P+P/4)]);let o=s.vertexList.map((e=>e.toArray())),r=xe(Be.scale/Ae.wobble.gridDivisions,.1),c=Ml({streamlineWorkerProps:{vectorFieldType:"bnnoise",addOutline:!1,vectorFieldNoiseProps:{warpStrength:xe(e,.01),rotationAngleAddition:xe(l+J.num(-.1,.1),.01),wobbleOffset:i,wobbleDetail:J.int(0,1)},postProcessingArgs:{directional:!1,wobbleFreq:.5,wobbleAmplitude:.5},maxStreamlines:Ae.wobble.count,minLength:xe(Be.scale*Ae.wobble.minLength,.1),maxLength:xe(3*P,.1),stepSize:r/4,minDistance:r,bounds:{topLeft:o[0],bottomRight:o[2]},boundingGeometry:o},noiseSeed:xn,randomSeed:q(J)});t.push(c)}}return t}(),s=new Map,r=0,c="◴ ◷ ◶ ◵".split(" "),d=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e];s.set(r,!1);let n=r;t.then((t=>{d[e]=t,s.set(n,!0)})),r++}for(;;){let e=[...s.values()].reduce(((e,t)=>e+(t?0:1)),0);if(yield{showUpdate:e>0,message:""+c[t(oi/4)%4],isPercent:!1,value:`${e>0?"Pausing for":"Waiting for"} ${e} tasks`},0==e)break}for(let e=0;e<d.length;e++){let t=d[e];if(Ee[Se.wobbles]>0)for(let n of t)Xi.push({line:n,id:Jn(),meta:{lineCategory:Se.wobbles,lineSubCategory:e}})}}],[function*(){let e=Ae.margin+Be.marginX,t=Ae.margin+Be.marginY,n=new ie(e,t),l=new ie(Y-e,P-t);Wi=new el(Be.scale/2,Xi),Li=[n,new Ut(l.x,n.y),l,new Ut(n.x,l.y)].map((e=>e.toArray())),yi=new kn(Li,[[0,1],[1,2],[2,3],[3,0]])}],[function*(){let{maxWidth:e,widthRange:t,spread:n,maxDivergence:l,tens
th:b,insetFromGeometry:s,addOutline:i,insetFromGeometryDistance:c,minDistance:p,bounds:{topLeft:[l.minX,l.minY],bottomRight:[l.maxX,l.maxY]},postProcessingArgs:{directional:!0,scribbleStrength:u?h:0,wobbleFreq:f,wobbleAmplitude:d*g}};switch(t){case"noise":case"bnnoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:e.num(1,2)}};case"outline":return{...Z,vectorFieldType:t,boundingGeometry:a};case"directional":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldDirectionalProps:{direction:n}};case"wobbles":return{...Z,vectorFieldType:"wobbles",boundingGeometry:a,blueNoiseProps:{warpStrength:1e3,minDist:1*p,maxDist:1.5*p},wobbleProps:{tension:{min:.5,max:3},maxPointUse:1,maxDivergence:4,maxLinePoints:30}};case"bluenoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:1},blueNoiseProps:{warpStrength:100,minDist:p+d,maxDist:4*(p+d)}};case"edgefill":return{...Z,vectorFieldType:t,boundingGeometry:a,blueNoiseProps:{warpStrength:100,minDist:2*(p+d),maxDist:2.2*(p+d)}}}},Hl=(e,t,n=[],l)=>{if(n.length){let e=n[0],t=l.int(0,e.verts.length-1),i=(t+1)%e.verts.length;return new Ut(...e.verts[t]).angleTo(new Ut(...e.verts[i]))}let i=Wi.getLinesIntersectingFace(e,!1),a=e.center,s=new Set([...t].map((e=>e.meta.lineCategory))),o=[Se.horizontal,Se.vertical,Se.perspective,Se.objects].filter((e=>!s.has(e))),r=i.filter((e=>!t.has(e.constructionLine)&&o.some((t=>t==e.constructionLine.meta.lineCategory))));if(r.length){let e=r.reduce(((e,t)=>Ln(a.toArray(),e.constructionLine.line)<Ln(a.toArray(),t.constructionLine.line)?e:t),r[0]);t.add(e.constructionLine);let n=e.constructionLine.line.map((e=>new Ut(...e)));return n[0].angleTo(n[n.length-1])}},Il=(e,t)=>{let{fade:n,scale:l}=e;return{fade:{in:{enabled:t.bool(n.in.enabledChance),length:t.num(n.in.min,n.in.max)},out:{enabled:t.bool(n.out.enabledChance),length:t.num(n.out.min,n.out.max)}},scale:{in:{enabled:t.bool(l.in.enabledChance),length:t.num(l.in.min,l.in.max)},out:{enabled:t.bool(l.out.enabledChance),length:t.num(l.out.min,l.out.max)}}}};async function Nl(e,t){let{colorOverride:n}=e?.detailObjectProps||{};const l=new _(e?.detailObjectProps?.noiseSeedOverride||t),i=new dn;i.expands(e.polygon),i.expandByValue(10);const a=e.faceRef?.center||i.center,s=e?.detailObjectProps?.inDominantShapes||[],o=e?.detailObjectProps?.inObject||[],d=s.length>0,u=!!e?.isInCurve,h=!!e?.detailObjectProps?.inObject?.length,m=e?.detailObjectProps?.isFineDetail,p=xe(e.lightingIntensity||Ie.default,Ie.clamp),{skipFill:b,skipDetails:g}=e.detailObjectProps||{};let f=Yl(je,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==mn.overlay,isInCurveOrObject:h||u}),x=Yl(Qe,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==mn.overlay,isInCurveOrObject:h||u});const Z=!b&&l.bool(f.fillChance),y=!g&&l.bool(x.fillChance),G=l.bool(f.insetChance),W=l.bool(x.insetChance),v=Z?l.weightedChoice(...f.layerCountChances):0,L=u?0:y?l.weightedChoice(...x.layerCountChances):0;let S=new Set,X=new Set,C=new Set,V=[],K=[],w=!1;function k(t,l,c){const h=[];for(let b=0;b<c;b++){const c=Pl("fill"===l?f:x,b);let g,Z=t.num(c.lineWeight.min,c.lineWeight.max),y=t.num(c.linePressure.min,c.linePressure.max);g=r(.4,Z*t.num(c.minDistanceMult.min,c.minDistanceMult.max)),m&&"detail"===l&&(Z*=.75,g*=.25);const v="fill"===l?zl.filter((e=>!S.has(e))):zl.filter((e=>!X.has(e)));let L,k=t.choice(v);v.length||("fill"===l?S.clear():X.clear(),k=t.choice(zl)),"fill"===l?S.add(k):X.add(k),d&&("fill"===l&&G||"detail"===l&&W)&&(L=u?e.isInCurve.line:s[0].face.vertexlist.map((e=>e.toArray())));let R=c.colorMap[b]||c.colorMap[0],T=t.weightedChoice(...R),M=bl(t,T,a,p,c.colorPalette,"fill"==l?V:K),z=null;if(t.bool(c.fadeAtLineSegmentChance)){let n,l,a=t.int(0,i.vertexList.length-1),s=[i.vertexList[a],i.vertexList[(a+1)%i.vertexList.length]],o=s[0].lerp(s[1],t.num(.01,.99));for(let t=0;t<e.polygon.length;t++){let n=[e.polygon[t],e.polygon[(t+1)%e.polygon.length]],i=Sn(o.toArray(),n[0].toArray(),n[1].toArray());(!l||i<l.dist)&&(l={seg:n,dist:i})}n=l.seg;const{fadeAtLineSegmentDistanceMult:r,fadeAtLineSegmentStrengthMult:d}=c;let u=i.center.distanceTo(n[0].lerp(n[1],.5));z={segment:n,distance:2*u*t.num(r.min,r.max),strength:t.num(d.min,d.max)}}let Y=t.weightedChoice(...c.styleChances),P=0;"directional"===Y&&(P=Hl(e.faceRef,C,o,t));let F,H,I="fill"==l&&u&&(w||0==b&&t.bool(qe.renderLightChance));w=I,"fill"===l?(n?M=n:I&&(M=bl(t,Ke.lightestOrDarkestBasedOnBg,a,p,c.colorPalette,V)),V.push(M)):"detail"==l&&K.push(M);const N=t.bool(c.ignoreLightingChance);F=!(u&&qe.ignoreLighting||N),H=!!(u&&qe.ignoreLighting||N),h.push({paintLineObj:{colorLayerType:T,lineBrightness:F?ye(p,Ie.min,Ie.max,ge(Ie.default,Ie.min,Ie.influencesBrightnessMult),ge(Ie.default,Ie.max,Ie.influencesBrightnessMult)):Ie.default,type:l,lines:[],closedPolyOrLine:!1,noiseOffset:[t.num(-1,1),t.num(-1,1)],canBulge:!0,isShading:!0,canWarp:!0,fadeAtLineSegment:z,lineTapering:Il("bluenoise"==Y&&"detail"==l?{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:0,min:4,max:6}},scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}}}:c.lineTapering,t),disableSaturationShift:H,linePressure:y*ye(p,Ie.max,Ie.min,ye(Ie.influencesPressureMult,1,0,.5,1),1),edgeSharpness:t.num(c.edgeSharpness.min,c.edgeSharpness.max),accumulationStrength:t.num(c.accumulationStrength.min,c.accumulationStrength.max),materialHardness:t.num(c.materialHardness.min,c.materialHardness.max),lineWeight:.8*Z,lineColor:M},workerData:{streamlineWorkerProps:Fl({type:Y,direction:P,addOutline:"edgefill"==Y,scribble:d?!u&&t.bool(c.scribbleChance):t.bool(c.scribbleChance),scribbleStrength:t.num(c.scribbleStrength.min,c.scribbleStrength.max),random:t,insetFromGeometry:L,insetFromGeometryDistance:{min:c.insetDistance.min,max:c.insetDistance.max},objAABB:i,boundingGeometry:e.polygon.map((e=>e.toArray())),lineWeight:Z,minDistance:"bluenoise"==Y&&"detail"==l?.4*g:r(.4,"fill"==l?g*fe(p,Ie.max,Ie.min,fe(Ie.influencesMinDistanceMult,1,0,1,1),fe(Ie.influencesMinDistanceMult,0,1,1,.5)):g),maxLength:c.maxLength?t.num(c.maxLength.min,c.maxLength.max):1e10,wobbleAmplitude:t.easedNum(We,c.wobbleAmplitude.min,c.wobbleAmplitude.max),wobbleFreq:t.easedNum(We,c.wobbleFreq.min,c.wobbleFreq.max),streamLineProps:{...k,wobbleDetail:t.int(1,2)}}),noiseSeed:xn,randomSeed:q(t)}})}return h}const R=[...k(l,"fill",v),...k(l,"detail",L)],T=R.map((e=>Ml(e.workerData))),M=await Promise.all(T);e.allowExtraDetails=!1,R.filter((e=>"detail"==e.paintLineObj.type)).length>=2&&R.filter((e=>"detail"==e.paintLineObj.type)).every((e=>"directional"==e.workerData.streamlineWorkerProps.vectorFieldType))&&(e.allowExtraDetails=!0);for(let t=0;t<M.length;t++){const n=[],l=M[t],i=R[t].paintLineObj;"detail"==i.type&&"bluenoise"==R[t].workerData.streamlineWorkerProps.vectorFieldType&&(i.lineWeight*=1.5);for(let e of l){const t=e;t.length&&n.push(t)}n.length<1||(i.lines=n,e.detailObject=e.detailObject||[],e.detailObject.push(i))}if(e?.detailObject?.length){let t=[];for(let n=e.detailObject.length-1;n>0;n--){let l=e.detailObject[n-1],i=e.detailObject[n];i.colorLayerType===Ke.previous&&l?.lines?.length&&i?.lines?.length&&(l.lines=[...l.lines,...i.lines],t.push(i))}t.length>0&&(e.detailObject=e.detailObject.filter((e=>!t.includes(e))))}e.allowExtraDetails&&e?.detailObject?.length&&!m&&l.bool(d?80:40)&&async function(e,t){let n=[...Si,...hn].filter((e=>e.category==mn.overlay));for(let t of n){let n=new dn;if(n.expands(t.polygon),e.faceRef.aabb.intersects(n))return}let l=e.detailObject.filter((e=>"detail"==e.type));const i=new dn;i.expands(e.polygon),i.expandByValue(10);const a=e.faceRef?.center||i.center;let s=new kn([],[]);s.insertPolygon(e.polygon.map((e=>e.toArray())),!0);for(let e=0;e<l.length;e++){let t=l[e];for(let e of t.lines)s.insertPolygon(e,!1),await new Promise((e=>setTimeout(e,0)))}s.cleanupTrailingEdges();let o=s.internalFaces(),r=c(yn(a.x,a.y,100,5,40,100)),d=yn(a.x,a.y,600,0,100)>60;if(o.length>2)for(let n of o.filter((e=>e.area>100)))if(n.hedges.every((e=>e.face&&e.twin.face&&e.face!==e.twin.face))&&t.bool(r)){let l=t.num(.35,.45),i=n.vertexlist.map((e=>e.addPolar(e.angleTo(n.center),e.distanceTo(n.center)*l))),a={category:mn.detail,faceRef:n,polygon:i,detailObject:[],detailObjectProps:{isFineDetail:!0,skipDetails:!d,skipFill:!!d,inObject:e.detailObjectProps?.inObject,inDominantShapes:e.detailObjectProps?.inDominantShapes,noiseSeedOverride:q(t)}};Si.push(a)}}(e,l),e.readyForRender=!0}let Ul,Dl,Ol=new Set;function Bl(e){let t,n=0;for(;!t&&n++<200;){let n=J.choice(e.internalFaces()),l=J.choice(n.vertexlist);Ol.has(l)||(t=l)}return t}class Ql{dcel;maxAngle;pathVerts=[];AABB=new dn;constructor(e,t=.3){this.dcel=e,this.maxAngle=t}*findDominantPaths(e=!1){let t=new Set(this.dcel.hedges.filter((e=>e.face&&e.face.area>0&&e.twin.face&&e.twin.face.area>0&&e.origin!==e.twin.origin&&e.face!==e.twin.face)));for(;t.size>0;){let n=t.values().next().value;t.delete(n),t.delete(n.twin);let l=[n.twin.origin],i=[n.origin],a=new Set;a.add(n.origin),a.add(n.twin.origin);let o=0;for(let r of[n,n.twin]){let c=r.twin.origin,d=r===n?l:i,u=r.origin,h=u.angleTo(c);for(;;){const n=c.hedgelist.filter((t=>(!e||t.twin.face&&t.twin.face.area>0)&&t.face&&t.face.area>0&&!a.has(t.twin.origin)&&s(c.angleTo(t.twin.origin)-h)<this.maxAngle)).sort(((e,t)=>s(c.angleTo(e.twin.origin)-h)-s(c.angleTo(t.twin.origin)-h)));if(!n.length)break;let l=n[0];o+=s(c.angleTo(l.twin.origin)-h),t.delete(l),t.delete(l.twin),u=c,c=l.twin.origin,d.push(c),a.add(c),h=u.angleTo(c)}}i.reverse();let r=i.concat(l),c=r.reduce(((e,t,n)=>0===n?0:e+t.distanceTo(r[n-1])),0);yield{vertices:r,length:c,curviness:o/r.length}}}walk(e,t,n=!0){let l=e;if(!l)return;let i=0,a=0;this.AABB.expand(l);let s=new Set;for(s.add(l),Ol.add(l);i<=t&&a++<400;){const e=l.hedgelist.filter((e=>!s.has(e.twin.origin)&&!Ol.has(e.twin.origin)));if(e.sort(((e,t)=>{let n=e.twin.origin,l=t.twin.origin,i=this.AABB.center.distanceTo(n);return this.AABB.center.distanceTo(l)-i})),0===e.length)break;let a=e[0].twin.origin;if(i+=l.distanceTo(a),n&&i>t){let e=(o=l,r=a,c=1-(i-t)/l.distanceTo(a),new Ut(ge(o.x,r.x,c),ge(o.y,r.y,c)));s.add(e),this.AABB.expand(e);break}s.add(a),Ol.add(a),this.AABB.expand(a),l=a}var o,r,c;this.pathVerts.push(...Array.from(s))}}class jl{heap;maxSize;valueFunction;epsilon=g;constructor(e,t){this.valueFunction=t,this.heap=[],this.maxSize=e}size(){return this.heap.length}push(e){this.heap.push(e),this.siftUp(this.heap.length-1),this.heap.length>this.maxSize&&this.heap.pop()}clear(){this.heap=[]}peek(){return this.heap[0]}remove(e){const t=this.heap.findIndex((t=>t===e));-1!==t&&(this.heap[t]=this.heap[this.heap.length-1],this.heap.pop(),t<this.heap.length&&this.siftDown(t))}replaceTop(e){this.heap[0]=e,this.siftDown(0)}toArray(){return[...this.heap]}siftUp(e){for(;e>0;){const t=Math.floor((e-1)/2),n=this.valueFunction(this.heap[e])-this.valueFunction(this.heap[t]);if(n<this.epsilon&&n>-this.epsilon)break;if(n<=0)break;[this.heap[e],this.heap[t]]=[this.heap[t],this.heap[e]],e=t}}siftDown(e){const t=this.heap.length;for(;;){let n=e;const l=2*e+1,i=2*e+2,a=this.valueFunction(this.heap[n]);if(l<t&&this.valueFunction(this.heap[l])-a>this.epsilon&&(n=l),i<t){const e=this.valueFunction(this.heap[n]);this.valueFunction(this.heap[i])-e>this.epsilon&&(n=i)}if(n===e)break;[this.heap[e],this.heap[n]]=[this.heap[n],this.heap[e]],e=n}}}class Jl{position;rotation;dimensions;numSides;cameraPos;fov;aspect;near;far;lights;cullBackfaces;localVertices=[];worldVertices=[];screenVertices=[];constructor(e,t,n,l,i,a=90,s=Y/P,o=.1,r=1e4,c=[],d=!1){this.position=e,this.rotation=t,this.dimensions=n,this.numSides=l,this.cameraPos=i,this.fov=a,this.aspect=s,this.near=o,this.far=r,this.lights=c,this.cullBackfaces=d,this._buildLocalGeometry()}_buildLocalGeometry(){const{width:e,height:t,depth:n}=this.dimensions,l=e/2,i=t/2,a=n/2,s=2*Math.PI/this.numSides,o=this.numSides%2==0?-Math.PI/this.numSides:-Math.PI/2;if(0===n)for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t)*l,a=Math.sin(t)*i;this.localVertices.push({x:n,y:a,z:0})}else for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t),r=Math.sin(t);this.localVertices.push({x:n*l,y:r*i,z:+a}),this.localVertices.push({x:n*l,y:r*i,z:-a})}}getFaces2D(){const e=function(e,t,n,l,i,a){const s=El(e*Math.PI/180),o=_l(t*Math.PI/180),r=ql(n*Math.PI/180),c=$l(l,i,a),d=ei(r,ei(o,s));return ei(c,d)}(this.rotation.x,this.rotation.y,this.rotation.z,this.position.x,this.position.y,this.position.z),t=$l(-this.cameraPos.x,-this.cameraPos.y,-this.cameraPos.z),n=ei(function(e,t,n,l){const i=1/Math.tan(e*Math.PI/180/2),a=1/(n-l);return[[i/t,0,0,0],[0,i,0,0],[0,0,(n+l)*a,n*l*a*2],[0,0,-1,0]]}(this.fov,this.aspect,this.near,this.far),ei(t,e));this.worldVertices=[],this.screenVertices=[];for(const t of this.localVertices){const l=ti(e,[t.x,t.y,t.z,1]);this.worldVertices.push({x:l[0],y:l[1],z:l[2]});const i=ti(n,[t.x,t.y,t.z,1]);0!==i[3]&&(i[0]/=i[3],i[1]/=i[3],i[2]/=i[3]);const a=(.5*i[0]+.5)*Y,s=(1-(.5*i[1]+.5))*P;this.screenVertices.push([a,s])}const l=this._buildFaces(),i=this.cameraPos.x,a=this.cameraPos.y,s=this.cameraPos.z,o=[];for(let e of l){const t=e.indices.map((e=>this.worldVertices[e])),n=e.indices.map((e=>this.screenVertices[e])),l=ni(t),r=li(t),c=ii(l,r,this.lights);if(this.cullBackfaces){const e={x:r.x-i,y:r.y-a,z:r.z-s};l[0]*e.x+l[1]*e.y+l[2]*e.z<0&&o.push({vertices:n,normal:l,lighting:c})}else o.push({vertices:n,normal:l,lighting:c})}return o}_buildFaces(){const e=[],t=this.numSides;if(0!==this.dimensions.depth){const n=[];for(let e=0;e<t;e++)n.push(2*e);e.push({indices:n});const l=[];for(let e=t-1;e>=0;e--)l.push(2*e+1);e.push({indices:l});for(let n=0;n<t;n++){const l=(n+1)%t,i=[2*n,2*n+1,2*l+1,2*l];e.push({indices:i})}}else e.push({indices:Array.from({length:t},((e,t)=>t))});return e}}class Al{vertices;rotation;perspective;zShift;transformOrigin;projectedVertices;vertices3D;constructor(e,t,n=800,l=-50,i={x:Y/2,y:P/2}){this.vertices=e,this.rotation=t,this.perspective=n,this.zShift=l,this.transformOrigin=i}getLineSegments(){let e=new dn;for(let t of this.vertices)e.expands(t.map((e=>new Ut(...e))));const{x:t,y:n,z:l}={...e.center,z:this.zShift},{x:i,y:a,z:s}=this.rotation,o=this.perspective,r=e.center,c=this.vertices.map((e=>e.map((e=>new Ut(...e).subtract(r)))));this.vertices3D=[];for(let e=0;e<c.length;e++){this.vertices3D.push([]);for(const t of c[e])this.vertices3D[e].push({x:t.x,y:t.y,z:0})}const d=function(e,t,n,l,i,a){const s=t*Math.PI/180,o=n*Math.PI/180,r=El(e*Math.PI/180),c=_l(s);let d=ei(ql(o),ei(c,r));return ei($l(l,i,a),d)}(i,a,s,t,n,l),u=this.vertices3D.map((e=>e.map((e=>{const t=[e.x,e.y,e.z,1],n=ti(d,t);return{x:n[0],y:n[1],z:n[2]}}))));return this.projectedVertices=u.map((e=>e.map((e=>function(e,t,n={x:Y/2,y:P/2}){const{x:l,y:i,z:a}=e,s=l-n.x,o=(i-n.y)*t/(t+a);return t+a<=0?null:[s*t/(t+a)+n.x,o+n.y]}(e,o,this.transformOrigin))).filter((e=>null!==e)))).map((e=>e.filter((e=>e[0]>=-100&&e[0]<=Y+100&&e[1]>=-100&&e[1]<=P+100)))).filter((e=>e.length>0)),this.projectedVertices}}function El(e){const t=Math.cos(e),n=Math.sin(e);return[[1,0,0,0],[0,t,-n,0],[0,n,t,0],[0,0,0,1]]}function _l(e){const t=Math.cos(e),n=Math.sin(e);return[[t,0,n,0],[0,1,0,0],[-n,0,t,0],[0,0,0,1]]}function ql(e){const t=Math.cos(e),n=Math.sin(e);return[[t,-n,0,0],[n,t,0,0],[0,0,1,0],[0,0,0,1]]}function $l(e,t,n=0){return[[1,0,0,e],[0,1,0,t],[0,0,1,n],[0,0,0,1]]}function ei(e,t){const n=Array.from(Array(e.length),(()=>Array(t[0].length).fill(0)));for(let l=0;l<e.length;l++)for(let i=0;i<t[0].length;i++)for(let a=0;a<e[0].length;a++)n[l][i]+=e[l][a]*t[a][i];return n}function ti(e,t){const n=[];for(let l=0;l<e.length;l++){let i=0;for(let n=0;n<t.length;n++)i+=e[l][n]*t[n];n.push(i)}return n}function ni(e){const t=e[0],n=e[1],l=e[2],i=[n.x-t.x,n.y-t.y,n.z-t.z],a=[l.x-t.x,l.y-t.y,l.z-t.z],s=[i[1]*a[2]-i[2]*a[1],i[2]*a[0]-i[0]*a[2],i[0]*a[1]-i[1]*a[0]],o=Math.sqrt(s[0]**2+s[1]**2+s[2]**2);return s.map((e=>e/o))}function li(e){const t=e.reduce(((e,t)=>(e.x+=t.x,e.y+=t.y,e.z+=t.z,e)),{x:0,y:0,z:0}),n=e.length;return{x:t.x/n,y:t.y/n,z:t.z/n}}function ii(e,t,n){let l=0;for(const i of n){const n={x:i.position.x-t.x,y:i.position.y-t.y,z:i.position.z-t.z},a=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);if(0===a)continue;const s=n.x/a,o=n.y/a,r=n.z/a;l+=(e[0]*s+e[1]*o+e[2]*r)*i.brightness}return l}let ai=!1,si=0,oi=0;T();let ri=T();const ci=()=>{if(!ki[si])return void ui();const e=ki[si][0](),t=ki[si][1]||!1;let n,l=!1;const i=()=>{n=e.next(),na?l=!1:(l=!0,n?.done||function(e){ai||(Ul=w.getParameter(w.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),Dl=w.SYNC_FLUSH_COMMANDS_BIT,ai=!0);const t=w.fenceSync(w.SYNC_GPU_COMMANDS_COMPLETE,0);!function n(){const l=w.clientWaitSync(t,Dl,Ul);l===w.ALREADY_SIGNALED||l===w.CONDITION_SATISFIED||na?(clearTimeout(void 0),w.deleteSync(t),e()):setTimeout(n,0)}()}(i))},a=()=>{const s=T();if(t)!l&&!na&&i();else for(;T()-s<1e3/30&&!na&&!n?.done;)n=e.next();oi++,n?.done?(di("Step took"),Ft?.copyBufferToScreen(),l=!1,n=null,si++,ci()):(v(n.value||{showUpdate:!1}),setTimeout(a,0))};a()};function di(e="",t=!1){T(),ri=T()}const ui=()=>{document.complete=!0,nl(gl([...dl][0],[...dl],dl.size)),di("Total render time",!0),function(){for(let e=0;e<Vl.length;e++){const t=Vl[e];t&&t.terminate()}}()};function hi(e,t,n=4){const l=t/2,i=[];for(let t=0;t<e.length-1;t++){const[n,l]=e[t],[a,s]=e[t+1],o=a-n,r=s-l,c=Math.hypot(o,r);if(0===c){i.push([0,0]);continue}const d=-r/c,u=o/c;i.push([d,u])}const a=[],s=[];for(let t=0;t<e.length;t++){const[o,r]=e[t];if(0===t){const[e,t]=i[0],n=e*l,c=t*l;a.push([o+n,r+c]),s.push([o-n,r-c])}else if(t===e.length-1){const[e,t]=i[i.length-1],n=e*l,c=t*l;a.push([o+n,r+c]),s.push([o-n,r-c])}else{const[e,c]=i[t-1],[d,u]=i[t],h=Math.sqrt((e*d+c*u+1)/2);if(0===h){const t=e*l,n=c*l;a.push([o+t,r+n]),s.push([o-t,r-n]);continue}const m=l/h;if(m>n*l){const[t,n]=[e*l,c*l],[i,h]=[d*l,u*l];a.push([o+t,r+n]),a.push([o+i,r+h]),s.push([o-t,r-n]),s.push([o-i,r-h])}else{const[t,n]=[e+d,c+u],i=Math.hypot(t,n);if(0===i){const t=e*l,n=c*l;a.push([o+t,r+n]),s.push([o-t,r-n])}else{const[e,l]=[t/i,n/i],c=e*m,d=l*m;a.push([o+c,r+d]),s.push([o-c,r-d])}}}}return[...a.reverse(),...s]}class mi{root=null;epsilon=g;count=0;wasRemoved=!1;insert(e){this.root=this.insertRec(this.root,e,0),this.count++}compareCoord(e,t){const n=e-t;return Math.abs(n)<this.epsilon||n<0?-1:1}insertRec(e,t,n){return e?((0===e.axis?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y))<0?e.left=this.insertRec(e.left,t,n+1):e.right=this.insertRec(e.right,t,n+1),e):{point:t,axis:n%2,left:null,right:null}}remove(e){this.wasRemoved=!1,this.root=this.removeRec(this.root,e,0),this.wasRemoved&&this.count--}removeRec(e,t,n){if(!e)return null;const l=e.axis;if(this.equals(e.point,t)){if(this.wasRemoved=!0,e.right){const t=this.findMin(e.right,l,n+1);e.point=t.point,e.right=this.removeRec(e.right,t.point,n+1)}else{if(!e.left)return null;{const t=this.findMin(e.left,l,n+1);e.point=t.point,e.right=this.removeRec(e.left,t.point,n+1),e.left=null}}return e}{let i;i=0===l?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y),i<0?e.left=this.removeRec(e.left,t,n+1):e.right=this.removeRec(e.right,t,n+1)}return e}findMin(e,t,n){if(!e)throw Error("Empty subtree when finding min.");if(e.axis===t)return e.left?this.findMin(e.left,t,n+1):e;const l=e.left?this.findMin(e.left,t,n+1):e,i=e.right?this.findMin(e.right,t,n+1):e;let a=e;return this.compareAxis(l.point,a.point,t)<0&&(a=l),this.compareAxis(i.point,a.point,t)<0&&(a=i),a}findNearest(e){return this.root?this.findNearestRec(this.root,e,this.root.point,0):null}findNearestRec(e,t,n,l){if(!e)return n;let i=n;this.distanceSq(e.point,t)<this.distanceSq(i,t)&&(i=e.point);const a=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let s,o;return a<-this.epsilon?(s=e.left,o=e.right):a>this.epsilon?(s=e.right,o=e.left):(s=e.left,o=e.right),i=this.findNearestRec(s,t,i,l+1),a**2<this.distanceSq(i,t)&&(i=this.findNearestRec(o,t,i,l+1)),i}findKNearest(e,t){if(!this.root)return[];const n=new jl(t,(e=>e.dist));return this.findKNearestRec(this.root,e,t,n),n.toArray().map((e=>e.point))}getTotalNodes(){return this.count}*pointsWithinDistanceGenerator(e,t){const n=t*t;yield*this.pointsWithinDistanceRecGen(this.root,e,n)}*pointsWithinDistanceRecGen(e,t,n,l=0){if(!e)return;this.distanceSq(e.point,t)<=n&&(yield e.point);const i=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let a,s;i<-this.epsilon?(a=e.left,s=e.right):(a=e.right,s=e.left),yield*this.pointsWithinDistanceRecGen(a,t,n,l+1),i**2<=n&&(yield*this.pointsWithinDistanceRecGen(s,t,n,l+1))}findKNearestRec(e,t,n,l,i=0){if(!e)return;const a=e.axis,s=this.distanceSq(e.point,t);if(l.size()<n)l.push({dist:s,point:e.point});else{const t=l.peek();t&&s<t.dist&&l.replaceTop({dist:s,point:e.point})}const o=0===a?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let r,c;o<-this.epsilon?(r=e.left,c=e.right):o>this.epsilon?(r=e.right,c=e.left):(r=e.left,c=e.right),this.findKNearestRec(r,t,n,l,i+1);const d=l.peek();d&&o**2<d.dist&&this.findKNearestRec(c,t,n,l,i+1)}distanceSq(e,t){const n=e.point.x-t.point.x,l=e.point.y-t.point.y;return n*n+l*l}compareAxis(e,t,n){const l=0===n?e.point.x-t.point.x:e.point.y-t.point.y;return Math.abs(l)<this.epsilon?0:l}equals(e,t){const n=e.point.x-t.point.x,l=e.point.y-t.point.y;return n*n+l*l<this.epsilon*this.epsilon}}class pi{opts;kTree=new mi;activeList=[];random;epsilon=g;maxDist;constructor(e){this.opts=e,this.random=e.random||J,this.maxDist=e.maxDist||1}*generate(){const{bounds:e,noiseField:t,initialCount:n=1,k:l=50}=this.opts;if(this.opts.seedPoints&&this.opts.seedPoints.length>0)for(let e of this.opts.seedPoints){const n={point:e,minDist:t(e.x,e.y)};this.placePoint(n),this.activeList.push(n),yield n}else for(let l=0;l<n;l++){const n=this.random.num(e.topLeft[0],e.bottomRight[0]),l=this.random.num(e.topLeft[1],e.bottomRight[1]),i=t(n,l),a={point:new Ut(n,l),minDist:i};this.placePoint(a),this.activeList.push(a),yield a}for(;this.activeList.length>0;){const n=0,i=this.activeList[n];let a=!1;for(let n=1;n<l;n++){const s=i.minDist*(.5+l/n),o=this.random.dec()*Math.PI*2,r=i.point.x+Math.cos(o)*s,c=i.point.y+Math.sin(o)*s;if(r<e.topLeft[0]||r>e.bottomRight[0]||c<e.topLeft[1]||c>e.bottomRight[1])continue;const d=t(r,c),u={point:new Ut(r,c),minDist:d};if(this.canPlace(u)){this.placePoint(u),this.activeList.push(u),yield u,a=!0;break}}a||this.activeList.splice(n,1)}}canPlace(e){for(let t of
1lLHRoaXMuc2lmdERvd24oMCl9dG9BcnJheSgpe3JldHVyblsuLi50aGlzLmhlYXBdfXNpZnRVcChlKXtmb3IoO2U+MDspe2NvbnN0IHQ9TWF0aC5mbG9vcigoZS0xKS8yKSxpPXRoaXMudmFsdWVGdW5jdGlvbih0aGlzLmhlYXBbZV0pLXRoaXMudmFsdWVGdW5jdGlvbih0aGlzLmhlYXBbdF0pO2lmKGk8dGhpcy5lcHNpbG9uJiZpPi10aGlzLmVwc2lsb24pYnJlYWs7aWYoaTw9MClicmVhaztbdGhpcy5oZWFwW2VdLHRoaXMuaGVhcFt0XV09W3RoaXMuaGVhcFt0XSx0aGlzLmhlYXBbZV1dLGU9dH19c2lmdERvd24oZSl7Y29uc3QgdD10aGlzLmhlYXAubGVuZ3RoO2Zvcig7Oyl7bGV0IGk9ZTtjb25zdCBuPTIqZSsxLHM9MiplKzIscj10aGlzLnZhbHVlRnVuY3Rpb24odGhpcy5oZWFwW2ldKTtpZihuPHQmJnRoaXMudmFsdWVGdW5jdGlvbih0aGlzLmhlYXBbbl0pLXI+dGhpcy5lcHNpbG9uJiYoaT1uKSxzPHQpe2NvbnN0IGU9dGhpcy52YWx1ZUZ1bmN0aW9uKHRoaXMuaGVhcFtpXSk7dGhpcy52YWx1ZUZ1bmN0aW9uKHRoaXMuaGVhcFtzXSktZT50aGl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ZShlLDApO3lpZWxkIHR9KHIpO2JyZWFrO2RlZmF1bHQ6dGhyb3cgRXJyb3IoIkludmFsaWQgZmllbGQgdHlwZSIpfWZvcihsZXQgZSBvZiBnKXtpZighZXx8ZS5sZW5ndGg8Miljb250aW51ZTtpZigib3V0bGluZSI9PT10KXtwb3N0TWVzc2FnZSh7cmVzdWx0OltlXSxkb25lOiExLGVycm9yOm51bGwsd29ya2VySWQ6ZH0pO2JyZWFrfWxldCBpPW1lKGUpO2lmKHIucG9zdFByb2Nlc3NpbmdBcmdzKXtpPXZlKGkscik7bGV0IGU9ZihpKTtpZighZS5sZW5ndGgpY29udGludWU7ZT1lLm1hcCgoZT0+TWUoZSxyKSkpLmZpbHRlcigoZT0+ZS5sZW5ndGg+PTIpKSx1LnB1c2goLi4uZSkscCgpfWVsc2UgdS5wdXNoKGkpLHAoKX1pZigib3V0bGluZSIhPT10JiZyLmFkZE91dGxpbmUmJiFyLmluc2V0RnJvbUdlb21ldHJ5JiZyLmJvdW5kaW5nR2VvbWV0cnkpe2xldCBlPXdlKHIpO3UucHVzaChlKX1wKCEwKX1jYXRjaChlKXtwb3N0TWVzc2FnZSh7cmVzdWx0Om51bGwsZXJyb3I6ZS5tZXNzYWdlLHdvcmtlcklkOmR9KX19fSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1zdHJlYW1saW5lcy53b3JrZXIuanMubWFwCgo=");const Cl=navigator.hardwareConcurrency||4,Vl=[],Kl={},wl={},kl=[],Rl={};for(let e=0;e<Cl;e++){const t=new Xl;Vl.push(t),Rl[e]=!0,wl[e]=[],t.onmessage=function(e){const{result:t,done:n,error:l,workerId:i}=e.data;if(t?.length>0&&wl[i].push(...t),n||l){const e=Kl[i];if(l?e.reject(l):e.resolve(wl[i]),delete Kl[i],Rl[i]=!0,wl[i]=[],kl.length>0){const e=kl.shift();e.data.workerId=i,Tl(i,e)}}}}function Tl(e,t){const n=Vl[e];Rl[e]=!1,Kl[e]=t,n.postMessage(t.data)}async function Ml(e){return new Promise(((t,n)=>{const l={data:e,resolve:t,reject:n};kl.push(l),function(){for(let e=0;e<Vl.length&&0!==kl.length;e++)if(Rl[e]){const t=kl.shift();t.data.workerId=e,Tl(e,t)}}()}))}let zl=[],Yl=(e,{isInDominantPoly:t,normal:n,isOverlay:l=!1,isInCurveOrObject:i=!1})=>{const a=[{condition:l,key:we.overlay},{condition:!0,key:we.override},{condition:t,key:we.dominant},{condition:!t,key:we.nonDominant},{condition:n>Ie.default,key:we.normalHigh},{condition:n<Ie.default,key:we.normalLow},{condition:i,key:we.inCurveOrObject},{condition:!i,key:we.notInCurveOrObject}].filter((({key:t})=>e.spatialOverride?.[t]));for(const{condition:t,key:n}of a)if(t&&e.spatialOverride[n])return be(e,e.spatialOverride[n]);return e},Pl=(e,t)=>e?.layerOverride?.[t]?be(e,e.layerOverride[t]):e,Fl=({random:e,type:t="noise",direction:n=e.num(0,360),objAABB:l,addOutline:i=!1,boundingGeometry:a,insetFromGeometry:s,insetFromGeometryDistance:c={min:2,max:4},lineWeight:d,scribble:u=!1,scribbleStrength:h=0,maxLength:m=1e10,minDistance:p=r(.2,.75*d),minLength:b=2*p,wobbleAmplitude:g=e.easedNum(We,.5,2),wobbleFreq:f=e.easedNum(We,10*d,20*d),streamLineProps:x})=>{const Z={stepSize:o(p/2,1),maxLength:m,minLeng
xlLHRoaXMudG9sZXJhbmNlKSYmbCsrfSkpLGw+MXx8ci5wdXNoKFtzLG9dKX19Zm9yKGxldCBlIG9mIHIpdi5ib29sKHQpJiZ0aGlzLnJlbW92ZUVkZ2UoZVswXS54LGVbMF0ueSxlWzFdLngsZVsxXS55KTt0aGlzLmNsZWFudXBUcmFpbGluZ0VkZ2VzKCl9aW5zZXJ0UG9seWdvbihlLHQ9ITApe2xldCBpPVtdLG49bmV3IE47bi5leHBhbmRzKGUubWFwKChlPT4obmV3IEQpLmZyb21BcnJheShlKSkpKSxuLmV4cGFuZEJ5VmFsdWUodGhpcy50b2xlcmFuY2UpO2xldCBzPX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S0pfXJldHVybiBwfSgodCsxMDApL3MsKGkrMTAwKS9zLChuKzEwMCkvcyksMCwxLHIsbyk7Y2xhc3MgY2V7aGVhcDttYXhTaXplO3ZhbHVlRnVuY3Rpb247ZXBzaWxvbj1wO2NvbnN0cnVjdG9yKGUsdCl7dGhpcy52YWx1ZUZ1bmN0aW9uPXQsdGhpcy5oZWFwPVtdLHRoaXMubWF4U2l6ZT1lfXNpemUoKXtyZXR1cm4gdGhpcy5oZWFwLmxlbmd0aH1wdXNoKGUpe3RoaXMuaGVhcC5wdXNoKGUpLHRoaXMuc2lmdFVwKHRoaXMuaGVhcC5sZW5ndGgtMSksdGhpcy5oZWFwLmxlbmd0aD50aGlzLm1heFNpemUmJnRoaXMuaGVhcC5wb3AoKX1jbGVhcigpe3RoaXMuaGVhcD1bXX1wZWVrKCl7cmV0dXJuIHRoaXMuaGVhcFswXX1yZW1vdmUoZSl7Y29uc3QgdD10aGlzLmhlYXAuZmluZEluZGV4KCh0PT50PT09ZSkpOy0xIT09dCYmKHRoaXMuaGVhcFt0XT10aGlzLmhlYXBbdGhpcy5oZWFwLmxlbmd0aC0xXSx0aGlzLmhlYXAucG9wKCksdDx0aGlzLmhlYXAubGVuZ3RoJiZ0aGlzLnNpZnREb3duKHQpKX1yZXBsYWNlVG9wKGUpe3RoaXMuaGVhcFswXT
h,h};let ol=[],rl=[],cl=[],dl=new Set,ul={L:1,C:1,H:2/Math.PI},hl=30,ml=ve;function pl(e,t,n=ul){e=Jt(e),t=Jt(t);const{L:l,C:i,H:a}=n,s=e[0]-t[0],o=e[1]-t[1];let r=e[2]-t[2];r=(r+180)%360-180;const c=r*Math.PI/180;return Math.sqrt(s*s*l+o*o*i+c*c*a)}function bl(e,t,n,l=1,i="fg",a=[]){let s,o=t,r=Re.bg[0][0]>=.5,c=a?.[0];if(o==Ke.previous)return c;if(o==Ke.brightnessBasedShadowOrHighlight){let t,a=c||Ll(e,n,l,null,i),s=l>=ge(Ie.max,Ie.min,.5),o=.2;if(a[0]>.75&&!s&&(o=.02),s){let e=Zl(a,cl,o);t=[ge(a[0]+o,e[0],.5),e[1],e[2]]}else{let e=Zl(a,cl,-o);t=[ge(a[0]+-o,e[0],.5),e[1],e[2]]}return Jt(t)}Ke.lightestOrDarkestBasedOnBg==o&&(o=r?Ke.lightest:Ke.darkest);let d=c||Ll(e,n,l,null,i),u=d[0]>.7&&d[1]<.05;switch(o){case Ke.color:s=Ll(e,n,l,null,i);break;case Ke.randomAccent:s=e.choice(ol);break;case Ke.base:s=Re.base[0];break;case Ke.line:s=Re.line.reduce(((e,t)=>r?e[0]<t[0]?e:t:e[0]>t[0]?e:t),Re.line[0]);break;case Ke.shadow:let t=c||Ll(e,n,l,null,i);s=xl([.3*t[0],t[1],t[2]],cl,0)[0];break;case Ke.highlight:let a=c||Ll(e,n,l,null,i);s=xl([Ze(0,1,1.5*a[0]),a[1],a[2]],cl,0)[0];break;case Ke.offset:s=u?d:xl(c||d,cl,hl*e.choice([-1,1]),1)[0];break;case Ke.offsetUp:s=u?d:xl(c||d,cl,hl,1)[0];break;case Ke.palettecomplement:s=xl(c||d,ol,180)[0];break;case Ke.offsetDown:s=u?d:xl(c||d,cl,hl,-1)[0];break;case Ke.darkest:s=ol.reduce(((e,t)=>e[0]<t[0]?e:t),ol[0]);break;case Ke.lightest:s=ol.reduce(((e,t)=>e[0]>t[0]?e:t),ol[0])}return dl.add(s),s}function gl(e,t,n=0){if(0===t.length)throw Error("Palette is empty.");const l=t.map((t=>({color:t,dist:pl(e,t)})));return l.sort(((e,t)=>e.dist-t.dist)),l.slice(0,n).map((e=>e.color))}function fl(e,t){let n=e.leastCommonIndex,l=e.mostCommonIndex,i=t.reduce(((e,t)=>e[0]<t[0]?e:t),t[0]),a=t.reduce(((e,t)=>e[0]>t[0]?e:t),t[0]);const s=(t.indexOf(i)-n+t.length)%t.length;let o=t.slice(s).concat(t.slice(0,s));if(o.indexOf(a)===l){const e=[];for(let t=0;t<o.length;t++)t!==l&&t!==n&&e.push(t);if(e.length>0){const t=J.choice(e);[o[l],o[t]]=[o[t],o[l]]}}return o}function xl(e,t,n=20,l=1){return gl([e[0],e[1],jt(e[2]+n)],t.filter((e=>e)),l)}function Zl(e,t,n=1){const l=[Ze(0,1,e[0]+n),e[1],e[2]];let i;for(let e of t){let t=pl(l,e,ul);(!i||t<i.dist)&&(i={color:e,dist:t})}return i.color}let yl,Gl,Wl=new Map,vl=new Set;function Ll(e,t,n=1,l=null,i="fg",a=null){let{freqMultiplier:o,singleAccent:r,usePolyIDColorOffset:d}=et,u=0,h="fg"==i?ol:rl,m="fg"==i?yl:Gl,p="fg"==i?o:500*o,b="bg"==i?ye(t.y,0,P,0,h.length-1):ye(ml(yn(t.x,t.y,0,p,0,1)),m.min,m.max,0,h.length-1);if(d){let n=Ki.getPolygonsAtPoint(t.toArray()).filter((e=>vl.has(e.meta.meta.id))).sort(((e,t)=>e.meta.meta.totalArea-t.meta.meta.totalArea)),l=n?.[0];if(l){let t=l.meta.meta.id;Wl.has(t)||Wl.set(t,e.int(1,h.length-1)),u+=Wl.get(t)}}if(null!==l){let t=xl(a||h[c(s(b+u))%h.length],cl,hl*l,et.samplesForComplimentary);return e.choice(t)}return h[c(s(b+u))%h.length]}function Sl(e,t,n){var l;return function(t){return l=l||function(e){var t=function(e){return atob(e)}(e),n=t.indexOf("\n",10)+1,l=t.substring(n)+"",i=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(i)}(e),new Worker(l,t)}}var Xl=Sl("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y29uc3R7Zmxvb3I6ZSxjZWlsOnQsc2luOmksY29zOm4scG93OnMsYWJzOnIsbWluOm8sbWF4OmwsaHlwb3Q6aCxyb3VuZDphLHNxcnQ6YyxhY29zOmQsc2lnbjpnLGxvZzpmLFBJOnV9PU1hdGgscD0xZS03O2Z1bmN0aW9uIHgodCxpPXApe3JldHVybiBl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RvbGVyYW5jZSlyZXR1cm4hMH19aXNMaW5lU2VnbWVudE9uRWRnZU9mRmFjZShlLHQsaT1wKXtmb3IobGV0IG49MDtuPGUudmVydGV4bGlzdC5sZW5ndGg7bisrKWlmKEgoW2UudmVydGV4bGlzdFtuXS50b0FycmF5KCksZS52ZXJ0ZXhsaXN0WyhuKzEpJWUudmVydGV4bGlzdC5sZW5ndGhdLnRvQXJyYXkoKV0sdCksaSlyZXR1cm4hMDtyZXR1cm4hMX1nZXRGYWNlc0ludGVyc2VjdGluZ0FBQkIoZSl7bGV0IHQ9W107Zm9yKGxldCBpIG9mIHRoaXMuZmFjZXMuZmlsdGVyKChlPT5lLmFyZWE+MCkpKWUuaW50ZXJzZWN0cyhpLmFhYmIsdGhpcy50b2xlcmFuY2UpJiZ0LnB1c2goaSk7cmV0dXJuIHR9cmVtb3ZlRWRnZXNJbnNpZGVQb2x5Z29uKGUsdD0xMDApe2xldCBpPW5ldyBOO2kuZXhwYW5kcyhlLm1hcCgoZT0+KG5ldyBEKS5mcm9tQXJyYXkoZSkpKSk7bGV0IG49ZS5tYXAoKGU9PihuZXcgRCkuZnJvbUFycmF5KGUpKSkscz10aGlzLmdldEZhY2VzSW50ZXJzZWN0aW5nQUFCQihpKSxyPVtdO2ZvcihsZXQgdCBvZiBzKXtsZXQgaT10LnZlcnRleGxpc3Q7Zm9yKGxldCB0PTA7dDxpLmxlbmd0aDt0Kyspe2xldCBzPWlbdF0sbz1pWyh0KzEpJWkubGVuZ3RoXTtpZighZWUobixzLHRoaXMudG9sZXJhbmNlKXx8IWVlKG4sbyx0aGlzLnRvbGVyYW5jZSkpY29udGludWU7bGV0IGw9MDtbcyxvXS5mb3JFYWNoKCh0PT57VSh0LnRvQXJyYXkoKS
).fromArray(e))),n=new dn;n.expands(t);let l=[];for(let i of this.faces)if(!(i.area<=this.tolerance)&&n.intersects(i.aabb)){if(Nn(t,i.vertexlist)){l.push({face:i,intersections:[],isContained:!0});continue}let n=[];for(let l=0;l<e.length;l++){let a=[t[l],t[(l+1)%e.length]];n.push(...i.intersectWithLineSeg(a))}n.length>0&&l.push({face:i,intersections:n,isContained:!1})}return l}}class kn extends wn{tolerance;constructor(e,t,n=Kn){super(e,t,n),this.tolerance=n}isPolyLineSegmentOnEdge(e,t){for(let n=0;n<t.length-1;n++){let l=[t[n],t[n+1]];if(this.isLineSegmentOnEdgeOfFace(e,l),this.tolerance)return!0}}isLineSegmentOnEdgeOfFace(e,t,n=g){for(let l=0;l<e.vertexlist.length;l++)if(Rn([e.vertexlist[l].toArray(),e.vertexlist[(l+1)%e.vertexlist.length].toArray()],t),n)return!0;return!1}getFacesIntersectingAABB(e){let t=[];for(let n of this.faces.filter((e=>e.area>0)))e.intersects(n.aabb,this.tolerance)&&t.push(n);return t}removeEdgesInsidePolygon(e,t=100){let n=new dn;n.expands(e.map((e=>(new Ut).fromArray(e))));let l=e.map((e=>(new Ut).fromArray(e))),i=this.getFacesIntersectingAABB(n),a=[];for(let t of i){let n=t.vertexlist;for(let t=0;t<n.length;t++){let i=n[t],s=n[(t+1)%n.length];if(!In(l,i,this.tolerance)||!In(l,s,this.tolerance))continue;let o=0;[i,s].forEach((t=>{Mn(t.toArray(),e,this.tolerance)&&o++})),o>1||a.push([i,s])}}for(let e of a)J.bool(t)&&this.removeEdge(e[0].x,e[0].y,e[1].x,e[1].y);this.cleanupTrailingEdges()}insertPolygon(e,t=!0){let n=[],l=new dn;l.expands(e.map((e=>(new Ut).fromArray(e)))),l.expandByValue(this.tolerance);let i=this.getFacesIntersectingAABB(l),a=new Set;for(let e of i){let t=e.vertexlist;for(let e=0;e<t.length;e++){let n=t[e],l=t[(e+1)%t.length],i=this.findHedge(n.x,n.y,l.x,l.y);a.has(i.twin)||a.add(i)}}for(let t of e)n.push({type:"addVertex",data:{x:t[0],y:t[1]}});for(let l of a){let i=[];e:for(let a=0;a<(t?e.length:e.length-1);a++){let t=[new Ut(...e[a]),new Ut(...e[(a+1)%e.length])],s=l.intersectWithLineSegment(t);if(s.type==Wn.intersecting){for(let e of i)if(e.isEqualTo(s.point))continue e;n.push({type:"addVertex",data:{x:s.point.x,y:s.point.y}})}}}for(let l=0;l<(t?e.length:e.length-1);l++){let t=[e[l],e[(l+1)%e.length]];n.push({type:"addEdge",data:{from:{x:t[0][0],y:t[0][1]},to:{x:t[1][0],y:t[1][1]}}})}this.executeAddOperations(n)}splitFaceByPolyLine(e,t,n=!1,l=!1,i=!1){const a=(e,t,n,l)=>{const i=[.5,.25,.75];for(let a of i){let i=e.lerp(t,a);if(n.containsPoint(i)&&!n.isPointOnBoundary(i,l))return!0}return!1},s=(e,t,n,l)=>{let i=[.25,.5,.75],a=0;for(let s of i){let i=e.lerp(t,s);if(n.isPointOnBoundary(i,l)&&(a++,a>=2))return!0}return a>=2};let o=[],r=[],c=!1,d=0;if(n){let n=t.findIndex((t=>!e.containsPoint(new Ut(...t))||e.isPointOnBoundary(new Ut(...t),this.tolerance)));if(!(n>=0))return!1;t=t.slice(n).concat(t.slice(0,n))}const u=n?t.length:t.length-1;for(let n=0;n<u;n++){let l=new Ut(...t[n]),i=new Ut(...t[(n+1)%t.length]),u=[l,i],h=e.intersectWithLineSeg(u);d+=h.length;let m=[l,...h.map((e=>e.point)),i];m=Tn(l,i,m,!0,this.tolerance);for(let t=0;t<m.length-1;t++){let n=m[t],l=m[t+1];a(n,l,e,this.tolerance)&&!s(n,l,e,this.tolerance)?(c||(r=[n],c=!0),r.push(l)):c&&(o.push(r),r=[],c=!1)}}if(!n&&c&&r.length>1&&o.push(r),l||(o=o.filter((t=>{let n=t[Math.floor(t.length/2)].lerp(t[Math.ceil(t.length/2)],.5);return e.containsPoint(n)}))),o.length>1&&i){let e=null;for(let t of o){let l=0;for(let e=0;e<(n?t.length:t.length-1);e++)l+=t[e].distanceTo(t[(e+1)%t.length]);(!e||l>e.length)&&(e={length:l,line:t})}if(!e)return!1;o=[e.line]}if(0===o.length)return!1;if(l)return{lines:o,intersectionCount:d};let h=[];for(let e of o)for(let t of e)h.push({type:"addVertex",data:{x:t.x,y:t.y}});for(let e of o)for(let t=0;t<e.length-1;t++)h.push({type:"addEdge",data:{from:{x:e[t].x,y:e[t].y},to:{x:e[t+1].x,y:e[t+1].y}}});return this.executeAddOperations(h),!0}executeAddOperations(e){const t=e.filter((e=>"addVertex"===e.type)),n=e.filter((e=>"addEdge"===e.type));let l=[];for(const e of n){let t=new dn,n=new Ut(e.data.from.x,e.data.from.y),i=new Ut(e.data.to.x,e.data.to.y);t.expands([n,i]),t.expandByValue(this.tolerance);let a=new Set;for(let e of this.hedges){let l=e.getAABB();if(l.expandByValue(this.tolerance),l.intersects(t)){let t=e.intersectWithLineSegment([n,i]);t.type==Wn.intersecting&&(a.add(t.point),this.findVertex(t.point.x,t.point.y)||this.splitEdge(e.origin.x,e.origin.y,e.twin.origin.x,e.twin.origin.y,t.point.x,t.point.y))}}if(a.size>1){let e=Tn(n,i,[n,...a,i],!0,this.tolerance);for(let t=0;t<e.length-1;t++)l.push({type:"addEdge",data:{from:{x:e[t].x,y:e[t].y},to:{x:e[t+1].x,y:e[t+1].y}}})}else l.push(e)}for(const e of t){let{x:t,y:n}=e.data;if(!this.findVertex(t,n)){let e=!1;for(let l of this.hedges){let i=l.getAABB();i.expandByValue(this.tolerance),i.containsPoint(new Ut(t,n))&&!this.findVertex(t,n)&&zn([t,n],[l.origin.toArray(),l.twin.origin.toArray()])&&(e=!1!==this.splitEdge(l.origin.x,l.origin.y,l.twin.origin.x,l.twin.origin.y,t,n))}!e&&this.addVertex(t,n)}}for(const e of l.filter((e=>"addEdge"===e.type))){let{from:t,to:n}=e.data,l=this.findVertex(t.x,t.y),i=this.findVertex(n.x,n.y);if(l&&i){let e=new Set;e.add(l);let t=new dn;t.expands([l,i]),t.expandByValue(this.tolerance);for(let n of this.verticesInBB(t))zn(n.toArray(),[l.toArray(),i.toArray()])&&e.add(n);e.add(i);let n=Tn(l,i,Array.from(e),!0);for(let e=0;e<n.length-1;e++)this.findHedge(n[e].x,n[e].y,n[e+1].x,n[e+1].y)||this.addEdge(n[e].x,n[e].y,n[e+1].x,n[e+1].y)}}}cleanupDegenerateHoles(){let e=new Set;this.faces.forEach((t=>{for(let n of this.faces)t!=n&&t.aabb.containsBB(n.aabb)&&t.vertexlist.every((e=>n.containsPoint(e)))&&n.hedges.forEach((t=>{t.face==n&&e.add(t)}))})),this.faces.filter((e=>e.area>0)).forEach((t=>{t.holes.forEach((n=>{n.hedges.forEach((n=>{n.face==t&&e.add(n)}))}))}));for(const t of e)t.origin&&t.twin.origin&&this.removeEdge(t.origin.x,t.origin.y,t.twin.origin.x,t.twin.origin.y)}cleanupTrailingEdges(){this.hedges.forEach((e=>{e.face==e.twin.face&&this.removeEdge(e.origin.x,e.origin.y,e.twin.origin.x,e.twin.origin.y)}))}}function Rn(e,t,n=g){let[l,i]=e,[a,o]=t;const r=i[0]-l[0],c=i[1]-l[1],u=o[0]-a[0],h=o[1]-a[1];if(s(r*h-c*u)>n)return!1;const m=s(r*(l[1]-a[1])-(l[0]-a[0])*c),p=d(r*r+c*c);return!(p<n)&&m/p<n}function Tn(e,t,n,l=!1,i=g){const a=t.x-e.x,s=t.y-e.y;let o=a*a+s*s;if(o<i)return n;const r=1/o,c=n.map((t=>{const n=((t.x-e.x)*a+(t.y-e.y)*s)*r;return{point:t,t:Math.max(0,Math.min(1,n))}}));c.sort(((t,n)=>{const l=t.t-n.t;return Math.abs(l)>i?l:(t.point.x-e.x)**2+(t.point.y-e.y)**2-((n.point.x-e.x)**2+(n.point.y-e.y)**2)}));let d=c.map((e=>e.point));return l&&(d=function(e,t){const n=[],l=new Map;for(const i of e){const e=`${Math.round(i.x/t)},${Math.round(i.y/t)}`;l.has(e)||(l.set(e,!0),n.push(i))}return n}(d,i)),d}function Mn(e,t,n=g){for(let l=0;l<t.length;l++){const i=t[l],a=t[(l+1)%t.length],s=o(i[0],a[0])-n,c=r(i[0],a[0])+n,d=o(i[1],a[1])+-n,u=r(i[1],a[1])+n;if(e[0]>=s&&e[0]<=c&&e[1]>=d&&e[1]<=u&&Yn(e,i,a)<=n*n)return!0}return!1}function zn(e,t,n=g){const[l,i]=t,a=(e[1]-l[1])*(i[0]-l[0])-(e[0]-l[0])*(i[1]-l[1]);if(Math.abs(a)>n)return!1;const s=(e[0]-l[0])*(i[0]-l[0])+(e[1]-l[1])*(i[1]-l[1]);return!(s<-n||s-((i[0]-l[0])*(i[0]-l[0])+(i[1]-l[1])*(i[1]-l[1]))>n)}function Yn(e,t,n){const l=n[0]-t[0],i=n[1]-t[1],a=l*l+i*i;if(a<1e-14){const n=e[0]-t[0],l=e[1]-t[1];return n*n+l*l}let s=((e[0]-t[0])*l+(e[1]-t[1])*i)/a;s=Math.max(0,Math.min(1,s));const o=t[0]+s*l,r=t[1]+s*i,c=e[0]-o,d=e[1]-r;return c*c+d*d}let Pn=0;class Fn{_dcel;id=Pn++;changeIndex=0;wedge=null;_area=0;_areaDirty=!0;_vertexlist=[];_vertexlistDirty=!0;_centerDirty=!0;_hedges=[];_hedgesDirty=!0;_center=null;_hasInsertedIntoPQ=!1;_holes=[];_holesDirty=!0;_aabb=null;_aabbDirty=!0;constructor(e){this._dcel=e}get area(){return this._areaDirty&&(this._area=Un(this.vertexlist),this._areaDirty=!1),this._area}get areaExceptHoles(){const e=this.holes;let t=this.area;for(let n=0,l=e.length;n<l;n++)t+=e[n].area;return t}get internal(){return this.area>Kn}get external(){return this.area<=Kn}get hedges(){if(this._hedgesDirty){const e=[];let t=this.wedge,n=0;const l=1e6;for(e.push(t);t.nexthedge!==this.wedge&&n<l;)t=t.nexthedge,e.push(t),n++;if(n>=l)throw Error("Face vertex list is too long");this._hedges=e,this._hedgesDirty=!1}return this._hedges}get center(){if(this._centerDirty){const e=this.vertexlist;let t=0,n=0,l=0;for(let i=0;i<e.length;i++){const a=e[i].x,s=e[i].y,o=e[(i+1)%e.length].x,r=e[(i+1)%e.length].y,c=a*r-s*o;t+=c,n+=(a+o)*c,l+=(s+r)*c}t*=.5,n/=6*t,l/=6*t,this._center=new Ut(n,l),this._centerDirty=!1}return this._center}get vertexlist(){return this._vertexlistDirty&&this.cleanVertexList(),this._vertexlist}cleanVertexList(){if(!this._vertexlistDirty)return;let e=this.wedge;const t=this._vertexlist;t.length=0;let n=0;const l=1e6;for(t.push(e.origin);e.nexthedge!==this.wedge&&n<l;)e=e.nexthedge,t.push(e.origin),n++;if(n>=l)throw Error("Face vertex list is too long");this._vertexlistDirty=!1}get holes(){if(this._holesDirty&&(this._holesDirty=!1,this._holes.length=0,this.internal)){const e=this._dcel.faces;for(let t=0,n=e.length;t<n;t++)this._tryAddHole(e[t])}return this._holes}get aabb(){return this._aabb||(this._aabb=new dn),this._aabbDirty&&(this._aabb.reset(),this._aabb.expands(this.vertexlist),this._aabbDirty=!1),this._aabb}equals(e){const t=this.vertexlist,n=e.vertexlist;if(t.length!==n.length)return!1;const l=t.length;for(let e=0;e<l;e++)for(let i=0;i<l&&t[i]===n[(e+i)%l];i++)if(i===l-1)return!0;return!1}findNearestEdge(e){return function(e,t){const n=Dn(e);let l=[e[0],e[1]],i=1e10,a=-1/0,s=null;for(let o=0;o<e.length;o++){const r=[e[o],e[(o+1)%e.length]],{distance:c,projection:d}=On(t,r[0],r[1]),u={x:r[1].x-r[0].x,y:r[1].y-r[0].y};let h={x:-u.y,y:u.x},m={x:(r[0].x+r[1].x)/2-n.x,y:(r[0].y+r[1].y)/2-n.y};h.x*m.x+h.y*m.y<0&&(h={x:u.y,y:-u.x});const p={x:t.x-(r[0].x+r[1].x)/2,y:t.y-(r[0].y+r[1].y)/2},b=h.x*p.x+h.y*p.y;(c<i||c===i&&b>a)&&b>0&&(i=c,l=r,a=b,s=d)}return{edge:l,distance:i,edgePoint:s}}(this.vertexlist,e)}containsPoint(e){return!(!this.aabb.containsPoint(e)||!In(this.vertexlist,e))}isPointOnBoundary(e,t=Kn){let n=this.vertexlist.map((e=>e.toArray()));return!!Mn(e.toArray(),n,t)}intersectWithPolyLine(e,t=!1){let n=[];const l=t?e.length:e.length-1;for(let i=0;i<l;i++){const l=t?(i+1)%e.length:i+1,a=[e[i],e[l]];n.push(...this.intersectWithLineSeg(a))}return n}intersectWithLineSeg(e){const t=[],n=this.hedges.filter((e=>e.face==this)),l=(new dn).expands(e);for(let i of n){if(!i.getAABB().intersects(l))continue;const n=i.intersectWithLineSegment(e);n.type===Wn.intersecting&&t.push({point:n.point,edge:[i.origin,i.twin.origin]})}return t}dirty(){this._areaDirty=!0,this._hedgesDirty=!0,this._centerDirty=!0,this._vertexlistDirty=!0,this._holesDirty=!0,this._aabbDirty=!0,this.changeIndex++}dispose(){this.wedge=null,this._vertexlist.length=0,this._holes.length=0,this._aabb=null,this._dcel=null}_tryAddHole(e){this._holesDirty||e.external&&this.area-Math.abs(e.area)>Kn&&this.aabb.containsPoints(e.vertexlist)&&Nn(this.vertexlist,e.vertexlist,Kn)&&this._holes.push(e)}}function Hn(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function In(e,t,n=Kn){if(Mn([t.x,t.y],e.map((e=>e.toArray())),n))return!0;let l=0;for(let n=0;n<e.length;n++){const i=e[n],a=e[(n+1)%e.length];i.y<=t.y?a.y>t.y&&Hn(i,a,t)>0&&l++:a.y<=t.y&&Hn(i,a,t)<0&&l--}return 0!==l}function Nn(e,t,n=Kn){for(let l=0,i=t.length;l<i;l++)if(!In(e,t[l],n))return!1;return!0}function Un(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const l=(n+1)%e.length;t+=e[n].x*e[l].y-e[n].y*e[l].x}return.5*t}function Dn(e){let t=0,n=0;for(let l=0;l<e.length;l++)t+=e[l].x,n+=e[l].y;return new Ut(t/e.length,n/e.length)}function On(e,t,n,l=Kn){const i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y);if(i<l)return{distance:e.distanceTo(t),projection:t};let a=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/i;a<-l?a=0:a>1+l&&(a=1);const s=new Ut(t.x+a*(n.x-t.x),t.y+a*(n.y-t.y));return{distance:e.distanceTo(s),projection:s}}function Bn(e,t,n=g){const[{x:l,y:i},{x:a,y:s}]=e,[{x:o,y:r},{x:c,y:d}]=t,u=(l-a)*(r-d)-(i-s)*(o-c);if(Math.abs(u)<n)return null;const h=((l-o)*(r-d)-(i-r)*(o-c))/u,m=((a-l)*(i-r)-(s-i)*(l-o))/u;return h>=-n&&h<=1+n&&m>=-n&&m<=1+n?new Ut(l+h*(a-l),i+h*(s-i)):null}function Qn(e,t){const n=[];for(let l=0;l<t.length;l++){const i=[t[l],t[(l+1)%t.length]],a=Bn(e,i);a&&n.push({point:a,edge:i})}return n}let jn=0;function Jn(){return jn++,jn}function An(e){let{boxCenter:t,perspectiveCenter:n,centerBoxMaskDimensions:l=[0,0],width:i,height:a,gThreshold:s=2.5,gMean:o=1,gStdDev:r=1.5}=e;n||(n=t);const[c,d]=t;let[u,h]=n;u=Ot(new Ut(u,h)).x,h=Ot(new Ut(u,h)).y;let m=[l[0]*Be.scale,l[1]*Be.scale];i=xe(i,Be.scale),a=xe(a,Be.scale);let p=[];const b=2*(i+a),g=b/Be.scale,f=b/g;let x=[[u-m[0],h-m[1]],[u+m[0],h-m[1]],[u+m[0],h+m[1]],[u-m[0],h+m[1]]],Z=0,y=0,G=0;for(let e=0;e<g;e++){if(G<i?(Z=c-i/2+G,y=d-a/2):G<i+a?(Z=c+i/2,y=d-a/2+(G-i)):G<2*i+a?(Z=c+i/2-(G-(i+a)),y=d+a/2):(Z=c-i/2,y=d+a/2-(G-(2*i+a))),J.gaussianBool(s,o,r)){let e=Qn([[u,h],[Z,y]].map((e=>new Ut(...e))),x.map((e=>new Ut(...e))));if(!e[0])continue;let t=[e[0].point.toArray(),[Z,y]];if(p.push(t),J.bool(0)){let e=J.int(1,3)*Be.scale;J.bool(50)&&(e*=-1);let n=[[t[0][0]+e,t[0][1]],[t[1][0]+e,t[1][1]]];p.push(n)}}G+=f}return p}function En({center:e,width:t,height:n,angle:a=0}){let[s,o]=e,r=t/2,c=n/2,d=[[s-r,o-c],[s+r,o-c],[s+r,o+c],[s-r,o+c]];return 0!==a&&(d=function(e,t,n){const a=n||function(e){const t=e.reduce(((e,t)=>[e[0]+t[0],e[1]+t[1]]),[0,0]);return[t[0]/e.length,t[1]/e.length]}(e),s=t*b/180;return e.map((e=>{const t=[e[0]-a[0],e[1]-a[1]],n=[t[0]*i(s)-t[1]*l(s),t[0]*l(s)+t[1]*i(s)];return[n[0]+a[0],n[1]+a[1]]}))}(d,a,e)),d}function _n(e){let{center:n,radius:l,startAngle:i=0,endAngle:a=180}=e,s=[],[o,r]=n;i=me(i),a=me(a);let c=t(l*Math.abs(a-i)*.125);for(let e=0;e<=c;e++){let t=i+e/c*(a-i),n=o+l*Math.cos(t),d=r+l*Math.sin(t);s.push([n,d])}let d=function(e){let t=0,n=0;for(let l=0;l<e.length;l++)t+=e[l][0],n+=e[l][1];return[t/e.length,n/e.length]}(s),u=[o-d[0],r-d[1]];return s=s.map((e=>[e[0]+u[0],e[1]+u[1]])),s}class qn{startX;startY;endX;endY;distances;constructor(e,t,n,l){this.startX=e,this.startY=t,this.endX=n,this.endY=l;const i=n-e+1,a=l-t+1;this.distances=Array(a).fill(null).map((()=>Array(i).fill(1/0)))}initializeWithEmptyCells(e,t){for(let e=0;e<this.distances.length;e++)for(let t=0;t<this.distances[0].length;t++)this.distances[e][t]=0;e.forEach((e=>{const[n,l]=t(e),i=n-this.startX,a=l-this.startY;i>=0&&a>=0&&i<this.distances[0].length&&a<this.distances.length&&(this.distances[a][i]=1/0)}));for(let e=0;e<this.distances.length;e++)this.distances[e][0]=0,this.distances[e][this.distances[0].length-1]=0;for(let e=0;e<this.distances[0].length;e++)this.distances[0][e]=0,this.distances[this.distances.length-1][e]=0;this.performJFA()}performJFA(){const e=this.distances.length,t=this.distances[0].length;let n=[];for(let l=0;l<e;l++)for(let e=0;e<t;e++)0===this.distances[l][e]&&n.push([e,l]);for(;n.length>0;){let e=n.length;for(let t=0;t<e;t++){const[e,t]=n.shift();this.checkAndUpdate(e,t,n)}}}checkAndUpdate(e,t,n){const l=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[i,a]of l){const l=e+i,s=t+a;l>=0&&l<this.distances[0].length&&s>=0&&s<this.distances.length&&this.distances[s][l]>this.distances[t][e]+1&&(this.distances[s][l]=this.distances[t][e]+1,n.push([l,s]))}}getDistance(e,t){const n=e-this.startX,l=t-this.startY;return n>=0&&l>=0&&n<this.distances[0].length&&l<this.distances.length?this.distances[l][n]:1/0}}var $n;!function(e){e.intersecting="INTERSECTING",e.contained="CONTAINED"}($n||($n={}));class el{cells=new Map;lines=new Map;lineMeta=new Map;distanceCalculator;nextLineId=0;cellSize;faceCellIndicesCache=new Map;aabbLineIntersectionCache=new Map;constructor(e,t){this.cellSize=e,t&&this.addLines(t)}getCellBounds(){let e=0,t=0,n=0,l=0;return this.cells.forEach(((i,a)=>{const[s,o]=this.getCellXYfromIndex(a);e=Math.min(e,s),t=Math.min(t,o),n=Math.max(n,s),l=Math.max(l,o)})),{width:n-e,height:l-t,minX:e,minY:t,maxX:n,maxY:l}}getCellIndex(e,t){return`${f(e)},${f(t)}`}getCellXYfromIndex(e){return e.split(",").map(Number)}getCellVertexFromIndex(e){let[t,n]=this.getCellXYfromIndex(e);return new Ut(t*this.cellSize,n*this.cellSize)}clear(){this.cells.clear(),this.lines.clear(),this.lineMeta.clear(),this.faceCellIndicesCache.clear(),this.aabbLineIntersectionCache.clear()}addLines(e){e.forEach((e=>this.addLine(e.line,e.meta)))}addLine(e,t){const n=this.nextLineId++;this.lines.set(n,e),this.lineMeta.set(n,t);let l=t.isClosed?e.length:e.length-1;for(let t=0;t<l;t++)this.addSegment(e[t],e[(t+1)%e.length],n);return this.aabbLineIntersectionCache.clear(),n}removeLineById(e){if(this.lines.get(e)){for(let t of this.cells.values())t.delete(e);this.lines.delete(e),this.lineMeta.delete(e),this.aabbLineIntersectionCache.clear()}}addSegment(e,t,n){let l,[i,a]=e,[o,r]=t,c=f(i/this.cellSize),d=f(a/this.cellSize),u=f(o/this.cellSize),h=f(r/this.cellSize),m=s(u-c),p=-s(h-d),b=c<u?1:-1,g=d<h?1:-1,x=m+p;for(;;){const e=this.getCellIndex(c,d);if(this.cells.has(e)||this.cells.set(e,new Set),this.cells.get(e).add(n),c===u&&d===h)break;l=2*x,l>=p&&(x+=p,c+=b),l<=m&&(x+=m,d+=g)}}getLinesIntersectingOrContainedWithinAABB(e){let t=new Set,n=f(e.minX/this.cellSize),l=f(e.maxX/this.cellSize),i=f(e.minY/this.cellSize),a=f(e.maxY/this.cellSize);for(let e=n;e<=l;e++)for(let n=i;n<=a;n++){const l=this.getCellIndex(e,n);this.cells.has(l)&&this.cells.get(l).forEach((e=>t.add(e)))}return Array.from(t).map((e=>({id:Jn(),line:this.lines.get(e),meta:this.lineMeta.get(e)})))}getAllLines(){return Array.from(this.lines).map((([e,t])=>({id:e,line:t,meta:this.lineMeta.get(e)})))}getCellsIntersectedByFace(e){const t=this.faceCellIndicesCache.get(e.id);if(t&&t.changeIndex===e.changeIndex)return t.cellIndices;const n=new Set,l=e.aabb,i=f(l.minX/this.cellSize),a=f(l.maxX/this.cellSize),s=f(l.minY/this.cellSize),o=f(l.maxY/this.cellSize);for(let t=i;t<=a;t++)for(let l=s;l<=o;l++){const i=new dn;i.expands([new Ut(t*this.cellSize,l*this.cellSize),new Ut((t+1)*this.cellSize,(l+1)*this.cellSize)]);for(let a of i.vertexList)if(e.containsPoint(a)){n.add(this.getCellIndex(t,l));break}}return this.faceCellIndicesCache.set(e.id,{changeIndex:e.changeIndex,cellIndices:n}),n}doesLineFullyIntersectFace(e,t){const n=this.lines.get(e),l=this.lineMeta.get(e);if(!n||!l)return!1;const i=t.hedges.map((e=>{let t=new dn;return t.expands([e.origin,e.nexthedge.origin]),{aabb:t,edge:e}})),a=[],s=l.isClosed?n.length:n.length-1;for(let e=0;e<s;e++){const t=new Ut(...n[e]),l=new Ut(...n[(e+1)%n.length]),s=l.x-t.x,o=l.y-t.y,r=s*s+o*o;let c=new dn;c.expands([t,l]);for(const{aabb:n,edge:d}of i){if(!n.intersects(c))continue;const i=d.intersectWithLineSegment([t,l]);if(i?.type===Wn.intersecting&&i.point){const n=((i.point.x-t.x)*s+(i.point.y-t.y)*o)/r;a.push(e+n)}}}a.sort(((e,t)=>e-t));const o=a.filter(((e,t)=>0===t||Math.abs(e-a[t-1])>g));if(o.length<2)return!1;const r=new Ut(...n[0]);let c=t.containsPoint(r)&&!t.isPointOnBoundary(r);for(let e=0;e<o.length-1;e++){c=!c;const l=o[e],i=o[e+1];if(l<g||i>s-g)continue;if(!c)continue;const a=(l+i)/2,r=Math.floor(a)%n.length,d=a-Math.floor(a),u=new Ut(...n[r]),h=new Ut(...n[(r+1)%n.length]),m=new Ut(u.x+(h.x-u.x)*d,u.y+(h.y-u.y)*d);if(t.containsPoint(m)&&!t.isPointOnBoundary(m))return!0}return!1}linesIntersectingAABB(e){const t=this.aabbLineIntersectionCache.get(e);if(t)return t;const n=new Set,l=f(e.minX/this.cellSize),i=f(e.maxX/this.cellSize),a=f(e.minY/this.cellSize),s=f(e.maxY/this.cellSize);for(let e=l;e<=i;e++)for(let t=a;t<=s;t++){const l=this.getCellIndex(e,t);this.cells.has(l)&&this.cells.get(l).forEach((e=>n.add(e)))}const o=[...n].map((e=>({constructionLine:{id:e,line:this.lines.get(e),meta:this.lineMeta.get(e)},intersectionType:$n.intersecting})));return this.aabbLineIntersectionCache.set(e,o),o}getLinesIntersectingFace(e,t=!0){const n=this.getCellsIntersectedByFace(e),l=new Set;for(const e of n){const t=this.cells.get(e);if(t)for(const e of t)l.add(e)}let i=Array.from(l);return t&&(i=i.filter((t=>this.doesLineFullyIntersectFace(t,e)))),i.map((e=>({constructionLine:{id:e,line:this.lines.get(e),meta:this.lineMeta.get(e)},intersectionType:$n.intersecting})))}getGridDistanceField(e=0,t=0){let{cellSize:n}=this;const l=new Set,i=new Set,a=[];let s=f(t/n),o=f((Y-2*t)/n),r=f(t/n),c=f((P-2*t)/n);for(let t=s;t<=o;t++)for(let n=r;n<=c;n++){const i=this.getCellIndex(t,n);(!this.cells.has(i)||this.cells.get(i)?.size<=e)&&l.add(i)}const d=(e,t)=>{const n=[e];for(;n.length>0;){const e=n.pop();if(!e||i.has(e)||!l.has(e))continue;i.add(e);const[a,s]=this.getCellXYfromIndex(e);t.indices.push(e);const o=[this.getCellIndex(a-1,s),this.getCellIndex(a+1,s),this.getCellIndex(a,s-1),this.getCellIndex(a,s+1)];for(const e of o)!i.has(e)&&l.has(e)&&n.push(e)}};l.forEach((e=>{if(!i.has(e)){const t={vertices:[],indices:[]};d(e,t),t.indices.length>1&&a.push(t)}}));let u=this.distanceCalculator||new qn(s,r,o,c);return u.initializeWithEmptyCells(l,this.getCellXYfromIndex.bind(this)),a.map((e=>{const t=new dn;let n=[];e.indices.forEach((e=>{const[t,l]=this.getCellXYfromIndex(e),i=u.getDistance(t,l);n.push([i,this.getCellVertexFromIndex(e)])}));let l=n.reduce(((e,t)=>e[0]>t[0]?e:t));return t.expands(n.map((([,e])=>e))),{aabb:t,cellCount:e.indices.length,maxDistance:l[0],cellsByDistance:n,indices:e.indices.map((e=>this.getCellVertexFromIndex(e)))}}))}}function tl(e){const[t,n,l]=e;return`oklch(${(100*(t||0)).toFixed(2)}% ${(n||0).toFixed(2)} ${(l||0).toFixed(2)})`}function nl(e){e.forEach((e=>{const[t,n,l]=e;tl(e)}))}function ll(e){const n=e.slice();for(let e=n.length-1;e>0;e--){const l=t(J.dec()*(e+1));[n[e],n[l]]=[n[l],n[e]]}return n}function il(e,t="right"){const n=e.slice();if("right"===t){const e=n.pop();void 0!==e&&n.unshift(e)}else if("left"===t){const e=n.shift();void 0!==e&&n.push(e)}return n}let al={};const sl=(e,t=5,n=0,l=Ge,i=[])=>{const a=`${e}-${n}-${t}`;if(al[a]?.min)return al[a];let s=0,o=-1/0,r=1/0,c=0,d=[],u=(t,i)=>{let a=l(yn(t,i,n,e));s+=a,c+=1,a>o&&(o=a),a<r&&(r=a),d.push(a)};if(i.length)for(let e of i)u(e.x,e.y);else for(let e=0;e<20*Be.countX;e+=Be.w/20)for(let t=0;t<20*Be.countY;t+=Be.h/20)u(e,t);let h={max:o,min:r,mean:s/c,indexValues:[],mostCommonIndex:0,leastCommonIndex:0};return d.map((e=>{let n=f(ye(e,h.min,h.max,0,t-1));h.indexValues[n]=h.indexValues[n]?h.indexValues[n]+1:1})),h.mostCommonIndex=h.indexValues.reduce(((e,t,n)=>t>h.indexValues[e]?n:e),0),h.leastCommonIndex=h.indexValues.reduce(((e,t,n)=>t<h.indexValues[e]?n:e),0),al[a]=
= clamp(\n (step(lineDistance, alphaSoftLineSpread) * alphaSoftLineNoise) * maxLineHardness,\n 0., .7);\n }\n \n\n float lineAlpha = max(alphaSoftLine, alphaHardLine) * segmentDistanceAlphaMult;\n \n accumulationValue = clamp(accumulationValue + (1.0 - accumulationValue) * lineAlpha * 0.1, 0., 5.);\n \n alpha = clamp(1.0 - (1.0 - alpha) * (1.0 - lineAlpha * alphaIncrement), 0., 1.);\n color.x = clamp(\n 1.0 - (1.0 - localColor.x) * (1.0 - lineAlpha * lightnessIncrement), \n originalColor.x - accumulationClamp.x, \n originalColor.x + accumulationClamp.x\n );\n if(!uDisableSaturationShift) {\n color.y = clamp(1.0 - (1.0 - localColor.y) * (1.0 - lineAlpha * chromaIncrement), \n originalColor.y - accumulationClamp.y, \n originalColor.y + accumulationClamp.y\n );\n }\n \n \n }\n\n if(alpha <= 0.) {\n return vec4(frameBuffer, 1.);\n }\n\n\n float brightnessNoiseInfluence = smoothstep(-1., 1., fbm(uv + uNoiseOffset, 2, 50., 0.9)) + 0.4;\n float brightnessNoise = smoothstep(0.1, 0.31, fbm(uv + uNoiseOffset, 2, 1800., 0.5)) * brightnessNoiseInfluence * 0.002;\n color.x += brightnessNoise;\n\n float alphaNoise2 = smoothstep(-1., 1., fbm(uv, 1, 1000., 0.1)) * 0.02;\n float alphaNoise = smoothstep(-0.6, 1., fbm(uv, 2, 1200., 0.1)) * 0.12;\n alpha -= (alphaNoise + alphaNoise2);\n alpha = clamp(alpha, 0., 1.);\n\n \n float colorBrightWobble = fbm(uv + uNoiseOffset, 2, 20., 0.9) * 0.001;\n float colorEase = (\n easeOut(smoothstep(.02, .0, sdf + colorBrightWobble), 1.) \n * (0.01 + (accumulationValue * 0.02))\n );\n\n float colorBrightNoise = smoothstep(-0.4, 0.4, fbm(uv + uNoiseOffset, 2, 700., 0.9));\n float darkenEdge = easeOut(smoothstep(.0035, .0, sdf - (colorBrightWobble * 4.)), 1.) \n * (0.06 + (accumulationValue * 0.02)) * colorBrightNoise;\n\n colorEase += darkenEdge;\n \n color.x -= colorEase;\n color.y += (colorEase * 0.4);\n\n color.x = clamp(color.x, 0., .84);\n color.y = clamp(color.y, 0., .4); \n\n // LIGHTING\n vec3 lightDir = normalize(vec3(.6f, 1.6f, 1.6f));\n vec3 lightColor = vec3(1.0f) * 1.7f;\n \n vec3 paperTextureNormals = calculateNormals(screenSpaceUV + msaaOffset, 0.0002 * tileScaleFactor.x, 4.);\n vec3 diffuse = calculateDiffuse(paperTextureNormals, lightDir, lightColor);\n\n vec3 colorRGB = OKLCHtoP3LRGB(color) * diffuse;\n vec3 colorMult = (frameBuffer * colorRGB) * diffuse;\n\n colorRGB = mix(frameBuffer, mix(colorMult, colorRGB * diffuse, clamp(0.9, 1., alpha + 0.3)), alpha);\n\n return vec4(colorRGB, 1.0);\n }\n\n void main() {\n const vec2 H2 = vec2(0.5698402909980532f, 0.7548776662466927f);\n vec2 px = 1.f / resolution;\n px *= 1.25;\n vec2 uv = vUv;\n\n \n // Check if this fragment is within the SDF\n vec2 uvOffset = lookupWarpSample(uv).xy;\n float texCheck = (texture(tPolyEdgeDistance, uv + uvOffset).r - 0.5) * 2.0;\n if(texCheck < -0.1) {\n discard;\n }\n\n vec3 frameBuffer = texture(tScreenBuffer, vUv).rgb;\n\n\n const float samples = 4.f;\n \n vec4 sumColour;\n vec2 d0 = vec2(randomNonDet(uv), randomNonDet(uv + 1.f));\n\n \n for(float i = 0.f; i < samples; i++) {\n vec2 d = (fract(i * H2 + d0) - .5f);\n\n vec2 localCoord = vUv + d * px;\n vec2 screenCoord = uTileOffset + localCoord * uTileSize;\n vec2 globalUV = screenCoord / resolution;\n\n \n vec4 sampleColor = render(globalUV, vUv, d * px, frameBuffer);\n sumColour += sampleColor;\n }\n \n vec4 averageColor = clamp(sumColour / samples, 0., 1.);\n \n outColor = averageColor;\n }\n `});let n=t.isShading?nn:ln;n.updatePolylines(t.lines,t.closedPolyOrLine);let l=tn.uniforms;re(tn),It.material=tn,l.tScreenBuffer.value=Ft.getReadBuffer().texture;let i=t.lineColor;if(l.uLineColor.value=Qt(i),l.uDisableSaturationShift.value=t.disableSaturationShift||!1,l.uLineWeight.value=t.lineWeight,l.uLineHardness.value=t.linePressure,l.uMaterialHardness.value=t.materialHardness||1,l.uIsShading.value=t.isShading||!1,l.tWarpTex.value=t.canWarp?Ht.displacementMapWarped.target.texture:Ht.displacementMap.target.texture,l.uNoiseOffset.value=new ie(...t.noiseOffset),l.uFaceIndex.value=an++,l.uLineWeight.value=t.lineWeight,l.uTaperingFadeIn.value=t.lineTapering.fade.in.enabled?t.lineTapering.fade.in.length:0,l.uTaperingFadeOut.value=t.lineTapering.fade.out.enabled?t.lineTapering.fade.out.length:0,l.uTaperingScaleIn.value=t.lineTapering.scale.in.enabled?t.lineTapering.scale.in.length:0,l.uTaperingScaleOut.value=t.lineTapering.scale.out.enabled?t.lineTapering.scale.out.length:0,l.uBrightness.value=t.lineBrightness||1,l.uEdgeSharpness.value=t.edgeSharpness||1,l.uAccumulationStrength.value=t.accumulationStrength||1,t?.fadeAtLineSegment){let e=_t(t.fadeAtLineSegment.segment);const n=l.uFadeAtLineSegmentVertices.value;n[0]=e[0][0],n[1]=e[0][1],n[2]=e[1][0],n[3]=e[1][1],l.uFadeAtLineSegmentDistance.value=t.fadeAtLineSegment.distance,l.uFadeAtLineSegmentStrength.value=t.fadeAtLineSegment.strength,l.uEnableFadeAtLineSegment.value=!0,tn.needsUpdate=!0}else l.uEnableFadeAtLineSegment.value=!1;if(!sn||on!==n){const{cellsWide:e,cellsHigh:t,cellSize:i}=n,{segmentDataTexture:a,segmentMetaDataTexture:s,segmentIndexTexture:o}=n.getTextures();l.uSegmentDataTex.value=a,l.uSegmentMetaDataTex.value=s,l.uSegmentIndexTex.value=o,l.tPolyLineGrid.value={width:e*i,height:t*i,cellSize:i},sn=!0}l.uIsClosedPoly.value=t.closedPolyOrLine,X.setRenderTarget(Ft.getWriteBuffer()),It.render(),Ft.copyAndSwapBuffers(),on=n}let cn=new e.Vector4;class dn{minX=1/0;minY=1/0;maxX=-1/0;maxY=-1/0;constructor(){}get width(){return this.maxX-this.minX}get height(){return this.maxY-this.minY}get center(){return new Ut((this.minX+this.maxX)/2,(this.minY+this.maxY)/2)}get vertexList(){return[new Ut(this.minX,this.minY),new Ut(this.maxX,this.minY),new Ut(this.maxX,this.maxY),new Ut(this.minX,this.maxY)]}get area(){return this.width*this.height}reset(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}expand(e){this.minX=Math.min(e.x,this.minX),this.minY=Math.min(e.y,this.minY),this.maxX=Math.max(e.x,this.maxX),this.maxY=Math.max(e.y,this.maxY)}expands(e){for(let t=0,n=e.length;t<n;t++)this.expand(e[t]);return this}expandByPoint(e){return this.minX=Math.min(e[0],this.minX),this.minY=Math.min(e[1],this.minY),this.maxX=Math.max(e[0],this.maxX),this.maxY=Math.max(e[1],this.maxY),this}expandsByPoint(e){for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t])}intersects(e,t=g){return!(e.maxX<this.minX-t||e.minX>this.maxX+t||e.maxY<this.minY-t||e.minY>this.maxY+t)}expandByValue(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,this}containsPoint(e){return e.x<=this.maxX+g&&e.x>=this.minX-g&&e.y<=this.maxY+g&&e.y>=this.minY-g}distanceToPoint(e){const t=r(this.minX-e.x,0,e.x-this.maxX),n=r(this.minY-e.y,0,e.y-this.maxY);return d(t*t+n*n)}containsBB(e){return e.minX>=this.minX-g&&e.maxX<=this.maxX+g&&e.minY>=this.minY-g&&e.maxY<=this.maxY+g}containsPoints(e){for(let t=0,n=e.length;t<n;t++)if(!this.containsPoint(e[t]))return!1;return!0}size(){return{width:this.maxX-this.minX,height:this.maxY-this.minY}}}let un,hn=[];var mn,pn;function bn(l){un=un||new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(Q,j)},tPositions:{value:new e.DataTexture},uPositionsCount:{value:0},...ce()},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n\t\t\tprecision highp int;\n \n uniform highp sampler2D tPositions;\n uniform vec2 resolution;\n uniform int uPositionsCount;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n \n varying vec2 vUv;\n out vec4 outColor;\n\n ${ne}\n\n float pointLineSegSDF(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\n return length(pa - ba * t);\n }\n \n bool isIntersecting(vec2 point, vec2 p1, vec2 p2) {\n if(p1.y == p2.y) {\n return false;\n }\n \n if(p1.y > point.y && p2.y > point.y) {\n return false;\n }\n \n if(p1.y < point.y && p2.y < point.y) {\n return false;\n }\n \n float intersectionX = p1.x + (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);\n return intersectionX > point.x;\n }\n\n vec2 fetchVertex(int vertexIndex) {\n int textureWidth = textureSize(tPositions, 0).x;\n int x = vertexIndex % textureWidth;\n int y = vertexIndex / textureWidth;\n return texelFetch(tPositions, ivec2(x, y), 0).rg;\n }\n \n float polyDistanceSDF(vec2 uv) {\n float minDist = 1e20;\n int intersections = 0;\n \n for(int i = 0; i < uPositionsCount; i++) {\n vec2 vertex1 = fetchVertex(i) / resolution.xy;\n vec2 vertex2 = fetchVertex((i + 1) % uPositionsCount) / resolution.xy;\n \n minDist = min(minDist, pointLineSegSDF(uv, vertex1, vertex2));\n \n if(isIntersecting(uv, vertex1, vertex2)) {\n intersections++;\n }\n }\n return float(intersections % 2 == 1 ? minDist : -minDist);\n // return float(intersections % 2 == 1 ? minDist : 1.5);\n }\n \n vec4 render(vec2 uv) {\n float dist = polyDistanceSDF(uv);\n return vec4(dist) * 0.5 + .5;\n }\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 4.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `});let i=_t(l.polygon);un.uniforms.uPositionsCount.value=i.length;let a=function(t){const l=t.flat(),i=l.length/2,a=o(C,i),s=n(i/C),r=new Float32Array(a*s*2);for(let e=0;e<i;e++){const t=2*e;r[t]=l[t]||0,r[t+1]=l[t+1]||0}let c=new e.DataTexture(r,a,s,e.RGFormat,e.FloatType);return c.needsUpdate=!0,{texture:c,width:a,height:s}}(i);un.uniforms.tPositions.value=a.texture,re(un),It.material=un,X.setRenderTarget(Ht.polyEdgeDistance.target),X.setClearColor(1,0),X.clear();let s=oe();var c;((e,l=5)=>{l/=D,X.setScissorTest(!0),X.setScissor(((e,l=5)=>{let i=l*D,a=o(...e.map((e=>e.x)))-i,s=r(...e.map((e=>e.x)))+i,c=o(...e.map((e=>e.y)))-i,d=r(...e.map((e=>e.y)))+i,u=s-a,h=d-c;return cn.set(Ze(t(a),0,Q),Ze(t(j-d),0,j),n(o(u,Q)),n(o(h,j))).divideScalar(U).round()})(e,l))})((c=l.polygon.map((e=>new ie(e.x,e.y))),c.map((e=>e.clone().multiplyScalar(D)))).map((e=>(e.x=t((e.x-s.xOff)*(Q/s.width)),e.y=n((e.y-s.yOff)*(j/s.height)),e))),n(10*D*(Q/s.width))),It.render(),X.setScissorTest(!1)}!function(e){e[e.constructionLine=0]="constructionLine",e[e.detail=1]="detail",e[e.foreground=2]="foreground",e[e.background=3]="background",e[e.shadow=4]="shadow",e[e.walker=5]="walker",e[e.overlay=6]="overlay",e[e.overlayOutline=7]="overlayOutline"}(mn||(mn={})),function(e){e[e.regular=0]="regular",e[e.warped=1]="warped"}(pn||(pn={}));const gn=4095,fn=e=>.5*(1-i(e*b));let xn;function Zn(e){xn=new Float32Array(4096);for(let e=0;e<4096;e++)xn[e]=J.dec()}let yn=(e,n,l=0,i=5,a=0,s=1)=>fe(function(e,n=0,l=0){xn||Zn(),e<0&&(e=-e),n<0&&(n=-n),l<0&&(l=-l);let i,a,s,o,r,c=t(e),d=t(n),u=t(l),h=e-c,m=n-d,p=l-u,b=0,g=.5;for(let e=0;e<3;e++){let e=c+(d<<4)+(u<<8);i=fn(h),a=fn(m),s=xn[e&gn],s+=i*(xn[e+1&gn]-s),o=xn[e+16&gn],o+=i*(xn[e+16+1&gn]-o),s+=a*(o-s),e+=256,o=xn[e&gn],o+=i*(xn[e+1&gn]-o),r=xn[e+16&gn],r+=i*(xn[e+16+1&gn]-r),o+=a*(r-o),s+=fn(p)*(o-s),b+=s*g,g*=.8,c<<=1,h*=2,d<<=1,m*=2,u<<=1,p*=2,h>=1&&(c++,h--),m>=1&&(d++,m--),p>=1&&(u++,p--)}return b}((e+100)/i,(n+100)/i,(l+100)/i),0,1,a,s);const Gn=g;var Wn;function vn(e,t,n=!1){if(0===t.length)return e;if(1===t.length)return t[0];let l,i=1/0,a=n?t.length:t.length-1;for(let n=0;n<a;n++){const a=t[n],s=t[(n+1)%t.length],o=Sn(e,a,s);o<i&&(i=o,l=[a,s])}return l?function(e,t,n){const[l,i]=t,[a,s]=n,[o,r]=e,c=a-l,d=s-i,u=c*c+d*d;if(u<Gn)return[l,i];let h=((o-l)*c+(r-i)*d)/u;return h<-1e-7?h=0:h>1+Gn&&(h=1),[l+h*c,i+h*d]}(e,...l):e}function Ln(e,t,n=!1){let l=1/0;const i=t.length,a=n?i:i-1;for(let n=0;n<a;n++){const a=Xn(e,t[n],n===i-1?t[0]:t[n+1]);if(a<Gn)return 0;l=Math.min(l,a)}return Math.sqrt(l)}function Sn(e,t,n){return d(Xn(e,t,n))}function Xn(e,t,n){const[l,i]=t,[a,s]=n,[o,r]=e,c=a-l,d=s-i,u=c*c+d*d;if(u<Gn){const e=o-l,t=r-i;return e*e+t*t}let h=((o-l)*c+(r-i)*d)/u;h<-1e-7?h=0:h>1+Gn&&(h=1);const m=o-(l+h*c),p=r-(i+h*d);return m*m+p*p}!function(e){e[e.intersecting=0]="intersecting",e[e.colinear=1]="colinear",e[e.parallel=2]="parallel"}(Wn||(Wn={}));let Cn=0;class Vn{v1;v2;id=Cn++;origin;angle;length;twin=null;nexthedge=null;prevhedge=null;face=null;constructor(e,t){this.v1=e,this.v2=t,this.id=Cn++,this.origin=t,this.angle=function(e,t){let n=t.x-e.x,l=t.y-e.y;const i=d(n*n+l*l);return l>0?u(n/i):2*b-u(n/i)}(e,t),this.length=d(a(t.x-e.x,2)+a(t.y-e.y,2))}dispose(){this.origin=null,this.twin=null,this.nexthedge=null,this.prevhedge=null,this.face=null}getAABB(){let e=new dn;return e.expands([this.origin,this.twin.origin]),e}intersectWithLineSegment([e,t]){return function(e,t,n,l){const{x:i,y:a}=e,{x:s,y:o}=t,{x:r,y:c}=n,{x:d,y:u}=l,h=(u-c)*(s-i)-(d-r)*(o-a),m=(d-r)*(a-c)-(u-c)*(i-r),p=(s-i)*(a-c)-(o-a)*(i-r);if(Math.abs(h)<Gn)return Math.abs(m)<Gn&&Math.abs(p)<Gn?{type:Wn.colinear,point:null,ua:0,ub:0}:{type:Wn.parallel,point:null,ua:0,ub:0};const b=m/h,g=p/h;return b>=-1e-7&&b<=1+Gn&&g>=-1e-7&&g<=1+Gn?{type:Wn.intersecting,point:new Ut(i+b*(s-i),a+b*(o-a)),ua:b,ub:g}:{type:null,point:null,ua:b,ub:g}}(this.origin,this.twin.origin,e,t)}}const Kn=g;class wn{tolerance;vertices=[];hedges=[];faces=[];vertexMap=new Map;constructor(e,t,n=Kn){this.tolerance=n,e&&t&&this.setDatas(e,t)}getVertexKey(e,t){const n=e/this.tolerance,l=t/this.tolerance;return`${Z(n,this.tolerance)},${Z(l,this.tolerance)}`}addVertex(e,t){const n=this.getVertexKey(e,t);let l=this.vertexMap.get(n);l||(l=[],this.vertexMap.set(n,l));for(const n of l)if(this.isClose(n.x,e)&&this.isClose(n.y,t))return n;const i=new Ut(e,t);return this.vertices.push(i),l.push(i),i}deleteVertex(e){const t=this.getVertexKey(e.x,e.y),n=this.vertexMap.get(t);if(n){const l=n.indexOf(e);l>-1&&(n.splice(l,1),0===n.length&&this.vertexMap.delete(t))}const l=this.vertices.indexOf(e);l>-1&&this.vertices.splice(l,1),e.dispose()}findVertex(e,t){const n=this.getVertexKey(e,t),l=this.vertexMap.get(n);if(l)for(const n of l)if(this.isClose(n.x,e)&&this.isClose(n.y,t))return n;return null}verticesInPoly(e){let t=e.map((e=>(new Ut).fromArray(e))),n=new dn;n.expands(t);let l=[],i=this.verticesInBB(n);for(let e of i)In(t,e)&&l.push(e);return l}verticesInBB(e){const t=[];for(let n of this.vertices)e.containsPoint(n)&&t.push(n);return t}setDatas(e,t){const{vertices:n,hedges:l,faces:i}=this;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addVertex(n[0],n[1])}for(let e=0,i=t.length;e<i;e++){const i=t[e],a=new Vn(n[i[0]],n[i[1]]),s=new Vn(n[i[1]],n[i[0]]);a.twin=s,s.twin=a,n[i[1]].hedgelist.push(a),n[i[0]].hedgelist.push(s),l.push(s),l.push(a)}for(let e=0,t=n.length;e<t;e++){const t=n[e];t.sortincident();const l=t.hedgelist.length;if(0!=l)if(l<2)t.hedgelist[0].prevhedge=t.hedgelist[0].twin,t.hedgelist[0].twin.nexthedge=t.hedgelist[0];else{for(let e=0;e<l-1;e++)t.hedgelist[e].twin.nexthedge=t.hedgelist[e+1],t.hedgelist[e+1].prevhedge=t.hedgelist[e].twin;t.hedgelist[l-1].twin.nexthedge=t.hedgelist[0],t.hedgelist[0].prevhedge=t.hedgelist[l-1].twin}}const a=l.slice(0);let s=l.length;for(;s>0;){let e=a.pop();if(s-=1,null==e.face){const t=new Fn(this);for(t.wedge=e,t.wedge.face=t;e.nexthedge!==t.wedge;)e=e.nexthedge,e.face=t;i.push(t)}}}internalFaces(){const e=[],t=this.faces;for(let n=0,l=t.length;n<l;n++){const l=t[n];l.internal&&e.push(l)}return e}externalFaces(){const e=[],t=this.faces;for(let n=0,l=t.length;n<l;n++){const l=t[n];l.external&&e.push(l)}return e}dispose(){const{vertices:e,hedges:t,faces:n}=this;for(let t=0,n=e.length;t<n;t++)e[t].dispose();for(let e=0,n=t.length;e<n;e++)t[e].dispose();for(let e=0,t=n.length;e<t;e++)n[e].dispose();e.length=0,t.length=0,n.length=0}isClose=(e,t)=>s(e-t)<this.tolerance;findHedge(e,t,n,l){const{isClose:i}=this,a=this.findVertex(e,t);if(a)for(const e of a.hedgelist){const t=e.twin.origin;if(i(t.x,n)&&i(t.y,l))return e}const s=this.findVertex(n,l);if(s)for(const n of s.hedgelist){const l=n.twin.origin;if(i(l.x,e)&&i(l.y,t))return n}return null}addEdge(e,t,n,l){const{vertices:i,hedges:a,faces:s}=this;let o=!1,r=!1,c=!1,d=this.findVertex(e,t);d||(d=this.addVertex(e,t),o=!0);let u=this.findVertex(n,l);u||(u=this.addVertex(n,l),r=!0);const h=new Vn(u,d);a.push(h),d.hedgelist.push(h),d.sortincident();const m=new Vn(d,u);if(a.push(m),u.hedgelist.push(m),u.sortincident(),h.twin=m,m.twin=h,o)h.prevhedge=m,m.nexthedge=h;else{const e=d.hedgelist.indexOf(h);let t,n;0===e?(t=d.hedgelist[d.hedgelist.length-1],n=d.hedgelist[(e+1)%d.hedgelist.length]):(t=d.hedgelist[e-1],n=d.hedgelist[(e+1)%d.hedgelist.length]),h.prevhedge=t.twin,t.twin.nexthedge=h,m.nexthedge=n,n.prevhedge=m}if(r)m.prevhedge=h,h.nexthedge=m;else{const e=u.hedgelist.indexOf(m);let t,n;0===e?(t=u.hedgelist[u.hedgelist.length-1],n=u.hedgelist[(e+1)%u.hedgelist.length]):(t=u.hedgelist[e-1],n=u.hedgelist[(e+1)%u.hedgelist.length]),m.prevhedge=t.twin,t.twin.nexthedge=m,h.nexthedge=n,n.prevhedge=h}const p=h.nexthedge,b=m.nexthedge;if(p.face){const e=s.indexOf(p.face);e>-1&&s.splice(e,1),p.face.dispose(),p.face.area<=this.tolerance&&(c=!0)}if(b.face){const e=s.indexOf(b.face);e>-1&&s.splice(e,1),b.face.dispose(),b.face.area<=this.tolerance&&(c=!0)}const g=new Fn(this);g.wedge=p;let f=new Fn(this);if(f.wedge=b,g.equals(f)&&(f.dispose(),f=null),g){let e=g.wedge;for(e.face=g;e.nexthedge!==g.wedge;)e=e.nexthedge,e.face=g;g.area<=this.tolerance&&(c=!0),s.push(g)}if(f){let e=f.wedge;for(e.face=f;e.nexthedge!==f.wedge;)e=e.nexthedge,e.face=f;f.area<=this.tolerance&&(c=!0),s.push(f)}if(c)for(let e=0,t=s.length;e<t;e++)s[e]._holesDirty=!0}removeEdge(e,t,n,l){const{vertices:i,hedges:a,faces:s}=this,o=this.findHedge(e,t,n,l);if(!o)return;const r=o.twin,c=o.nexthedge,d=r.nexthedge;let u,h=!0,m=!0,p=!1;if(u=a.indexOf(o),a.splice(u,1),u=a.indexOf(r),a.splice(u,1),u=s.indexOf(o.face),u>-1&&s.splice(u,1),o.face.dispose(),o.face.area<=this.tolerance&&(p=!0),u=s.indexOf(r.face),u>-1&&s.splice(u,1),r.face.dispose(),r.face.area<=this.tolerance&&(p=!0),u=o.origin.hedgelist.indexOf(o),o.origin.hedgelist.splice(u,1),o.origin.hedgelist.length>0){let e,t;0===u?(e=o.origin.hedgelist[o.origin.hedgelist.length-1],t=o.origin.hedgelist[u]):(e=o.origin.hedgelist[u-1],t=o.origin.hedgelist[u%o.origin.hedgelist.length]),t.prevhedge=e.twin,e.twin.nexthedge=t}else this.deleteVertex(o.origin),m=!1;if(u=r.origin.hedgelist.indexOf(r),r.origin.hedgelist.splice(u,1),r.origin.hedgelist.length>0){let e,t;0===u?(e=r.origin.hedgelist[r.origin.hedgelist.length-1],t=r.origin.hedgelist[u]):(e=r.origin.hedgelist[u-1],t=r.origin.hedgelist[u%r.origin.hedgelist.length]),t.prevhedge=e.twin,e.twin.nexthedge=t}else this.deleteVertex(r.origin),h=!1;o.dispose(),r.dispose();const b=h?new Fn(this):null;b&&(b.wedge=c);let g=m?new Fn(this):null;if(g&&(g.wedge=d),b&&g)try{b.equals(g)&&(g.dispose(),g=null)}catch{g=null}if(b){let e=b.wedge;for(e.face=b;e.nexthedge!==b.wedge;){if(e=e.nexthedge,!e.face)return;e.face=b}b.area<=this.tolerance&&(p=!0),s.push(b)}if(g){let e=g.wedge;for(e.face=g;e.nexthedge!==g.wedge;)e=e.nexthedge,e.face=g;g.area<=this.tolerance&&(p=!0),s.push(g)}if(p)for(let e=0,t=s.length;e<t;e++)s[e]._holesDirty=!0}splitEdge(e,t,n,l,i,a){const{vertices:s,hedges:o}=this;let r=this.findVertex(i,a),c=this.findHedge(e,t,n,l);if(!c)return!1;if(r)return!0;const d=c.twin;let u;const h=this.addVertex(i,a),m=new Vn(h,c.origin),p=new Vn(d.origin,h);o.push(m),o.push(p);const b=new Vn(h,d.origin),g=new Vn(c.origin,h);return o.push(b),o.push(g),c.face.wedge===c&&(c.face.wedge=m),c.face._vertexlistDirty=!0,m.face=c.face,p.face=c.face,d.face.wedge===d&&(d.face.wedge=b),d.face._vertexlistDirty=!0,b.face=d.face,g.face=d.face,m.nexthedge=p,p.prevhedge=m,b.nexthedge=g,g.prevhedge=b,m.prevhedge=c.prevhedge!==d?c.prevhedge:g,m.prevhedge.nexthedge=m,p.nexthedge=c.nexthedge!==d?c.nexthedge:b,p.nexthedge.prevhedge=p,b.prevhedge=d.prevhedge!==c?d.prevhedge:p,b.prevhedge.nexthedge=b,g.nexthedge=d.nexthedge!==c?d.nexthedge:m,g.nexthedge.prevhedge=g,m.twin=g,p.twin=b,b.twin=p,g.twin=m,h.hedgelist.push(p,g),u=c.origin.hedgelist.indexOf(c),c.origin.hedgelist.splice(u,1,m),u=d.origin.hedgelist.indexOf(d),d.origin.hedgelist.splice(u,1,b),c.dispose(),d.dispose(),u=o.indexOf(c),o.splice(u,1),u=o.indexOf(d),o.splice(u,1),{h1:m,h2:p}}intersectFaceWithPolyLine(e,t,n=!1,l=!1){let i=[],a=l?t.length:t.length-1;for(let l=0;l<a;l++){let a=[t[l],t[(l+1)%t.length]];if(i.push(...e.intersectWithLineSeg(a.map((e=>(new Ut).fromArray(e))))),n&&i.length>=2)break}return i}getFacesAtPoint(e){let t=[],n=new Ut(...e);for(let e of this.faces)e.aabb.containsPoint(n)&&e.containsPoint(n)&&t.push(e);return t}getFacesIntersectingPoly(e){let t=e.map((e=>(new Ut
his.cellsWide=t(Y/this.cellSize),this.cellsHigh=t(P/this.cellSize);const{cellsWide:l,cellsHigh:i}=this;this.segmentMetaDataTexture={texture:new e.DataTexture(new Float32Array(l*i*2),l,i,e.RGFormat,e.FloatType),width:l,height:i},this.segmentMetaDataTexture.texture.needsUpdate=!0,this.segmentIndexTexture={texture:new qt(n,n,e.RedFormat,e.FloatType,new Float32Array(n*n)),width:n,height:n},this.segmentIndexTexture.texture.setRenderer(X)}updatePolylines(e,t=!1){this.isClosed=t,this.polyLines=e,this.texturesInitialised||(this.initializeTextures(),this.texturesInitialised=!0),this.buildSegmentRecords(),this.buildSegmentCellIndex(),this.buildSegmentDataTextures()}buildSegmentRecords(){const e=this.polyLines.reduce(((e,t)=>{const n=this.isClosed?t.length:t.length-1;return n>0?e+n:e}),0);this._segmentRecords=new Float32Array(8*e);let t=0;this.polyLines.forEach(((e,n)=>{let l=0;for(let t=0;t<e.length-1;t++)l+=$t(e[t],e[t+1]);this.isClosed&&e.length>1&&(l+=$t(e[e.length-1],e[0]));let i=0;const a=this.isClosed?e.length:e.length-1;for(let s=0;s<a;s++){const a=e[s],o=e[(s+1)%e.length],r=$t(a,o);this._segmentRecords[t++]=a[0],this._segmentRecords[t++]=a[1],this._segmentRecords[t++]=o[0],this._segmentRecords[t++]=o[1],this._segmentRecords[t++]=n,this._segmentRecords[t++]=i,this._segmentRecords[t++]=i+r,this._segmentRecords[t++]=l,i+=r}}))}buildSegmentCellIndex(){const e=this.cellsWide*this.cellsHigh;this._cellCounts=new Float32Array(e),this._cellOffsets=new Float32Array(e);const n=this._segmentRecords.length/8;let l=0;for(let e=0;e<n;e++){const e=this._segmentRecords[l+0],n=this._segmentRecords[l+1],i=this._segmentRecords[l+2],a=this._segmentRecords[l+3];l+=8;const o=t(e/this.cellSize),r=t(n/this.cellSize),c=t(i/this.cellSize),d=t(a/this.cellSize);let u=s(c-o),h=s(d-r),m=o,p=r,b=1+u+h;const g=c>o?1:-1,f=d>r?1:-1;let x=u-h;for(u*=2,h*=2;b--;){if(m>=0&&m<this.cellsWide&&p>=0&&p<this.cellsHigh){const e=p*this.cellsWide+m;this._cellCounts[e]++}if(x>0)m+=g,x-=h;else if(x<0)p+=f,x+=u;else{if(m+=g,p+=f,x+=u-h,b--,b<0)break;if(m>=0&&m<this.cellsWide&&p>=0&&p<this.cellsHigh){const e=p*this.cellsWide+m;this._cellCounts[e]++}}}}let i=0;for(let t=0;t<e;t++){const e=this._cellCounts[t];this._cellOffsets[t]=i,i+=e}this._indexData=new Float32Array(i),l=0;for(let e=0;e<n;e++){const n=this._segmentRecords[l+0],i=this._segmentRecords[l+1],a=this._segmentRecords[l+2],o=this._segmentRecords[l+3];l+=8;const r=t(n/this.cellSize),c=t(i/this.cellSize),d=t(a/this.cellSize),u=t(o/this.cellSize);let h=s(d-r),m=s(u-c),p=r,b=c,g=1+h+m;const f=d>r?1:-1,x=u>c?1:-1;let Z=h-m;for(h*=2,m*=2;g--;){if(p>=0&&p<this.cellsWide&&b>=0&&b<this.cellsHigh){const t=b*this.cellsWide+p,n=this._cellOffsets[t];this._indexData[n]=e,this._cellOffsets[t]=n+1}if(Z>0)p+=f,Z-=m;else if(Z<0)b+=x,Z+=h;else{if(p+=f,b+=x,Z+=h-m,g--,g<0)break;if(p>=0&&p<this.cellsWide&&b>=0&&b<this.cellsHigh){const t=b*this.cellsWide+p,n=this._cellOffsets[t];this._indexData[n]=e,this._cellOffsets[t]=n+1}}}}}buildSegmentDataTextures(){const e=this.segmentDataTexture.texture.texture.image.data,t=this.segmentDataTexture.width,n=this.segmentDataTexture.height,l=this._segmentRecords.length/8,i=o(2*l,t*n);let a=0,s=0;for(let t=0;t<l&&!(2*t+1>=i);t++){const n=2*t*4,l=4*(2*t+1),i=this._segmentRecords[a+0],o=this._segmentRecords[a+1],r=this._segmentRecords[a+2],c=this._segmentRecords[a+3],d=this._segmentRecords[a+4],u=this._segmentRecords[a+5],h=this._segmentRecords[a+6],m=this._segmentRecords[a+7];e[n+0]=i,e[n+1]=o,e[n+2]=r,e[n+3]=c,e[l+0]=d,e[l+1]=u,e[l+2]=h,e[l+3]=m,a+=8,s+=8}this.segmentDataTexture.texture.uploadSubData(s);const r=this.segmentMetaDataTexture.texture.image.data,c=this.segmentMetaDataTexture.width*this.segmentMetaDataTexture.height;for(let e=0;e<c;e++){const t=this._cellCounts[e],n=this._cellOffsets[e]-t,l=2*e;r[l+0]=n,r[l+1]=t}this.segmentMetaDataTexture.texture.needsUpdate=!0;const d=this.segmentIndexTexture.texture.texture.image.data,u=d.length,h=Math.min(this._indexData.length,u);d.set(this._indexData.subarray(0,h)),this.segmentIndexTexture.texture.uploadSubData(this._indexData.length)}getTextures(){return{segmentMetaDataTexture:this.segmentMetaDataTexture.texture,segmentDataTexture:this.segmentDataTexture.texture.texture,segmentIndexTexture:this.segmentIndexTexture.texture.texture}}reset(){this._segmentRecords=new Float32Array(0),this._cellCounts=new Float32Array(0),this._cellOffsets=new Float32Array(0),this._indexData=new Float32Array(0)}dispose(){this.segmentDataTexture.texture.texture.dispose(),this.segmentMetaDataTexture.texture.dispose(),this.segmentIndexTexture.texture.texture.dispose()}}let tn,nn=new en(4),ln=new en(20),an=0,sn=!1,on=null;function rn(t){if(0===t.lines.length)return;tn=tn||new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(Q,j)},uInternalResolution:{value:new e.Vector2(Y,P)},uFaceIndex:{value:0},tPaperTexture:{value:Ht.paperTexture.target.texture},uSegmentDataTex:{value:null},uSegmentIndexTex:{value:null},uSegmentMetaDataTex:{value:null},uBrightness:{value:1},...ce(),uAccumulationStrength:{value:1},uEdgeSharpness:{value:1},uTaperingFadeIn:{value:0},uTaperingFadeOut:{value:0},uTaperingScaleIn:{value:0},uTaperingScaleOut:{value:0},uFadeAtLineSegmentVertices:{value:new Float32Array([0,0,0,0])},uFadeAtLineSegmentDistance:{value:0},uFadeAtLineSegmentStrength:{value:1},uEnableFadeAtLineSegment:{value:!1},uIsShading:{value:!0},uDisableSaturationShift:{value:!1},uIsClosedPoly:{value:!1},tScreenBuffer:{value:Ft.getReadBuffer().texture},tPolyEdgeDistance:{value:Ht.polyEdgeDistance.target.texture},uNoiseOffset:{value:new ie(0,0)},tWarpTex:{value:Ht.displacementMap.target.texture},uLineColor:{value:new e.Vector3(1,0,0)},uLineHardness:{value:1},uLineWeight:{value:1},uMaterialHardness:{value:1},uLighting:{value:{center:Ie.default,min:ge(Ie.default,Ie.min,Ie.influencesBrightnessMult),max:ge(Ie.default,Ie.max,Ie.influencesBrightnessMult)}},tPolyLineGrid:{value:{width:0,height:0,cellSize:0}}},vertexShader:le,glslVersion:e.GLSL3,fragmentShader:`\n precision highp float;\n precision highp int;\n\n uniform highp sampler2D tWarpTex;\n uniform highp sampler2D tScreenBuffer;\n uniform highp sampler2D tPaperTexture;\n uniform highp sampler2D tPolyEdgeDistance;\n\n uniform highp sampler2D uSegmentDataTex;\n uniform highp sampler2D uSegmentMetaDataTex;\n uniform highp sampler2D uSegmentIndexTex;\n\n struct TPolyLineGrid {\n float width;\n float height;\n float cellSize;\n };\n\n uniform TPolyLineGrid tPolyLineGrid;\n\n\n struct Lighting {\n float center;\n float min;\n float max;\n };\n\n uniform Lighting uLighting;\n \n // uniform int uPositionsCount;\n uniform bool uIsClosedPoly;\n \n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n\n uniform vec2 uInternalResolution;\n uniform vec2 uNoiseOffset;\n uniform bool uIsShading;\n // uniform bool uBulge;\n\n uniform float uTaperingFadeIn;\n uniform float uTaperingFadeOut;\n uniform float uTaperingScaleIn;\n uniform float uTaperingScaleOut;\n\n uniform bool uEnableFadeAtLineSegment;\n uniform vec2 uFadeAtLineSegmentVertices[2];\n uniform float uFadeAtLineSegmentDistance;\n uniform float uFadeAtLineSegmentStrength;\n\n uniform float uBrightness;\n uniform float uEdgeSharpness;\n uniform float uAccumulationStrength;\n uniform float uMaterialHardness;\n uniform vec3 uLineColor;\n uniform float uLineHardness;\n uniform float uLineWeight;\n uniform float uFaceIndex;\n uniform bool uDisableSaturationShift;\n\n // Max number of lines to consider for this fragment\n const int MAX_LINE_COUNT = 64;\n\n in vec2 vUv;\n out vec4 outColor;\n\n ${Et}\n ${te}\n ${Vt}\n ${Ct}\n ${ee}\n ${ne}\n ${At}\n\n //-----------------------------------------\n \n\n vec2 pointLineSDFInfinite(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = dot(pa, ba) / dot(ba, ba);\n float dist = length(pa - ba * t);\n return vec2(dist, t);\n }\n\n // 1) Helper to fetch offset+count from segmentMetaDataTexture\n vec2 getSegmentMeta(ivec2 cellCoords) {\n // each pixel stores (offset, count)\n return texelFetch(uSegmentMetaDataTex, cellCoords, 0).rg;\n }\n \n ivec2 getCellCounts() {\n return ivec2(\n int(tPolyLineGrid.width / tPolyLineGrid.cellSize),\n int(tPolyLineGrid.height / tPolyLineGrid.cellSize)\n );\n }\n\n ivec2 getGridCoords(vec2 uv) {\n ivec2 cellCount = getCellCounts();\n \n // Flip Y so top-left is (0,0)\n float flippedY = 1.0 - uv.y;\n \n int x = int(floor(uv.x * float(cellCount.x)));\n int y = int(floor(flippedY * float(cellCount.y)));\n \n return ivec2(x, y);\n }\n\n\n // 2) Helper to read the segment ID from segmentIndexTexture\n int getSegmentID(int globalIndex) {\n ivec2 size = textureSize(uSegmentIndexTex, 0);\n // clamp the fetch\n globalIndex = clamp(globalIndex, 0, size.x*size.y - 1);\n int x = globalIndex % size.x;\n int y = globalIndex / size.x;\n return int(texelFetch(uSegmentIndexTex, ivec2(x,y), 0).r);\n }\n\n // 3) Helper to read the 2 texels for the given segment\n struct SegmentData {\n vec2 a; // x1,y1\n vec2 b; // x2,y2\n float lineIndex; \n float segStart;\n float segEnd;\n float totalLen;\n };\n\n SegmentData getSegmentData(int segmentID) {\n SegmentData seg;\n\n // each segment uses 2 RGBA texels = 8 floats\n // texel1 => (x1, y1, x2, y2)\n // texel2 => (lineIndex, segStartLen, segEndLen, totalLineLen)\n int texelIndex1 = segmentID * 2;\n int texelIndex2 = segmentID * 2 + 1;\n\n ivec2 size = textureSize(uSegmentDataTex, 0);\n\n // clamp fetch\n int maxTexels = size.x * size.y;\n texelIndex1 = clamp(texelIndex1, 0, maxTexels-1);\n texelIndex2 = clamp(texelIndex2, 0, maxTexels-1);\n\n // decode coordinates\n int x1 = texelIndex1 % size.x;\n int y1 = texelIndex1 / size.x;\n int x2 = texelIndex2 % size.x;\n int y2 = texelIndex2 / size.x;\n\n vec4 d1 = texelFetch(uSegmentDataTex, ivec2(x1,y1), 0);\n vec4 d2 = texelFetch(uSegmentDataTex, ivec2(x2,y2), 0);\n\n seg.a = d1.xy / uInternalResolution;\n seg.b = d1.zw / uInternalResolution;\n\n seg.a = vec2(seg.a.x, 1.0 - seg.a.y);\n seg.b = vec2(seg.b.x, 1.0 - seg.b.y);\n\n seg.lineIndex = d2.x;\n seg.segEnd = d2.z / uInternalResolution.x;\n seg.segStart = d2.y / uInternalResolution.x;\n seg.totalLen = d2.w / uInternalResolution.x; // scale to pixel space\n\n return seg;\n }\n\n vec2 pointLineSegSDF(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\n float dist = length(pa - ba * t);\n return vec2(dist, t);\n }\n\n\n // This struct stores the final line-based result\n struct LineDistanceResult {\n float dist; // nearest distance for this line\n float lineT; // fraction along the entire line\n float lineIndex; // which line\n };\n \n const ivec2 offsets[9] = ivec2[](\n ivec2(-1,-1), ivec2(0,-1), ivec2(1,-1),\n ivec2(-1, 0), ivec2(0, 0), ivec2(1, 0),\n ivec2(-1, 1), ivec2(0, 1), ivec2(1, 1)\n );\n\n // This function will find the closest lines to the given uv coordinate\n void lineDistanceSDFSegments(\n vec2 uv,\n float distanceThreshold,\n out LineDistanceResult linesWithin[MAX_LINE_COUNT],\n out int linesCount\n ){\n linesCount = 0;\n \n // Keep track of each line's nearest distance\n float lineDistances[MAX_LINE_COUNT];\n float lineTvalues[MAX_LINE_COUNT];\n int lineIDs[MAX_LINE_COUNT];\n \n // Initialize with defaults\n for (int i = 0; i < MAX_LINE_COUNT; i++) {\n lineDistances[i] = 1e20;\n lineTvalues[i] = 0.0;\n lineIDs[i] = -1;\n }\n \n // Figure out the base cell coords from uv\n ivec2 baseCellCoords = getGridCoords(uv);\n ivec2 cellCount = getCellCounts();\n \n // For each of the 9 offsets, gather segments from neighboring cells.\n for (int c = 0; c < 9; c++) {\n ivec2 cellCoords = baseCellCoords + offsets[c];\n \n // clamp cellCoords to grid boundaries\n if(cellCoords.x < 0 || cellCoords.x >= cellCount.x) continue;\n if(cellCoords.y < 0 || cellCoords.y >= cellCount.y) continue;\n \n // 1) fetch offset+count from the segmentMetaDataTexture\n vec2 meta = getSegmentMeta(cellCoords);\n int segOffset = int(meta.r);\n int segCount = int(meta.g);\n \n // 2) read each segment\n for (int i = 0; i < 1024; i++) {\n if (i >= segCount) break;\n \n int segID = getSegmentID(segOffset + i);\n SegmentData seg = getSegmentData(segID);\n \n // compute distance to this segment\n vec2 dt = pointLineSegSDF(uv, seg.a, seg.b);\n float dist = dt.x;\n float localT = dt.y;\n \n float segLen = seg.segEnd - seg.segStart;\n float absoluteDistanceAlongLine = seg.segStart + localT * segLen;\n float fraction = (seg.totalLen > 0.0) ? (absoluteDistanceAlongLine / seg.totalLen) : 0.0;\n \n // if within threshold\n if (dist <= distanceThreshold) {\n int lineID = int(seg.lineIndex);\n \n // check if we already have that line\n int foundIndex = -1;\n for (int j = 0; j < MAX_LINE_COUNT; j++) {\n if (lineIDs[j] == lineID) {\n foundIndex = j;\n break;\n }\n }\n \n if (foundIndex == -1) {\n // new line\n for (int j = 0; j < MAX_LINE_COUNT; j++) {\n if (lineIDs[j] < 0) {\n lineIDs[j] = lineID;\n lineDistances[j] = dist;\n lineTvalues[j] = fraction;\n break;\n }\n }\n } else {\n // line already exists => keep closer distance\n if (dist < lineDistances[foundIndex]) {\n lineDistances[foundIndex] = dist;\n lineTvalues[foundIndex] = fraction;\n }\n }\n }\n }\n }\n \n // Final pass: gather valid lines into linesWithin\n int validCount = 0;\n for (int i = 0; i < MAX_LINE_COUNT; i++) {\n if (lineIDs[i] >= 0) {\n linesWithin[validCount].dist = lineDistances[i];\n linesWithin[validCount].lineT = lineTvalues[i];\n linesWithin[validCount].lineIndex = float(lineIDs[i]);\n validCount++;\n if (validCount >= MAX_LINE_COUNT) break;\n }\n }\n\n // Now 'validCount' lines are in linesWithin[0..validCount-1].\n // Sort them by dist ascending.\n for (int i = 0; i < MAX_LINE_COUNT - 1; i++) {\n // If 'i' >= validCount - 1, break\n if (i >= validCount - 1) break;\n\n for (int j = i + 1; j < MAX_LINE_COUNT; j++) {\n // If 'j' >= validCount, break\n if (j >= validCount) break;\n\n if (linesWithin[j].dist < linesWithin[i].dist) {\n // Swap\n LineDistanceResult tmp = linesWithin[i];\n linesWithin[i] = linesWithin[j];\n linesWithin[j] = tmp;\n }\n }\n }\n \n linesCount = validCount;\n }\n\n\n float easeOut(float t, float strength) {\n return 1.0 - pow(1.0 - t, strength);\n }\n\n vec4 render(vec2 uv, vec2 screenSpaceUV, vec2 msaaOffset, vec3 frameBuffer) {\n\n float scaleFactor = (1. / uInternalResolution.x);\n vec2 tileScaleFactor = resolution / uTileSize;\n \n \n vec2 uvWarp = lookupWarpSample(screenSpaceUV + msaaOffset).xy;\n vec2 ssLookupWarp = uvWarp * tileScaleFactor;\n\n uv += uvWarp;\n\n float sdf = (texture(tPolyEdgeDistance, screenSpaceUV + ssLookupWarp + msaaOffset).r - 0.5) * 2.0;\n\n \n vec3 color = uLineColor;\n float rampStart = 0.7;\n float rampEnd = 1.0;\n float lowValue = 0.015;\n float highValue = 0.06;\n\n float t = clamp((color.x - rampStart) / (rampEnd - rampStart), 0.0, 1.0);\n \n float accumulationClampMax = 0.15;\n float accumulationIncrement = mix(lowValue, highValue, smoothstep(rampStart, rampEnd, color.x));\n vec2 accumulationClamp = vec2(accumulationClampMax, accumulationClampMax * 0.4);\n float chromaIncrement = (accumulationIncrement * 0.4) * uAccumulationStrength;\n float lightnessIncrement = (-accumulationIncrement) * uAccumulationStrength;\n float alphaIncrement = uIsShading ? .95 : 1.5;\n \n if(uIsShading) {\n float colorShift = uBrightness - uLighting.center;\n float shiftFactor = (colorShift > 0. && color.x > 0.6) ? (1.0 - clamp(color.x / 0.82, 0., 1.)) : 1.0;\n float newMult = ((colorShift * 1.5 * shiftFactor) + 1.0);\n \n color.x *= newMult;\n \n color.x -= 0.0;\n color.y -= 0.025;\n \n color.x = clamp(color.x, 0., 0.82);\n }\n\n color.x = clamp(color.x, 0., .81);\n color.y = clamp(color.y, 0., .4);\n \n vec3 originalColor = color;\n\n // SHAPE SDF\n \n float alpha = 0.0;\n \n float segmentDistanceAlphaMult = 1.;\n\n if(uEnableFadeAtLineSegment) {\n vec2 fadeStartVert = uFadeAtLineSegmentVertices[0] / resolution.xy;\n vec2 fadeEndVert = uFadeAtLineSegmentVertices[1] / resolution.xy;\n float fadeDistance = uFadeAtLineSegmentDistance * scaleFactor;\n float fadeAlpha = pointLineSDFInfinite(uv, fadeStartVert, fadeEndVert).x;\n float fadeLerp = smoothstep(0., fadeDistance, fadeAlpha);\n fadeLerp = clamp(remap(fadeLerp, 0., 1., 1. - uFadeAtLineSegmentStrength, 1.), 0., 1.);\n segmentDistanceAlphaMult = fadeLerp;\n }\n\n float edgeSharpness = remap(uEdgeSharpness, 0., 1., -0.1, -0.0015);\n\n segmentDistanceAlphaMult *= smoothstep(edgeSharpness, -0.0, sdf);\n\n if(segmentDistanceAlphaMult <= 0.) {\n return vec4(frameBuffer, 1.);\n }\n\n\n float accumulationValue = 0.0;\n float lineSampleDistanceMax = scaleFactor * (uLineWeight * 2.);\n\n LineDistanceResult linesWithin[MAX_LINE_COUNT];\n int linesCount;\n lineDistanceSDFSegments(uv, lineSampleDistanceMax, linesWithin, linesCount);\n\n for(int i = 0; i < linesCount; i++) {\n vec3 localColor = color;\n \n float lineSDF = linesWithin[i].dist;\n float lineT = linesWithin[i].lineT;\n float lineIndex = linesWithin[i].lineIndex;\n\n float currentLineNoiseOffset = float(lineIndex) * 10.;\n\n // Line Tapering and Fade\n float fadeLineCap = 1.;\n float scaleLineCap = 1.;\n \n if(uTaperingFadeIn > 0. || uTaperingFadeOut > 0.) {\n float fadeWarp = abs(fbm(uv + uNoiseOffset + currentLineNoiseOffset, 1, 10., 0.9)) * 0.05;\n \n if(uTaperingFadeIn > 0.) {\n fadeLineCap = easeOut(smoothstep(0.0, (uTaperingFadeIn / 2.) - fadeWarp, lineT), 10.);\n }\n\n if(uTaperingFadeOut > 0.) {\n fadeLineCap *= easeOut(smoothstep(1., 1. - (uTaperingFadeOut / 2.) - fadeWarp, lineT), 10.);\n }\n }\n\n if(uTaperingScaleIn > 0. || uTaperingScaleOut > 0.) {\n float scaleWarp = abs(fbm(uv + uNoiseOffset + currentLineNoiseOffset, 1, 10., 0.9)) * 0.05;\n if(uTaperingScaleIn > 0.) {\n scaleLineCap = easeOut(smoothstep(0.0, (uTaperingScaleIn / 2.), lineT + scaleWarp), 1.);\n }\n\n if(uTaperingScaleOut > 0.) {\n scaleLineCap *= easeOut(smoothstep(1., 1. - (uTaperingScaleOut / 2.), lineT + scaleWarp), 1.);\n }\n }\n\n float lineHardness = uLineHardness * fadeLineCap;\n float lineWeight = uLineWeight;\n \n float lineDistanceMax = (scaleFactor * lineWeight) * scaleLineCap;\n float lineWeightWobble = fbm(uv + currentLineNoiseOffset, 3, 8., 0.6) * (lineDistanceMax / (uIsShading ? 2. : 2.));\n \n float lineWeightEdgeNoise = fbm(uv + uNoiseOffset + currentLineNoiseOffset, 3, 300., 0.54) * (lineDistanceMax / 10.);\n\n float lineDistance = (lineSDF + lineWeightWobble + lineWeightEdgeNoise); \n \n \n float lineFineNoise = clamp(\n smoothstep(0., 0.9, fbm(uv + currentLineNoiseOffset, 2, 700., 0.9) - 0.1) + remap(lineHardness, 1., 0., 1. - uMaterialHardness, 0.5),\n 0., 1.);\n\n float lineFineNoise2 = clamp(\n smoothstep(0., 0.9, fbm(uv, 1, 900., 0.9)) + remap(lineHardness, 1., 0., 0.01, 0.5),\n 0., (1. - uMaterialHardness) + .1);\n \n\n float alphaWobblePerLine = fbm(uNoiseOffset + currentLineNoiseOffset, 1, 300., 0.9) * 0.015;\n\n float lineColorWobble = 0.008;\n \n float lightnessWobblePerLine = ((fbm(uNoiseOffset + (currentLineNoiseOffset / 1.), 1, 1000., 0.9) + .5) / 2. ) * lineColorWobble;\n localColor.x += lightnessWobblePerLine;\n\n float saturationWobblePerLine = ((fbm(uNoiseOffset + (currentLineNoiseOffset / 1.1), 1, 1100., 0.9) + .5) / 2. ) * (lineColorWobble * 0.4);\n localColor.y += saturationWobblePerLine;\n \n float maxLineHardness = clamp(smoothstep(0., 1., lineHardness - alphaWobblePerLine), 0., 1.);\n\n float lineRolloff = 0.0001;\n float alphaHardLineSpread = lineDistanceMax * 1.;\n float hardLineSS = smoothstep(alphaHardLineSpread + lineRolloff, alphaHardLineSpread - lineRolloff, lineDistance);\n\n float alphaHardLine = clamp(\n (hardLineSS * (1. - lineFineNoise) * (1. - lineFineNoise2)) * maxLineHardness,\n 0., 1.);\n\n float alphaSoftLine = 0.;\n\n if(!uIsShading) {\n float alphaSoftLineNoise = clamp((fbm(uv + currentLineNoiseOffset, 1, 800., 0.9) - 0.3), 0., 1.);\n\n\n float alphaSoftLineSpread = lineDistanceMax * 1.5;\n float softLineSS = smoothstep(alphaSoftLineSpread + lineRolloff, alphaSoftLineSpread - lineRolloff, lineDistance);\n\n alphaSoftLine
m]:J.int(4,4),[ut.md]:J.int(4,4),[ut.lg]:J.int(4,4),default:2});Ae=be(Ae,{margin:c*Be.scale,HVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},VVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),tt={...tt,cropToMargin:!1,margin:6*Be.scale}},vt=new e.OrthographicCamera(-1,1,1,-1,0,1);class Lt extends e.BufferGeometry{constructor(){super(),this.setAttribute("position",new e.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new e.Float32BufferAttribute([0,2,0,0,2,0],2))}}const St=new Lt;class Xt{_mesh;constructor(t){this._mesh=new e.Mesh(St,t)}dispose(){this._mesh.geometry.dispose()}render(e=X){e.render(this._mesh,vt)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}let Ct="\n vec2 lookupWarpSample(const vec2 uv) {\n\n // vec2 offset = vec2(0.2);\n return ((texture(tWarpTex, uv).xy - 0.5) * 2.);\n }\n",Vt="\n float remap(float t, float a1, float b1, float a2, float b2) {\n return a2 + (b2 - a2) * ((t - a1) / (b1 - a1));\n }\n";function Kt(){return new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(Q,j)},noiseOffset:{value:new e.Vector2(ke[0],ke[1])},...ce(),wave:{value:{...$e}},uWarpEnabled:{value:!1},grid:{value:{...Be}}},depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec2 noiseOffset;\n uniform bool uWarpEnabled;\n\n struct Wave {\n bool warpX;\n bool warpY;\n\n bool offAxisY;\n bool offAxisX;\n\n float warpXMult;\n float warpYMult;\n\n float displacementStrength;\n \n bool noiseMapEnabled;\n };\n \n uniform Wave wave;\n\n struct Grid {\n float countX;\n float countY;\n float marginX;\n float marginY;\n float w;\n float h;\n float scale;\n };\n\n uniform Grid grid;\n\n varying vec2 vUv;\n out vec4 outColor;\n\n // const float scale = 10.;\n\n #include <packing>\n\n ${ee}\n ${Vt}\n ${te}\n \n // Third compomnent is the intersection\n // const float PI2 = acos(-1.);\n \n float noiseLookup(vec2 uv, float freq) {\n float influence = fbm(uv + noiseOffset, 2, freq + 0.2, 0.8);\n return smoothstep(0., 1., abs(fbm(uv - influence, 2, freq, 0.5)));\n }\n\n// vec2 warpTextureSampleUv(const vec2 uv) {\n// // Center of the drop\n// vec2 center = vec2(0.5, 0.5);\n// // Spacing between each ripple (distance in UV space)\n// float ringSpacing = 0.1;\n\n// // Thickness of each ripple peak\n// float ringThickness = 0.01;\n\n// // Overall ripple strength\n// float amplitude = 0.05;\n\n// // Distance from UV to the center\n// float dist = distance(uv, center);\n\n// // We compute the ripple shape by creating rings around the center at multiples of ringSpacing\n// // - sector is how far dist is from the last multiple of ringSpacing\n// // - ringDist is how far we are from the center of that ring\n// float sector = mod(dist, ringSpacing);\n// float ringDist = abs(sector - (ringSpacing * 0.5));\n\n// // Create a peak shape at the ring center\n// // wave is 1.0 near the ring center and 0.0 outside\n// float wave = 1.0 - smoothstep(0.0, ringThickness, ringDist);\n\n// // Convert wave to displacement strength\n// float offsetStrength = wave * amplitude;\n\n// // Direction outward from the center\n// vec2 direction = normalize(uv - center);\n\n// return direction * offsetStrength;\n// }\n \n vec2 warpTextureSampleUv(const vec2 uv) {\n\n float PI = acos(-1.);\n float gridSize = grid.w / 1000.;\n float strength = gridSize * .2;\n float edgeFalloff = 1.;\n\n // strength *= 50.; \n\n vec2 warpSpread = vec2(1.) * .1;\n\n float aspectRatio = resolution.x / resolution.y;\n\n vec2 offsetUV = uv + (noiseOffset * 2.);\n\n offsetUV.x *= 1.;\n offsetUV.y *= 1.2;\n\n // float noiseMask = snoise2D(offsetUV / .2) ;\n // float noiseMask2 = snoise2D(offsetUV / .18);\n // float noiseWarped = snoise2D(vec2((offsetUV.x + 1.) / .1 * noiseMask2, uv.y / 1.2 * noiseMask));\n // float noiseWarped2 = snoise2D(vec2((offsetUV.x + .8) / .25 * noiseMask2, uv.y / 1.2 * noiseMask));\n \n float freq = 10.1;\n float warpedDivisor = .5;\n\n float noiseMaskMask = smoothstep(0.95, 1., fbm(offsetUV, 1, freq * 3., 0.5));\n float noiseMask = (fbm(offsetUV, 1, freq + 0.001, 0.5) + 0.01) - fbm(offsetUV, 1, freq, 0.5);\n noiseMask *= 50.;\n noiseMask *= clamp(abs(noiseMaskMask), .5, 1e6);\n // float direction = smoothstep(-1., 1., fbm(offsetUV, 2, freq * .1, 0.5));\n\n // float noiseY = fbm(offsetUV * .5, 2, freq, 0.1);\n // float noiseX = fbm(offsetUV * .5, 3, freq/2., 0.2);\n\n float epsilon = 0.01;\n\n\n\n\n float noiseWarpedCenter = noiseLookup(offsetUV , warpedDivisor);\n float noiseWarpedY = noiseLookup(offsetUV + vec2(epsilon, 0.), warpedDivisor);\n float noiseWarpedX = noiseLookup(offsetUV + vec2(0., epsilon), warpedDivisor);\n\n // float dFdx = (noiseWarpedX - noiseWarpedCenter) / epsilon;\n // float dFdy = (noiseWarpedY - noiseWarpedCenter) / epsilon;\n\n // vec2 gradient = vec2(dFdx, dFdy);\n // gradient = vec2(-gradient.y, gradient.x);\n \n // gradient = normalize(gradient);\n\n // float projection = dot(uv, gradient);\n // float wave = sin(projection * .1); \n // gradient = vec2(-gradient.y, gradient.x);\n // float noiseWarped2 = fbm(offsetUV + vec2(freq/2.) * vec2(1.) * warpedUV, 1, freq * .5, 0.1);\n \n\n // float nNoise = snoise2D(offsetUV * .5);\n // float result = ((noiseWarped * 1.f) * (noiseWarped2 * 1.f)) * noiseMask;\n // float noiseSwirl = noiseMask;\n // float result = noiseWarped1 * 2. * PI - (PI * .5);\n\n vec2 divergence = vec2(0.);\n // divergence += vec2(cos(result), sin(result));\n // divergence += (result * strength) * noiseMask;\n divergence += noiseWarpedCenter * strength * noiseMask;\n // divergence *= screenEdgeDist(uv, edgeFalloff);\n \n // float simpleWarp = fbm(offsetUV, 6, 600.6, .9);\n\n // divergence += simpleWarp * .0003;\n\n return vec2(divergence); \n }\n\n\n const float PI = acos(-1.);\n\n const float waveWarpDivisor = 1.;\n // const int waveNoiseMapEnabled = 0;\n\n \n\n vec2 waveUv(vec2 uv) {\n\n vec2 margins = vec2(grid.marginX / resolution.x, grid.marginY / resolution.y);\n float width = grid.w / resolution.x;\n\n float lookupRemap = noiseOffset.x;\n \n // float influence = clamp(snoise2D((uv + lookupRemap)), 0.f, 1.f);\n float influence = grid.countX * wave.displacementStrength;\n \n // if(wave.noiseMapEnabled == 1)\n // influence = .9f + (influence / 10.f);\n \n float strength = (width / (waveWarpDivisor * PI) - 2.f) * (width / grid.countX) * influence;\n float sinX = sin(wave.warpXMult * PI * ((uv.x / width) + margins.x) - PI /2.) * strength;\n float sinY = sin(wave.warpYMult * PI * ((uv.y / width) + margins.y) - PI /2.) * strength;\n \n vec2 result = vec2(0.);\n \n if(wave.warpX)\n result.x += sinX;\n \n if(wave.warpY)\n result.y += sinY;\n \n if(wave.offAxisY)\n result.y += sinX;\n \n if(wave.offAxisX)\n result.x += sinY;\n \n // result.y = sin(waveWarpXMult * PI * ((uv.x + margins.y) / width)) * strength;\n // result.x = sin(waveWarpYMult * PI * ((uv.x + margins.x) / width)) * strength;\n\n return result;\n }\n\n // vec2 calculatePerspectiveOffset(vec2 uv) {\n // // Store the original UV coordinates\n // vec2 originalUv = uv;\n \n // // Define perspective depth factors\n // float perspectiveStrength = .0; // Controls the overall perspective effect\n // float tiltX = -0.3; // Controls the leftward skew\n // float tiltY = 0.2; // Controls the backward tilt\n \n // // Shift UVs to the center of the texture\n // uv -= 0.5;\n \n // // Apply perspective transformation\n // float depth = 1.0 - perspectiveStrength * (tiltX * uv.x + tiltY * uv.y);\n // uv /= depth;\n \n // // Calculate the min and max bounds of the transformed UVs\n // vec2 minBounds = vec2(-0.5) / (1.0 - perspectiveStrength * vec2(-tiltX, -tiltY));\n // vec2 maxBounds = vec2(0.5) / (1.0 - perspectiveStrength * vec2(tiltX, tiltY));\n \n // // Normalize the UV coordinates to the [0, 1] range\n // uv = (uv - minBounds) / (maxBounds - minBounds);\n \n // // Apply scaling to fill the scene\n // uv = uv * (maxBounds - minBounds);\n \n // // Calculate the offset by subtracting the original UV from the transformed and normalized UV\n // vec2 offset = uv - originalUv;\n \n // return offset;\n // }\n\n vec4 render(vec2 uv, vec2 screenSpaceUV, vec2 msaaOffset) {\n vec2 offset = uWarpEnabled ? warpTextureSampleUv(uv) : vec2(0.);\n vec2 warpedUv = waveUv(uv);\n offset += warpedUv;\n // offset += calculatePerspectiveOffset(uv);\n return(vec4(offset * 0.5 + 0.5, 0., 1.0));\n }\n\n float randomNonDet(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n\n void main() {\n const vec2 H2 = vec2(0.5698402909980532f, 0.7548776662466927f);\n vec2 px = 1.f / resolution;\n px *= 1.25;\n vec2 uv = vUv;\n\n \n // Check if this fragment is within the SDF\n // vec2 uvOffset = lookupWarpSample(uv).xy;\n // float texCheck = (texture(tPolyEdgeDistance, uv + uvOffset).r - 0.5) * 2.0;\n // if(texCheck < -0.1) {\n // discard;\n // }\n\n\n const float samples = 6.f;\n \n vec4 sumColour;\n vec2 d0 = vec2(randomNonDet(uv), randomNonDet(uv + 1.f));\n\n \n for(float i = 0.f; i < samples; i++) {\n vec2 d = (fract(i * H2 + d0) - .5f);\n\n vec2 localCoord = vUv + d * px; /* changed */\n vec2 screenCoord = uTileOffset + localCoord * uTileSize; /* changed */\n vec2 globalUV = screenCoord / resolution; /* changed */\n\n // vec4 sampleColor = render(globalUV, vUv, d * px);\n vec4 sampleColor = render(globalUV, vUv, d * px);\n // sampleColor.rgb *= sampleColor.a; // Convert to premultiplied alpha\n sumColour += sampleColor;\n }\n \n vec4 averageColor = clamp(sumColour / samples, 0., 1.);\n \n outColor = averageColor;\n }\n `})}let wt="\n\n vec3 sCurve(vec3 c, float contrast, float midpoint) {\n // c in [0, 1], midpoint could be 0.5 or 0.18\n // contrast is how steep the curve is\n // A simple logistic-based S-curve\n return 1.0 / (1.2 + exp(-(c - midpoint) * contrast)) ;\n }\n\n vec4 adjustContrast(vec4 color, float factor) {\n float midpoint = 0.3; // 0.18\n // Factor is effectively the steepness of the slope\n vec3 curved = sCurve(color.rgb, factor, midpoint);\n return vec4(curved, color.a);\n }\n",kt="\n const float l2p3alpha = 1.055;\n const float l2p3beta = 0.00304;\n const float l2p3gamma = 2.4;\n const float l2p3delta = 0.055;\n\n vec3 linear2P3(vec3 linearRgb) {\n vec3 a = l2p3alpha * pow(linearRgb, vec3(1.0 / l2p3gamma)) - l2p3delta;\n vec3 b = linearRgb / 12.92;\n vec3 mask = step(vec3(l2p3beta), linearRgb);\n\n return mix(b, a, mask);\n }\n";function Rt(){return new e.ShaderMaterial({uniforms:{tTex:{value:null}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n in vec2 vUv;\n out vec4 outColor;\n\n ${kt}\n ${wt}\n\n // vec4 desaturateRGBA(vec4 color, float factor) {\n // float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));\n // vec3 desaturatedColor = mix(color.rgb, vec3(gray), factor);\n // return vec4(desaturatedColor, color.a);\n // }\n\n void main() {\n vec4 color = vec4(texture2D(tTex, vUv).rgb, 1.);\n // vec4 contrasty = adjustContrast(color, 12.);\n // color = mix(color, contrasty, 0.05);\n // color = adjustBrightness(color, 1.001);\n // color *= 0.95;\n // color = desaturateRGBA(color, 0.001);\n outColor = vec4(linear2P3(vec3(color)), 1.);\n }\n `})}const Tt=Rt(),Mt=new e.ShaderMaterial({uniforms:{tTex:{value:null},uChannel:{value:0}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:le,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n uniform int uChannel;\n\n in vec2 vUv;\n out vec4 outColor;\n\n // ${kt}\n // ${wt}\n\n void main() {\n vec4 color = vec4(texture2D(tTex, vUv).rgba);\n if(uChannel == -1) {\n outColor = color;\n return;\n }\n float channelColor = color[ int(uChannel) ];\n outColor = vec4(vec3(channelColor), 1.0);\n }\n `}),zt=new Xt(Tt);function Yt(e,t){zt.material=Tt,Tt.uniforms.tTex.value=e,X.setRenderTarget(t||null),zt.render(X)}class Pt{width;height;bufferIdx=0;textureCount=1;renderBuffers=[];renderBufferProps;maskEnabled=!1;constructor(t=Q,n=j,l){this.width=t,this.height=n;let i=K?e.LinearFilter:e.NearestFilter;this.renderBufferProps={anisotropy:V,minFilter:i,magFilter:i,stencilBuffer:!1,premultipliedAlpha:!0,alpha:!0,depthBuffer:!1,colorSpace:e.LinearDisplayP3ColorSpace,generateMipmaps:!1,format:e.RGBAFormat,type:e.FloatType,internalFormat:"RGBA32F",...l},this.setupFrameBuffers(),this.clearFrameBuffers(),X.autoClear=!1}setupFrameBuffers(){for(let t=0;t<2;t++)this.renderBuffers.push(new e.WebGLRenderTarget(this.width,this.height,this.renderBufferProps))}clearFrameBuffers(e=!0,t=!0,n=!0){X.setClearColor(16777215,0);const{stencil:l,color:i,depth:a}=X.state.buffers;this.renderBuffers.forEach((s=>{X.setRenderTarget(s),e&&i.setLocked(!1),t&&a.setLocked(!1),n&&l.setLocked(!1),X.clear(e,t,n)}))}enableMask(e=1){this.maskEnabled=!0;const{stencil:t}=X.state.buffers,n=X.getContext();t.setLocked(!1),t.setTest(!0),t.setFunc(n.EQUAL,e,4294967295),t.setOp(n.KEEP,n.KEEP,n.KEEP),t.setLocked(!0)}disableMask(){this.maskEnabled=!1;const{stencil:e}=X.state.buffers;e.setLocked(!1),e.setTest(!1),e.setLocked(!0)}renderMaterialAsMask(e,t=1){if(!this.renderBufferProps.stencilBuffer)throw Error("Stencil buffer not enabled in render buffer properties");const n=X.getContext(),{color:l,depth:i,stencil:a}=X.state.buffers;i.setMask(!1),i.setLocked(!0),l.setMask(!1),l.setLocked(!0),a.setLocked(!1),a.setTest(!0),a.setOp(n.KEEP,n.KEEP,n.REPLACE),a.setFunc(n.ALWAYS,t,4294967295),a.setClear(0),a.setLocked(!0),zt.material=e,X.setRenderTarget(this.getReadBuffer()),zt.render(),X.setRenderTarget(this.getWriteBuffer()),zt.render(),l.setLocked(!1),l.setMask(!0),i.setLocked(!1),i.setMask(!0)}getWriteBuffer(){return this.renderBuffers[(this.bufferIdx+1)%2]}getReadBuffer(){return this.renderBuffers[this.bufferIdx%2]}copyBufferChannelToScreen(e=0,t=this.getReadBuffer()){let n=this.maskEnabled;n&&this.disableMask(),X.setRenderTarget(null),zt.material=Mt,Mt.uniforms.tTex.value=t.texture,Mt.uniforms.uChannel.value=e,zt.render(),n&&this.enableMask()}copyBufferToBuffer(e){let t=this.maskEnabled;t&&this.disableMask(),X.setRenderTarget(e),X.copyFramebufferToTexture(this.getReadBuffer().texture),t&&this.enableMask()}copyAndSwapBuffers(){this.copyBufferToBuffer(this.getWriteBuffer()),this.bufferIdx++}copyBufferToScreen(e=this.getReadBuffer()){let t=this.maskEnabled;t&&this.disableMask(),Yt(e.texture),t&&this.enableMask()}}let Ft,Ht={},It=new Xt(null),Nt=0;class Ut{x;y;id=Nt++;hedgelist=[];constructor(e=0,t=0){this.x=e,this.y=t}sortincident(){this.hedgelist&&this.hedgelist.sort(Dt)}subtract(e){return new Ut(this.x-e.x,this.y-e.y)}addPolar(e,t){return new Ut(this.x+t*i(e),this.y+t*l(e))}normalize(e=g){const t=d(this.x*this.x+this.y*this.y);return t<e?new Ut(0,0):new Ut(this.x/t,this.y/t)}multiply(e){return new Ut(this.x*e,this.y*e)}add(e){return new Ut(this.x+e.x,this.y+e.y)}toArray(){return[this.x,this.y]}fromArray(e){return this.x=e[0],this.y=e[1],this}distanceTo(e){return d(a(e.x-this.x,2)+a(e.y-this.y,2))}angleTo(e){return Math.atan2(e.y-this.y,e.x-this.x)}lerp(e,t){return new Ut(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}translate(e,t){this.x+=t*i(e),this.y+=t*l(e)}clone(){return new Ut(this.x,this.y)}isEqualTo(e,t=g){const n=e.x-this.x,l=e.y-this.y;return n*n+l*l<=t*t}isCloseTo(e,t=g){return this.distanceTo(e)<t}dispose(){this.hedgelist.length=0}}function Dt(e,t){return t.angle-e.angle}function Ot(e,t=1){if(0===t)return e;let n=Be.w/t,l=Be.h/t,i=xe(e.x,n),a=xe(e.y,l);return new Ut(i,a)}function Bt(e,t=1){return function(e){return new Ut(e.x+Be.marginX,e.y+Be.marginY)}(Ot(new Ut(e.x,e.y),t))}function Qt(e){return[e[0],e[1],e[2]*Math.PI/180]}function jt(e){return(e%360+360)%360}function Jt(e){return[Ze(e[0],0,1),Ze(e[1],0,1),jt(e[2])]}let At="\n float getPaperTexture( const vec2 screenPosition ) {\n return texture(tPaperTexture, screenPosition).x;\n }\n\n vec3 calculateNormals(vec2 uv, float offsetScale, float scale) {\n // float offsetScale = .5;\n vec2 offset = vec2(offsetScale, offsetScale);\n // float scale = 1.;\n\n float left = getPaperTexture(vec2(uv.x + offset.x, uv.y));\n float right = getPaperTexture(vec2(uv.x - offset.x, uv.y));\n float up = getPaperTexture(vec2(uv.x, uv.y + offset.y));\n float down = getPaperTexture(vec2(uv.x, uv.y - offset.y));\n\n vec3 dx = vec3(1.0, 0.0, (left - right) * scale);\n vec3 dy = vec3(0.0, 1.0, (up - down) * scale);\n\n vec3 normal = normalize(cross(dy, dx));\n\n return -normal;\n }\n\n vec3 calculateDiffuse(vec3 normal, vec3 lightDir, vec3 lightColor) {\n // Calculate the diffuse component\n float diff = max(dot(normal, lightDir), 0.0);\n float angleAttenuation = pow(diff, 1.);\n return angleAttenuation * lightColor;\n }\n",Et="\n // Partially adapted from - https://github.com/yum-food/HLSL_OKLAB/blob/main/oklab.cginc\n const mat3 m1i = mat3(vec3(1.22700842, -0.5576564, 0.28111404), vec3(-0.04047048, 1.11219073, -0.07157255), vec3(-0.07643651, -0.42138367, 1.58625265));\n const mat3 m2i = mat3(vec3(1.00003964, 0.39638005, 0.21589049), vec3(0.99998945, -0.10553958, -0.06374665), vec3(0.99999105, -0.08946276, -1.291495));\n // XYZ -> linear RGB (p3) from colorjs.io - https://github.com/color-js/color.js/blob/main/src/spaces/p3-linear.js\n const mat3 xyz_to_rgb_p3 = mat3(vec3(2.493496911941425, -0.9313836179191239, -0.40271078445071684), vec3(-0.8294889695615747, 1.7626640603183463, 0.023624685841943577), vec3(0.03584583024378447, -0.07617238926804182, 0.9568845240076872));\n\n // Functions for matrix multiplication and power, as GLSL doesn't have built-in matrix multiplication for 3x3 matrices\n vec3 mat3_mul_vec3(mat3 m, vec3 v) {\n return vec3(dot(m[0], v), dot(m[1], v), dot(m[2], v));\n }\n\n vec3 vec3_pow(vec3 v, float p) {\n return vec3(pow(v.x, p), pow(v.y, p), pow(v.z, p));\n }\n\n // Converts OKLCH color to XYZ color space\n vec3 OKLCHtoXYZ(vec3 c) {\n // Convert OKLCH to OKLAB\n float a = c.y * cos(c.z);\n float b = c.y * sin(c.z);\n vec3 oklab = vec3(c.x, a, b);\n\n // Convert OKLAB to XYZ\n oklab = mat3_mul_vec3(m2i, oklab);\n oklab = vec3_pow(oklab, 3.0);\n return mat3_mul_vec3(m1i, oklab);\n }\n\n // Converts XYZ color to linear RGB color space (p3)\n vec3 XYZtoP3LRGB(vec3 c) {\n return mat3_mul_vec3(xyz_to_rgb_p3, c);\n }\n\n // Main function to convert OKLCH to Linear RGB\n vec3 OKLCHtoP3LRGB(vec3 oklchColor) {\n vec3 xyzColor = OKLCHtoXYZ(oklchColor);\n vec3 lrgbColor = XYZtoP3LRGB(xyzColor);\n return lrgbColor;\n }\n";const _t=e=>e.map((({x:e,y:t})=>[e*D,j-t*D]));class qt{width;height;format;type;channels;texture;gl;_glFormat;_glType;_glTexture;renderer;constructor(t,n,l,i,a){if(this.width=t,this.height=n,this.format=l,this.type=i,l===e.RGBAFormat)this.channels=4;else if(l===e.RGFormat)this.channels=2;else{if(l!==e.RedFormat)throw Error("Unsupported format for PartialDataTexture.");this.channels=1}const s=t*n*this.channels,o=a||new Float32Array(s);if(o.length!==s)throw Error("Initial data length does not match texture dimensions.");this.texture=new e.DataTexture(o,t,n,l,i),this.texture.needsUpdate=!0,this.gl=null,this._glFormat=null,this._glType=null,this._glTexture=null}setRenderer(t){this.renderer=t;const n=t.getContext();if(this.gl=n,this.format===e.RGBAFormat)this._glFormat=n.RGBA;else if(this.format===e.RGFormat)this._glFormat=n.RG;else{if(this.format!==e.RedFormat)throw Error("Unsupported format for PartialDataTexture.");this._glFormat=n.RED}if(this.type!==e.FloatType)throw Error("PartialDataTexture currently only supports Float32 data type.");this._glType=n.FLOAT,t.initTexture(this.texture);const l=t.properties.get(this.texture);this._glTexture=l.__webglTexture}uploadSubData(e){if(!this.gl||!this._glTexture)throw Error("Renderer not set or texture not initialized. Call setRenderer() before updating.");const t=this.gl,n=Math.floor(e/this.channels);if(n<=0)return;const l=this.width*this.height,i=Math.min(n,l),a=Math.floor(i/this.width),s=i%this.width,o=this.texture.image.data,r=t.getParameter(t.TEXTURE_BINDING_2D);if(t.bindTexture(t.TEXTURE_2D,this._glTexture),a>0){const e=o.subarray(0,a*this.width*this.channels);t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,a,this._glFormat,this._glType,e)}if(s>0){const e=a*this.width*this.channels,n=o.subarray(e,e+s*this.channels);t.texSubImage2D(t.TEXTURE_2D,0,0,a,s,1,this._glFormat,this._glType,n)}t.bindTexture(t.TEXTURE_2D,r)}}function $t(e,t){const n=t[0]-e[0],l=t[1]-e[1];return d(n*n+l*l)}class en{polyLines=[];isClosed;cellSize;cellsWide;cellsHigh;_segmentRecords;_cellCounts;_cellOffsets;_indexData;segmentDataTexture;segmentIndexTexture;segmentMetaDataTexture;texturesInitialised=!1;constructor(e=1){this.cellSize=e}initializeTextures(){const n=o(C,2048);this.segmentDataTexture={texture:new qt(n,n,e.RGBAFormat,e.FloatType,new Float32Array(n*n*4)),width:n,height:n},this.segmentDataTexture.texture.setRenderer(X),t
ce:2,tension:{min:.9,max:1.2},maxPointUse:1,pointsToConsider:30,maxLinePoints:30},$e={warpX:!0,warpY:!1,offAxisX:!0,offAxisY:!1,warpXMult:.05,warpYMult:.05,displacementStrength:.05,noiseMapEnabled:!0},et=Pe,tt={cropToMargin:!0,cropBGShapesAtMargin:!0,cropToMarginFillDark:!1,margin:30},nt={count:100,lineRemoveStrength:.1,polyOverfitting:.75,noiseOverfittingSpread:0,noiseOverfitFreq:100,excludeWeakSplits:!1,longestSplitOnlyChance:50,noiseFieldCategoryInfluence:1e3},lt=Fe,it=100,at=.1,st=0,ot="",rt=!1;const ct=(e,t)=>{Be.scale=J.int(e,t);const n=Y/Be.scale,l=P/Be.scale;Be.countX=Math.ceil(n),Be.countY=Math.ceil(l);const i=Be.countX*Be.scale,a=Be.countY*Be.scale;Be.marginX=(Y-i)/2,Be.marginY=(P-a)/2,Be.w=Be.scale,Be.h=Be.scale};var dt,ut,ht,mt,pt,bt;function gt(e,t){return function(e){return void 0!==e[t]?e[t]:e.default}}!function(e){e.filledFractured="filledFractured",e.centralNatural="centralNatural",e.sparseFractured="sparseFractured",e.sparseBlockyFracture="sparseBlockFracture",e.smoothObjects="flowingObjects",e.islands="islands",e.bigObjects="focusedObjects",e.fractures="fractures"}(dt||(dt={})),function(e){e.xs="xsmall",e.sm="small",e.md="medium",e.lg="large",e.xl="xlarge"}(ut||(ut={})),function(e){e.none="none",e.sparse="sparse",e.light="light",e.dense="dense",e.filled="filled",e.detailOnly="detailOnly"}(ht||(ht={})),function(e){e.light="light",e.medium="medium",e.heavy="heavy"}(mt||(mt={})),function(e){e.color="color",e.dark="dark",e.light="light"}(pt||(pt={})),function(e){e.objects="objects",e.curves="curves",e.angles="angles",e.grid="grid",e.mesh="mesh",e.all="all",e.random="random"}(bt||(bt={}));const ft=()=>({[bt.objects]:{splits:{[Se.horizontal]:1,[Se.vertical]:2,[Se.perspective]:0,[Se.circle]:2,[Se.wobbles]:3,[Se.objects]:15,[Se.curves]:5,[Se.rects]:1,[Se.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:J.choice([10,0]),forceInsertObjectsChance:J.choice([20,0])}}},[bt.grid]:{splits:{[Se.horizontal]:2,[Se.vertical]:4,[Se.perspective]:0,[Se.circle]:4,[Se.wobbles]:1,[Se.objects]:10,[Se.curves]:0,[Se.rects]:0,[Se.borderRect]:0},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[bt.curves]:{splits:{[Se.horizontal]:1,[Se.vertical]:2,[Se.perspective]:0,[Se.circle]:10,[Se.wobbles]:10,[Se.objects]:J.choice([10,1]),[Se.curves]:10,[Se.rects]:0,[Se.borderRect]:1},meta:{usedLineReplayChance:10,forceSplit:{forceInsertCurvesChance:J.choice([0,20]),forceInsertObjectsChance:J.choice([0,20])}}},[bt.angles]:{splits:{[Se.horizontal]:2,[Se.vertical]:3,[Se.perspective]:3,[Se.circle]:0,[Se.wobbles]:0,[Se.objects]:3,[Se.curves]:2,[Se.rects]:0,[Se.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[bt.mesh]:{splits:{[Se.horizontal]:1,[Se.vertical]:1,[Se.perspective]:1,[Se.circle]:1,[Se.wobbles]:0,[Se.objects]:1,[Se.curves]:0,[Se.rects]:0,[Se.borderRect]:0},meta:{objectProps:{forceYUp:!0},forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:50}}},[bt.all]:{splits:{[Se.horizontal]:2,[Se.vertical]:2,[Se.perspective]:2,[Se.circle]:2,[Se.wobbles]:2,[Se.objects]:4,[Se.curves]:2,[Se.rects]:1,[Se.borderRect]:2},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}}});let xt,Zt,yt;const Gt=()=>{let e=ft();yt=J.weightedChoice([8,dt.filledFractured],[10,dt.sparseFractured],[rt?0:14,dt.centralNatural],[8,dt.sparseBlockyFracture],[8,dt.smoothObjects],[8,dt.islands],[8,dt.bigObjects],[8,dt.fractures]);let n=gt(0,yt);ot="Pencils",ct(20,20),Zt=n({[dt.filledFractured]:ut.lg,[dt.sparseFractured]:ut.lg,[dt.centralNatural]:ut.md,[dt.sparseBlockyFracture]:ut.md,[dt.smoothObjects]:ut.sm,[dt.islands]:J.choice([ut.lg,ut.md]),[dt.bigObjects]:ut.sm,[dt.fractures]:ut.lg});let l=gt(0,Zt);xt=J.weightedChoice([n({[dt.centralNatural]:1,default:0}),ht.light],[n({default:0}),ht.dense],[n({[dt.filledFractured]:1,[dt.sparseFractured]:1,[dt.sparseBlockyFracture]:1,[dt.smoothObjects]:1,[dt.bigObjects]:1,default:0}),ht.filled],[n({[dt.islands]:1,[dt.fractures]:1,default:0}),ht.detailOnly]);let i=gt(0,xt),a=J.weightedChoice([n({[dt.filledFractured]:1,[dt.sparseFractured]:1,[dt.smoothObjects]:1,[dt.islands]:1,[dt.bigObjects]:1,default:0}),bt.objects],[n({[dt.filledFractured]:1,[dt.islands]:1,default:0}),bt.curves],[n({[dt.centralNatural]:2,[dt.sparseBlockyFracture]:1,[dt.islands]:1,default:0}),bt.angles],[n({[dt.fractures]:1,default:0}),bt.grid]),s=e[a];Ee=be(Ee,s.splits),De=be(De,s.meta.forceSplit),nt=be(nt,{noiseOverfittingSpread:n({[dt.filledFractured]:J.num(.2,.5),[dt.sparseFractured]:J.num(.2,.5),[dt.centralNatural]:J.num(.2,1),[dt.sparseBlockyFracture]:J.num(.25,.35),[dt.smoothObjects]:J.num(.001,.01),[dt.islands]:J.num(0,.3),[dt.bigObjects]:J.num(.25,.35),[dt.fractures]:J.num(.13,.19),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:n({[dt.bigObjects]:.97,default:1}),longestSplitOnlyChance:n({default:50}),noiseFieldCategoryInfluence:n({[dt.filledFractured]:1,[dt.sparseFractured]:1,[dt.centralNatural]:4,[dt.sparseBlockyFracture]:4,[dt.smoothObjects]:4,[dt.islands]:1,[dt.bigObjects]:4,[dt.fractures]:4,default:J.int(1,4)})}),st=s.meta?.usedLineReplayChance||4,it=t(n({[dt.filledFractured]:J.easedInt(ve,250,450),[dt.sparseFractured]:J.easedInt(ve,260,450),[dt.centralNatural]:J.easedInt(ve,200,240),[dt.sparseBlockyFracture]:J.easedInt(ve,240,400),[dt.smoothObjects]:J.easedInt(ve,170,260),[dt.islands]:l({[ut.lg]:J.easedInt(ve,250,660),default:J.easedInt(ve,230,400)}),[dt.bigObjects]:J.easedInt(ve,170,220),[dt.fractures]:J.easedInt(ve,290,330)})*J.num(.95,1.05)),at=n({[dt.filledFractured]:J.num(.003,.01),[dt.sparseFractured]:J.num(.003,.01),[dt.centralNatural]:J.num(.025,.035),[dt.sparseBlockyFracture]:J.num(.11,.15),[dt.smoothObjects]:J.num(.001,.006),[dt.islands]:J.num(.1,.27),[dt.bigObjects]:J.num(0,.008),[dt.fractures]:J.num(.03,.05),default:J.num(0,.3)});let o=n({[dt.centralNatural]:J.bool(20),[dt.filledFractured]:!0,default:J.bool(50)});et={...et,curveMap:n({[dt.filledFractured]:J.choice([Ge,ve]),[dt.sparseFractured]:J.choice([Ge,ve]),default:We}),mutation:rt?"none":n({default:J.weightedChoice([1,"offsetUp"],[3,"none"])}),addBGContrast:i({[ht.detailOnly]:!1,default:!0}),useNoiseLookup:!0,samplesForComplimentary:n({[dt.filledFractured]:J.int(1,2),default:J.weightedChoice([3,1],[2,2])}),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:n({[dt.filledFractured]:J.num(300,400),[dt.sparseFractured]:J.num(300,400),[dt.centralNatural]:J.num(280,320),default:J.num(100,500)}),usePolyIDColorOffset:o,maxAccents:n({[dt.centralNatural]:J.choice([4,6,100]),default:J.weightedChoice([0,4],[2,6],[4,100])}),darksOnly:!1};let r=gt(0,J.weightedChoice([10,pt.color],[n({default:0}),pt.dark],[n({default:0}),pt.light]));lt={...lt,size:l({[ut.md]:{min:5,max:6},[ut.lg]:{min:4,max:5},[ut.sm]:{min:6,max:8}})},_e=[Se.horizontal,Se.vertical],Ie={...Ie,default:1,clamp:.01,min:.6,max:.99,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.2},xt!=ht.filled||Zt!=ut.lg&&Zt!=ut.md||!J.bool(10)||(Ie={...Ie,default:1,clamp:.025,min:.5,max:.55,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:0});let c=n({[dt.filledFractured]:!1,[dt.sparseBlockyFracture]:!1,[dt.centralNatural]:!0,[dt.sparseFractured]:!0,[dt.smoothObjects]:!1,[dt.islands]:!1,[dt.bigObjects]:!1,[dt.fractures]:!0,default:J.bool(40)});qe={...qe,ignoreLighting:J.bool(50),maxWidth:n({[dt.filledFractured]:J.num(35,45),[dt.sparseFractured]:J.num(35,45),[dt.centralNatural]:J.int(38,42),[dt.sparseBlockyFracture]:J.int(38,42),[dt.smoothObjects]:J.int(31,36),[dt.islands]:l({[ut.lg]:J.int(30,40),default:J.int(30,45)}),[dt.bigObjects]:J.num(30,35),[dt.fractures]:J.num(35,37)}),renderLightChance:n({[dt.filledFractured]:7,[dt.sparseFractured]:J.int(0,10),[dt.centralNatural]:J.int(0,1),[dt.sparseBlockyFracture]:J.int(5,9),[dt.smoothObjects]:J.int(0,1),[dt.islands]:J.int(0,20),default:0}),maxPointUse:1,maxDivergence:2,pointsToConsider:10},Ue=be({...Ue,layers:n({default:2}),layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:n({[dt.islands]:Ce.scene,[dt.fractures]:Ce.border,default:Ce.none}),forceYUp:a==bt.grid||J.bool(30),clampVertsToGrid:!1,...n({[dt.sparseBlockyFracture]:{maxDist:230,minDist:150},[dt.centralNatural]:{maxDist:J.num(105,190),minDist:J.num(70,100)},[dt.filledFractured]:{maxDist:J.num(140,180),minDist:95},[dt.sparseFractured]:{maxDist:J.num(140,180),minDist:103},[dt.smoothObjects]:{minDist:170,maxDist:262},[dt.islands]:J.choice([{minDist:85,maxDist:150},{minDist:125,maxDist:260}]),[dt.bigObjects]:{minDist:176,maxDist:271},[dt.fractures]:{minDist:243,maxDist:216}}),bnFreq:n({[dt.sparseBlockyFracture]:J.int(280,320),[dt.filledFractured]:J.int(200,210),[dt.sparseFractured]:J.int(180,190),[dt.centralNatural]:J.int(500,600),[dt.smoothObjects]:J.int(200,230),[dt.islands]:J.int(150,170),[dt.bigObjects]:J.int(470,480),[dt.fractures]:J.int(220,221)}),fieldFreq:n({[dt.sparseBlockyFracture]:J.int(1350,1450),[dt.filledFractured]:J.int(6e3,6100),[dt.sparseFractured]:J.int(6500,7500),[dt.centralNatural]:J.int(1e3,1200),[dt.smoothObjects]:J.int(1e3,1200),[dt.islands]:J.int(6e3,7500),[dt.bigObjects]:J.int(1500,1600),[dt.fractures]:J.int(4700,4800)}),clampRotationTo:n({[dt.sparseBlockyFracture]:11.25,[dt.bigObjects]:22.5,default:1}),minSizeMult:n({[dt.smoothObjects]:J.num(.6,.8),[dt.islands]:J.num(.6,.8),default:.75}),maxSizeMult:n({[dt.smoothObjects]:J.num(.9,1.1),[dt.islands]:J.num(1,1.1),default:1}),maxSides:5,minSides:3,perspective:2e4},s.meta?.objectProps||{});let d={edgeSharpness:{min:.8,max:1},fillChance:100,insetChance:n({[dt.sparseBlockyFracture]:0,[dt.filledFractured]:0,[dt.centralNatural]:0,[dt.sparseFractured]:J.int(3,20),[dt.smoothObjects]:J.int(0,10),[dt.islands]:J.int(0,10),default:J.choice([8,5,0])}),wobbleFreq:{min:40,max:80},wobbleAmplitude:{min:1,max:3},accumulationStrength:{min:1,max:1},materialHardness:i({[ht.light]:{min:.9,max:.97},default:{min:.93,max:.99}}),linePressure:{min:.65,max:.7},minDistanceMult:l({default:J.choice([{min:.7,max:.8}])}),lineTapering:{fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}},scale:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}}},layerCountChances:n({[dt.sparseBlockyFracture]:J.choice([[[1,4],[1,6]],[[1,6]]]),[dt.filledFractured]:J.choice([[[1,4],[1,6]],[[1,6]]]),[dt.sparseFractured]:J.choice([[[1,4],[1,6]],[[1,6]]]),[dt.smoothObjects]:J.choice([[[1,4],[1,6]],[[1,6]]]),[dt.centralNatural]:[[1,6]],[dt.islands]:[[1,6]],[dt.bigObjects]:J.choice([[[1,4]],[[1,6]],[[1,4],[1,6]]]),[dt.fractures]:J.choice([[[1,4]],[[1,6]],[[1,4],[1,6]]]),default:[[1,6]]}),lineWeight:l({[ut.sm]:{min:1.4,max:1.5},default:{min:1.4,max:1.5}}),layerOverride:[{fadeAtLineSegmentChance:0,lineTapering:{fade:{out:{enabledChance:l({[ut.sm]:50,[ut.md]:J.int(0,20),[ut.lg]:J.int(0,20),default:0}),min:1,max:2}}},wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:50,max:70},styleChances:[[1,"bnnoise"]],colorMap:"none"===et.mutation&&J.bool(rt?0:10)?[[[100,J.choice([Ke.offsetDown,Ke.offsetUp])],[J.weightedChoice([2,0],[1,J.int(0,15)]),Ke.color]]]:[[[100,Ke.color],[J.weightedChoice([2,0],[1,J.int(0,15)]),Ke.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,Ke.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:40,max:100}},J.weightedChoice([0,{scribbleChance:100,scribbleStrength:{min:.2,max:.4},colorMap:[[[1,Ke.offset]]],styleChances:[[1,"bnnoise"]],linePressure:{min:.9,max:.95},lineTapering:{scale:{out:{enabledChance:100,min:0,max:.2},in:{enabledChance:100,min:0,max:.2}}}}],[2,{scribbleChance:0,colorMap:[[[1,Ke.offsetUp]]],wobbleAmplitude:{min:1,max:1},styleChances:[[1,"bnnoise"]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:.6,max:1},fadeAtLineSegmentStrengthMult:{min:1,max:1.1},linePressure:{min:1.2,max:1.25},materialHardness:{min:.9,max:.95},lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:100,min:3,max:8}}}}]),{styleChances:[[1,"directional"],[1,"bnnoise"]],colorMap:[[[1,Ke.previous]]],wobbleAmplitude:{min:4,max:8},wobbleFreq:{min:40,max:60}},{colorMap:[[[1,Ke.brightnessBasedShadowOrHighlight]]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:1.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},materialHardness:{min:.7,max:.8},linePressure:{min:1.3,max:1.4},minDistanceMult:{min:.5,max:.6},wobbleAmplitude:{min:1,max:2},wobbleFreq:{min:50,max:100},styleChances:[[1,"bnnoise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"],[0,"edgefill"]],lineTapering:{fade:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:100,min:2,max:4}}}},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,Ke.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:80,max:200}}]};je=be(je,{ignoreLightingChance:0,wobbleAmplitude:{min:2,max:2},wobbleFreq:{min:35,max:45},materialHardness:{min:.8,max:.85},linePressure:{min:.7,max:.9},minDistanceMult:i({[ht.sparse]:{min:2.7,max:3.8},default:{min:1.4,max:1.5}}),spatialOverride:{[we.notInCurveOrObject]:{fillChance:100,colorMap:[[[1,Ke.offset]]],colorPalette:"fg",ignoreLightingChance:100,insetChance:100,scribbleChance:0,insetDistance:{min:10,max:20},minDistanceMult:{min:2.5,max:5},linePressure:{min:.8,max:.9},lineWeight:{min:.8,max:1.6},fadeAtLineSegmentChance:0},[we.nonDominant]:i({[ht.light]:be(d,{colorPalette:"bg",fillChance:100,layerCountChances:[[1,2]],minDistanceMult:{min:1,max:1.3},lineWeight:{min:1.1,max:1.2},layerOverride:[be(d.layerOverride[0],{colorPalette:"bg",colorMap:[[[1,Ke.color]]],linePressure:{min:.15,max:.2},styleChances:[[1,"bnnoise"]]}),be(d.layerOverride[1],{linePressure:{min:.5,max:.6},colorMap:[[[1,Ke.previous]]],styleChances:[[1,"edgefill"]]})]}),[ht.detailOnly]:{fillChance:0},default:d}),[we.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:{0:{styleChances:[[1,"bnnoise"]],colorMap:[[[1,Ke.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},1:{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,Ke.brightnessBasedShadowOrHighlight]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}}},[n({default:c?we.inCurveOrObject:we.dominant})]:be(d,{fillChance:100,insetDistance:{min:6,max:12}})}}),Qe=be(Qe,{insetChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,fillChance:0,layerCountChances:[[1,2],[1,1]],colorMap:i({[ht.detailOnly]:[[[1,Ke.color]],[[1,Ke.previous]]],default:[[[1,Ke.line]]]}),lineTapering:{fade:{out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.9,max:.95},materialHardness:{min:.9,max:.95},lineWeight:{min:.6,max:1.5},minDistanceMult:{min:3,max:5},spatialOverride:{[we.nonDominant]:{scribbleChance:0,lineWeight:{min:1,max:1.5},colorMap:[J.choice([[[100,Ke.line]]])],colorPalette:J.choice(["bg","fg"]),insetChance:100,insetDistance:{min:7,max:12},fillChance:i({[ht.detailOnly]:100,default:0}),linePressure:i({[ht.light]:{min:.5,max:.6},default:{min:.5,max:.6}}),minDistanceMult:l({[ut.sm]:{min:5,max:7},default:{min:4,max:6}}),styleChances:J.weightedChoice([1,[[1,"directional"]]],[1,[[1,"bnnoise"]]],[1,[[2,"bnnoise"],[2,"directional"],[0,"wobbles"],[0,"bluenoise"]]],[2,[[1,"bluenoise"]]])},[we.dominant]:{ignoreLightingChance:100,fillChance:l({[ut.sm]:i({[ht.detailOnly]:J.int(30,40),default:J.int(40,60)}),default:J.weightedChoice([1,30],[1,J.num(40,70)])}),layerCountChances:[[2,2],[1,1]],linePressure:{min:.7,max:.9},styleChances:[[5,"bnnoise"],[5,"directional"],[1,"wobbles"],[4,"bluenoise"]],materialHardness:{min:.8,max:.9},colorMap:[[[100,Ke.randomAccent]],[[100,Ke.previous]]],minDistanceMult:{min:6,max:15},lineWeight:l({[ut.lg]:{min:1,max:1.25},default:{min:1,max:1.25}})}}}),Ne=be(Ne,{count:10,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let u=n({[dt.sparseBlockyFracture]:J.int(70,80),[dt.filledFractured]:J.int(80,90),[dt.sparseFractured]:J.int(80,89),[dt.centralNatural]:J.int(70,80),[dt.smoothObjects]:J.int(90,99.9),[dt.islands]:J.int(65,70),[dt.bigObjects]:J.int(90,99.9),[dt.fractures]:J.int(95,99)}),h=J.num(.75,1);Oe=be(Oe,{meshInsetMuliplier:0,lineFilter:u<80?"none":n({[dt.filledFractured]:"none",[dt.sparseFractured]:"none",[dt.centralNatural]:"none",default:J.weightedChoice([0,"curves"],[0,"straight"],[3,"none"])}),meshDensity:u,skipLongest:l({[ut.lg]:J.int(0,10),default:0}),percentage:n({[dt.sparseBlockyFracture]:J.int(50,70),[dt.filledFractured]:J.int(50,80),[dt.sparseFractured]:J.int(50,80),[dt.centralNatural]:J.int(70,85),[dt.smoothObjects]:J.int(60,80),[dt.islands]:J.int(60,75),[dt.bigObjects]:J.int(50,70),[dt.fractures]:J.choice([0,J.int(60,75)])}),cropToDominantShape:!1,colors:r({[pt.color]:!0,default:!1}),backgroundColor:r({[pt.light]:!(xt!==ht.filled&&u<80),default:!1}),materialHardness:{min:.9,max:.96},linePressure:{min:.9,max:.95},thickness:l({[ut.lg]:{min:2.85*h,max:3*h},[ut.md]:{min:2.25*h,max:3.65*h},default:{min:2.25*h,max:4.25*h}})});let m=J.weightedChoice([3,J.int(0,1)],[1,J.int(2,10)]),p=n({[dt.fractures]:3,default:4});Ae=be(Ae,{margin:p*Be.scale,HVariance:{min:-m,max:m,threshold:1,mean:1,stdDev:1},VVariance:{min:-m,max:m,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),tt={...tt,cropToMargin:!1,margin:6*Be.scale}},Wt=()=>{ot="Sparse",ct(20,20);let e=gt(0,J.weightedChoice([1,ut.sm],[1,ut.md],[1,ut.lg]));J.weightedChoice([1,mt.heavy]);let t=J.weightedChoice([e({[ut.sm]:1,default:1}),bt.objects],[e({[ut.sm]:0,default:2}),bt.curves],[e({[ut.sm]:0,default:1}),bt.angles],[e({[ut.sm]:0,default:1}),bt.grid]),n=ft()[t];n.splits[Se.circle]=3,Ee=be(Ee,n.splits),De=be(De,n.meta.forceSplit),nt=be(nt,{noiseOverfittingSpread:e({[ut.sm]:J.num(0,1),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:J.num(.5,1.5)}),st=e({default:n.meta?.usedLineReplayChance||4}),it=J.int(200,800),at=.1;let l=J.weightedChoice([1,!1],[1,!0]);et={...et,mutation:J.weightedChoice([0,"offsetUp"],[0,"offsetDown"],[3,"none"]),useNoiseLookup:!0,samplesForComplimentary:J.int(1,2),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:e({default:l?J.num(600,1e3):J.num(100,200)}),usePolyIDColorOffset:l,maxAccents:e({default:J.weightedChoice([0,4],[1,6],[2,100])}),darksOnly:!1};let i=gt(0,J.weightedChoice([e({[ut.lg]:1,default:1}),pt.dark]));lt={...lt,count:0},_e=[Se.horizontal,Se.vertical],Ie={...Ie,default:1,clamp:.05,min:.9,max:1.1,influencesBrightnessMult:1,influencesMinDistanceMult:0,influencesPressureMult:0},qe={...qe,maxWidth:.75*e({[ut.sm]:J.int(40,50),[ut.md]:J.int(40,50),default:J.num(35,45)}),renderLightChance:100,maxPointUse:J.int(1,2),maxDivergence:J.int(2,4),pointsToConsider:10};let a=J.num(.75,1.5);Ue=be({...Ue,layers:2,layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:e({default:J.choice([Ce.none])}),forceYUp:!0,...e({[ut.sm]:{maxDist:200*a,minDist:130*a},[ut.md]:{maxDist:150*a,minDist:100*a},[ut.lg]:J.weightedChoice([5,{maxDist:150*a,minDist:100*a}])}),bnFreq:J.num(10,1e3),fieldFreq:e({[ut.lg]:J.int(4e3,1e4),[ut.sm]:J.int(1e3,2e3),default:J.choice([J.int(1e3,4e3),J.int(4e3,1e4)])}),clampRotationTo:J.weightedChoice([1,22.5],[4,1],[1,11.25]),minSizeMult:1,maxSizeMult:e({default:.75}),maxSides:5,minSides:3,perspective:2e4},n.meta?.objectProps||{}),Je=be(Je,{});let s={edgeSharpness:{min:0,max:0},fillChance:90,insetChance:10,wobbleFreq:{min:30,max:60},wobbleAmplitude:{min:3,max:8},accumulationStrength:{min:10,max:10},materialHardness:{min:.4,max:.45},linePressure:{min:1.3,max:1.3},lineWeight:it<300?{min:1.9,max:2}:{min:1.6,max:1.7},minDistanceMult:{min:.45,max:.5},lineTapering:{scale:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:0,min:1.5,max:2}},fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:100,min:3,max:8}}},layerCountChances:[[1,3]],layerOverride:[{fadeAtLineSegmentChance:0,scribbleChance:10,scribbleStrength:{min:.2,max:.4},styleChances:[[1,"bnnoise"],[1,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:"none"===et.mutation&&J.bool(50)?[[[100,Ke.offsetUp],[1,Ke.color]]]:[[[100,Ke.color],[1,Ke.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[2,"bnnoise"],[2,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:[[[100,Ke.previous]]]},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,Ke.brightnessBasedShadowOrHighlight]]]}]};je=be(je,{ignoreLightingChance:0,spatialOverride:{[we.nonDominant]:s,[we.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:[{styleChances:[[1,"bnnoise"]],colorMap:[[[1,Ke.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},{fadeAtLineSegmentChance:0,styleChances:[[1,"bnnoise"]],colorMap:[[[1,Ke.lightest],[1,Ke.darkest]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}]},[we.dominant]:be(s,{fillChance:100,lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:50,min:6,max:8}}},insetChance:20,insetDistance:{min:6,max:12}})}}),Qe=be(Qe,{insetChance:50,fillChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,layerCountChances:[[1,2],[1,1]],colorMap:[[[1,Ke.line]]],lineTapering:{fade:{out:{enabledChance:50,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.8,max:1},materialHardness:{min:.65,max:.82},lineWeight:{min:1.25,max:1.5},ignoreLightingChance:100,styleChances:[[6,"bnnoise"],[6,"directional"],[1,"wobbles"],[1,"bluenoise"]],minDistanceMult:{min:4,max:8}}),Ne=be(Ne,{count:0,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let o=e({[ut.sm]:J.int(95,100),[ut.lg]:J.int(65,90),default:J.int(70,100)});Oe=be(Oe,{meshInsetMuliplier:0,lineFilter:"none",meshDensity:o,skipLongest:0,percentage:100,cropToDominantShape:!1,colors:i({default:!1}),backgroundColor:i({default:!1}),linePressure:{min:1.1,max:1.4},materialHardness:{min:.75,max:.82},lineTapering:{fade:{in:{enabledChance:0,min:0,max:1},out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.1,max:.5},out:{enabledChance:100,min:.1,max:.5}}},thickness:e({default:it<600?{min:2,max:2.5}:{min:1.5,max:2}})});let r=J.weightedChoice([1,J.int(0,1)],[1,J.int(2,10)]),c=e({[ut.s
import*as e from"three";const{floor:t,ceil:n,sin:l,cos:i,pow:a,abs:s,min:o,max:r,round:c,sqrt:d,acos:u,sign:h,log:m,random:p,PI:b}=Math,g=1e-7;function f(e,n=g){return t(e+n)}function x(e,t=g){return n(e-t)}function Z(e,t=g){const n=t*h(e);return c(e+n)}let y,G,W="#fff";const v=e=>{e.showUpdate?(!G&&(()=>{y=document.createElement("div"),y.id="loading";const e=y.style;e.position="absolute",e.fontSize="1vmax",e.top=e.left="0",e.width="100%",e.height="100%",e.zIndex="1000",G=document.createElement("div");const t=G.style;t.textTransform="uppercase",t.position="fixed",t.lineHeight="0",t.top=t.left="0",t.width="100vw",t.height="100vh",t.height="fill-available",t.display="flex",t.justifyContent=t.alignItems="center",t.flexDirection="column",t.color=W,t.fontFamily="system-ui",t.fontWeight="500",y.appendChild(G),document.body.appendChild(y)})(),G.innerHTML=(e=>{const{message:t="",value:n=0,isPercent:l=!1}=e;let i=`<p>${t}</p>`,a="";return a=l?`<div style="max-width: 15vmin; margin-top: 1.25em; width: 100%; border: .5px solid ${W}"><div style="width: ${e.value||0}%; height: .75vmin; background-color: ${W}; overflow: hidden;"></div>`:`<p style="margin-top: 1.5em">${n}</p>`,""+(i+a)})(e)):G&&L()},L=()=>{let e=document.getElementById("loading");e&&document.body.removeChild(e),G=null};let S,X,C,V,K,w,k=()=>{S.style.display="none"},R=()=>{S.style.display="block"};const T=performance.now.bind(performance);let M,z,Y,P,F=null,H=()=>{M.style.display="none"},I=2200,N=.72;const U=r(window.devicePixelRatio,2);let D,O,B,Q,j,J,A,E=0;class _{useA;prngA;prngB;hash;constructor(e){this.useA=!1,this.hash=e;const t=globalThis.parseInt;let n=function(e){let n=t(e.substring(0,8),16),l=t(e.substring(8,16),16),i=t(e.substring(16,24),16),a=t(e.substring(24,32),16);return function(){n|=0,l|=0,i|=0,a|=0;let e=(n+l|0)+a|0;return a=a+1|0,n=l^l>>>9,l=i+(i<<3)|0,i=i<<21|i>>>11,i=i+e|0,(e>>>0)/4294967296}};this.prngA=n(this.hash.substring(2,34)),this.prngB=n(this.hash.substring(34,66))}dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}num(e,t){return e+(t-e)*this.dec()}int(e,n){return t(this.num(e,n+1))}bool(e=50){return this.dec()<e/100}choice(e){return e[this.int(0,e.length-1)]}easedDec(e){return e(this.dec())}easedInt(e,n,l){return t(this.easedNum(e,n,l))}easedNum(e,t,n){return t+(n-t)*this.easedDec(e)}weightedChoice(...e){const t=e.reduce(((e,[t])=>e+t),0);let n=this.dec()*t;for(const[t,l]of e)if((n-=t)<0)return l;return e[e.length-1][1]}gaussian(e=0,t=1){let n=0,l=0;for(;0===n;)n=this.dec();for(;0===l;)l=this.dec();return d(-2*m(n))*i(2*b*l)*t+e}gaussianBool(e=0,t=0,n=1){return this.gaussian(t,n)>=e}}function q(e=J){let t="0x";for(let n=0;n<64;n++)t+=Math.floor(16*e.dec()).toString(16);return t}function $(){let e="0x";for(var n=0;n<64;n++)e+=t(16*p()).toString(16);return new URLSearchParams(globalThis.location.search).get("hash")||("undefined"!=typeof tokenData&&tokenData?.hash?tokenData.hash:e)}A=$();let ee="\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec2 mod289(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec3 permute(vec3 x) {\n return mod289(((x * 34.0) + 10.0) * x);\n }\n\n // Noise\n float snoise2D(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289(i);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));\n\n vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);\n m = m * m;\n m = m * m;\n\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n\n m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n }\n\n float fbm(const vec2 v, const int octaves, float frequency, float amplitude) {\n float total = 0.0;\n float maxAmplitude = 0.0;\n for(int i = 0; i < octaves; i++) {\n total += snoise2D(v * frequency) * amplitude;\n maxAmplitude += amplitude;\n frequency *= 2.0;\n amplitude *= 0.5;\n }\n return total / maxAmplitude;\n }\n\n",te="\n float screenEdgeDist(vec2 uv, const float falloff) {\n vec2 normalizedCoords = gl_FragCoord.xy / resolution;\n\n // Calculate distances to the nearest edges\n float distanceToLeftEdge = normalizedCoords.x;\n float distanceToRightEdge = 1.0 - normalizedCoords.x;\n float distanceToBottomEdge = normalizedCoords.y;\n float distanceToTopEdge = 1.0 - normalizedCoords.y;\n\n // Find the minimum distance to any edge\n float minDistanceToEdge = min(min(distanceToLeftEdge, distanceToRightEdge), min(distanceToBottomEdge, distanceToTopEdge));\n\n float scaledDistance = 1.0 - abs(2.0 * minDistanceToEdge - 1.0);\n\n // Apply customizable falloff\n float falloffEffect = pow(scaledDistance, falloff);\n\n return falloffEffect;\n }\n",ne="\n float randomNonDet(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n",le="\n out vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n";const ie=e.Vector2;let ae=!1,se={countX:1,countY:1,index:{x:0,y:0}},oe=(e=!1)=>{let t=e?P:j,l=n((e?Y:Q)/se.countX),i=n(t/se.countY);return{width:l,height:i,xOff:se.index.x*l,yOff:se.index.y*i,yOffFlippedY:(se.countY-1-se.index.y)*i}},re=t=>{let n=t.uniforms,{width:l,height:i,xOff:a,yOffFlippedY:s}=oe();n.uTileOffset.value=new e.Vector2(a,s),n.uTileSize.value=new e.Vector2(l,i)},ce=()=>(!ae&&(()=>{ae=!0;let e=new URL(window.location.href),t=e.searchParams.get("tileCount"),n=e.searchParams.get("index");if(t){let e=parseInt(t);se.countX=e,se.countY=e}if(n){let[e,t]=n.split(",").map((e=>parseInt(e)));se.index.x=o(e,se.countX-1),se.index.y=o(t,se.countY-1)}})(),{uTileOffset:{value:new e.Vector2(0,0)},uTileSize:{value:new e.Vector2(Q,j)}});var de=[{name:"Faces",bg:[[.7409,.0057,69.9871]],line:[[.12,0,68]],base:[[.7995,.0104,53.9144]],accent:[[.55,.092,133],[.37,.1,8],[.47,.124,28],[.7,.112,90],[.48,.088,247],[.59,.048,197],[.78,.012,56.581],[.12,0,68],[.52,.12,342],[.71,.068,44],[.44,.04,299],[.21,.004,329],[.7883,.0264,44]],commonPool:!0,solo:!1},{name:"Chalks",bg:[[.6919,.0323,69.9871]],line:[[.1285578041548887,4.7918630361524376e-9,null]],stroke:[[.9104718532196331,.02929501882422003,89.58052190776175]],base:[[.7968,.033,55.4365]],accent:[[.4391005470961144,.053143667197297274,179.45284673806202],[.7430751481851373,.0929,39.83760570859084],[.7703,.0895,64.56344067218811],[.6641410434441858,.15689118437280108,37.13690468980104],[.7559,.0178,222.564179724743]],disabled:!1,commonPool:!0,solo:!1},{name:"Beach",bg:[[.6835,.03883960001602766,67.25848906440592]],stroke:[[.9372288972261885,.020696467664658196,67.57155893750883]],line:[[.23356138751632896,.02729114952576314,246.90070685897228]],base:[[.8371,.0215,57.0279]],accent:[[.2774185198607467,.04318925551193144,167.75274001919718],[.42064998654759594,.03120177133138129,171.32246538045877],[.4311384415174281,.02336516751567073,241.2330314983908],[.6176019379584577,.1270253885540799,74.1805651416355],[.7260022319511451,.09724578337934522,55.06470317899317],[.7582608113288266,.02549172589125699,166.85185191796654],[.8204,.023,61.9891]],commonPool:!0,solo:!1},{name:"Morning Sun In A Dusty Room",bg:[[.25615282357231434,.011591200093299888,338.1519820725431]],line:[[.14287287327771095,.004143654188326715,345.4391631242127],[.7742,.0276,98.479]],stroke:[[.9136637420289497,.02687443532425364,80.24542314462997]],base:[[.7783871111844314,.042589978975680454,25.529877185969667]],accent:[[.2152,.011591200093299888,338.1519820725431],[.4974379254425503,.08269393625659356,333.938678657093],[.6377751669772775,.16624575588870555,29.858240404234152],[.7303722440997971,.14878423535567212,65.78690162717032],[.525648519572251,.044624199378743616,227.89564437801943]],commonPool:!0,solo:!1},{name:"Jazz",stroke:[[.2866006793419412,.021957785534446477,88.03909075711272]],bg:[[.7399,.0328,69.58004864146267]],base:[[.8051,.0372,74.6117]],line:[[.1285578041548887,4.7918630361524376e-9,null]],accent:[[.6315375414148215,.1638,34.478822707810366],[.5221231161993111,.0802,231.97797627692054],[.7332,.1561,64.69716240181685],[.7786,.0269,54.0471]],disabled:!1,commonPool:!0,solo:!1},{name:"Beige Box",bg:[[.2169,.004109954650405697,264.48855986171543]],line:[[.1921,.004109954650405697,264.48855986171543],[.7094,.004109954650405697,264.48855986171543]],base:[[.7044,.0027,264.3],[.2582,0,264.15]],stroke:[[.6451555150878627,.1324103074498338,351.3679204443482]],accent:[[.2944,0,264.1525],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.7812,.1276,96.14554462682747],[.7098,.1359,63.701],[.6861,.007,63.701]],commonPool:!0,solo:!1},{name:"Master",bg:[[.6936,.0211,82.40092539697929]],line:[[.2507780863015607,.009572580032197206,67.3680640985574]],base:[[.7269,.0162,157.61886984444504]],stroke:[[.9060102804608031,.012170144621286422,23.7150415636807]],accent:[[.6295566765037485,.1211519827044528,67.32018448430034],[.7605,.0195,238.616994352628],[.6174604546514465,.05042117055871639,256.5164449583005],[.4181072443550769,.072,173.90831954879036],[.6627,.1667,37.60803793025025],[.8234,.0071,74.2545],[.7783,.073,8.0298]],commonPool:!0,solo:!1},{name:"New York Autumn",bg:[[.7037,.0281,65.28937708039064]],stroke:[[.8626142182586253,.08537649420452362,82.03909126824601]],line:[[.19548782481388519,.00430705323020645,264.468763979492]],base:[[.7661,.0329,58.25082050504636]],accent:[[.45478156079252346,.039285338382841796,179.22836606186138],[.7553531036330657,.08130837219892006,99.24794847558877],[.5594780208031984,.07916054354499198,245.43994841186026],[.42899728927916636,.04922887943462986,76.52219098535193],[.8309661998821414,.04281039028933322,48.183040275461394],[.7850648916204185,.1273241170717795,79.558262732039],[.8022,.1082,91.79312487991842],[.5727044802833001,.1271825150640351,18.826326398068147],[.5371544884294275,.13634924860871195,21.160585432853736]],commonPool:!0,solo:!1},{name:"The Coast",bg:[[.6974,.0085,76.58691599832048]],stroke:[[.8444869430616695,.08523591444134622,87.01376484878972]],line:[[.22755957415683586,.0015428045966122382,17.270340681712298]],base:[[.7669770002469423,.0030391208463875215,84.56153889362372]],accent:[[.3779357986919375,.0535,176.4086979076003],[.6184542058002529,.0765,130.0878133972343],[.8444869430616695,.0863,87.01376484878972],[.8204404719119529,.0562,13.36293462743373],[.6466292227896673,.1007,248.2503623167608],[.6163,.1335,21.160585432853736],[.7968000000000001,.01676,79.345]],commonPool:!0,solo:!1},{name:"Aged",bg:[[.7084,.0396,87.75614537114114]],stroke:[[.94095456060748,.015612821171329101,86.4264441546818]],line:[[.2703834919362128,.003498268640239951,48.59454667339406]],base:[[.7841,.021041287596747362,75.5028]],accent:[[.6599008372479219,.14410614712594896,43.767864491957255],[.5406041428443183,.0810794492722289,156.20612626175443],[.5030711080692698,.15264841257121137,26.608155858968416],[.7691417851736347,.1353050284474489,77.87710240074239],[.7874426063872318,.04659921665479499,51.68182155996902],[.467824859321765,.056096190272488924,217.56676918001241]],commonPool:!0,solo:!1},{name:"Ink & Colour",bg:[[.7601,.014,255.4795978283716]],stroke:[[.9553483843727791,.002877617626355211,84.55913178523588]],line:[[.23724829442832204,.009300030023333045,159.3038618360598]],base:[[.5326,.0294,169.58],[.5352,.1055,153.65],[.7482,.0675,265.537],[.5786,.1009,265.537]],accent:[[.3475,.065,169.58],[.4333,.08067410261737115,292.88016945552295],[.8007868908561364,.0333,7.942656494991638],[.6086666969575215,.1634,28.003190670134757],[.3195,.034575073883449464,254.02069392111645],[.6738,.1201,79.6718],[.8711,.00292,264.54],[.6613,.0632,169.58],[.5352,.1055,153.6549],[.6531,.1061,265.54]],disabled:!1,commonPool:!0,solo:!1},{name:"Oranges",bg:[[.705,.0354,65.1718]],stroke:[[.9912189562526743,.006931254927170287,88.6413010074412]],base:[[.7842,.0305,86.3684]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],accent:[[.35508002090426666,.043787467826530785,211.52484726500788],[.5510005837793092,.08755866639046411,103.27386758796968],[.691,.1582,47.266522185041936],[.7373,.1324,67.62887023877073],[.7999,.0316,88.72052641225343],[.7631,.0647,19.8072]],commonPool:!0,solo:!1},{name:"Henri",bg:[[.7213,.0319,80.6824944352112]],stroke:[[.7121124312829297,.09603422725607345,34.15613531599104]],line:[[.24303319779115856,.004923290798673418,355.16568727574077]],base:[[.8256,.0305,76.17859369988122]],accent:[[.4159,.0591,191.39940656052516],[.7920378039704564,.1352,73.45878915862028],[.7593,.0165,220.7288245953125],[.4637,.0738,237.7123227684075]],disabled:!1,commonPool:!0,solo:!1},{name:"Rand-ey",bg:[[.7426,.0171,87.52315695161104]],line:[[.19419793765469762,.0219,297.0814230776026]],stroke:[[.9076072420048279,.019870599528847212,87.51855970858247]],base:[[.595,.0433,247.9],[.7126,.0966,68.946],[.7791,0,64.059],[.5968,.1097,151.59]],accent:[[.575943267748716,.1486,29.4685],[.5129975835116938,.0741,305.527422000483],[.7538026010313094,.139,68.94572099685297],[.6147,.1332,247.9],[.8423,0,64.0592],[.53766,.1084,167.07]],disabled:!0,commonPool:!0,solo:!1},{name:"Olivetti",bg:[[.2222,.004109954650405697,264.48855986171543]],line:[[.234784254171478,.004109954650405697,264.48855986171543]],stroke:[[.7186588335782654,.1392507657144271,63.7012930132442]],base:[[.2551,0,34.30274488067005]],accent:[[.7186588335782654,.1392507657144271,63.7012930132442],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.8373623117765204,.15785248852128372,95.6270196002983],[.2582,.0037,275.8924],[.5803,.0037,275.8924]],disabled:!0,commonPool:!0,solo:!1},{name:"Toddler",bg:[[.7421,.0212,48.4352]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],stroke:[[.18797280274608968,.026745997001574016,159.25756384014687]],base:[[.6859848282821445,.008266766434931419,61.396302349703944],[.9349265127013049,.01153735356888476,84.57925253447382],[.7688,.0216,61.396302349703944]],accent:[[.3500879126177943,.0865,264.1433132212142],[.4453610930960556,.02928835497819446,336.8043193096847],[.569281111283594,.1860449489679648,25.02687693308303],[.5558543866168449,.054963958871380815,108.06205545681729],[.7052281079548163,.16337391917830385,43.93536507302679],[.8036,.1343,80.58696151433355],[.6763,.0745,108.06205545681729],[.7615,.0782,25.02687693308303]],disabled:!0,commonPool:!0,solo:!1}];let ue=(de.some((e=>e.solo))?de.filter((e=>e.solo)):de.filter((e=>!e.disabled))).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent}))),he=de.filter((e=>e.commonPool)).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent})));function me(e){return e*b/180}function pe(e){return function(e){return null!==e&&"object"==typeof e}(e)&&!Array.isArray(e)}function be(...e){const t={};for(const n of e)if(n)for(const e of Object.keys(n)){const l=n[e];if(Array.isArray(l))t[e]=[...l];else if(pe(l)){const n=t[e];pe(n)?t[e]=be(n,l):t[e]=be({},l)}else t[e]=l}return t}const ge=(e,t,n)=>(t-e)*n+e,fe=(e,t,n,l,i)=>ge(l,i,((e,t,n)=>(n-e)/(t-e))(t,n,e));function xe(e,t,n=g){if(0===t)return e;const l=n*Math.sign(e);return Math.round((e+l)/t)*t}function Ze(e,t,n){return o(r(e,t),n)}const ye=(e,t,n,l,i)=>Ze(fe(e,t,n,l,i),l,i),Ge=e=>e,We=e=>1-i(e*b/2),ve=e=>-(i(b*e)-1)/2,Le=e=>e<.5?(1-d(1-a(2*e,2)))/2:(d(1-a(-2*e+2,2))+1)/2;var Se,Xe,Ce;!function(e){e[e.horizontal=0]="horizontal",e[e.vertical=1]="vertical",e[e.perspective=2]="perspective",e[e.circle=3]="circle",e[e.wobbles=4]="wobbles",e[e.curves=5]="curves",e[e.rects=6]="rects",e[e.borderRect=7]="borderRect",e[e.triangle=8]="triangle",e[e.objects=9]="objects",e[e.used=10]="used"}(Se||(Se={})),function(e){e[e.front=0]="front",e[e.up=1]="up",e[e.right=2]="right",e[e.down=3]="down",e[e.left=4]="left"}(Xe||(Xe={})),function(e){e.border="border",e.scene="scene",e.none="none"}(Ce||(Ce={}));let Ve={layers:2,layerScaleMult:2.5,zDepthMaxMult:1,cropTo:Ce.none,forceYUp:!0,clampVertsToGrid:!1,maxDist:200,minDist:130,bnFreq:500,fieldFreq:1500,clampRotationTo:1,minSizeMult:1,maxSizeMult:.75,maxSides:5,minSides:3,perspective:2e4};var Ke,we;!function(e){e[e.color=0]="color",e[e.line=1]="line",e[e.palettecomplement=2]="palettecomplement",e[e.previous=3]="previous",e[e.base=4]="base",e[e.paletteOffset=5]="paletteOffset",e[e.shadow=6]="shadow",e[e.highlight=7]="highlight",e[e.randomAccent=8]="randomAccent",e[e.offset=9]="offset",e[e.offsetUp=10]="offsetUp",e[e.lightestOrDarkestBasedOnBg=11]="lightestOrDarkestBasedOnBg",e[e.brightnessBasedShadowOrHighlight=12]="brightnessBasedShadowOrHighlight",e[e.offsetDown=13]="offsetDown",e[e.darkest=14]="darkest",e[e.lightest=15]="lightest"}(Ke||(Ke={})),function(e){e.override="override",e.dominant="dominant",e.inCurveOrObject="inCurveOrObject",e.notInCurveOrObject="notInCurveOrObject",e.nonDominant="nonDominant",e.normalHigh="normalHigh",e.normalLow="normalLow",e.overlay="overlay",e.noop="noop"}(we||(we={}));let ke,Re,Te={scribbleChance:0,edgeSharpness:{min:.2,max:.2},scribbleStrength:{min:.5,max:.5},accumulationStrength:{min:1,max:1},materialHardness:{min:1,max:1},fillChance:100,fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},minDistanceMult:{min:5,max:5},linePressure:{min:.8,max:.9},brightnessHighLowThreshold:.75,fadeAtLineSegmentChance:0,detailMinScaleDivisor:30,ignoreLightingChance:0,colorMap:[[[1,Ke.color]],[[1,Ke.color]]],dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:.5,max:1},wobbleFreq:{min:.5,max:1},layerCountChances:[[0,0],[1,1],[2,2]],styleChances:[[3,"bnnoise"],[4,"directional"],[1,"wobbles"],[3,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},lineWeight:{min:1.1,max:1.1},spatialOverride:{[we.overlay]:{fillChance:0}}},Me={scribbleChance:0,edgeSharpness:{min:.5,max:.5},scribbleStrength:{min:.3,max:.3},fillChance:100,accumulationStrength:{min:1,max:1},fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},colorMap:[[[1,Ke.color]]],fadeAtLineSegmentChance:100,brightnessHighLowThreshold:.75,ignoreLightingChance:0,detailMinScaleDivisor:30,minDistanceMult:{min:.75,max:.75},dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:2,max:3},wobbleFreq:{min:20,max:40},layerCountChances:[[1,1]],styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},linePressure:{min:1,max:1},materialHardness:{min:1,max:1},lineWeight:{min:1.1,max:1.1},spatialOverride:{[we.overlay]:{fillChance:100,lineWeight:{min:2.5,max:2.5},fadeAtLineSegmentChance:0,insetChance:0,ignoreLightingChance:100,styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],minDistanceMult:{min:.75,max:.75},lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},layerCountChances:[[1,2]]}}},ze={[Se.horizontal]:0,[Se.vertical]:10,[Se.perspective]:0,[Se.circle]:10,[Se.wobbles]:0,[Se.objects]:8,[Se.curves]:10,[Se.rects]:5,[Se.borderRect]:10},Ye=[Se.horizontal,Se.vertical,Se.perspective],Pe={maxAccents:4,mutation:"none",dominantIsAccentChance:50,curveMap:ve,useNoiseLookup:!0,samplesForComplimentary:3,samplesForPaletteOffset:2,addBGContrast:!1,freqMultiplier:10,usePolyIDColorOffset:!0,singleAccent:!1,darksOnly:!1},Fe={count:1,outline:!0,colors:[[0,Ke.color],[0,Ke.offset],[0,Ke.base],[0,Ke.line],[0,Ke.darkest],[1,Ke.lightest]],colorOffsets:!1,size:{min:4,max:9}},He=[],Ie={default:1,min:.45,max:1.12,clamp:.001,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.3,position:{x:-10005.5,y:-1e4,z:-12e3}},Ne={colors:!1,isLineColor:!1,count:50,warpChance:100,lineTapering:{scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},length:{min:20,max:100},hardness:{min:1,max:1},thickness:{min:.5,max:5}},Ue=Ve,De={forceInsertCurvesChance:0,forceInsertObjectsChance:0},Oe={meshDensity:80,lineFilter:"none",meshInsetMuliplier:1,dominantLineInsetMultiplier:1,percentage:50,skipLongest:3,cropToDominantShape:!1,materialHardness:{min:.9,max:.95},colors:!1,backgroundColor:!1,lineTapering:{scale:{in:{enabledChance:100,min:.3,max:.6},out:{enabledChance:100,min:.3,max:.6}},fade:{in:{enabledChance:50,min:.1,max:.2},out:{enabledChance:50,min:.1,max:.2}}},linePressure:{min:.9,max:.95},thickness:{min:.5,max:3}},Be={countX:0,countY:0,marginX:0,marginY:0,w:0,h:0,scale:0},Qe=Te,je=Me,Je={enabled:!0,percentage:60,materialHardness:{min:.4,max:.4},lineTapering:{scale:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}},fade:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}}},linePressure:{min:.5,max:.5},lineWeight:{min:.6,max:.6}},Ae={margin:0,HVariance:{min:0,max:10,threshold:2,mean:1,stdDev:1},VVariance:{min:0,max:10,threshold:2,mean:1,stdDev:1},rects:{insetRectEnabled:!0,spiralRectsEnabled:!0},circles:{count:0,minRadius:2,maxRadius:30},wobble:{enabled:!1,count:1e10,layers:2,multiLayers:1,minLength:5,gridDivisions:1,warpFreq:{min:600,max:800},offsetMultiplier:1},perspectiveBox:{enabled:!0,threshold:2,mean:1,stdDev:1,count:1,firstFull:!0}},Ee=ze,_e=Ye,qe={layers:1,renderLightChance:0,ignoreLighting:!0,renderAccentChance:0,insetMult:2,maxWidth:80,spread:4,widthRange:.3,maxDivergen
nWarp:!1,lineTapering:Pi(a,J),lineWeight:J.num(i.min,i.max),lineColor:ve.line[0]}]};Wl.push(r)}],[function*(){const e={[sn.constructionLine]:0,[sn.background]:1,[sn.foreground]:2,[sn.detail]:3,[sn.walker]:3,[sn.overlay]:4,[sn.overlayOutline]:5};Wl.sort(((t,n)=>{if(e[t.category]<e[n.category])return-1;if(e[t.category]>e[n.category])return 1;let i=new nn;i.expands(t.polygon);let l=new nn;return l.expands(n.polygon),new zt(i.maxX,i.maxY).distanceTo(new zt(0,0))-new zt(l.maxX,l.maxY).distanceTo(new zt(0,0))}))}],[function*(){let e=new Map,n=0,i="◴ ◷ ◶ ◵".split(" "),l=function*(){let e=oe(!0),t=new nn;for(t.expands([new zt(e.xOff,e.yOff),new zt(e.xOff+e.width,e.yOff+e.height)]),t.expandByValue(10);Wl.length;){let e=Wl[0];if(e.readyForRender){if(e.detailObject?.length){let n=new nn;if(n.expands(e.polygon),t.intersects(n)){rn(e);for(let t=0;t<e.detailObject.length;t++)en(e.detailObject[t]);Xt.copyBufferToScreen(),yield{rendering:!0}}}let n=Wl.splice(0,1);an.push(...n)}else yield{rendering:!1}}Xt.copyBufferToScreen()}(),a=!1,s=[];for(let e=0;e<1e3;e++)s.push(E());let o=0;for(;!a;){if($l){yield{showUpdate:!0,message:"Rendering Paused",value:"press space to continue",isPercent:!1};continue}for(let t=0;t<Wl.length;t++){let i=Wl[t];if((i.category==sn.foreground||i.category==sn.detail||i.category==sn.overlay)&&!i.detailsProcessed){i.detailsProcessed=!0,e.set(n,!1);let t=n;Ii(i,s[o++%s.length]).then((()=>{e.set(t,!0)})),n++}}let r=l.next();a=r.done;let c=r.value?.rendering||!1,d=0;for(let e of Object.keys(wi))0==wi[e]&&(d+=1);let u=[...e.values()].reduce(((e,t)=>e+(t?0:1)),0);if(yield{showUpdate:!c&&(u>0||d>0||u>0),message:""+i[t(ll/4)%4],isPercent:!1,value:`${d>0?`Waiting on 1 of ${d} threads, `:"Waiting for"} ${u} jobs queued`},0==u&&0==Vi.length&&0==d&&a)break}yield{showUpdate:!1},Xt.copyBufferToScreen()},!0]],wl=new class{heap;constructor(e){this.heap=new Oi(1e10,e)}clear(){this.heap.clear()}topN(e){return this.heap.toArray().slice(0,e)}update(e){const t=new Set(this.heap.toArray());for(const n of e)t.has(n)?t.delete(n):this.heap.push(n);for(const e of t)this.heap.remove(e);return this.heap.toArray()}}((e=>{let{polyOverfitting:t,noiseOverfittingSpread:n,noiseOverfitFreq:i}=Qe,l=e.area;if(1!=t&&(l*=Xl.getPolygonsAtPoint(e.center.toArray()).length>0?1:t),n>0){let t=n/2;l*=Rt(mn(e.center.x,e.center.y,0,i,1-t,1+t),.001)}return Rt(l,.001)})),Kl=new Set;function Rl(e){let t={x:e.center[0],y:e.center[1],z:-100},n={width:e.width,height:e.height,depth:e.depth};return{faces:new Bi(t,e.rotationProps,n,e.sides,{x:e.perspectiveCenter[0],y:e.perspectiveCenter[1],z:-1e3},90,Y/P,.001,1e3,[{position:Ke.position,brightness:1},{position:{x:-Ke.position.x,y:-Ke.position.y,z:Ke.position.z},brightness:.95},{position:{x:0,y:Ke.position.y,z:-1e3},brightness:.2},{position:{x:0,y:-Ke.position.y,z:-1e3},brightness:.2}],!0).getFaces2D(),shapeArgs:e}}let kl,Tl=!1,Ml=(e,t,n,i=0)=>{let l=1e3*n,a=1e3*i;if(!Tl){let e=J.num(800,1600),t=Qe.noiseFieldCategoryInfluence;kl={[be.used]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.horizontal]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.vertical]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.perspective]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.circle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.wobbles]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.curves]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.rects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.borderRect]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.triangle]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)},[be.objects]:{freq:e,min:1,max:t,offset:J.int(-4e3,4e3)}},Tl=!0}let s=ei,o=ii(kl[e].freq,10,kl[e].offset,s),r=Tt(s(Rt(mn(t.x+kl[e].offset,t.y+kl[e].offset,kl[e].offset-a,kl[e].freq,0,1),.3)),o.min,o.max,kl[e].min,kl[e].max);return c(l*r)},zl=()=>[Ql,Ol,Bl,Al,jl,Jl,()=>!0],Yl=0,Pl=!1,Il=!1;function Hl(){I.save(),I.scale(U,U),Il||(I.fillStyle="#FFF",I.rect(0,0,Y,P),I.fill(),Il=!0)}function Fl(){I.restore()}function Nl(){Il=!1}function Ul(e,t="red",n=!0){if(e.length){Hl(),I.beginPath(),I.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)I.lineTo(e[t].x,e[t].y);I.closePath(),I.lineCap="round",n?(I.fillStyle=t,I.fill()):(I.lineWidth=3,I.strokeStyle=t,I.stroke()),Fl()}}function Dl(e,t="red",n=!1,i=1){Hl(),I.beginPath(),I.lineCap="round",I.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)I.lineTo(e[t].x,e[t].y);n&&I.closePath(),I.lineWidth=i,I.strokeStyle=t,I.stroke(),Fl()}function Ol(){Nl();for(let e of[...an,...Wl])if(e.category==sn.foreground){let t=e?.detailObjectProps?.inDominantShapes?.length>0;Ul(e.polygon,t?"blue":"red",!0),Ul(e.polygon,"black",!1)}return!1}function Bl(){Nl();for(let e of[...an,...Wl])if(e.category==sn.foreground){let t=jn(e.detailObject?.[0].lineColor||[0,0,0]);Ul(e.polygon,t,!0),Ul(e.polygon,"black",!1)}return!1}function Ql(){Nl();for(let e of[...an,...Wl])if(e.category==sn.foreground){let t=e.lightingIntensity||Ke.default,n=Kt(t,Ke.min,Ke.max,0,255);Ul(e.polygon,`rgba(${n},${n},${n},1)`,!0)}return!1}function Jl(){Nl();for(let e of[...an,...Wl])if(e.category==sn.foreground&&Ul(e.polygon,"black",!1),e?.detailObject?.length)for(let t of e.detailObject)for(let e of t.lines)Dl(e.map((e=>new zt(...e))),"black",!1,.5);return!1}function jl(){return Nl(),Zl&&Zl.getAllLines().forEach((e=>{Dl(e.line.map((e=>(new le).fromArray(e))),"black",e.meta.isClosed)})),!1}function Al(){return Nl(),xl&&xl.internalFaces().forEach(((e,t)=>{Ul(e.vertexlist,`rgba(${J.num(0,255)},${J.num(0,255)},${J.num(0,255)},0.9)`)})),!1}let El=!1;function _l(e){let{verts:t,parentSvg:n,strokeColor:i="black",strokeWidth:l=1,className:a="path",isClosed:s=!1}=e,o=`M ${t[0].x} ${t[0].y}`;for(let e=1;e<t.length;e++)o+=` L ${t[e].x} ${t[e].y}`;s&&(o+=" Z");const r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d",o),r.setAttribute("fill","none"),r.setAttribute("stroke",i),r.setAttribute("stroke-width",l.toString()),r.setAttribute("class",a),n.appendChild(r),r}let ql=()=>{let e=document.querySelector("svg");e?(El=!1,e.remove(),k()):(R(),e=(()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width",D+"px"),e.setAttribute("height",O+"px"),e.setAttribute("style","position: relative; background-color: white;"),e.setAttribute("viewBox",`0 0 ${Y} ${P}`),e.setAttribute("preserveAspectRatio","xMinYMin meet"),e.setAttribute("xmlns","http://www.w3.org/2000/svg");let t=[[new zt(0,5),new zt(0,0),new zt(5,0)],[new zt(0,P-5),new zt(0,P),new zt(5,P)],[new zt(Y-5,0),new zt(Y,0),new zt(Y,5)],[new zt(Y-5,P),new zt(Y,P),new zt(Y,P-5)]];for(let n=0;n<t.length;n++)_l({verts:t[n],parentSvg:e,strokeWidth:2,className:"marker",isClosed:!1,strokeColor:"rgb(1, 0, 0)"});for(let t of[...Wl,...an])if(t.category==sn.foreground){if(_l({verts:t.polygon,parentSvg:e,strokeWidth:2,className:"outline",isClosed:!0,strokeColor:t?.detailObjectProps?.inDominantShapes?.length>0?"rgb(0, 0, 0)":"rgb(1, 1, 1)"}),!t?.detailObject?.length)continue;for(let n of t?.detailObject)if("detail"===n.type)for(let t of n?.lines)_l({verts:t.map((e=>new zt(...e))),parentSvg:e,strokeWidth:1,className:"detail",strokeColor:"rgb(5, 5, 5)"})}else if(t.category==sn.walker){if(!t?.detailObject?.length)continue;for(let n of t.detailObject)for(let t of n.lines)_l({verts:t.map((e=>new zt(...e))),parentSvg:e,strokeWidth:4,className:"topline",isClosed:!1,strokeColor:"rgb(10, 10, 10)"})}else if(t.category==sn.overlay){let n=2;for(let i=0;i<n;i++)_l({verts:t.polygon,parentSvg:e,strokeWidth:2,className:"oerlay",isClosed:!0,strokeColor:"rgb(15, 15, 15)"})}return e})(),document.body.appendChild(e),El=!0)},$l=!1;const ea=()=>{zl()[Yl]()?(H(),k()):(R(),M.style.display="block"),Pl=!Pl,Yl=(Yl+1)%zl().length},ta=()=>{$l=!$l};var na;document.complete=!1,(()=>{new URL(window.location.href).searchParams.get("noFrame")&&(j=0);const{innerWidth:n,innerHeight:i}=window;S=document.createElement("canvas"),S.style.backgroundColor="#000",K=S.getContext("webgl2",{colorSpace:"display-p3",preserveDrawingBuffer:!0,stencil:!1,alpha:!1,premultipliedAlpha:!1}),X=new e.WebGLRenderer({canvas:S,context:K,preserveDrawingBuffer:!0,precision:"highp",alpha:!1,premultipliedAlpha:!1,antialias:!1,stencil:!1,depth:!0,powerPreference:"high-performance"}),w=!!K.getExtension("OES_texture_float_linear"),K.getParameter(K.MAX_UNIFORM_BLOCK_SIZE),X.setClearColor(new e.Color(1,1,1),1),C=X.capabilities.maxTextureSize,V=X.capabilities.getMaxAnisotropy(),X.shadowMap.enabled=!0,X.outputColorSpace=e.DisplayP3ColorSpace,X.shadowMap.type=e.PCFSoftShadowMap,document.body.appendChild(S),M=document.createElement("canvas"),M.style.backgroundColor="#000",z=M.style,I=M.getContext("2d",{alpha:!1,colorSpace:"display-p3"}),document.body.appendChild(M),H(),Y=t(1584),P=t(2200);let l=j/100*o(n,i);n<i*F?(O=t(1/F*(n-l)),D=t(n-l)):(O=t(i-l),D=t((i-l)*F)),X.setSize(D,O),X.setPixelRatio(N),B=D*N,Q=O*N,((e,t)=>{M.width=e,M.height=t,z.width=D+"px",z.height=O+"px"})(B,Q),U=B/Y})(),na=$(),J=new A(na||""),(()=>{let t=document.createElement("a");addEventListener("keydown",(n=>{if("s"===n.key&&El){let e=document.querySelector("svg");if(!e)return;let n=_+".svg";t.setAttribute("download",n);const i=new Blob([e.outerHTML],{type:"image/svg+xml"});t.href=URL.createObjectURL(i),t.click()}else if("s"===n.key){let e=_+".png";se.countX>1&&(e=`${_}-${se.index.x}-${se.index.y}.png`),t.setAttribute("download",e),S.toBlob((e=>{t.href=URL.createObjectURL(e),t.click()}))}"x"===n.key&&function(){v({showUpdate:!0,message:"Sending PNG Export",value:_});let t=new e.WebGLRenderTarget(B,Q,{anisotropy:V,colorSpace:e.DisplayP3ColorSpace,minFilter:e.LinearFilter,magFilter:e.LinearFilter,format:e.RGBAFormat,type:e.FloatType,internalFormat:"RGBA32F"});Lt(Xt.getReadBuffer().texture,t);const n=new Float32Array(B*Q*4);X.readRenderTargetPixels(t,0,0,B,Q,n);let i=""+_;if(se.countX>1&&(i=`${_}-tiled-${se.index.x}-${se.index.y}`),void 0!==window?.electronAPI?.sendPixelData){const e=Buffer.from(n.buffer);window?.electronAPI.sendPixelData({buffer:e,width:B,height:Q,filename:i})}else window.framebuffer=n;setTimeout((()=>{L()}),1e3)}(),"Space"===n.code&&ta(),"v"===n.key&&(Pl&&ea(),ql()),"d"===n.key&&(El&&ql(),ea())}))})(),document.metaData=(()=>{We=[J.num(-1,1),J.num(-1,1)];for(let e=0;e<1e3;e++)we.push(J.dec());ve=J.choice(ue),J.weightedChoice([3,rt],[1,ct],[1,dt])();let e={"Artist Curated":q.includes(_),"Input Hash":_};const t=[{name:"Name",value:_e},{name:"Meta",value:e},{name:"Divisions",value:je},{name:"Division Props",value:Qe},{name:"Line Removal",value:Ae},{name:"Division Chances",value:Object.fromEntries(Object.entries(Fe).map((([e,t])=>[be[Number(e)],t])))},{name:"lighting",value:Ke},{name:"color props",value:Oe},{name:"topLines",value:Re},{name:"dominantLines",value:Me},{name:"fillStyles",value:Pe},{name:"detailStyles",value:Ye},{name:"constructionLineProps",value:He},{name:"sceneObjects",value:ke},{name:"colorProps",value:Oe},{name:"curveProps",value:Ue},{name:"fillMargin",value:Be},{name:"grid",value:ze}];for(let e of t);return e})(),S.addEventListener("click",(e=>{let t=e.clientX,n=e.clientY,i=S.getBoundingClientRect();t-=i.left,n-=i.top;let l=new zt(t*N/U,n*N/U);for(let e of[...an,...Wl])e.category==sn.foreground&&Tn(e.polygon,l)})),sl();
});for(let i=e.x;i<t.x;i+=ze.scale/2)J.gaussianBool(He.VVariance.threshold,He.VVariance.mean,He.VVariance.stdDev)||l.push({id:Nn(),meta:{lineCategory:be.vertical},line:[[i+J.num(-ze.scale*s,ze.scale*s),e.y-ze.scale*n],[i+J.num(-ze.scale*s,ze.scale*s),t.y+ze.scale*n]]});vl.push(...i,...l)})(i,l),yl=function(e,t){let n;if(!He.perspectiveBox.enabled)return;let i=[e,new zt(t.x,e.y),t,new zt(e.x,t.y)].map((e=>e.toArray())),l=new Ln(i,[[0,1],[1,2],[2,3],[3,0]]);for(let e=0;e<He.perspectiveBox.count;e++){let e,t=l.internalFaces(),n=J.choice(t),i=n.aabb,a=J.bool(50),s=o(i.height,i.width)/4;if(a){let t=J.num(i.minX+s,i.maxX-s);e=[[t,i.minY],[t,i.maxY]]}else{let t=J.num(i.minY+s,i.maxY-s);e=[[i.minX,t],[i.maxX,t]]}l.splitFaceByPolyLine(n,e)}let a=l.internalFaces(),s=!1,r=!1,c=!1,d=He.perspectiveBox.firstFull;for(let e of a){if(-1==He.perspectiveBox.count)break;let t=e.aabb,i=t.width*J.num(.75,1.25),l=t.height*J.num(.75,1.25),a=!(!d||c)||J.bool(s?0:50),o=!(!d||c)||J.bool(r?0:50);a&&(r=!0),o&&(s=!0);let u=[a?Y/2:t.center.x,o?P/2:t.center.y];c||(n=u),c=!0,Fe[be.perspective]>1&&vl.push(...Un({gStdDev:He.perspectiveBox.threshold,gMean:He.perspectiveBox.mean,gThreshold:He.perspectiveBox.stdDev,boxCenter:u,perspectiveCenter:[t.center.x+J.int(-i/4,i/4),t.center.y+J.int(-l/4,l/4)],width:a?4*Y:i*J.num(.75,1.25),height:o?P:l*J.num(.75,1.25),centerBoxMaskDimensions:[J.int(1,i/ze.scale*.5),J.int(1,l/ze.scale*.5)]}).map((e=>({id:Nn(),line:e,meta:{lineCategory:be.perspective}}))))}return n}(i,l),function(){for(let e=0;e<He.circles.count;e++){let e=Rt(J.num(ze.scale*He.circles.minRadius,ze.scale*He.circles.maxRadius),ze.scale),t=e/2,n=[Y/2+J.num(-Y/2+t,Y/2-t),P/2+J.num(-P/2+t,P/2-t)],i=J.num(0,360),l=On({center:n,radius:e,startAngle:i,endAngle:i+J.int(25,360)});l.length>3&&vl.push({id:Nn(),line:l,meta:{lineCategory:be.circle}})}}(),function(){if(!He.rects.spiralRectsEnabled)return;let e=Pt(new zt(J.num(.4*Y,.6*Y),J.num(.4*P,.6*P))).toArray(),t=J.num(0,22.5)*J.choice([-1,1]),n=ze.scale*J.int(5,10),i=J.num(0,360),l=ze.scale*(2*J.int(1,8));for(;n<P;){let a=Dn({width:n,height:n,center:e,angle:i});vl.push({id:Nn(),line:a,meta:{lineCategory:be.rects,isClosed:!0}}),n+=l,i+=t}}(),function(){if(!He.rects.insetRectEnabled)return;let e=2*He.margin+ze.scale*(2*J.int(1,4)),t=Pt(new zt(J.num(Y/2,Y/2),J.num(P/2,P/2))).toArray(),n=Dn({width:Y-e,height:P-e,center:t,angle:J.num(-1,1)});vl.push({id:Nn(),line:n,meta:{lineCategory:be.borderRect,isClosed:!0}})}();let a=function(){let e=J.num(He.wobble.warpFreq.min,He.wobble.warpFreq.max),t=[];for(let n=0;n<He.wobble.layers;n++){let i=me(180/He.wobble.layers*n);for(let n=0;n<He.wobble.multiLayers;n++){let l=n*He.wobble.offsetMultiplier,a={warpStrength:e,rotationAngleAddition:i,wobbleOffset:l};ki.push(a);let s=new nn;s.expands([new zt(-Y/4,-P/4),new zt(Y+Y/4,P+P/4)]);let o=s.vertexList.map((e=>e.toArray())),r=Rt(ze.scale/He.wobble.gridDivisions,.1),c=Ri({streamlineWorkerProps:{vectorFieldType:"bnnoise",addOutline:!1,vectorFieldNoiseProps:{warpStrength:Rt(e,.01),rotationAngleAddition:Rt(i+J.num(-.1,.1),.01),wobbleOffset:l,wobbleDetail:J.int(0,1)},postProcessingArgs:{directional:!1,wobbleFreq:.5,wobbleAmplitude:.5},maxStreamlines:He.wobble.count,minLength:Rt(ze.scale*He.wobble.minLength,.1),maxLength:Rt(3*P,.1),stepSize:r/4,minDistance:r,bounds:{topLeft:o[0],bottomRight:o[2]},boundingGeometry:o},noiseSeed:un,randomSeed:E(J)});t.push(c)}}return t}(),s=new Map,r=0,c="◴ ◷ ◶ ◵".split(" "),d=Array(a.length);for(let e=0;e<a.length;e++){let t=a[e];s.set(r,!1);let n=r;t.then((t=>{d[e]=t,s.set(n,!0)})),r++}for(;;){let e=[...s.values()].reduce(((e,t)=>e+(t?0:1)),0);if(yield{showUpdate:e>0,message:""+c[t(ll/4)%4],isPercent:!1,value:`${e>0?"Pausing for":"Waiting for"} ${e} tasks`},0==e)break}for(let e=0;e<d.length;e++){let t=d[e];if(Fe[be.wobbles]>0)for(let n of t)vl.push({line:n,id:Nn(),meta:{lineCategory:be.wobbles,lineSubCategory:e}})}}],[function*(){let e=He.margin+ze.marginX,t=He.margin+ze.marginY,n=new le(e,t),i=new le(Y-e,P-t);Zl=new Jn(ze.scale/2,vl),Gl=[n,new zt(i.x,n.y),i,new zt(n.x,i.y)].map((e=>e.toArray())),fl=new Ln(Gl,[[0,1],[1,2],[2,3],[3,0]])}],[function*(){let{maxWidth:e,widthRange:t,spread:n,maxDivergence:i,tension:l,maxPointUse:a,layers:s,maxLinePoints:o,pointsToConsider:r,insetMult:c}=Ue,d=Zl.getAllLines().filter((e=>e.meta.lineCategory==be.objects&&e.meta.isClosed&&J.bool(50))).map((e=>Yn(e.line.map((e=>new zt(...e))))));for(let u=0;u<s;u++){let s=function(t,i){return mn(t,i,0,400,e,e*n)},u=He.margin+e*c,h=He.margin+e*c,m=new ul({maxDist:e*n,bounds:{topLeft:It(new zt(u,h)).toArray(),bottomRight:It(new zt(Y-u,P-h)).toArray()},noiseField:s,seedPoints:d}),p=m.generate();for(let e of p)yield;let g,b=m.kTree,f=[],x=new Set,Z=new Map,y=e=>{x.add(g);let t=Z.get(e)||0;Z.set(e,t+1),Z.get(e)>=a&&b.remove(e)};for(;!(b.count<=0);){if(!g){let e={point:new zt(J.num(0,Y),J.num(0,P)),minDist:1/0};g=b.findNearest(e),y(g)}let e=J.choice(b.findKNearest(g,r).filter((e=>!x.has(e)&&e.point.distanceTo(g.point)<g.minDist*i)));!e||x.size>=o||b.count<=0?(f.push([...x].map((e=>e.point))),x=new Set,g=null):(g=e,y(g))}let G=[];for(let e of f){if(e.length<3)continue;let t=bl(gl(e,{tension:J.num(l.min,l.max),cyclic:!1}),6,!1).map((e=>new zt(e.x,e.y)));G.push(t)}for(let n of G){if(n.length<3)continue;let i=cl(n.map((e=>e.toArray())),J.int(e*(1-t),e*(1+t)),120);vl.push({line:i,id:Nn(),meta:{lineCategory:be.curves,isClosed:!0}}),Zl.addLine(i,{lineCategory:be.curves,isClosed:!0})}}}],[function*(){for(let e=0;e<ke.layers;e++){let{maxDist:t,minDist:n,bnFreq:i,minSizeMult:l,maxSizeMult:a,fieldFreq:s,maxSides:o,minSides:r,clampVertsToGrid:c,clampRotationTo:d,layerScaleMult:u,perspective:h}=ke,m=0==e?1:e*u,p=ke.cropTo==xe.border?Gl:ke.cropTo==xe.scene?[[0,0],[Y,P]]:null,g=null;null!==p&&(g=new nn,g.expandsByPoint(p));let b=function(e,l){return mn(e,l,0,i,n*m,t*m)},f=new ul({maxDist:t*m,bounds:{topLeft:Gl[0],bottomRight:Gl[2]},noiseField:b}).generate(),x=J.num(150,300)*J.choice([-1,1]),Z=40;for(let t of f){let n=ke.forceYUp?0:mn(t.point.x,t.point.y,1e3,s,-40,Z),i=mn(t.point.x+1e3,t.point.y+1e3,2e3,s,-(Z+x),Z+x),c=ke.forceYUp?0:mn(t.point.x-1e3,t.point.y-1e3,-1e3,s,-40,Z),u={w:l,h:l,d:l},m={w:a,h:a,d:a},p=J.weightedChoice([1,"w"],[3,"h"],[0,"d"]),b=J.weightedChoice([1,1],[3,2],[1,3]);u[p]*=b,m[p]*=b;let f=Rl({sides:J.easedInt(ei,r,o),perspectiveCenter:yl,perspectiveStrength:h,width:J.num(t.minDist*u.w,t.minDist*m.w),height:J.num(t.minDist*u.h,t.minDist*m.h),depth:J.num(t.minDist*u.d,t.minDist*m.d*(0==e?ke.zDepthMaxMult:1)),center:[t.point.x,t.point.y],rotationProps:{x:Rt(n,d),y:Rt(i,d),z:Rt(c,d)}}),y=J.int(0,1e10),G=f.faces.reduce(((e,t)=>e+zn(t.vertices.map((e=>new zt(...e))))),0);f.faces=f.faces.filter((e=>null===g||!e.vertices.some((e=>!g.containsPoint(new zt(...e))))));for(let e of f.faces)e.vertices=e.vertices.map((t=>{if(!(t[0]>=Gl[0][0]&&t[1]>=Gl[0][1]&&t[0]<=Gl[2][0]&&t[1]<=Gl[2][1]))return t;let n=new nn;n.expandsByPoint(e.vertices),n.expandByValue(20);let i=Zl.getLinesIntersectingOrContainedWithinAABB(n).filter((e=>{let t=e.meta.lineCategory;return t==be.horizontal||t==be.vertical||t==be.perspective}));if(!i.length)return t;let l=i.reduce(((e,n)=>fn(t,e.line)<fn(t,n.line)?e:n),i[0]);return bn(t,l.line)}));for(let e of f.faces)Xl.addPolygon(e.vertices,{category:"face",meta:{id:y,lightingIntensity:e.lighting,normal:e.normal,area:zn(e.vertices.map((e=>new zt(...e)))),totalArea:G}});Cl.push(f),yield{showUpdate:!0,message:"Generating Scene",isPercent:!1,value:""}}}let e=Xl.getAllPolygons(),t=.8*Math.min(...e.map((e=>e.meta.meta.lightingIntensity))),n=.95*Math.max(...e.map((e=>e.meta.meta.lightingIntensity)));e.forEach((e=>{const i=e.meta.meta.lightingIntensity;let l=Tt(i,t,n,0,1),a=Tt($n(l),-0,1,Ke.min,Ke.max);e.meta.meta.lightingIntensity=a}));for(let t of e){let e={line:t.verts,id:Nn(),meta:{lineCategory:be.objects,id:t.meta.meta.id,isClosed:!0}};vl.push(e),Zl.addLine(t.verts,e.meta)}}],[function*(){let e=fl.internalFaces().sort(((e,t)=>t.area-e.area))[0],n=e.area,i=n,l=e,s=new Set,r=Ne;for(Fe[be.objects]>0&&r.push(be.objects);i/n>.95+b;){let e=Zl.getAllLines().filter((e=>e.meta.lineCategory==be.vertical||e.meta.lineCategory==be.horizontal)),t=J.choice(e);fl.splitFaceByPolyLine(l,t.line,t.meta.isClosed,!1),s.add(t),l=fl.internalFaces().sort(((e,t)=>t.area-e.area))[0],i=l.area,yield{showUpdate:!0,message:"Searching for initial structure",isPercent:!0,value:o(.95*n/i*100,100)}}fl.cleanupTrailingEdges();let c=!0,d=new Map;for(let e=0;e<je;e++){if(e%t(je/5)==0&&e>0&&e<t(je-je/5)){let e=new Di(fl,.75).findDominantPaths(),t=[];for(let n of e)t.push(n);[...t.filter((e=>e.curviness>.02)).sort(((e,t)=>t.length-e.length)).slice(0,2),...t.filter((e=>e.curviness<.02)).sort(((e,t)=>t.length-e.length)).slice(0,2)].forEach((e=>{let t=e.vertices;if(c){for(let e=1;e<t.length-2;e++){let n=[t[e],t[e+1]],i=fl.findHedge(n[0].x,n[0].y,n[1].x,n[1].y);i?.face?.area>0&&fl.removeEdge(n[0].x,n[0].y,n[1].x,n[1].y)}c=!1}else{let e=[t[0],t[1]],n=e[0].distanceTo(e[1]);for(let i=1;i<t.length-2;i++){let l=t[i].distanceTo(t[i+1]);l>n&&(e=[t[i],t[i+1]],n=l);let a=fl.findHedge(e[0].x,e[0].y,e[1].x,e[1].y);a?.face?.area>0&&a.twin.face?.area>0&&fl.removeEdge(e[0].x,e[0].y,e[1].x,e[1].y)}}})),fl.cleanupDegenerateHoles(),fl.cleanupTrailingEdges()}fl.cleanupTrailingEdges(),fl.insertPolygon(Gl,!0);let i,l=fl.internalFaces();wl.update(l);let s=wl.topN(1e3).filter((e=>!Kl.has(e.id))),o=[];for(let e of s){let t=new Ln([],[]);t.insertPolygon(e.vertexlist.map((e=>e.toArray())),!0);let l=t.faces[0],a=new Set,s=()=>{const n=[];for(let i=0;i<o.length;i++){const s=o[i];if(a.has(s.constructionLine.id))continue;const r=s.constructionLine.meta.lineCategory,c=s.constructionLine.meta.lineSubCategory;if(Ml(r,e.aabb.center,Fe[r],c)<=0)continue;const d=s.constructionLine.line;let u=s?.constructionLine?.meta?.aabb;if(u||(u=new nn,u.expandsByPoint(d),s.constructionLine.meta.aabb=u),!e.aabb.intersects(u))continue;const h=s?.constructionLine?.meta?.isClosed,m=t.splitFaceByPolyLine(l,d,h,!0);m?.lines?.length>0&&m?.intersectionCount>=2&&n.push(s)}o=n},r=e,c=n/10;if(e.area>c){let t=100,n=new nn;for(n.expand(e.center);!o.length&&n.area<c&&n.area<e.area;){n.expandByValue(t),o=Zl.linesIntersectingAABB(n),t+=50,s();for(let e of o)a.add(e.constructionLine.id)}}if(o.length||(o=Zl.getLinesIntersectingFace(r,!1),s()),o.length>0){i={face:e,intersecting:o},t.dispose();break}}if(!i)break;let{face:r,intersecting:h}=i,m=new Map;Object.values(be).forEach((e=>{"string"!=typeof e&&0!=Fe[e]&&m.set(e,h.filter((t=>{let n=t.constructionLine.meta;return n.lineCategory===e&&!(n.unableToSplitFaces&&n.unableToSplitFaces.has(r.id))})))}));let p=[];if(m.forEach(((e,t)=>{if(!e.length)return;let n=Ml(t,r.aabb.center,Fe[t]);if(n>0)if(e.some((e=>e.constructionLine.meta?.lineSubCategory))){let n=new Map;e.map((e=>{let t=e.constructionLine.meta.lineSubCategory;n.has(t)?n.get(t).push(e):n.set(t,[e])}));for(let[e,i]of n){let n=Ml(t,r.aabb.center,Fe[t],e);p.push([n,i.reduce(((e,t)=>{let n=fn(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-b?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])}}else p.push([n,e.reduce(((e,t)=>{let n=fn(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance-b?{distance:n,line:t}:e}),{distance:1/0,line:null}).line])})),Ee>0){let e=h.filter((e=>e.constructionLine?.meta?.used&&!e.constructionLine?.meta?.unableToSplitFaces?.has(r.id)&&e.constructionLine.meta.lineCategory==be.objects)).reduce(((e,t)=>{let n=fn(r.aabb.center.toArray(),t.constructionLine.line);return n<e.distance?{distance:n,line:t}:e}),{distance:1/0,line:null}).line;e&&p.push([Ml(be.used,r.aabb.center,Ee),e])}if(p=p.filter((e=>e[1])),0==p.length){Kl.add(r.id);continue}let g=J.weightedChoice(...p),f=fl.splitFaceByPolyLine(r,g.constructionLine.line,g.constructionLine.meta.isClosed,!1,J.bool(Qe.longestSplitOnlyChance));if(f&&(g.constructionLine.meta.used=!0),!f&&(d.set(r.id,(d.get(r.id)||0)+1),e--,!g.constructionLine.meta.unableToSplitFaces&&(g.constructionLine.meta.unableToSplitFaces=new Set),g.constructionLine.meta.unableToSplitFaces.add(r.id),d.get(r.id)>5)){let e=fl.faces.find((e=>e.id==r.id));for(let t of e.hedges.filter((t=>t.face==e)))fl.removeEdge(t.origin.x,t.origin.y,t.twin.origin.x,t.twin.origin.y);fl.cleanupTrailingEdges()}yield{showUpdate:!0,message:"Composing",isPercent:!0,value:t(100*(u=e/je,1-a(1-u,3)))}}var u}],[function*(){Cl.sort(((e,t)=>e.faces.reduce(((e,t)=>e+zn(t.vertices.map((e=>new zt(...e))))),0)-t.faces.reduce(((e,t)=>e+zn(t.vertices.map((e=>new zt(...e))))),0))),Cl=En(Cl.slice(t(Cl.length/4),n(Cl.length/4*2)));for(let e=0;e<Cl.length;e++){if(J.bool(100-Te.forceInsertObjectsChance))continue;let t=Cl[e];for(let e of t.faces)J.bool(50)||(fl.insertPolygon(e.vertices,!0),J.bool(50)&&fl.removeEdgesInsidePolygon(e.vertices))}let e=vl.filter((e=>e.meta.lineCategory==be.curves)).sort(((e,t)=>{let n=zn(e.line.map((e=>new zt(...e))));return zn(t.line.map((e=>new zt(...e))))-n}));for(let n=0;n<e.length;n++){if(J.bool(100-Te.forceInsertCurvesChance))continue;let i=e[n];n<t(e.length/10)&&(fl.insertPolygon(i.line,!0),fl.removeEdgesInsidePolygon(i.line,10))}}],[function*(){let e=fl.internalFaces().filter((e=>e.area>1)),n=e.length*Ae;for(let i=0;i<n&&!(e.length<10);i++){let l=J.choice(e.sort(((e,t)=>{const n=e.area-t.area;return Math.abs(n)<b?e.id-t.id:n})).slice(0,100));if(!l)continue;let a=l.hedges.filter((e=>e.twin&&e.face!==e.twin.face&&e.twin.face.area>0&&e.face.area>0)),s=J.choice(a);s&&fl.removeEdge(s.origin.x,s.origin.y,s.twin.origin.x,s.twin.origin.y),fl.cleanupTrailingEdges(),e=fl.internalFaces().filter((e=>e.area>1)),yield{showUpdate:!0,message:"Deconstructing",isPercent:!0,value:t(i/n*100)}}}],[function*(){fl.insertPolygon(Gl,!0)}],[function*(){let e=new Di(fl,.4).findDominantPaths();for(let t of e)Ll.push(t),yield{showUpdate:!0,message:"Walking Paths",isPercent:!1,value:Ll.length}}],[function*(){xl=new Ln(Gl,[[0,1],[1,2],[2,3],[3,0]]);let e=Me.meshDensity,t=xl.internalFaces()[0].area;xl.dispose();let n=P/15,i=[J.num(Y/2,Y/2),J.num(P/2-n,P/2+n)],l=Ll.sort(((e,t)=>fn(i,e.vertices.map((e=>e.toArray())))-fn(i,t.vertices.map((e=>e.toArray()))))).slice(0,Ll.length),a=[],s=0;for(;s<e&&l.length>0;){let n=l.shift();xl.insertPolygon(n.vertices.map((e=>[e.x,e.y])),!1),a.push(n),s=xl.internalFaces().reduce(((e,t)=>e+t.area),0)/t*100,yield{showUpdate:!0,message:"Defining subject",isPercent:!0,value:s/e*100}}xl.cleanupTrailingEdges();let o=xl.vertices.filter((e=>e.y<.75*P&&Cn(e.toArray(),Gl)));for(let e of o)for(let t of e.hedgelist){let e=[t.origin.x,t.origin.y],n=[t.twin.origin.x,t.twin.origin.y];if(Cn(e,Gl)&&Cn(n,Gl)){if(t.origin.distanceTo(t.twin.origin)<10)continue;xl.removeEdge(e[0],e[1],n[0],n[1])}}xl.cleanupTrailingEdges(),Sl.push(...a.sort(((e,t)=>t.length-e.length)))}],[function*(){let e=Ll.filter((e=>{let t=(Be.cropToMargin?Be.margin:He.margin)*Me.dominantLineInsetMultiplier;return!e.vertices.some((e=>e.x<=t||e.x>=Y-t||e.y<=t||e.y>=P-t))}));"none"!==Me.lineFilter&&(e=e.filter((e=>{let t=e.curviness>.01;return"curves"==Me.lineFilter?t:!t})));let n=[];for(let i of e){let e=t(i.vertices.length/2),l=!1;for(let t of n){let n=0;for(let a of i.vertices){for(let i of t.vertices)if(a.isEqualTo(i)&&(n++,n>=e)){l=!0;break}if(l)break}if(l)break}l||n.push(i)}e=n,Me.cropToDominantShape&&(e=e.filter((e=>xl.getFacesAtPoint(e.vertices[0].toArray()).length>0&&xl.getFacesAtPoint(e.vertices[e.vertices.length-1].toArray()).length>0)));let a=t(e.length/100*Me.skipLongest),s=e.sort(((e,t)=>t.length-e.length)).slice(a,e.length/100*Me.percentage+a),o=ve.bg[0][0]>.5?ve.line[0]:[...ve.line,...ve.base,...ve.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),ve.line[0]),r=[...ve.line,...ve.base,...ve.accent].filter((e=>e[1]<.05)).reduce(((e,t)=>t[0]>e[0]?t:e),ve.line[0]);for(let e of s){if(J.bool(50)){let t=e.vertices.reduce(((t,n,i)=>0===i?0:t+n.distanceTo(e.vertices[i-1])),0)/J.num(10,15),n=e.vertices[1].angleTo(e.vertices[0]),a=new zt(e.vertices[0].x+l(n)*t,e.vertices[0].y+i(n)*t),s=e.vertices[e.vertices.length-2].angleTo(e.vertices[e.vertices.length-1]),o=new zt(e.vertices[e.vertices.length-1].x+l(s)*t,e.vertices[e.vertices.length-1].y+i(s)*t);e.vertices=[a,...e.vertices,o]}let t=new nn;t.expands(e.vertices),t.expandByValue(Me.thickness.max+3);let n={polygon:t.vertexList,faceRef:null,category:sn.walker,readyForRender:!0,detailObject:[{lines:[e.vertices.map((e=>e.toArray()))],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Me.materialHardness.min,Me.materialHardness.max),linePressure:J.num(Me.linePressure.min,Me.linePressure.max),canWarp:!0,lineTapering:Pi(Me.lineTapering,J),lineWeight:J.num(Me.thickness.min,Me.thickness.max),lineColor:Me.backgroundColor?r:Me.colors?J.choice([...ve.accent,...ve.base,...ve.line]):o}]};Wl.push(n)}}],[function*(){let e=Re.count;for(let t=0;t<e;t++){let e=new Di(fl),t=Ui(fl);if(!t)break;e.walk(t,J.int(Re.length.min,Re.length.max),!0),e.AABB.expandByValue(10);let n=Re.isLineColor?ve.line[0]:Re.colors?J.weightedChoice([1,J.choice(ve.accent)],[0,J.choice(ve.line)],[1,J.choice(ve.base)]):J.choice(ve.bg),{fade:i,scale:l}=Re.lineTapering,a={polygon:e.AABB.vertexList,faceRef:null,category:sn.walker,readyForRender:!0,detailObject:[{lines:[e.pathVerts.map((e=>e.toArray()))],closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],lineTapering:{fade:{in:{enabled:J.bool(i.in.enabledChance),length:J.num(i.in.min,i.in.max)},out:{enabled:J.bool(i.out.enabledChance),length:J.num(i.out.min,i.out.max)}},scale:{in:{enabled:J.bool(l.in.enabledChance),length:J.num(l.in.min,l.in.max)},out:{enabled:J.bool(l.out.enabledChance),length:J.num(l.out.min,l.out.max)}}},linePressure:J.num(Re.hardness.min,Re.hardness.max),canWarp:J.bool(Re.warpChance),lineWeight:J.num(Re.thickness.min,Re.thickness.max),lineColor:n}]};Wl.push(a)}}],[function*(){let e=fl.internalFaces().filter((e=>e.area>1)),n=new nn;n.expandsByPoint(Gl),e=e.filter((e=>n.containsPoint(e.center))),Be.cropToMargin&&(e=e.filter((e=>e.center.x>Be.margin&&e.center.x<Y-Be.margin&&e.center.y>Be.margin&&e.center.y<P-Be.margin)));let i=Zl.getAllLines().filter((e=>e.meta.lineCategory==be.curves&&e.meta.used)),l=e=>{let n=e.aabb;for(let l of i){let i=l.line.map((e=>new zt(...e)));if(l.meta?.aabb||(l.meta.aabb=new nn,l.meta.aabb.expands(i)),l.meta.aabb.intersects(n)){let n=t(.9*e.vertexlist.length),a=0;for(let t=0;t<e.vertexlist.length;t++){if(a>=n)return l;let s=e.vertexlist[t],o=!1;for(let e of i)if(s.isEqualTo(e)){a++,o=!0;break}!o&&Tn(i,s)&&a++}}}},a=e=>Xl.getPolygonsAtPoint(e.center.toArray()).sort(((e,t)=>e.meta.meta.totalArea-t.meta.meta.totalArea)),s=e=>{const t=xl.getFacesIntersectingPoly(e.vertexlist.map((e=>[e.x,e.y])));return e.vertexlist.every((e=>t.some((t=>Cn(e.toArray(),t.face.vertexlist.map((e=>e.toArray())))||Tn(t.face.vertexlist,e)))))?t:[]};for(let n=0;n<e.length;n++){let i=e[n],o=n,r=a(i),c=l(i),d=s(i),u=r.length?r[0].meta.meta.lightingIntensity:Ke.default,h={polygon:i.vertexlist,faceRef:i,lightingIntensity:u,category:sn.foreground,isInCurve:c,detailObjectProps:{inObject:r,inDominantShapes:d}};Wl.push(h),yield{showUpdate:!0,message:"Determining Layout",isPercent:!0,value:t(o/e.length*100)}}const o=[...Wl.filter((e=>e.category==sn.foreground&&e.lightingIntensity)).map((e=>e.lightingIntensity))].sort(((e,t)=>e-t));for(let e of Wl){const t=(r=e.lightingIntensity,(o.indexOf(r)+o.lastIndexOf(r))/2/(o.length-1));e.lightingIntensity=wt(Kt(ti(t),0,1,Ke.min,Ke.max),e.lightingIntensity,.9)}var r}],[function*(){let{freqMultiplier:e}=Oe,t=e,n=500*e;Zl.getAllLines().filter((e=>e.meta.lineCategory==be.objects&&e.meta.used)).forEach((e=>{yi.add(e.meta.id)}));let i=Wl.filter((e=>e.category==sn.foreground)),{base:l,accent:a,line:s,bg:o}=ve,r=En([...l,...a,...s,...o]),c=J.int(0,r.length-1);li=function(e,t,n="right"){let i=e.slice();for(let e=0;e<t;e++)i=_n(i,n);return i}(r,c),li.length>Oe.maxAccents&&(li=li.slice(0,Oe.maxAccents));let d=Oe.mutation;if("none"!==d){let e=e=>{let t,n=ci;switch(d){case"offsetUp":t=n;break;case"offsetDown":t=-30}return J.choice(gi(e,si,t,Oe.samplesForPaletteOffset))},t=[];for(let n=1;n<li.length;n++){let i=li[n],l=li[n-1],a=J.bool(50);if(l&&a){let n=e(l);t.push(n)}else t.push(i)}li=t}ai=ai.map((e=>[e[0],e[1],e[2]])),fi=ii(t,li.length,0,di,i.filter((e=>e.detailObjectProps?.inDominantShapes?.length>0)).map((e=>e.faceRef.center))),xi=ii(n,ai.length,0,di,i.filter((e=>!e.detailObjectProps?.inDominantShapes?.length)).map((e=>e.faceRef.center))),ai=pi(xi,ai),li=pi(fi,li)}],[function*(){let e=Wl.filter((e=>e.category==sn.foreground&&e.detailObjectProps?.inDominantShapes?.length>0)),t=new zt(Y/2,P/2),n=e.map((e=>e.faceRef.hedges.reduce(((e,n)=>e.origin?n.origin?t.distanceTo(e.origin)<t.distanceTo(n.origin)?e:n:e:n),e.faceRef.hedges[0])));for(let e=0;e<Je.count;e++){let e=Rt(J.num(ze.scale*Je.size.min,ze.scale*Je.size.max),ze.scale),t=n.map((e=>{let t=e.origin.lerp(e.twin.origin,.5);return{distance:fn(t.toArray(),Gl,!0),edge:e,point:t}})).filter((t=>t.distance>1.25*e)),i=2.5*e;t.sort(((e,t)=>Math.abs(e.distance-i)-Math.abs(t.distance-i)));let l=t[0];n.splice(n.indexOf(l.edge),1);let a=l.point,s=J.num(0,360),o=On({center:a.toArray(),radius:e,startAngle:s,endAngle:s+359.5}),r=new Qi([o],{x:J.num(-15,15),y:J.num(-15,15),z:J.num(-15,15)},1200,0,{x:yl[0],y:yl[1]}).getLineSegments(),c={polygon:r[0].map((e=>new zt(...e))),faceRef:null,category:sn.overlay,readyForRender:!1,detailObjectProps:{}};if(Wl.push(c),Je.outline){let e=r[0],t=new nn;t.expandsByPoint(e),t.expandByValue(2*Me.thickness.max);let n={polygon:t.vertexList,faceRef:null,category:sn.overlayOutline,readyForRender:!0,detailObject:[{lines:[e],noiseOffset:[J.num(-1,1),J.num(-1,1)],closedPolyOrLine:!1,materialHardness:J.num(Me.materialHardness.min,Me.materialHardness.max),linePressure:J.num(Me.linePressure.min,Me.linePressure.max),canWarp:!1,lineTapering:Pi(Me.lineTapering,J),lineWeight:J.num(Me.thickness.min,Me.thickness.max),lineColor:Me.backgroundColor?ve.bg[0]:Me.colors?J.choice([...ve.accent,...ve.base,...ve.line]):ve.line[0]}]};Wl.push(n)}}}],[function*(){let{enabled:e,linePressure:t,materialHardness:n,lineWeight:i,percentage:l,lineTapering:a}=Ie;if(!e)return;let s=vl.filter((e=>e.meta.used)).filter((()=>J.bool(l))),o=new nn;o.expands([new zt(0,0),new zt(Y,P)]);let r={polygon:o.vertexList,faceRef:null,category:sn.constructionLine,readyForRender:!0,detailObject:[{lines:s.map((e=>e.line)),closedPolyOrLine:!1,noiseOffset:[J.num(-1,1),J.num(-1,1)],linePressure:J.num(t.min,t.max),materialHardness:J.num(n.min,n.max),ca
(e,t){const n=e-t;return Math.abs(n)<this.epsilon||n<0?-1:1}insertRec(e,t,n){return e?((0===e.axis?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y))<0?e.left=this.insertRec(e.left,t,n+1):e.right=this.insertRec(e.right,t,n+1),e):{point:t,axis:n%2,left:null,right:null}}remove(e){this.wasRemoved=!1,this.root=this.removeRec(this.root,e,0),this.wasRemoved&&this.count--}removeRec(e,t,n){if(!e)return null;const i=e.axis;if(this.equals(e.point,t)){if(this.wasRemoved=!0,e.right){const t=this.findMin(e.right,i,n+1);e.point=t.point,e.right=this.removeRec(e.right,t.point,n+1)}else{if(!e.left)return null;{const t=this.findMin(e.left,i,n+1);e.point=t.point,e.right=this.removeRec(e.left,t.point,n+1),e.left=null}}return e}{let l;l=0===i?this.compareCoord(t.point.x,e.point.point.x):this.compareCoord(t.point.y,e.point.point.y),l<0?e.left=this.removeRec(e.left,t,n+1):e.right=this.removeRec(e.right,t,n+1)}return e}findMin(e,t,n){if(!e)throw Error("Empty subtree when finding min.");if(e.axis===t)return e.left?this.findMin(e.left,t,n+1):e;const i=e.left?this.findMin(e.left,t,n+1):e,l=e.right?this.findMin(e.right,t,n+1):e;let a=e;return this.compareAxis(i.point,a.point,t)<0&&(a=i),this.compareAxis(l.point,a.point,t)<0&&(a=l),a}findNearest(e){return this.root?this.findNearestRec(this.root,e,this.root.point,0):null}findNearestRec(e,t,n,i){if(!e)return n;let l=n;this.distanceSq(e.point,t)<this.distanceSq(l,t)&&(l=e.point);const a=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let s,o;return a<-this.epsilon?(s=e.left,o=e.right):a>this.epsilon?(s=e.right,o=e.left):(s=e.left,o=e.right),l=this.findNearestRec(s,t,l,i+1),a**2<this.distanceSq(l,t)&&(l=this.findNearestRec(o,t,l,i+1)),l}findKNearest(e,t){if(!this.root)return[];const n=new Oi(t,(e=>e.dist));return this.findKNearestRec(this.root,e,t,n),n.toArray().map((e=>e.point))}getTotalNodes(){return this.count}*pointsWithinDistanceGenerator(e,t){const n=t*t;yield*this.pointsWithinDistanceRecGen(this.root,e,n)}*pointsWithinDistanceRecGen(e,t,n,i=0){if(!e)return;this.distanceSq(e.point,t)<=n&&(yield e.point);const l=0===e.axis?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let a,s;l<-this.epsilon?(a=e.left,s=e.right):(a=e.right,s=e.left),yield*this.pointsWithinDistanceRecGen(a,t,n,i+1),l**2<=n&&(yield*this.pointsWithinDistanceRecGen(s,t,n,i+1))}findKNearestRec(e,t,n,i,l=0){if(!e)return;const a=e.axis,s=this.distanceSq(e.point,t);if(i.size()<n)i.push({dist:s,point:e.point});else{const t=i.peek();t&&s<t.dist&&i.replaceTop({dist:s,point:e.point})}const o=0===a?t.point.x-e.point.point.x:t.point.y-e.point.point.y;let r,c;o<-this.epsilon?(r=e.left,c=e.right):o>this.epsilon?(r=e.right,c=e.left):(r=e.left,c=e.right),this.findKNearestRec(r,t,n,i,l+1);const d=i.peek();d&&o**2<d.dist&&this.findKNearestRec(c,t,n,i,l+1)}distanceSq(e,t){const n=e.point.x-t.point.x,i=e.point.y-t.point.y;return n*n+i*i}compareAxis(e,t,n){const i=0===n?e.point.x-t.point.x:e.point.y-t.point.y;return Math.abs(i)<this.epsilon?0:i}equals(e,t){const n=e.point.x-t.point.x,i=e.point.y-t.point.y;return n*n+i*i<this.epsilon*this.epsilon}}class ul{opts;kTree=new dl;activeList=[];random;epsilon=b;maxDist;constructor(e){this.opts=e,this.random=e.random||J,this.maxDist=e.maxDist||1}*generate(){const{bounds:e,noiseField:t,initialCount:n=1,k:i=50}=this.opts;if(this.opts.seedPoints&&this.opts.seedPoints.length>0)for(let e of this.opts.seedPoints){const n={point:e,minDist:t(e.x,e.y)};this.placePoint(n),this.activeList.push(n),yield n}else for(let i=0;i<n;i++){const n=this.random.num(e.topLeft[0],e.bottomRight[0]),i=this.random.num(e.topLeft[1],e.bottomRight[1]),l=t(n,i),a={point:new zt(n,i),minDist:l};this.placePoint(a),this.activeList.push(a),yield a}for(;this.activeList.length>0;){const n=0,l=this.activeList[n];let a=!1;for(let n=1;n<i;n++){const s=l.minDist*(.5+i/n),o=this.random.dec()*Math.PI*2,r=l.point.x+Math.cos(o)*s,c=l.point.y+Math.sin(o)*s;if(r<e.topLeft[0]||r>e.bottomRight[0]||c<e.topLeft[1]||c>e.bottomRight[1])continue;const d=t(r,c),u={point:new zt(r,c),minDist:d};if(this.canPlace(u)){this.placePoint(u),this.activeList.push(u),yield u,a=!0;break}}a||this.activeList.splice(n,1)}}canPlace(e){for(let t of this.kTree.pointsWithinDistanceGenerator(e,this.maxDist+b))if(t.point.distanceTo(e.point)+this.epsilon<Math.max(t.minDist,e.minDist))return!1;return!0}placePoint(e){this.kTree.insert(e)}}const hl=function(e,t,n){const i=1/t,l=1/n;return Math.min(4,((3-i)*i**2*e+l**3)/(i**3*e+(3-l)*l**2))},ml=(e,t,n,i,l)=>Math.min(4,(2+Math.sqrt(2)*(e-n/16)*(n-e/16)*(t-i))/(1.5*l*(2+(Math.sqrt(5)-1)*t+(3-Math.sqrt(5))*i))),pl=(e,t)=>{const n=Math.sin(e.theta),i=Math.cos(e.theta),l=Math.sin(t.phi),a=Math.cos(t.phi),s=t.leftY,o=e.rightY,r=ml(n,i,l,a,s),c=ml(l,a,n,i,o);e.rightX=e.x+(e.deltaX*i-e.deltaY*n)*r,e.rightY=e.y+(e.deltaY*i+e.deltaX*n)*r,t.leftX=t.x-(e.deltaX*a+e.deltaY*l)*c,t.leftY=t.y-(e.deltaY*a-e.deltaX*l)*c},gl=(e,{tension:t=1,cyclic:n=!1}={})=>{const i=((e,t=1,n=!1)=>{const i=e.map((({x:e,y:n})=>((e,t,n)=>({x:e,y:t,leftY:n,rightY:n,leftX:n,rightX:n,deltaX:0,deltaY:0,delta:0,theta:0,phi:0,psi:0}))(e,n,t))),l=i[0],a=i[i.length-1];for(let e=0;e<i.length;e++)i[e].next=i[e+1]??l,i[e].prev=i[e-1]??a;if(((e,t)=>{const n=t?e.length:e.length-1;for(let t=0;t<n;t++){const n=e[t],i=e[t+1]??e[0];n.deltaX=i.x-n.x,n.deltaY=i.y-n.y,n.delta=Math.hypot(n.deltaX,n.deltaY)}})(i,n),2===e.length&&!n)return((e,t)=>{let n=1/(3*e.rightY);e.rightX=e.x+e.deltaX*n,e.rightY=e.y+e.deltaY*n,n=1/(3*t.leftY),t.leftX=t.x-e.deltaX*n,t.leftY=t.y-e.deltaY*n})(l,a),i;((e,t)=>{const[n,i]=t?[0,e.length]:[1,e.length-1];for(let t=n;t<i;t++){const n=e[t],i=n.prev,l=i.deltaY/i.delta,a=i.deltaX/i.delta;n.psi=Math.atan2(n.deltaY*a-n.deltaX*l,n.deltaX*a+n.deltaY*l)}})(i,n),function(e,t){const n=[],i=[],l=[],a=e[0],s=e[1],o=e[e.length-1],r=t?e.length+1:e.length;if(t)n[0]=0,l[0]=0,i[0]=1;else{const e=a.next,t=a.rightX,o=Math.abs(e.leftY),r=Math.abs(a.rightY);n[0]=hl(t,r,o),l[0]=-s.psi*n[0],i[0]=0}for(let s=1;s<r;s++){const c=e[s]??a,d=c.next,u=c.prev,h=s===r-1;if(!t&&h){const e=c.leftX,t=Math.abs(c.leftY),i=Math.abs(u.rightY),a=hl(e,t,i);o.theta=-l[r-2]*a/(1-a*n[r-2]);break}{let e=1/(3*Math.abs(u.rightY)-1),o=c.delta*(3-1/Math.abs(u.rightY)),m=1/(3*Math.abs(d.leftY)-1),p=u.delta*(3-1/Math.abs(d.leftY));const g=1-n[s-1]*e;o*=g;const b=Math.abs(c.leftY),f=Math.abs(c.rightY);b<f?o*=(b/f)**2:p*=(f/b)**2;let x=p/(p+o);n[s]=x*m;let Z=-d.psi*n[s];if(x=(1-x)/g,Z-=c.psi*x,x*=e,l[s]=Z-l[s-1]*x,i[s]=-i[s-1]*x,t&&h){let e=0,t=1;for(let a=s-1;a>=0;a--){const s=0===a?r-1:a;e=l[s]-e*n[s],t=i[s]-t*n[s]}e/=1-t,a.theta=e,l[0]=e;for(let t=1;t<r-1;t++)l[t]=l[t]+e*i[t];break}}}for(let t=r-2;t>=0;t-=1)e[t].theta=l[t]-e[t].next.theta*n[t]}(i,n),(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.phi=-n.psi-n.theta}})(i);const s=n?i.length:i.length-1;for(let e=0;e<s;e++)pl(i[e],i[e].next);return i})(e,t,n),l=[],a=n?i.length:i.length-1;for(let e=0;e<a;e++){const t=i[e];l.push({startControl:{x:t.rightX,y:t.rightY},endControl:{x:t.next.leftX,y:t.next.leftY},point:{x:t.next.x,y:t.next.y}})}return l};function bl(e,t,n=!1,i=.01){const l=[],a=e.length;if(a<2)return l;const s=n?a:a-1;let o=null;for(let n=1;n<=s;n++){const s=n%a,r=e[(n-1)%a].point,c=e[s].startControl,d=e[s].endControl,u=e[s].point;let h=0;for(;h<=1;){const e=1-h,n={x:e**3*r.x+3*e**2*h*c.x+3*e*h**2*d.x+h**3*u.x,y:e**3*r.y+3*e**2*h*c.y+3*e*h**2*d.y+h**3*u.y};if(o){const e=n.x-o.x,i=n.y-o.y;e*e+i*i>=t*t&&(l.push(n),o=n)}else l.push(n),o=n;h+=i}const m={x:u.x,y:u.y};!o||o.x===m.x&&o.y===m.y||(l.push(m),o=m)}if(!n){const t=e[a-1].point,n=l[l.length-1];n.x===t.x&&n.y===t.y||l.push(t)}return l}let fl,xl,Zl,yl,Gl,Wl=[],vl=[],Ll=[],Sl=[],Xl=new class{cells=new Map;polygons=new Map;polygonMeta=new Map;nextPolygonId=0;cellSize;constructor(e,t){this.cellSize=e,t&&this.addPolygons(t)}getCellIndex(e,t){return`${f(e)},${f(t)}`}clear(){this.cells.clear(),this.polygons.clear(),this.polygonMeta.clear()}getCellTestVertices(e,t){let{cellSize:n}=this;return[new zt(e*n,t*n),new zt((e+1)*n,t*n),new zt((e+1)*n,(t+1)*n),new zt(e*n,(t+1)*n)]}addPolygons(e){e.forEach((e=>this.addPolygon(e.verts,e.meta)))}getPolygonsAtPoint(e){let{cellSize:t}=this,n=f(e[0]/t),i=f(e[1]/t);const l=this.getCellIndex(n,i);let a=new Set;return this.cells.has(l)&&Array.from(this.cells.get(l)).map((t=>{Tn(this.polygons.get(t).map((e=>(new zt).fromArray(e))),new zt(e[0],e[1]))&&a.add(t)})),Array.from(a).map((e=>({verts:this.polygons.get(e),meta:this.polygonMeta.get(e)})))}addPolygon(e,t){let{cellSize:n}=this;const i=this.nextPolygonId++;this.polygons.set(i,e),this.polygonMeta.set(i,t);let l=e.map((e=>(new zt).fromArray(e))),a=new nn;a.expands(l);const s=f(a.minX/n),o=x(a.maxX/n)-1,r=f(a.minY/n),c=x(a.maxY/n)-1;for(let e=s;e<=o;e++)for(let t=r;t<=c;t++){const n=this.getCellIndex(e,t),a=this.getCellTestVertices(e,t);if(a.some((e=>Tn(l,e))))this.cells.has(n)||this.cells.set(n,new Set),this.cells.get(n).add(i);else for(let e=0;e<a.length;e++)if(Hn([a[e],a[(e+1)%a.length]],l)){this.cells.has(n)||this.cells.set(n,new Set),this.cells.get(n).add(i);break}}return i}checkIntersections(e){let{cellSize:t}=this,n=e.map((e=>(new zt).fromArray(e))),i=new nn;i.expands(n);const l=f(i.minX/t),a=x(i.maxX/t)-1,s=f(i.minY/t),o=x(i.maxY/t)-1;let r=new Set;for(let e=l;e<=a;e++)for(let t=s;t<=o;t++){const i=this.getCellIndex(e,t),l=this.getCellTestVertices(e,t);this.cells.has(i)&&this.cells.get(i).forEach((e=>{if(l.some((e=>Tn(n,e))))r.add(e);else for(let t=0;t<l.length;t++)if(Hn([l[t],l[(t+1)%l.length]],n)){r.add(e);break}}))}return Array.from(r).map((e=>({verts:this.polygons.get(e),meta:this.polygonMeta.get(e)})))}getAllPolygons(){return Array.from(this.polygons).map((([e,t])=>({verts:t,meta:this.polygonMeta.get(e)})))}}(10),Cl=[],Vl=[[function*(){hn()}],[function*(){let e=ve.bg[0][0]>=.5,t=e?1:1.008,n=e?1:1.02;si=si.length?si:he.filter((e=>e!==ve)).map((e=>[...e.accent,...e.base,...e.line])).flat().map((e=>(e[0]*=n,e[1]*=t,e))),[...ve.accent,...ve.base,...ve.line].forEach((e=>{e[0]*=n,e[1]*=t}));let i=[...ve.accent,...ve.base,...ve.line];li=i,ai=[...ve.base].sort(((e,t)=>t[0]-e[0])),li=[...li].sort(((e,t)=>t[2]-e[2])),An([...li]),An([...ai])}],[function*(){let t=w?e.LinearFilter:e.NearestFilter,n={anisotropy:V,colorSpace:e.LinearDisplayP3ColorSpace,minFilter:t,magFilter:t,type:e.FloatType};Xt=new St(B,Q,{stencilBuffer:!1,depthBuffer:!1}),Ct={paperTexture:{target:new e.WebGLRenderTarget(B,Q,{...n,format:e.RedFormat,internalFormat:"R32F"}),pass:()=>{let t=new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(B,Q)},noiseOffset:{value:new e.Vector2(We[0],We[1])},...ce()},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec3 backgroundColor;\n uniform vec3 lineColor;\n uniform vec2 noiseOffset;\n\n ${ee}\n ${te}\n\n varying vec2 vUv;\n out vec4 outColor;\n\n #include <packing>\n\n ${ne}\n\n vec4 render(vec2 uv) {\n\n float noiseTex1 = fbm(uv - noiseOffset, 5, 300., 0.9) - 0.5;\n float noiseTex2 = fbm(uv - noiseOffset, 3, 400., 0.9) - 0.5;\n float texCombined = step(0.001, -(noiseTex1 * noiseTex2)) * .05;\n\n float noiseTexDark1 = fbm(uv + noiseOffset + 1., 5, 280., 0.9) - 0.5;\n float noiseTexDark2 = fbm(uv + noiseOffset + 1., 3, 300., 0.9) - 0.5;\n float texDarkCombined = step(0.0001, -(noiseTexDark1 * noiseTexDark2)) * .05;\n\n float smoothNoise1 = smoothstep(0., 0.6, fbm(uv, 3, 420., 0.9)) * 0.03;\n\n // vec3 lchColor = vec3(0., 0.5, 0.5);\n float result;\n result += texCombined;\n result -= texDarkCombined;\n result += smoothNoise1;\n \n // vec3 colorRGB = OKLCHtoP3LRGB(lchColor);\n // float canvasTexture = fbm(uv, 6, 120., 0.7);\n return vec4(vec3(result), 1.);\n }\n\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 6.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `});re(t),Vt.material=t,X.setRenderTarget(Ct.paperTexture.target),Vt.render(X)}},displacementMap:{target:new e.WebGLRenderTarget(B,Q,{...n,format:e.RGFormat,internalFormat:"RG32F"}),pass:()=>{let e=ft();re(e),Vt.material=e,X.setRenderTarget(Ct.displacementMap.target),Vt.render(X)}},displacementMapWarped:{target:new e.WebGLRenderTarget(B,Q,{...n,format:e.RGFormat,internalFormat:"RG32F"}),pass:()=>{let e=ft();re(e),e.uniforms.uWarpEnabled.value=!0,Vt.material=e,X.setRenderTarget(Ct.displacementMapWarped.target),Vt.render(X)}},polyEdgeDistance:{target:new e.WebGLRenderTarget(B,Q,{...n,format:e.RedFormat,internalFormat:"R32F"}),skipSetup:!0}};let i=function*(){for(let e of Object.keys(Ct)){const t=Ct[e];t.skipSetup||t.pass&&t.pass()}return X.shadowMap.enabled=!0,void X.setRenderTarget(null)}();for(;!i.next().done;)yield}],[function*(){let e=yt();Vt.material=e;for(let t of Object.keys(Ct)){if(!Ct[t].debug)continue;let n=Ct[t].target.texture;e.uniforms.tTex.value=n,X.setRenderTarget(null),Vt.render(X),ta(),yield}}],[function*(){let t=(n=Ct.paperTexture.target.texture,new e.ShaderMaterial({uniforms:{grid:{value:{...ze}},...ce(),tWarpTex:{value:Ct.displacementMap.target.texture},resolution:{value:new e.Vector2(B,Q)},coordsResolution:{value:new e.Vector2(Y,P)},noiseOffset:{value:new e.Vector2(0,0)},tPaperTexture:{value:n},backgroundColor:{value:new e.Vector3(0,0,0)},lineColor:{value:new e.Vector3(0,0,0)},uGridStrength:{value:.3}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n\t\t\tprecision highp int;\n \n // uniform highp sampler2D tTex;\n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec2 coordsResolution;\n uniform vec3 backgroundColor;\n uniform vec3 lineColor;\n uniform vec2 noiseOffset;\n uniform float uGridStrength;\n uniform highp sampler2D tPaperTexture;\n uniform highp sampler2D tWarpTex;\n\n struct Grid {\n float countX;\n float countY;\n float marginX;\n float marginY;\n float w;\n float h;\n float scale;\n };\n uniform Grid grid;\n\n ${ee}\n ${Dt}\n ${te}\n \n float drawGridLines(vec2 uv, float lineWeight, float gridScale) {\n vec2 scale = resolution / coordsResolution;\n // This should be the desired line width in pixels\n float lineWeightNoise = snoise2D(uv * 200.f) * .09f;\n float gridLineWeight = (lineWeight + lineWeightNoise) * scale.y; // Width of the grid lines in pixels\n\n vec2 offset = vec2(grid.marginX, grid.marginY) * scale; // Applying scale to margins\n\n // Compute UVs for grid lines based on actual screen resolution and grid scaling\n vec2 gridUV = (uv * resolution - offset);\n\n // Convert grid dimensions from whatever space they are in to pixel space directly\n float gridWidthInPixelsX = grid.w * (resolution.x / coordsResolution.x) * 1.;\n float gridWidthInPixelsY = grid.h * (resolution.y / coordsResolution.y) * 1.;\n\n // Calculate the distance to the nearest grid line in pixels\n float lineDistX = min(mod(gridUV.x, gridWidthInPixelsX / gridScale), gridWidthInPixelsX - mod(gridUV.x, gridWidthInPixelsX / gridScale));\n float lineDistY = min(mod(gridUV.y, gridWidthInPixelsY / gridScale), gridWidthInPixelsY - mod(gridUV.y, gridWidthInPixelsY / gridScale));\n float lineDist = min(lineDistX, lineDistY);\n\n // Use smoothstep to create anti-aliased lines with a specified pixel width\n float lineFactor = 1.0 - smoothstep(gridLineWeight - 0.1, gridLineWeight + 0.1, lineDist);\n\n return lineFactor;\n }\n\n float drawGridBlocks(vec2 uv, float gridScale ) {\n vec2 scale = resolution / coordsResolution;\n vec2 offset = vec2(grid.marginX, grid.marginY) * scale; // Applying scale to margins\n vec2 gridUV = (uv * resolution - offset); // Apply resolution scaling to UV, then subtract offset\n\n float tileX = floor(gridUV.x / (grid.w * scale.x));\n float tileY = floor(gridUV.y / (grid.h * scale.y));\n\n vec2 centerUV = (vec2(tileX, tileY)) * vec2(grid.w, grid.h) / resolution;\n\n float noiseValue = clamp(fbm(centerUV, 3, 300., 0.5) + .5, 0.0, 1.); // Adjust for correct scaling if necessary\n\n return noiseValue;\n\n // float checker = mod(tileX + tileY, 2.0);\n \n // return checker == 0.0;\n }\n\n ${gt}\n\n varying vec2 vUv;\n out vec4 outColor;\n\n #include <packing>\n\n ${ne}\n ${Ut}\n\n vec4 render(vec2 uv, vec2 texUv, vec2 msaaOffset) {\n\n // vec2 uvOffset = lookupWarpSample(uv).xy;\n\n // vec2 offsetUV = uv + uvOffset;\n vec2 offsetUV = uv;\n\n float gridNoise = fbm(uv, 3, 10., 0.9);\n float gridNoise2 = fbm(uv + 2., 3, 600., 0.9);\n\n float tileScaleFactor = resolution.x / uTileSize.x;\n\n // float gridFactor = clamp(0., .12, drawGridLines(uv, 38.));\n float aspectRatio = resolution.x / resolution.y;\n vec2 uvNormalised = offsetUV * vec2(aspectRatio, 1.);\n\n const float gridDarkness = 0.3;\n\n float gridDivisor = 1.;\n float edgeFactor = smoothstep(0.2f, 1.f, screenEdgeDist(uvNormalised, 0.22 - (gridNoise * .06)));\n \n float gridFactor = clamp(0., gridDarkness, drawGridLines(offsetUV, .3 , 5.) * edgeFactor);\n float gridFactor2 = clamp(0., gridDarkness + 0.025, drawGridLines(offsetUV, .5 , 1.) * edgeFactor);\n \n vec3 lineCol = lineColor;\n \n lineCol.x += (step(0.6, gridNoise - gridNoise2) * 0.4);\n \n float gridTextureNoise = fbm(uv + noiseOffset, 6, 700., 0.7) * 0.5;\n vec3 lchColor = mix(backgroundColor, lineCol, clamp((gridFactor2 - gridTextureNoise) * uGridStrength, 0., 1.));\n \n float smoothNoise1 = texture(tPaperTexture, texUv + msaaOffset).x * 0.8;\n\n float colourNoise = fbm(uv + noiseOffset, 12, 5., 0.7) * 0.001;\n float colourNoise2 = fbm(uv - noiseOffset + 1., 12, 3., 0.7) * 0.001;\n\n lchColor.x += smoothNoise1 - colourNoise + colourNoise2;\n\n float edgeFactorVignette = smoothstep(0.2f, 1.f, screenEdgeDist(uvNormalised, 0.5));\n lchColor.x -= (1. - edgeFactorVignette) * 0.005;\n lchColor.y += (1. - edgeFactorVignette) * 0.005;\n // lchColor.y *= colourNoise;\n \n\n // lchColor = vec3(lchColor.x, lchColor.y, lchColor.z);\n\n vec3 colorRGB = OKLCHtoP3LRGB(lchColor);\n\n vec3 lightDir = normalize(vec3(.6f, 1.6f, 1.6f));\n vec3 lightColor = vec3(1.0f) * 1.7f;\n\n vec3 paperTextureNormals = calculateNormals(texUv + msaaOffset, 0.0002 * tileScaleFactor, 2.);\n vec3 diffuse = calculateDiffuse(paperTextureNormals, lightDir, lightColor);\n\n colorRGB *= diffuse;\n \n // float canvasTexture = fbm(uv, 6, 120., 0.7);\n return vec4(colorRGB, 1.);\n }\n\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 16.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV, vUv, d * px);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `}));var n;Vt.material=t,re(t);let i=Ht(J.choice(ve.bg)),l=Ht(J.choice(ve.line));t.uniforms.backgroundColor.value=(new e.Vector3).fromArray(i),t.uniforms.lineColor.value=(new e.Vector3).fromArray(l),t.uniforms.noiseOffset.value=new e.Vector2(We[0],We[1]),t.uniforms.uGridStrength.value=.2,X.setRenderTarget(Xt.getWriteBuffer()),Vt.render(X),Xt.copyAndSwapBuffers(),Xt.copyBufferToScreen()}],[function*(){let e=He.margin+ze.marginX,n=He.margin+ze.marginY,i=new zt(e,n),l=new zt(Y-e,P-n);(function(e,t,n=0){let i=[],l=[],a=J.weightedChoice([0,J.easedNum(ti,He.HVariance.min,He.HVariance.max)]),s=J.weightedChoice([0,J.easedNum(ti,He.VVariance.min,He.VVariance.max)]);for(let l=e.y;l<t.y;l+=ze.scale/2)J.gaussianBool(He.HVariance.threshold,He.HVariance.mean,He.HVariance.stdDev)||i.push({id:Nn(),meta:{lineCategory:be.horizontal},line:[[e.x-ze.scale*n,l+J.num(-ze.scale*a,ze.scale*a)],[t.x+ze.scale*n,l+J.num(-ze.scale*a,ze.scale*a)]]
xlbmd0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oZSxyKSkpLmZpbHRlcigoZT0+ZS5sZW5ndGg+PTIpKSx1LnB1c2goLi4uZSkscCgpfWVsc2UgdS5wdXNoKGkpLHAoKX1pZigib3V0bGluZSIhPT10JiZyLmFkZE91dGxpbmUmJiFyLmluc2V0RnJvbUdlb21ldHJ5JiZyLmJvdW5kaW5nR2VvbWV0cnkpe2xldCBlPXdlKHIpO3UucHVzaChlKX1wKCEwKX1jYXRjaChlKXtwb3N0TWVzc2FnZSh7cmVzdWx0Om51bGwsZXJyb3I6ZS5tZXNzYWdlLHdvcmtlcklkOmR9KX19fSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1zdHJlYW1saW5lcy53b3JrZXIuanMubWFwCgo=");const Li=navigator.hardwareConcurrency||4,Si=[],Xi={},Ci={},Vi=[],wi={};for(let e=0;e<Li;e++){const t=new vi;Si.push(t),wi[e]=!0,Ci[e]=[],t.onmessage=function(e){const{result:t,done:n,error:i,workerId:l}=e.data;if(t?.length>0&&Ci[l].push(...t),n||i){const e=Xi[l];if(i?e.reject(i):e.resolve(Ci[l]),delete Xi[l],wi[l]=!0,Ci[l]=[],Vi.length>0){const e=Vi.shift();e.data.workerId=l,Ki(l,e)}}}}function Ki(e,t){const n=Si[e];wi[e]=!1,Xi[e]=t,n.postMessage(t.data)}async function Ri(e){return new Promise(((t,n)=>{const i={data:e,resolve:t,reject:n};Vi.push(i),function(){for(let e=0;e<Si.length&&0!==Vi.length;e++)if(wi[e]){const t=Vi.shift();t.data.workerId=e,Ki(e,t)}}()}))}let ki=[],Ti=(e,{isInDominantPoly:t,normal:n,isOverlay:i=!1,isInCurveOrObject:l=!1})=>{const a=[{condition:i,key:Ge.overlay},{condition:!0,key:Ge.override},{condition:t,key:Ge.dominant},{condition:!t,key:Ge.nonDominant},{condition:n>Ke.default,key:Ge.normalHigh},{condition:n<Ke.default,key:Ge.normalLow},{condition:l,key:Ge.inCurveOrObject},{condition:!l,key:Ge.notInCurveOrObject}].filter((({key:t})=>e.spatialOverride?.[t]));for(const{condition:t,key:n}of a)if(t&&e.spatialOverride[n])return ge(e,e.spatialOverride[n]);return e},Mi=(e,t)=>e?.layerOverride?.[t]?ge(e,e.layerOverride[t]):e,zi=({random:e,type:t="noise",direction:n=e.num(0,360),objAABB:i,addOutline:l=!1,boundingGeometry:a,insetFromGeometry:s,insetFromGeometryDistance:c={min:2,max:4},lineWeight:d,scribble:u=!1,scribbleStrength:h=0,maxLength:m=1e10,minDistance:p=r(.2,.75*d),minLength:g=2*p,wobbleAmplitude:b=e.easedNum($n,.5,2),wobbleFreq:f=e.easedNum($n,10*d,20*d),streamLineProps:x})=>{const Z={stepSize:o(p/2,1),maxLength:m,minLength:g,insetFromGeometry:s,addOutline:l,insetFromGeometryDistance:c,minDistance:p,bounds:{topLeft:[i.minX,i.minY],bottomRight:[i.maxX,i.maxY]},postProcessingArgs:{directional:!0,scribbleStrength:u?h:0,wobbleFreq:f,wobbleAmplitude:d*b}};switch(t){case"noise":case"bnnoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:e.num(1,2)}};case"outline":return{...Z,vectorFieldType:t,boundingGeometry:a};case"directional":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldDirectionalProps:{direction:n}};case"wobbles":return{...Z,vectorFieldType:"wobbles",boundingGeometry:a,blueNoiseProps:{warpStrength:1e3,minDist:1*p,maxDist:1.5*p},wobbleProps:{tension:{min:.5,max:3},maxPointUse:1,maxDivergence:4,maxLinePoints:30}};case"bluenoise":return{...Z,vectorFieldType:t,boundingGeometry:a,vectorFieldNoiseProps:{...x,wobbleDetail:1},blueNoiseProps:{warpStrength:100,minDist:p+d,maxDist:4*(p+d)}};case"edgefill":return{...Z,vectorFieldType:t,boundingGeometry:a,blueNoiseProps:{warpStrength:100,minDist:2*(p+d),maxDist:2.2*(p+d)}}}},Yi=(e,t,n=[],i)=>{if(n.length){let e=n[0],t=i.int(0,e.verts.length-1),l=(t+1)%e.verts.length;return new zt(...e.verts[t]).angleTo(new zt(...e.verts[l]))}let l=Zl.getLinesIntersectingFace(e,!1),a=e.center,s=new Set([...t].map((e=>e.meta.lineCategory))),o=[be.horizontal,be.vertical,be.perspective,be.objects].filter((e=>!s.has(e))),r=l.filter((e=>!t.has(e.constructionLine)&&o.some((t=>t==e.constructionLine.meta.lineCategory))));if(r.length){let e=r.reduce(((e,t)=>fn(a.toArray(),e.constructionLine.line)<fn(a.toArray(),t.constructionLine.line)?e:t),r[0]);t.add(e.constructionLine);let n=e.constructionLine.line.map((e=>new zt(...e)));return n[0].angleTo(n[n.length-1])}},Pi=(e,t)=>{let{fade:n,scale:i}=e;return{fade:{in:{enabled:t.bool(n.in.enabledChance),length:t.num(n.in.min,n.in.max)},out:{enabled:t.bool(n.out.enabledChance),length:t.num(n.out.min,n.out.max)}},scale:{in:{enabled:t.bool(i.in.enabledChance),length:t.num(i.in.min,i.in.max)},out:{enabled:t.bool(i.out.enabledChance),length:t.num(i.out.min,i.out.max)}}}};async function Ii(e,t){let{colorOverride:n}=e?.detailObjectProps||{};const i=new A(e?.detailObjectProps?.noiseSeedOverride||t),l=new nn;l.expands(e.polygon),l.expandByValue(10);const a=e.faceRef?.center||l.center,s=e?.detailObjectProps?.inDominantShapes||[],o=e?.detailObjectProps?.inObject||[],d=s.length>0,u=!!e?.isInCurve,h=!!e?.detailObjectProps?.inObject?.length,m=e?.detailObjectProps?.isFineDetail,p=Rt(e.lightingIntensity||Ke.default,Ke.clamp),{skipFill:g,skipDetails:b}=e.detailObjectProps||{};let f=Ti(Pe,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==sn.overlay,isInCurveOrObject:h||u}),x=Ti(Ye,{isInDominantPoly:m||d,normal:p,isOverlay:e.category==sn.overlay,isInCurveOrObject:h||u});const Z=!g&&i.bool(f.fillChance),y=!b&&i.bool(x.fillChance),G=i.bool(f.insetChance),W=i.bool(x.insetChance),v=Z?i.weightedChoice(...f.layerCountChances):0,L=u?0:y?i.weightedChoice(...x.layerCountChances):0;let S=new Set,X=new Set,C=new Set,V=[],w=[],K=!1;function R(t,i,c){const h=[];for(let g=0;g<c;g++){const c=Mi("fill"===i?f:x,g);let b,Z=t.num(c.lineWeight.min,c.lineWeight.max),y=t.num(c.linePressure.min,c.linePressure.max);b=r(.4,Z*t.num(c.minDistanceMult.min,c.minDistanceMult.max)),m&&"detail"===i&&(Z*=.75,b*=.25);const v="fill"===i?ki.filter((e=>!S.has(e))):ki.filter((e=>!X.has(e)));let L,R=t.choice(v);v.length||("fill"===i?S.clear():X.clear(),R=t.choice(ki)),"fill"===i?S.add(R):X.add(R),d&&("fill"===i&&G||"detail"===i&&W)&&(L=u?e.isInCurve.line:s[0].face.vertexlist.map((e=>e.toArray())));let k=c.colorMap[g]||c.colorMap[0],T=t.weightedChoice(...k),M=hi(t,T,a,p,c.colorPalette,"fill"==i?V:w),z=null;if(t.bool(c.fadeAtLineSegmentChance)){let n,i,a=t.int(0,l.vertexList.length-1),s=[l.vertexList[a],l.vertexList[(a+1)%l.vertexList.length]],o=s[0].lerp(s[1],t.num(.01,.99));for(let t=0;t<e.polygon.length;t++){let n=[e.polygon[t],e.polygon[(t+1)%e.polygon.length]],l=xn(o.toArray(),n[0].toArray(),n[1].toArray());(!i||l<i.dist)&&(i={seg:n,dist:l})}n=i.seg;const{fadeAtLineSegmentDistanceMult:r,fadeAtLineSegmentStrengthMult:d}=c;let u=l.center.distanceTo(n[0].lerp(n[1],.5));z={segment:n,distance:2*u*t.num(r.min,r.max),strength:t.num(d.min,d.max)}}let Y=t.weightedChoice(...c.styleChances),P=0;"directional"===Y&&(P=Yi(e.faceRef,C,o,t));let I,H,F="fill"==i&&u&&(K||0==g&&t.bool(Ue.renderLightChance));K=F,"fill"===i?(n?M=n:F&&(M=hi(t,ye.lightestOrDarkestBasedOnBg,a,p,c.colorPalette,V)),V.push(M)):"detail"==i&&w.push(M);const N=t.bool(c.ignoreLightingChance);I=!(u&&Ue.ignoreLighting||N),H=!!(u&&Ue.ignoreLighting||N),h.push({paintLineObj:{colorLayerType:T,lineBrightness:I?Tt(p,Ke.min,Ke.max,wt(Ke.default,Ke.min,Ke.influencesBrightnessMult),wt(Ke.default,Ke.max,Ke.influencesBrightnessMult)):Ke.default,type:i,lines:[],closedPolyOrLine:!1,noiseOffset:[t.num(-1,1),t.num(-1,1)],canBulge:!0,isShading:!0,canWarp:!0,fadeAtLineSegment:z,lineTapering:Pi("bluenoise"==Y&&"detail"==i?{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:0,min:4,max:6}},scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}}}:c.lineTapering,t),disableSaturationShift:H,linePressure:y*Tt(p,Ke.max,Ke.min,Tt(Ke.influencesPressureMult,1,0,.5,1),1),edgeSharpness:t.num(c.edgeSharpness.min,c.edgeSharpness.max),accumulationStrength:t.num(c.accumulationStrength.min,c.accumulationStrength.max),materialHardness:t.num(c.materialHardness.min,c.materialHardness.max),lineWeight:.8*Z,lineColor:M},workerData:{streamlineWorkerProps:zi({type:Y,direction:P,addOutline:"edgefill"==Y,scribble:d?!u&&t.bool(c.scribbleChance):t.bool(c.scribbleChance),scribbleStrength:t.num(c.scribbleStrength.min,c.scribbleStrength.max),random:t,insetFromGeometry:L,insetFromGeometryDistance:{min:c.insetDistance.min,max:c.insetDistance.max},objAABB:l,boundingGeometry:e.polygon.map((e=>e.toArray())),lineWeight:Z,minDistance:"bluenoise"==Y&&"detail"==i?.4*b:r(.4,"fill"==i?b*Kt(p,Ke.max,Ke.min,Kt(Ke.influencesMinDistanceMult,1,0,1,1),Kt(Ke.influencesMinDistanceMult,0,1,1,.5)):b),maxLength:c.maxLength?t.num(c.maxLength.min,c.maxLength.max):1e10,wobbleAmplitude:t.easedNum($n,c.wobbleAmplitude.min,c.wobbleAmplitude.max),wobbleFreq:t.easedNum($n,c.wobbleFreq.min,c.wobbleFreq.max),streamLineProps:{...R,wobbleDetail:t.int(1,2)}}),noiseSeed:un,randomSeed:E(t)}})}return h}const k=[...R(i,"fill",v),...R(i,"detail",L)],T=k.map((e=>Ri(e.workerData))),M=await Promise.all(T);e.allowExtraDetails=!1,k.filter((e=>"detail"==e.paintLineObj.type)).length>=2&&k.filter((e=>"detail"==e.paintLineObj.type)).every((e=>"directional"==e.workerData.streamlineWorkerProps.vectorFieldType))&&(e.allowExtraDetails=!0);for(let t=0;t<M.length;t++){const n=[],i=M[t],l=k[t].paintLineObj;"detail"==l.type&&"bluenoise"==k[t].workerData.streamlineWorkerProps.vectorFieldType&&(l.lineWeight*=1.5);for(let e of i){const t=e;t.length&&n.push(t)}n.length<1||(l.lines=n,e.detailObject=e.detailObject||[],e.detailObject.push(l))}if(e?.detailObject?.length){let t=[];for(let n=e.detailObject.length-1;n>0;n--){let i=e.detailObject[n-1],l=e.detailObject[n];l.colorLayerType===ye.previous&&i?.lines?.length&&l?.lines?.length&&(i.lines=[...i.lines,...l.lines],t.push(l))}t.length>0&&(e.detailObject=e.detailObject.filter((e=>!t.includes(e))))}e.allowExtraDetails&&e?.detailObject?.length&&!m&&i.bool(d?80:40)&&async function(e,t){let n=[...Wl,...an].filter((e=>e.category==sn.overlay));for(let t of n){let n=new nn;if(n.expands(t.polygon),e.faceRef.aabb.intersects(n))return}let i=e.detailObject.filter((e=>"detail"==e.type));const l=new nn;l.expands(e.polygon),l.expandByValue(10);const a=e.faceRef?.center||l.center;let s=new Ln([],[]);s.insertPolygon(e.polygon.map((e=>e.toArray())),!0);for(let e=0;e<i.length;e++){let t=i[e];for(let e of t.lines)s.insertPolygon(e,!1),await new Promise((e=>setTimeout(e,0)))}s.cleanupTrailingEdges();let o=s.internalFaces(),r=c(mn(a.x,a.y,100,5,40,100)),d=mn(a.x,a.y,600,0,100)>60;if(o.length>2)for(let n of o.filter((e=>e.area>100)))if(n.hedges.every((e=>e.face&&e.twin.face&&e.face!==e.twin.face))&&t.bool(r)){let i=t.num(.35,.45),l=n.vertexlist.map((e=>e.addPolar(e.angleTo(n.center),e.distanceTo(n.center)*i))),a={category:sn.detail,faceRef:n,polygon:l,detailObject:[],detailObjectProps:{isFineDetail:!0,skipDetails:!d,skipFill:!!d,inObject:e.detailObjectProps?.inObject,inDominantShapes:e.detailObjectProps?.inDominantShapes,noiseSeedOverride:E(t)}};Wl.push(a)}}(e,i),e.readyForRender=!0}let Hi,Fi,Ni=new Set;function Ui(e){let t,n=0;for(;!t&&n++<200;){let n=J.choice(e.internalFaces()),i=J.choice(n.vertexlist);Ni.has(i)||(t=i)}return t}class Di{dcel;maxAngle;pathVerts=[];AABB=new nn;constructor(e,t=.3){this.dcel=e,this.maxAngle=t}*findDominantPaths(e=!1){let t=new Set(this.dcel.hedges.filter((e=>e.face&&e.face.area>0&&e.twin.face&&e.twin.face.area>0&&e.origin!==e.twin.origin&&e.face!==e.twin.face)));for(;t.size>0;){let n=t.values().next().value;t.delete(n),t.delete(n.twin);let i=[n.twin.origin],l=[n.origin],a=new Set;a.add(n.origin),a.add(n.twin.origin);let o=0;for(let r of[n,n.twin]){let c=r.twin.origin,d=r===n?i:l,u=r.origin,h=u.angleTo(c);for(;;){const n=c.hedgelist.filter((t=>(!e||t.twin.face&&t.twin.face.area>0)&&t.face&&t.face.area>0&&!a.has(t.twin.origin)&&s(c.angleTo(t.twin.origin)-h)<this.maxAngle)).sort(((e,t)=>s(c.angleTo(e.twin.origin)-h)-s(c.angleTo(t.twin.origin)-h)));if(!n.length)break;let i=n[0];o+=s(c.angleTo(i.twin.origin)-h),t.delete(i),t.delete(i.twin),u=c,c=i.twin.origin,d.push(c),a.add(c),h=u.angleTo(c)}}l.reverse();let r=l.concat(i),c=r.reduce(((e,t,n)=>0===n?0:e+t.distanceTo(r[n-1])),0);yield{vertices:r,length:c,curviness:o/r.length}}}walk(e,t,n=!0){let i=e;if(!i)return;let l=0,a=0;this.AABB.expand(i);let s=new Set;for(s.add(i),Ni.add(i);l<=t&&a++<400;){const e=i.hedgelist.filter((e=>!s.has(e.twin.origin)&&!Ni.has(e.twin.origin)));if(e.sort(((e,t)=>{let n=e.twin.origin,i=t.twin.origin,l=this.AABB.center.distanceTo(n);return this.AABB.center.distanceTo(i)-l})),0===e.length)break;let a=e[0].twin.origin;if(l+=i.distanceTo(a),n&&l>t){let e=(o=i,r=a,c=1-(l-t)/i.distanceTo(a),new zt(wt(o.x,r.x,c),wt(o.y,r.y,c)));s.add(e),this.AABB.expand(e);break}s.add(a),Ni.add(a),this.AABB.expand(a),i=a}var o,r,c;this.pathVerts.push(...Array.from(s))}}class Oi{heap;maxSize;valueFunction;epsilon=b;constructor(e,t){this.valueFunction=t,this.heap=[],this.maxSize=e}size(){return this.heap.length}push(e){this.heap.push(e),this.siftUp(this.heap.length-1),this.heap.length>this.maxSize&&this.heap.pop()}clear(){this.heap=[]}peek(){return this.heap[0]}remove(e){const t=this.heap.findIndex((t=>t===e));-1!==t&&(this.heap[t]=this.heap[this.heap.length-1],this.heap.pop(),t<this.heap.length&&this.siftDown(t))}replaceTop(e){this.heap[0]=e,this.siftDown(0)}toArray(){return[...this.heap]}siftUp(e){for(;e>0;){const t=Math.floor((e-1)/2),n=this.valueFunction(this.heap[e])-this.valueFunction(this.heap[t]);if(n<this.epsilon&&n>-this.epsilon)break;if(n<=0)break;[this.heap[e],this.heap[t]]=[this.heap[t],this.heap[e]],e=t}}siftDown(e){const t=this.heap.length;for(;;){let n=e;const i=2*e+1,l=2*e+2,a=this.valueFunction(this.heap[n]);if(i<t&&this.valueFunction(this.heap[i])-a>this.epsilon&&(n=i),l<t){const e=this.valueFunction(this.heap[n]);this.valueFunction(this.heap[l])-e>this.epsilon&&(n=l)}if(n===e)break;[this.heap[e],this.heap[n]]=[this.heap[n],this.heap[e]],e=n}}}class Bi{position;rotation;dimensions;numSides;cameraPos;fov;aspect;near;far;lights;cullBackfaces;localVertices=[];worldVertices=[];screenVertices=[];constructor(e,t,n,i,l,a=90,s=Y/P,o=.1,r=1e4,c=[],d=!1){this.position=e,this.rotation=t,this.dimensions=n,this.numSides=i,this.cameraPos=l,this.fov=a,this.aspect=s,this.near=o,this.far=r,this.lights=c,this.cullBackfaces=d,this._buildLocalGeometry()}_buildLocalGeometry(){const{width:e,height:t,depth:n}=this.dimensions,i=e/2,l=t/2,a=n/2,s=2*Math.PI/this.numSides,o=this.numSides%2==0?-Math.PI/this.numSides:-Math.PI/2;if(0===n)for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t)*i,a=Math.sin(t)*l;this.localVertices.push({x:n,y:a,z:0})}else for(let e=0;e<this.numSides;e++){const t=o+s*e,n=Math.cos(t),r=Math.sin(t);this.localVertices.push({x:n*i,y:r*l,z:+a}),this.localVertices.push({x:n*i,y:r*l,z:-a})}}getFaces2D(){const e=function(e,t,n,i,l,a){const s=Ji(e*Math.PI/180),o=ji(t*Math.PI/180),r=Ai(n*Math.PI/180),c=Ei(i,l,a),d=_i(r,_i(o,s));return _i(c,d)}(this.rotation.x,this.rotation.y,this.rotation.z,this.position.x,this.position.y,this.position.z),t=Ei(-this.cameraPos.x,-this.cameraPos.y,-this.cameraPos.z),n=_i(function(e,t,n,i){const l=1/Math.tan(e*Math.PI/180/2),a=1/(n-i);return[[l/t,0,0,0],[0,l,0,0],[0,0,(n+i)*a,n*i*a*2],[0,0,-1,0]]}(this.fov,this.aspect,this.near,this.far),_i(t,e));this.worldVertices=[],this.screenVertices=[];for(const t of this.localVertices){const i=qi(e,[t.x,t.y,t.z,1]);this.worldVertices.push({x:i[0],y:i[1],z:i[2]});const l=qi(n,[t.x,t.y,t.z,1]);0!==l[3]&&(l[0]/=l[3],l[1]/=l[3],l[2]/=l[3]);const a=(.5*l[0]+.5)*Y,s=(1-(.5*l[1]+.5))*P;this.screenVertices.push([a,s])}const i=this._buildFaces(),l=this.cameraPos.x,a=this.cameraPos.y,s=this.cameraPos.z,o=[];for(let e of i){const t=e.indices.map((e=>this.worldVertices[e])),n=e.indices.map((e=>this.screenVertices[e])),i=$i(t),r=el(t),c=tl(i,r,this.lights);if(this.cullBackfaces){const e={x:r.x-l,y:r.y-a,z:r.z-s};i[0]*e.x+i[1]*e.y+i[2]*e.z<0&&o.push({vertices:n,normal:i,lighting:c})}else o.push({vertices:n,normal:i,lighting:c})}return o}_buildFaces(){const e=[],t=this.numSides;if(0!==this.dimensions.depth){const n=[];for(let e=0;e<t;e++)n.push(2*e);e.push({indices:n});const i=[];for(let e=t-1;e>=0;e--)i.push(2*e+1);e.push({indices:i});for(let n=0;n<t;n++){const i=(n+1)%t,l=[2*n,2*n+1,2*i+1,2*i];e.push({indices:l})}}else e.push({indices:Array.from({length:t},((e,t)=>t))});return e}}class Qi{vertices;rotation;perspective;zShift;transformOrigin;projectedVertices;vertices3D;constructor(e,t,n=800,i=-50,l={x:Y/2,y:P/2}){this.vertices=e,this.rotation=t,this.perspective=n,this.zShift=i,this.transformOrigin=l}getLineSegments(){let e=new nn;for(let t of this.vertices)e.expands(t.map((e=>new zt(...e))));const{x:t,y:n,z:i}={...e.center,z:this.zShift},{x:l,y:a,z:s}=this.rotation,o=this.perspective,r=e.center,c=this.vertices.map((e=>e.map((e=>new zt(...e).subtract(r)))));this.vertices3D=[];for(let e=0;e<c.length;e++){this.vertices3D.push([]);for(const t of c[e])this.vertices3D[e].push({x:t.x,y:t.y,z:0})}const d=function(e,t,n,i,l,a){const s=t*Math.PI/180,o=n*Math.PI/180,r=Ji(e*Math.PI/180),c=ji(s);let d=_i(Ai(o),_i(c,r));return _i(Ei(i,l,a),d)}(l,a,s,t,n,i),u=this.vertices3D.map((e=>e.map((e=>{const t=[e.x,e.y,e.z,1],n=qi(d,t);return{x:n[0],y:n[1],z:n[2]}}))));return this.projectedVertices=u.map((e=>e.map((e=>function(e,t,n={x:Y/2,y:P/2}){const{x:i,y:l,z:a}=e,s=i-n.x,o=(l-n.y)*t/(t+a);return t+a<=0?null:[s*t/(t+a)+n.x,o+n.y]}(e,o,this.transformOrigin))).filter((e=>null!==e)))).map((e=>e.filter((e=>e[0]>=-100&&e[0]<=Y+100&&e[1]>=-100&&e[1]<=P+100)))).filter((e=>e.length>0)),this.projectedVertices}}function Ji(e){const t=Math.cos(e),n=Math.sin(e);return[[1,0,0,0],[0,t,-n,0],[0,n,t,0],[0,0,0,1]]}function ji(e){const t=Math.cos(e),n=Math.sin(e);return[[t,0,n,0],[0,1,0,0],[-n,0,t,0],[0,0,0,1]]}function Ai(e){const t=Math.cos(e),n=Math.sin(e);return[[t,-n,0,0],[n,t,0,0],[0,0,1,0],[0,0,0,1]]}function Ei(e,t,n=0){return[[1,0,0,e],[0,1,0,t],[0,0,1,n],[0,0,0,1]]}function _i(e,t){const n=Array.from(Array(e.length),(()=>Array(t[0].length).fill(0)));for(let i=0;i<e.length;i++)for(let l=0;l<t[0].length;l++)for(let a=0;a<e[0].length;a++)n[i][l]+=e[i][a]*t[a][l];return n}function qi(e,t){const n=[];for(let i=0;i<e.length;i++){let l=0;for(let n=0;n<t.length;n++)l+=e[i][n]*t[n];n.push(l)}return n}function $i(e){const t=e[0],n=e[1],i=e[2],l=[n.x-t.x,n.y-t.y,n.z-t.z],a=[i.x-t.x,i.y-t.y,i.z-t.z],s=[l[1]*a[2]-l[2]*a[1],l[2]*a[0]-l[0]*a[2],l[0]*a[1]-l[1]*a[0]],o=Math.sqrt(s[0]**2+s[1]**2+s[2]**2);return s.map((e=>e/o))}function el(e){const t=e.reduce(((e,t)=>(e.x+=t.x,e.y+=t.y,e.z+=t.z,e)),{x:0,y:0,z:0}),n=e.length;return{x:t.x/n,y:t.y/n,z:t.z/n}}function tl(e,t,n){let i=0;for(const l of n){const n={x:l.position.x-t.x,y:l.position.y-t.y,z:l.position.z-t.z},a=Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z);if(0===a)continue;const s=n.x/a,o=n.y/a,r=n.z/a;i+=(e[0]*s+e[1]*o+e[2]*r)*l.brightness}return i}let nl=!1,il=0,ll=0;T();let al=T();const sl=()=>{if(!Vl[il])return void rl();const e=Vl[il][0](),t=Vl[il][1]||!1;let n,i=!1;const l=()=>{n=e.next(),$l?i=!1:(i=!0,n?.done||function(e){nl||(Hi=K.getParameter(K.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),Fi=K.SYNC_FLUSH_COMMANDS_BIT,nl=!0);const t=K.fenceSync(K.SYNC_GPU_COMMANDS_COMPLETE,0);!function n(){const i=K.clientWaitSync(t,Fi,Hi);i===K.ALREADY_SIGNALED||i===K.CONDITION_SATISFIED||$l?(clearTimeout(void 0),K.deleteSync(t),e()):setTimeout(n,0)}()}(l))},a=()=>{const s=T();if(t)!i&&!$l&&l();else for(;T()-s<1e3/30&&!$l&&!n?.done;)n=e.next();ll++,n?.done?(ol("Step took"),Xt?.copyBufferToScreen(),i=!1,n=null,il++,sl()):(v(n.value||{showUpdate:!1}),setTimeout(a,0))};a()};function ol(e="",t=!1){T(),al=T()}const rl=()=>{document.complete=!0,An(mi([...oi][0],[...oi],oi.size)),ol("Total render time",!0),function(){for(let e=0;e<Si.length;e++){const t=Si[e];t&&t.terminate()}}()};function cl(e,t,n=4){const i=t/2,l=[];for(let t=0;t<e.length-1;t++){const[n,i]=e[t],[a,s]=e[t+1],o=a-n,r=s-i,c=Math.hypot(o,r);if(0===c){l.push([0,0]);continue}const d=-r/c,u=o/c;l.push([d,u])}const a=[],s=[];for(let t=0;t<e.length;t++){const[o,r]=e[t];if(0===t){const[e,t]=l[0],n=e*i,c=t*i;a.push([o+n,r+c]),s.push([o-n,r-c])}else if(t===e.length-1){const[e,t]=l[l.length-1],n=e*i,c=t*i;a.push([o+n,r+c]),s.push([o-n,r-c])}else{const[e,c]=l[t-1],[d,u]=l[t],h=Math.sqrt((e*d+c*u+1)/2);if(0===h){const t=e*i,n=c*i;a.push([o+t,r+n]),s.push([o-t,r-n]);continue}const m=i/h;if(m>n*i){const[t,n]=[e*i,c*i],[l,h]=[d*i,u*i];a.push([o+t,r+n]),a.push([o+l,r+h]),s.push([o-t,r-n]),s.push([o-l,r-h])}else{const[t,n]=[e+d,c+u],l=Math.hypot(t,n);if(0===l){const t=e*i,n=c*i;a.push([o+t,r+n]),s.push([o-t,r-n])}else{const[e,i]=[t/l,n/l],c=e*m,d=i*m;a.push([o+c,r+d]),s.push([o-c,r-d])}}}}return[...a.reverse(),...s]}class dl{root=null;epsilon=b;count=0;wasRemoved=!1;insert(e){this.root=this.insertRec(this.root,e,0),this.count++}compareCoord
l7bGV0IGE9ZSxjPTAsZD0wO2Zvcig7YzxuOyl7Y29uc3QgZT10KGEpO2lmKGVbMF0qZVswXStlWzFdKmVbMV08cCpwKWJyZWFrO2NvbnN0IG49W2FbMF0raCppKmVbMF0sYVsxXStoKmkqZVsxXV07aWYoIXJlKG4sbCl8fCFzLmlzVmFsaWRJbnNlcnRpb25Qb2ludChuKXx8cy5pc05lYXJPdGhlclN0cmVhbWxpbmVzKG4scixvKSlicmVhaztjb25zdCBnPXtzdGFydDphLGVuZDpuLHN0cmVhbWxpbmVJZDpyLHNlZ21lbnRJbmRleDpkfTtzLmFkZFNlZ21lbnQoZyksYT1uLGMrPWksZCsrLHlpZWxke3BvaW50OmEsZGlyZWN0aW9uOmh9fX1mdW5jdGlvbipsZShlLHQsaSl7Y29uc3Qgbj1lW3RdLFtzLHJdPWZ1bmN0aW9uKGUsdCxpPXApe2lmKHQ+MCYmdDxlLmxlbmd0aC0xKXtjb25zdCBuPWVbdC0xXSxzPWVbdCsxXSxyPXNbMF0tblswXSxvPXNbMV0tblsxXSxsPU1hdGguaHlwb3QocixvKTtpZihsPGkpcmV0dXJuW1swLDBdLFswLDBdXTtjb25zdCBoPVstby9sLHIvbF0sYT1bby9sLC1yL2xdLGM9aFswXSpoWzBdK2hbMV0qaFsxXSxkPWFbMF0qYVswXSthWzFdKmFbMV07cmV0dXJuIGM8aSppJiYoaFswXT0wLGhbMV09MCksZDxpKmkmJihhWzBdPTAsYVsxXT0wKSxbaCxhXX1yZXR1cm5bWzAsMF0sWzAsMF1dfShlLHQscCk7aWYoMD09PXNbMF0mJjA9PT1zWzFdfHwwPT09clswXSYmMD09PXJbMV0pcmV0dXJu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m90dG9tUmlnaHRbMF0rcCYmZVsxXT49dC50b3BMZWZ0WzFdLXAmJmVbMV08PXQuYm90dG9tUmlnaHRbMV0rcH1mdW5jdGlvbipvZShlLHQsaSxuLHMscixvLGwsaC
ex,cellIndices:n}),n}doesLineFullyIntersectFace(e,t){const n=this.lines.get(e),i=this.lineMeta.get(e);if(!n||!i)return!1;const l=t.hedges.map((e=>{let t=new nn;return t.expands([e.origin,e.nexthedge.origin]),{aabb:t,edge:e}})),a=[],s=i.isClosed?n.length:n.length-1;for(let e=0;e<s;e++){const t=new zt(...n[e]),i=new zt(...n[(e+1)%n.length]),s=i.x-t.x,o=i.y-t.y,r=s*s+o*o;let c=new nn;c.expands([t,i]);for(const{aabb:n,edge:d}of l){if(!n.intersects(c))continue;const l=d.intersectWithLineSegment([t,i]);if(l?.type===gn.intersecting&&l.point){const n=((l.point.x-t.x)*s+(l.point.y-t.y)*o)/r;a.push(e+n)}}}a.sort(((e,t)=>e-t));const o=a.filter(((e,t)=>0===t||Math.abs(e-a[t-1])>b));if(o.length<2)return!1;const r=new zt(...n[0]);let c=t.containsPoint(r)&&!t.isPointOnBoundary(r);for(let e=0;e<o.length-1;e++){c=!c;const i=o[e],l=o[e+1];if(i<b||l>s-b)continue;if(!c)continue;const a=(i+l)/2,r=Math.floor(a)%n.length,d=a-Math.floor(a),u=new zt(...n[r]),h=new zt(...n[(r+1)%n.length]),m=new zt(u.x+(h.x-u.x)*d,u.y+(h.y-u.y)*d);if(t.containsPoint(m)&&!t.isPointOnBoundary(m))return!0}return!1}linesIntersectingAABB(e){const t=this.aabbLineIntersectionCache.get(e);if(t)return t;const n=new Set,i=f(e.minX/this.cellSize),l=f(e.maxX/this.cellSize),a=f(e.minY/this.cellSize),s=f(e.maxY/this.cellSize);for(let e=i;e<=l;e++)for(let t=a;t<=s;t++){const i=this.getCellIndex(e,t);this.cells.has(i)&&this.cells.get(i).forEach((e=>n.add(e)))}const o=[...n].map((e=>({constructionLine:{id:e,line:this.lines.get(e),meta:this.lineMeta.get(e)},intersectionType:Qn.intersecting})));return this.aabbLineIntersectionCache.set(e,o),o}getLinesIntersectingFace(e,t=!0){const n=this.getCellsIntersectedByFace(e),i=new Set;for(const e of n){const t=this.cells.get(e);if(t)for(const e of t)i.add(e)}let l=Array.from(i);return t&&(l=l.filter((t=>this.doesLineFullyIntersectFace(t,e)))),l.map((e=>({constructionLine:{id:e,line:this.lines.get(e),meta:this.lineMeta.get(e)},intersectionType:Qn.intersecting})))}getGridDistanceField(e=0,t=0){let{cellSize:n}=this;const i=new Set,l=new Set,a=[];let s=f(t/n),o=f((Y-2*t)/n),r=f(t/n),c=f((P-2*t)/n);for(let t=s;t<=o;t++)for(let n=r;n<=c;n++){const l=this.getCellIndex(t,n);(!this.cells.has(l)||this.cells.get(l)?.size<=e)&&i.add(l)}const d=(e,t)=>{const n=[e];for(;n.length>0;){const e=n.pop();if(!e||l.has(e)||!i.has(e))continue;l.add(e);const[a,s]=this.getCellXYfromIndex(e);t.indices.push(e);const o=[this.getCellIndex(a-1,s),this.getCellIndex(a+1,s),this.getCellIndex(a,s-1),this.getCellIndex(a,s+1)];for(const e of o)!l.has(e)&&i.has(e)&&n.push(e)}};i.forEach((e=>{if(!l.has(e)){const t={vertices:[],indices:[]};d(e,t),t.indices.length>1&&a.push(t)}}));let u=this.distanceCalculator||new Bn(s,r,o,c);return u.initializeWithEmptyCells(i,this.getCellXYfromIndex.bind(this)),a.map((e=>{const t=new nn;let n=[];e.indices.forEach((e=>{const[t,i]=this.getCellXYfromIndex(e),l=u.getDistance(t,i);n.push([l,this.getCellVertexFromIndex(e)])}));let i=n.reduce(((e,t)=>e[0]>t[0]?e:t));return t.expands(n.map((([,e])=>e))),{aabb:t,cellCount:e.indices.length,maxDistance:i[0],cellsByDistance:n,indices:e.indices.map((e=>this.getCellVertexFromIndex(e)))}}))}}function jn(e){const[t,n,i]=e;return`oklch(${(100*(t||0)).toFixed(2)}% ${(n||0).toFixed(2)} ${(i||0).toFixed(2)})`}function An(e){e.forEach((e=>{const[t,n,i]=e;jn(e)}))}function En(e){const n=e.slice();for(let e=n.length-1;e>0;e--){const i=t(J.dec()*(e+1));[n[e],n[i]]=[n[i],n[e]]}return n}function _n(e,t="right"){const n=e.slice();if("right"===t){const e=n.pop();void 0!==e&&n.unshift(e)}else if("left"===t){const e=n.shift();void 0!==e&&n.push(e)}return n}const qn=e=>e,$n=e=>1-l(e*g/2),ei=e=>-(l(g*e)-1)/2,ti=e=>e<.5?(1-d(1-a(2*e,2)))/2:(d(1-a(-2*e+2,2))+1)/2;let ni={};const ii=(e,t=5,n=0,i=qn,l=[])=>{const a=`${e}-${n}-${t}`;if(ni[a]?.min)return ni[a];let s=0,o=-1/0,r=1/0,c=0,d=[],u=(t,l)=>{let a=i(mn(t,l,n,e));s+=a,c+=1,a>o&&(o=a),a<r&&(r=a),d.push(a)};if(l.length)for(let e of l)u(e.x,e.y);else for(let e=0;e<20*ze.countX;e+=ze.w/20)for(let t=0;t<20*ze.countY;t+=ze.h/20)u(e,t);let h={max:o,min:r,mean:s/c,indexValues:[],mostCommonIndex:0,leastCommonIndex:0};return d.map((e=>{let n=f(Tt(e,h.min,h.max,0,t-1));h.indexValues[n]=h.indexValues[n]?h.indexValues[n]+1:1})),h.mostCommonIndex=h.indexValues.reduce(((e,t,n)=>t>h.indexValues[e]?n:e),0),h.leastCommonIndex=h.indexValues.reduce(((e,t,n)=>t<h.indexValues[e]?n:e),0),ni[a]=h,h};let li=[],ai=[],si=[],oi=new Set,ri={L:1,C:1,H:2/Math.PI},ci=30,di=ei;function ui(e,t,n=ri){e=Nt(e),t=Nt(t);const{L:i,C:l,H:a}=n,s=e[0]-t[0],o=e[1]-t[1];let r=e[2]-t[2];r=(r+180)%360-180;const c=r*Math.PI/180;return Math.sqrt(s*s*i+o*o*l+c*c*a)}function hi(e,t,n,i=1,l="fg",a=[]){let s,o=t,r=ve.bg[0][0]>=.5,c=a?.[0];if(o==ye.previous)return c;if(o==ye.brightnessBasedShadowOrHighlight){let t,a=c||Gi(e,n,i,null,l),s=i>=wt(Ke.max,Ke.min,.5),o=.2;if(a[0]>.75&&!s&&(o=.02),s){let e=bi(a,si,o);t=[wt(a[0]+o,e[0],.5),e[1],e[2]]}else{let e=bi(a,si,-o);t=[wt(a[0]+-o,e[0],.5),e[1],e[2]]}return Nt(t)}ye.lightestOrDarkestBasedOnBg==o&&(o=r?ye.lightest:ye.darkest);let d=c||Gi(e,n,i,null,l),u=d[0]>.7&&d[1]<.05;switch(o){case ye.color:s=Gi(e,n,i,null,l);break;case ye.randomAccent:s=e.choice(li);break;case ye.base:s=ve.base[0];break;case ye.line:s=ve.line.reduce(((e,t)=>r?e[0]<t[0]?e:t:e[0]>t[0]?e:t),ve.line[0]);break;case ye.shadow:let t=c||Gi(e,n,i,null,l);s=gi([.3*t[0],t[1],t[2]],si,0)[0];break;case ye.highlight:let a=c||Gi(e,n,i,null,l);s=gi([kt(0,1,1.5*a[0]),a[1],a[2]],si,0)[0];break;case ye.offset:s=u?d:gi(c||d,si,ci*e.choice([-1,1]),1)[0];break;case ye.offsetUp:s=u?d:gi(c||d,si,ci,1)[0];break;case ye.palettecomplement:s=gi(c||d,li,180)[0];break;case ye.offsetDown:s=u?d:gi(c||d,si,ci,-1)[0];break;case ye.darkest:s=li.reduce(((e,t)=>e[0]<t[0]?e:t),li[0]);break;case ye.lightest:s=li.reduce(((e,t)=>e[0]>t[0]?e:t),li[0])}return oi.add(s),s}function mi(e,t,n=0){if(0===t.length)throw Error("Palette is empty.");const i=t.map((t=>({color:t,dist:ui(e,t)})));return i.sort(((e,t)=>e.dist-t.dist)),i.slice(0,n).map((e=>e.color))}function pi(e,t){let n=e.leastCommonIndex,i=e.mostCommonIndex,l=t.reduce(((e,t)=>e[0]<t[0]?e:t),t[0]),a=t.reduce(((e,t)=>e[0]>t[0]?e:t),t[0]);const s=(t.indexOf(l)-n+t.length)%t.length;let o=t.slice(s).concat(t.slice(0,s));if(o.indexOf(a)===i){const e=[];for(let t=0;t<o.length;t++)t!==i&&t!==n&&e.push(t);if(e.length>0){const t=J.choice(e);[o[i],o[t]]=[o[t],o[i]]}}return o}function gi(e,t,n=20,i=1){return mi([e[0],e[1],Ft(e[2]+n)],t.filter((e=>e)),i)}function bi(e,t,n=1){const i=[kt(0,1,e[0]+n),e[1],e[2]];let l;for(let e of t){let t=ui(i,e,ri);(!l||t<l.dist)&&(l={color:e,dist:t})}return l.color}let fi,xi,Zi=new Map,yi=new Set;function Gi(e,t,n=1,i=null,l="fg",a=null){let{freqMultiplier:o,singleAccent:r,usePolyIDColorOffset:d}=Oe,u=0,h="fg"==l?li:ai,m="fg"==l?fi:xi,p="fg"==l?o:500*o,g="bg"==l?Tt(t.y,0,P,0,h.length-1):Tt(di(mn(t.x,t.y,0,p,0,1)),m.min,m.max,0,h.length-1);if(d){let n=Xl.getPolygonsAtPoint(t.toArray()).filter((e=>yi.has(e.meta.meta.id))).sort(((e,t)=>e.meta.meta.totalArea-t.meta.meta.totalArea)),i=n?.[0];if(i){let t=i.meta.meta.id;Zi.has(t)||Zi.set(t,e.int(1,h.length-1)),u+=Zi.get(t)}}if(null!==i){let t=gi(a||h[c(s(g+u))%h.length],si,ci*i,Oe.samplesForComplimentary);return e.choice(t)}return h[c(s(g+u))%h.length]}function Wi(e,t,n){var i;return function(t){return i=i||function(e){var t=function(e){return atob(e)}(e),n=t.indexOf("\n",10)+1,i=t.substring(n)+"",l=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(l)}(e),new Worker(i,t)}}var vi=Wi("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y29uc3R7Zmxvb3I6ZSxjZWlsOnQsc2luOmksY29zOm4scG93OnMsYWJzOnIsbWluOm8sbWF4OmwsaHlwb3Q6aCxyb3VuZDphLHNxcnQ6YyxhY29zOmQsc2lnbjpnLGxvZzpmLFBJOnV9PU1hdGgscD0xZS03O2Z1bmN0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m9yaWdpbi5oZWRnZWxpc3Quc3BsaWNlKGQsMSksbC5vcmlnaW4uaGVkZ2VsaXN0Lmxlbmd0aD4wKXtsZXQgZSx0OzA9PT1kPyhlPWwub3JpZ2luLmhlZGdlbGlzdFtsLm9yaWdpbi5oZWRnZWxpc3QubGVuZ3RoLTFdLHQ9bC5vcmlnaW4uaGVkZ2VsaXN0W2RdKTooZT1sLm9yaWdpbi5oZWRnZWxpc3RbZC0xXSx0PWwub3JpZ2luLmhlZGdlbGlzdFtkJWwub3JpZ2luLmhlZGdlbGlzdC5sZW5ndGhdKSx0LnByZXZoZWRnZT1lLnR3aW4sZS50d2luLm5leHRoZWRnZT10fWVsc2UgdGhpcy5kZWxldGVWZXJ0ZXgobC5vcmlnaW4pLGY9ITE7aWYoZD1oLm9yaWdpbi5oZWRnZWxpc3QuaW5kZXhPZihoKSxoLm9yaWdpbi5oZWRnZWxpc3Quc3BsaWNlKGQsMSksaC5vcmlnaW4uaGVkZ2VsaXN0Lmxlbmd0aD4wKXtsZXQgZSx0OzA9PT1kPyhlPWgub3JpZ2luLmhlZGdlbGlzdFtoLm9yaWdpbi5oZWRnZWxpc3QubGVuZ3RoLTFdLHQ9aC5vcmlnaW4uaGVkZ2VsaXN0W2RdKTooZT1oLm9yaWdpbi5oZWRnZWxpc3RbZC0xXSx0PWgub3JpZ2luLmhlZGdlbGlzdFtkJWgub3JpZ2luLmhlZGdlbGlzdC5sZW5ndGhdKSx0LnByZXZoZWRnZT1lLnR3aW4sZS50d2luLm5leHRoZWRnZT10fWVsc2UgdGhpcy
prevhedge=m,m.nexthedge=h;else{const e=d.hedgelist.indexOf(h);let t,n;0===e?(t=d.hedgelist[d.hedgelist.length-1],n=d.hedgelist[(e+1)%d.hedgelist.length]):(t=d.hedgelist[e-1],n=d.hedgelist[(e+1)%d.hedgelist.length]),h.prevhedge=t.twin,t.twin.nexthedge=h,m.nexthedge=n,n.prevhedge=m}if(r)m.prevhedge=h,h.nexthedge=m;else{const e=u.hedgelist.indexOf(m);let t,n;0===e?(t=u.hedgelist[u.hedgelist.length-1],n=u.hedgelist[(e+1)%u.hedgelist.length]):(t=u.hedgelist[e-1],n=u.hedgelist[(e+1)%u.hedgelist.length]),m.prevhedge=t.twin,t.twin.nexthedge=m,h.nexthedge=n,n.prevhedge=h}const p=h.nexthedge,g=m.nexthedge;if(p.face){const e=s.indexOf(p.face);e>-1&&s.splice(e,1),p.face.dispose(),p.face.area<=this.tolerance&&(c=!0)}if(g.face){const e=s.indexOf(g.face);e>-1&&s.splice(e,1),g.face.dispose(),g.face.area<=this.tolerance&&(c=!0)}const b=new Rn(this);b.wedge=p;let f=new Rn(this);if(f.wedge=g,b.equals(f)&&(f.dispose(),f=null),b){let e=b.wedge;for(e.face=b;e.nexthedge!==b.wedge;)e=e.nexthedge,e.face=b;b.area<=this.tolerance&&(c=!0),s.push(b)}if(f){let e=f.wedge;for(e.face=f;e.nexthedge!==f.wedge;)e=e.nexthedge,e.face=f;f.area<=this.tolerance&&(c=!0),s.push(f)}if(c)for(let e=0,t=s.length;e<t;e++)s[e]._holesDirty=!0}removeEdge(e,t,n,i){const{vertices:l,hedges:a,faces:s}=this,o=this.findHedge(e,t,n,i);if(!o)return;const r=o.twin,c=o.nexthedge,d=r.nexthedge;let u,h=!0,m=!0,p=!1;if(u=a.indexOf(o),a.splice(u,1),u=a.indexOf(r),a.splice(u,1),u=s.indexOf(o.face),u>-1&&s.splice(u,1),o.face.dispose(),o.face.area<=this.tolerance&&(p=!0),u=s.indexOf(r.face),u>-1&&s.splice(u,1),r.face.dispose(),r.face.area<=this.tolerance&&(p=!0),u=o.origin.hedgelist.indexOf(o),o.origin.hedgelist.splice(u,1),o.origin.hedgelist.length>0){let e,t;0===u?(e=o.origin.hedgelist[o.origin.hedgelist.length-1],t=o.origin.hedgelist[u]):(e=o.origin.hedgelist[u-1],t=o.origin.hedgelist[u%o.origin.hedgelist.length]),t.prevhedge=e.twin,e.twin.nexthedge=t}else this.deleteVertex(o.origin),m=!1;if(u=r.origin.hedgelist.indexOf(r),r.origin.hedgelist.splice(u,1),r.origin.hedgelist.length>0){let e,t;0===u?(e=r.origin.hedgelist[r.origin.hedgelist.length-1],t=r.origin.hedgelist[u]):(e=r.origin.hedgelist[u-1],t=r.origin.hedgelist[u%r.origin.hedgelist.length]),t.prevhedge=e.twin,e.twin.nexthedge=t}else this.deleteVertex(r.origin),h=!1;o.dispose(),r.dispose();const g=h?new Rn(this):null;g&&(g.wedge=c);let b=m?new Rn(this):null;if(b&&(b.wedge=d),g&&b)try{g.equals(b)&&(b.dispose(),b=null)}catch{b=null}if(g){let e=g.wedge;for(e.face=g;e.nexthedge!==g.wedge;){if(e=e.nexthedge,!e.face)return;e.face=g}g.area<=this.tolerance&&(p=!0),s.push(g)}if(b){let e=b.wedge;for(e.face=b;e.nexthedge!==b.wedge;)e=e.nexthedge,e.face=b;b.area<=this.tolerance&&(p=!0),s.push(b)}if(p)for(let e=0,t=s.length;e<t;e++)s[e]._holesDirty=!0}splitEdge(e,t,n,i,l,a){const{vertices:s,hedges:o}=this;let r=this.findVertex(l,a),c=this.findHedge(e,t,n,i);if(!c)return!1;if(r)return!0;const d=c.twin;let u;const h=this.addVertex(l,a),m=new Gn(h,c.origin),p=new Gn(d.origin,h);o.push(m),o.push(p);const g=new Gn(h,d.origin),b=new Gn(c.origin,h);return o.push(g),o.push(b),c.face.wedge===c&&(c.face.wedge=m),c.face._vertexlistDirty=!0,m.face=c.face,p.face=c.face,d.face.wedge===d&&(d.face.wedge=g),d.face._vertexlistDirty=!0,g.face=d.face,b.face=d.face,m.nexthedge=p,p.prevhedge=m,g.nexthedge=b,b.prevhedge=g,m.prevhedge=c.prevhedge!==d?c.prevhedge:b,m.prevhedge.nexthedge=m,p.nexthedge=c.nexthedge!==d?c.nexthedge:g,p.nexthedge.prevhedge=p,g.prevhedge=d.prevhedge!==c?d.prevhedge:p,g.prevhedge.nexthedge=g,b.nexthedge=d.nexthedge!==c?d.nexthedge:m,b.nexthedge.prevhedge=b,m.twin=b,p.twin=g,g.twin=p,b.twin=m,h.hedgelist.push(p,b),u=c.origin.hedgelist.indexOf(c),c.origin.hedgelist.splice(u,1,m),u=d.origin.hedgelist.indexOf(d),d.origin.hedgelist.splice(u,1,g),c.dispose(),d.dispose(),u=o.indexOf(c),o.splice(u,1),u=o.indexOf(d),o.splice(u,1),{h1:m,h2:p}}intersectFaceWithPolyLine(e,t,n=!1,i=!1){let l=[],a=i?t.length:t.length-1;for(let i=0;i<a;i++){let a=[t[i],t[(i+1)%t.length]];if(l.push(...e.intersectWithLineSeg(a.map((e=>(new zt).fromArray(e))))),n&&l.length>=2)break}return l}getFacesAtPoint(e){let t=[],n=new zt(...e);for(let e of this.faces)e.aabb.containsPoint(n)&&e.containsPoint(n)&&t.push(e);return t}getFacesIntersectingPoly(e){let t=e.map((e=>(new zt).fromArray(e))),n=new nn;n.expands(t);let i=[];for(let l of this.faces)if(!(l.area<=this.tolerance)&&n.intersects(l.aabb)){if(Mn(t,l.vertexlist)){i.push({face:l,intersections:[],isContained:!0});continue}let n=[];for(let i=0;i<e.length;i++){let a=[t[i],t[(i+1)%e.length]];n.push(...l.intersectWithLineSeg(a))}n.length>0&&i.push({face:l,intersections:n,isContained:!1})}return i}}class Ln extends vn{tolerance;constructor(e,t,n=Wn){super(e,t,n),this.tolerance=n}isPolyLineSegmentOnEdge(e,t){for(let n=0;n<t.length-1;n++){let i=[t[n],t[n+1]];if(this.isLineSegmentOnEdgeOfFace(e,i),this.tolerance)return!0}}isLineSegmentOnEdgeOfFace(e,t,n=b){for(let i=0;i<e.vertexlist.length;i++)if(Sn([e.vertexlist[i].toArray(),e.vertexlist[(i+1)%e.vertexlist.length].toArray()],t),n)return!0;return!1}getFacesIntersectingAABB(e){let t=[];for(let n of this.faces.filter((e=>e.area>0)))e.intersects(n.aabb,this.tolerance)&&t.push(n);return t}removeEdgesInsidePolygon(e,t=100){let n=new nn;n.expands(e.map((e=>(new zt).fromArray(e))));let i=e.map((e=>(new zt).fromArray(e))),l=this.getFacesIntersectingAABB(n),a=[];for(let t of l){let n=t.vertexlist;for(let t=0;t<n.length;t++){let l=n[t],s=n[(t+1)%n.length];if(!Tn(i,l,this.tolerance)||!Tn(i,s,this.tolerance))continue;let o=0;[l,s].forEach((t=>{Cn(t.toArray(),e,this.tolerance)&&o++})),o>1||a.push([l,s])}}for(let e of a)J.bool(t)&&this.removeEdge(e[0].x,e[0].y,e[1].x,e[1].y);this.cleanupTrailingEdges()}insertPolygon(e,t=!0){let n=[],i=new nn;i.expands(e.map((e=>(new zt).fromArray(e)))),i.expandByValue(this.tolerance);let l=this.getFacesIntersectingAABB(i),a=new Set;for(let e of l){let t=e.vertexlist;for(let e=0;e<t.length;e++){let n=t[e],i=t[(e+1)%t.length],l=this.findHedge(n.x,n.y,i.x,i.y);a.has(l.twin)||a.add(l)}}for(let t of e)n.push({type:"addVertex",data:{x:t[0],y:t[1]}});for(let i of a){let l=[];e:for(let a=0;a<(t?e.length:e.length-1);a++){let t=[new zt(...e[a]),new zt(...e[(a+1)%e.length])],s=i.intersectWithLineSegment(t);if(s.type==gn.intersecting){for(let e of l)if(e.isEqualTo(s.point))continue e;n.push({type:"addVertex",data:{x:s.point.x,y:s.point.y}})}}}for(let i=0;i<(t?e.length:e.length-1);i++){let t=[e[i],e[(i+1)%e.length]];n.push({type:"addEdge",data:{from:{x:t[0][0],y:t[0][1]},to:{x:t[1][0],y:t[1][1]}}})}this.executeAddOperations(n)}splitFaceByPolyLine(e,t,n=!1,i=!1,l=!1){const a=(e,t,n,i)=>{const l=[.5,.25,.75];for(let a of l){let l=e.lerp(t,a);if(n.containsPoint(l)&&!n.isPointOnBoundary(l,i))return!0}return!1},s=(e,t,n,i)=>{let l=[.25,.5,.75],a=0;for(let s of l){let l=e.lerp(t,s);if(n.isPointOnBoundary(l,i)&&(a++,a>=2))return!0}return a>=2};let o=[],r=[],c=!1,d=0;if(n){let n=t.findIndex((t=>!e.containsPoint(new zt(...t))||e.isPointOnBoundary(new zt(...t),this.tolerance)));if(!(n>=0))return!1;t=t.slice(n).concat(t.slice(0,n))}const u=n?t.length:t.length-1;for(let n=0;n<u;n++){let i=new zt(...t[n]),l=new zt(...t[(n+1)%t.length]),u=[i,l],h=e.intersectWithLineSeg(u);d+=h.length;let m=[i,...h.map((e=>e.point)),l];m=Xn(i,l,m,!0,this.tolerance);for(let t=0;t<m.length-1;t++){let n=m[t],i=m[t+1];a(n,i,e,this.tolerance)&&!s(n,i,e,this.tolerance)?(c||(r=[n],c=!0),r.push(i)):c&&(o.push(r),r=[],c=!1)}}if(!n&&c&&r.length>1&&o.push(r),i||(o=o.filter((t=>{let n=t[Math.floor(t.length/2)].lerp(t[Math.ceil(t.length/2)],.5);return e.containsPoint(n)}))),o.length>1&&l){let e=null;for(let t of o){let i=0;for(let e=0;e<(n?t.length:t.length-1);e++)i+=t[e].distanceTo(t[(e+1)%t.length]);(!e||i>e.length)&&(e={length:i,line:t})}if(!e)return!1;o=[e.line]}if(0===o.length)return!1;if(i)return{lines:o,intersectionCount:d};let h=[];for(let e of o)for(let t of e)h.push({type:"addVertex",data:{x:t.x,y:t.y}});for(let e of o)for(let t=0;t<e.length-1;t++)h.push({type:"addEdge",data:{from:{x:e[t].x,y:e[t].y},to:{x:e[t+1].x,y:e[t+1].y}}});return this.executeAddOperations(h),!0}executeAddOperations(e){const t=e.filter((e=>"addVertex"===e.type)),n=e.filter((e=>"addEdge"===e.type));let i=[];for(const e of n){let t=new nn,n=new zt(e.data.from.x,e.data.from.y),l=new zt(e.data.to.x,e.data.to.y);t.expands([n,l]),t.expandByValue(this.tolerance);let a=new Set;for(let e of this.hedges){let i=e.getAABB();if(i.expandByValue(this.tolerance),i.intersects(t)){let t=e.intersectWithLineSegment([n,l]);t.type==gn.intersecting&&(a.add(t.point),this.findVertex(t.point.x,t.point.y)||this.splitEdge(e.origin.x,e.origin.y,e.twin.origin.x,e.twin.origin.y,t.point.x,t.point.y))}}if(a.size>1){let e=Xn(n,l,[n,...a,l],!0,this.tolerance);for(let t=0;t<e.length-1;t++)i.push({type:"addEdge",data:{from:{x:e[t].x,y:e[t].y},to:{x:e[t+1].x,y:e[t+1].y}}})}else i.push(e)}for(const e of t){let{x:t,y:n}=e.data;if(!this.findVertex(t,n)){let e=!1;for(let i of this.hedges){let l=i.getAABB();l.expandByValue(this.tolerance),l.containsPoint(new zt(t,n))&&!this.findVertex(t,n)&&Vn([t,n],[i.origin.toArray(),i.twin.origin.toArray()])&&(e=!1!==this.splitEdge(i.origin.x,i.origin.y,i.twin.origin.x,i.twin.origin.y,t,n))}!e&&this.addVertex(t,n)}}for(const e of i.filter((e=>"addEdge"===e.type))){let{from:t,to:n}=e.data,i=this.findVertex(t.x,t.y),l=this.findVertex(n.x,n.y);if(i&&l){let e=new Set;e.add(i);let t=new nn;t.expands([i,l]),t.expandByValue(this.tolerance);for(let n of this.verticesInBB(t))Vn(n.toArray(),[i.toArray(),l.toArray()])&&e.add(n);e.add(l);let n=Xn(i,l,Array.from(e),!0);for(let e=0;e<n.length-1;e++)this.findHedge(n[e].x,n[e].y,n[e+1].x,n[e+1].y)||this.addEdge(n[e].x,n[e].y,n[e+1].x,n[e+1].y)}}}cleanupDegenerateHoles(){let e=new Set;this.faces.forEach((t=>{for(let n of this.faces)t!=n&&t.aabb.containsBB(n.aabb)&&t.vertexlist.every((e=>n.containsPoint(e)))&&n.hedges.forEach((t=>{t.face==n&&e.add(t)}))})),this.faces.filter((e=>e.area>0)).forEach((t=>{t.holes.forEach((n=>{n.hedges.forEach((n=>{n.face==t&&e.add(n)}))}))}));for(const t of e)t.origin&&t.twin.origin&&this.removeEdge(t.origin.x,t.origin.y,t.twin.origin.x,t.twin.origin.y)}cleanupTrailingEdges(){this.hedges.forEach((e=>{e.face==e.twin.face&&this.removeEdge(e.origin.x,e.origin.y,e.twin.origin.x,e.twin.origin.y)}))}}function Sn(e,t,n=b){let[i,l]=e,[a,o]=t;const r=l[0]-i[0],c=l[1]-i[1],u=o[0]-a[0],h=o[1]-a[1];if(s(r*h-c*u)>n)return!1;const m=s(r*(i[1]-a[1])-(i[0]-a[0])*c),p=d(r*r+c*c);return!(p<n)&&m/p<n}function Xn(e,t,n,i=!1,l=b){const a=t.x-e.x,s=t.y-e.y;let o=a*a+s*s;if(o<l)return n;const r=1/o,c=n.map((t=>{const n=((t.x-e.x)*a+(t.y-e.y)*s)*r;return{point:t,t:Math.max(0,Math.min(1,n))}}));c.sort(((t,n)=>{const i=t.t-n.t;return Math.abs(i)>l?i:(t.point.x-e.x)**2+(t.point.y-e.y)**2-((n.point.x-e.x)**2+(n.point.y-e.y)**2)}));let d=c.map((e=>e.point));return i&&(d=function(e,t){const n=[],i=new Map;for(const l of e){const e=`${Math.round(l.x/t)},${Math.round(l.y/t)}`;i.has(e)||(i.set(e,!0),n.push(l))}return n}(d,l)),d}function Cn(e,t,n=b){for(let i=0;i<t.length;i++){const l=t[i],a=t[(i+1)%t.length],s=o(l[0],a[0])-n,c=r(l[0],a[0])+n,d=o(l[1],a[1])+-n,u=r(l[1],a[1])+n;if(e[0]>=s&&e[0]<=c&&e[1]>=d&&e[1]<=u&&wn(e,l,a)<=n*n)return!0}return!1}function Vn(e,t,n=b){const[i,l]=t,a=(e[1]-i[1])*(l[0]-i[0])-(e[0]-i[0])*(l[1]-i[1]);if(Math.abs(a)>n)return!1;const s=(e[0]-i[0])*(l[0]-i[0])+(e[1]-i[1])*(l[1]-i[1]);return!(s<-n||s-((l[0]-i[0])*(l[0]-i[0])+(l[1]-i[1])*(l[1]-i[1]))>n)}function wn(e,t,n){const i=n[0]-t[0],l=n[1]-t[1],a=i*i+l*l;if(a<1e-14){const n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}let s=((e[0]-t[0])*i+(e[1]-t[1])*l)/a;s=Math.max(0,Math.min(1,s));const o=t[0]+s*i,r=t[1]+s*l,c=e[0]-o,d=e[1]-r;return c*c+d*d}let Kn=0;class Rn{_dcel;id=Kn++;changeIndex=0;wedge=null;_area=0;_areaDirty=!0;_vertexlist=[];_vertexlistDirty=!0;_centerDirty=!0;_hedges=[];_hedgesDirty=!0;_center=null;_hasInsertedIntoPQ=!1;_holes=[];_holesDirty=!0;_aabb=null;_aabbDirty=!0;constructor(e){this._dcel=e}get area(){return this._areaDirty&&(this._area=zn(this.vertexlist),this._areaDirty=!1),this._area}get areaExceptHoles(){const e=this.holes;let t=this.area;for(let n=0,i=e.length;n<i;n++)t+=e[n].area;return t}get internal(){return this.area>Wn}get external(){return this.area<=Wn}get hedges(){if(this._hedgesDirty){const e=[];let t=this.wedge,n=0;const i=1e6;for(e.push(t);t.nexthedge!==this.wedge&&n<i;)t=t.nexthedge,e.push(t),n++;if(n>=i)throw Error("Face vertex list is too long");this._hedges=e,this._hedgesDirty=!1}return this._hedges}get center(){if(this._centerDirty){const e=this.vertexlist;let t=0,n=0,i=0;for(let l=0;l<e.length;l++){const a=e[l].x,s=e[l].y,o=e[(l+1)%e.length].x,r=e[(l+1)%e.length].y,c=a*r-s*o;t+=c,n+=(a+o)*c,i+=(s+r)*c}t*=.5,n/=6*t,i/=6*t,this._center=new zt(n,i),this._centerDirty=!1}return this._center}get vertexlist(){return this._vertexlistDirty&&this.cleanVertexList(),this._vertexlist}cleanVertexList(){if(!this._vertexlistDirty)return;let e=this.wedge;const t=this._vertexlist;t.length=0;let n=0;const i=1e6;for(t.push(e.origin);e.nexthedge!==this.wedge&&n<i;)e=e.nexthedge,t.push(e.origin),n++;if(n>=i)throw Error("Face vertex list is too long");this._vertexlistDirty=!1}get holes(){if(this._holesDirty&&(this._holesDirty=!1,this._holes.length=0,this.internal)){const e=this._dcel.faces;for(let t=0,n=e.length;t<n;t++)this._tryAddHole(e[t])}return this._holes}get aabb(){return this._aabb||(this._aabb=new nn),this._aabbDirty&&(this._aabb.reset(),this._aabb.expands(this.vertexlist),this._aabbDirty=!1),this._aabb}equals(e){const t=this.vertexlist,n=e.vertexlist;if(t.length!==n.length)return!1;const i=t.length;for(let e=0;e<i;e++)for(let l=0;l<i&&t[l]===n[(e+l)%i];l++)if(l===i-1)return!0;return!1}findNearestEdge(e){return function(e,t){const n=Yn(e);let i=[e[0],e[1]],l=1e10,a=-1/0,s=null;for(let o=0;o<e.length;o++){const r=[e[o],e[(o+1)%e.length]],{distance:c,projection:d}=Pn(t,r[0],r[1]),u={x:r[1].x-r[0].x,y:r[1].y-r[0].y};let h={x:-u.y,y:u.x},m={x:(r[0].x+r[1].x)/2-n.x,y:(r[0].y+r[1].y)/2-n.y};h.x*m.x+h.y*m.y<0&&(h={x:u.y,y:-u.x});const p={x:t.x-(r[0].x+r[1].x)/2,y:t.y-(r[0].y+r[1].y)/2},g=h.x*p.x+h.y*p.y;(c<l||c===l&&g>a)&&g>0&&(l=c,i=r,a=g,s=d)}return{edge:i,distance:l,edgePoint:s}}(this.vertexlist,e)}containsPoint(e){return!(!this.aabb.containsPoint(e)||!Tn(this.vertexlist,e))}isPointOnBoundary(e,t=Wn){let n=this.vertexlist.map((e=>e.toArray()));return!!Cn(e.toArray(),n,t)}intersectWithPolyLine(e,t=!1){let n=[];const i=t?e.length:e.length-1;for(let l=0;l<i;l++){const i=t?(l+1)%e.length:l+1,a=[e[l],e[i]];n.push(...this.intersectWithLineSeg(a))}return n}intersectWithLineSeg(e){const t=[],n=this.hedges.filter((e=>e.face==this)),i=(new nn).expands(e);for(let l of n){if(!l.getAABB().intersects(i))continue;const n=l.intersectWithLineSegment(e);n.type===gn.intersecting&&t.push({point:n.point,edge:[l.origin,l.twin.origin]})}return t}dirty(){this._areaDirty=!0,this._hedgesDirty=!0,this._centerDirty=!0,this._vertexlistDirty=!0,this._holesDirty=!0,this._aabbDirty=!0,this.changeIndex++}dispose(){this.wedge=null,this._vertexlist.length=0,this._holes.length=0,this._aabb=null,this._dcel=null}_tryAddHole(e){this._holesDirty||e.external&&this.area-Math.abs(e.area)>Wn&&this.aabb.containsPoints(e.vertexlist)&&Mn(this.vertexlist,e.vertexlist,Wn)&&this._holes.push(e)}}function kn(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function Tn(e,t,n=Wn){if(Cn([t.x,t.y],e.map((e=>e.toArray())),n))return!0;let i=0;for(let n=0;n<e.length;n++){const l=e[n],a=e[(n+1)%e.length];l.y<=t.y?a.y>t.y&&kn(l,a,t)>0&&i++:a.y<=t.y&&kn(l,a,t)<0&&i--}return 0!==i}function Mn(e,t,n=Wn){for(let i=0,l=t.length;i<l;i++)if(!Tn(e,t[i],n))return!1;return!0}function zn(e){if(e.length<3)return 0;let t=0;for(let n=0;n<e.length;n++){const i=(n+1)%e.length;t+=e[n].x*e[i].y-e[n].y*e[i].x}return.5*t}function Yn(e){let t=0,n=0;for(let i=0;i<e.length;i++)t+=e[i].x,n+=e[i].y;return new zt(t/e.length,n/e.length)}function Pn(e,t,n,i=Wn){const l=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y);if(l<i)return{distance:e.distanceTo(t),projection:t};let a=((e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y))/l;a<-i?a=0:a>1+i&&(a=1);const s=new zt(t.x+a*(n.x-t.x),t.y+a*(n.y-t.y));return{distance:e.distanceTo(s),projection:s}}function In(e,t,n=b){const[{x:i,y:l},{x:a,y:s}]=e,[{x:o,y:r},{x:c,y:d}]=t,u=(i-a)*(r-d)-(l-s)*(o-c);if(Math.abs(u)<n)return null;const h=((i-o)*(r-d)-(l-r)*(o-c))/u,m=((a-i)*(l-r)-(s-l)*(i-o))/u;return h>=-n&&h<=1+n&&m>=-n&&m<=1+n?new zt(i+h*(a-i),l+h*(s-l)):null}function Hn(e,t){const n=[];for(let i=0;i<t.length;i++){const l=[t[i],t[(i+1)%t.length]],a=In(e,l);a&&n.push({point:a,edge:l})}return n}let Fn=0;function Nn(){return Fn++,Fn}function Un(e){let{boxCenter:t,perspectiveCenter:n,centerBoxMaskDimensions:i=[0,0],width:l,height:a,gThreshold:s=2.5,gMean:o=1,gStdDev:r=1.5}=e;n||(n=t);const[c,d]=t;let[u,h]=n;u=Pt(new zt(u,h)).x,h=Pt(new zt(u,h)).y;let m=[i[0]*ze.scale,i[1]*ze.scale];l=Rt(l,ze.scale),a=Rt(a,ze.scale);let p=[];const g=2*(l+a),b=g/ze.scale,f=g/b;let x=[[u-m[0],h-m[1]],[u+m[0],h-m[1]],[u+m[0],h+m[1]],[u-m[0],h+m[1]]],Z=0,y=0,G=0;for(let e=0;e<b;e++){if(G<l?(Z=c-l/2+G,y=d-a/2):G<l+a?(Z=c+l/2,y=d-a/2+(G-l)):G<2*l+a?(Z=c+l/2-(G-(l+a)),y=d+a/2):(Z=c-l/2,y=d+a/2-(G-(2*l+a))),J.gaussianBool(s,o,r)){let e=Hn([[u,h],[Z,y]].map((e=>new zt(...e))),x.map((e=>new zt(...e))));if(!e[0])continue;let t=[e[0].point.toArray(),[Z,y]];if(p.push(t),J.bool(0)){let e=J.int(1,3)*ze.scale;J.bool(50)&&(e*=-1);let n=[[t[0][0]+e,t[0][1]],[t[1][0]+e,t[1][1]]];p.push(n)}}G+=f}return p}function Dn({center:e,width:t,height:n,angle:a=0}){let[s,o]=e,r=t/2,c=n/2,d=[[s-r,o-c],[s+r,o-c],[s+r,o+c],[s-r,o+c]];return 0!==a&&(d=function(e,t,n){const a=n||function(e){const t=e.reduce(((e,t)=>[e[0]+t[0],e[1]+t[1]]),[0,0]);return[t[0]/e.length,t[1]/e.length]}(e),s=t*g/180;return e.map((e=>{const t=[e[0]-a[0],e[1]-a[1]],n=[t[0]*l(s)-t[1]*i(s),t[0]*i(s)+t[1]*l(s)];return[n[0]+a[0],n[1]+a[1]]}))}(d,a,e)),d}function On(e){let{center:n,radius:i,startAngle:l=0,endAngle:a=180}=e,s=[],[o,r]=n;l=me(l),a=me(a);let c=t(i*Math.abs(a-l)*.125);for(let e=0;e<=c;e++){let t=l+e/c*(a-l),n=o+i*Math.cos(t),d=r+i*Math.sin(t);s.push([n,d])}let d=function(e){let t=0,n=0;for(let i=0;i<e.length;i++)t+=e[i][0],n+=e[i][1];return[t/e.length,n/e.length]}(s),u=[o-d[0],r-d[1]];return s=s.map((e=>[e[0]+u[0],e[1]+u[1]])),s}class Bn{startX;startY;endX;endY;distances;constructor(e,t,n,i){this.startX=e,this.startY=t,this.endX=n,this.endY=i;const l=n-e+1,a=i-t+1;this.distances=Array(a).fill(null).map((()=>Array(l).fill(1/0)))}initializeWithEmptyCells(e,t){for(let e=0;e<this.distances.length;e++)for(let t=0;t<this.distances[0].length;t++)this.distances[e][t]=0;e.forEach((e=>{const[n,i]=t(e),l=n-this.startX,a=i-this.startY;l>=0&&a>=0&&l<this.distances[0].length&&a<this.distances.length&&(this.distances[a][l]=1/0)}));for(let e=0;e<this.distances.length;e++)this.distances[e][0]=0,this.distances[e][this.distances[0].length-1]=0;for(let e=0;e<this.distances[0].length;e++)this.distances[0][e]=0,this.distances[this.distances.length-1][e]=0;this.performJFA()}performJFA(){const e=this.distances.length,t=this.distances[0].length;let n=[];for(let i=0;i<e;i++)for(let e=0;e<t;e++)0===this.distances[i][e]&&n.push([e,i]);for(;n.length>0;){let e=n.length;for(let t=0;t<e;t++){const[e,t]=n.shift();this.checkAndUpdate(e,t,n)}}}checkAndUpdate(e,t,n){const i=[[-1,0],[1,0],[0,-1],[0,1],[-1,-1],[-1,1],[1,-1],[1,1]];for(const[l,a]of i){const i=e+l,s=t+a;i>=0&&i<this.distances[0].length&&s>=0&&s<this.distances.length&&this.distances[s][i]>this.distances[t][e]+1&&(this.distances[s][i]=this.distances[t][e]+1,n.push([i,s]))}}getDistance(e,t){const n=e-this.startX,i=t-this.startY;return n>=0&&i>=0&&n<this.distances[0].length&&i<this.distances.length?this.distances[i][n]:1/0}}var Qn;!function(e){e.intersecting="INTERSECTING",e.contained="CONTAINED"}(Qn||(Qn={}));class Jn{cells=new Map;lines=new Map;lineMeta=new Map;distanceCalculator;nextLineId=0;cellSize;faceCellIndicesCache=new Map;aabbLineIntersectionCache=new Map;constructor(e,t){this.cellSize=e,t&&this.addLines(t)}getCellBounds(){let e=0,t=0,n=0,i=0;return this.cells.forEach(((l,a)=>{const[s,o]=this.getCellXYfromIndex(a);e=Math.min(e,s),t=Math.min(t,o),n=Math.max(n,s),i=Math.max(i,o)})),{width:n-e,height:i-t,minX:e,minY:t,maxX:n,maxY:i}}getCellIndex(e,t){return`${f(e)},${f(t)}`}getCellXYfromIndex(e){return e.split(",").map(Number)}getCellVertexFromIndex(e){let[t,n]=this.getCellXYfromIndex(e);return new zt(t*this.cellSize,n*this.cellSize)}clear(){this.cells.clear(),this.lines.clear(),this.lineMeta.clear(),this.faceCellIndicesCache.clear(),this.aabbLineIntersectionCache.clear()}addLines(e){e.forEach((e=>this.addLine(e.line,e.meta)))}addLine(e,t){const n=this.nextLineId++;this.lines.set(n,e),this.lineMeta.set(n,t);let i=t.isClosed?e.length:e.length-1;for(let t=0;t<i;t++)this.addSegment(e[t],e[(t+1)%e.length],n);return this.aabbLineIntersectionCache.clear(),n}removeLineById(e){if(this.lines.get(e)){for(let t of this.cells.values())t.delete(e);this.lines.delete(e),this.lineMeta.delete(e),this.aabbLineIntersectionCache.clear()}}addSegment(e,t,n){let i,[l,a]=e,[o,r]=t,c=f(l/this.cellSize),d=f(a/this.cellSize),u=f(o/this.cellSize),h=f(r/this.cellSize),m=s(u-c),p=-s(h-d),g=c<u?1:-1,b=d<h?1:-1,x=m+p;for(;;){const e=this.getCellIndex(c,d);if(this.cells.has(e)||this.cells.set(e,new Set),this.cells.get(e).add(n),c===u&&d===h)break;i=2*x,i>=p&&(x+=p,c+=g),i<=m&&(x+=m,d+=b)}}getLinesIntersectingOrContainedWithinAABB(e){let t=new Set,n=f(e.minX/this.cellSize),i=f(e.maxX/this.cellSize),l=f(e.minY/this.cellSize),a=f(e.maxY/this.cellSize);for(let e=n;e<=i;e++)for(let n=l;n<=a;n++){const i=this.getCellIndex(e,n);this.cells.has(i)&&this.cells.get(i).forEach((e=>t.add(e)))}return Array.from(t).map((e=>({id:Nn(),line:this.lines.get(e),meta:this.lineMeta.get(e)})))}getAllLines(){return Array.from(this.lines).map((([e,t])=>({id:e,line:t,meta:this.lineMeta.get(e)})))}getCellsIntersectedByFace(e){const t=this.faceCellIndicesCache.get(e.id);if(t&&t.changeIndex===e.changeIndex)return t.cellIndices;const n=new Set,i=e.aabb,l=f(i.minX/this.cellSize),a=f(i.maxX/this.cellSize),s=f(i.minY/this.cellSize),o=f(i.maxY/this.cellSize);for(let t=l;t<=a;t++)for(let i=s;i<=o;i++){const l=new nn;l.expands([new zt(t*this.cellSize,i*this.cellSize),new zt((t+1)*this.cellSize,(i+1)*this.cellSize)]);for(let a of l.vertexList)if(e.containsPoint(a)){n.add(this.getCellIndex(t,i));break}}return this.faceCellIndicesCache.set(e.id,{changeIndex:e.changeInd
3, 8., 0.6) * (lineDistanceMax / (uIsShading ? 2. : 2.));\n \n float lineWeightEdgeNoise = fbm(uv + uNoiseOffset + currentLineNoiseOffset, 3, 300., 0.54) * (lineDistanceMax / 10.);\n\n float lineDistance = (lineSDF + lineWeightWobble + lineWeightEdgeNoise); \n \n \n float lineFineNoise = clamp(\n smoothstep(0., 0.9, fbm(uv + currentLineNoiseOffset, 2, 700., 0.9) - 0.1) + remap(lineHardness, 1., 0., 1. - uMaterialHardness, 0.5),\n 0., 1.);\n\n float lineFineNoise2 = clamp(\n smoothstep(0., 0.9, fbm(uv, 1, 900., 0.9)) + remap(lineHardness, 1., 0., 0.01, 0.5),\n 0., (1. - uMaterialHardness) + .1);\n \n\n float alphaWobblePerLine = fbm(uNoiseOffset + currentLineNoiseOffset, 1, 300., 0.9) * 0.015;\n\n float lineColorWobble = 0.008;\n \n float lightnessWobblePerLine = ((fbm(uNoiseOffset + (currentLineNoiseOffset / 1.), 1, 1000., 0.9) + .5) / 2. ) * lineColorWobble;\n localColor.x += lightnessWobblePerLine;\n\n float saturationWobblePerLine = ((fbm(uNoiseOffset + (currentLineNoiseOffset / 1.1), 1, 1100., 0.9) + .5) / 2. ) * (lineColorWobble * 0.4);\n localColor.y += saturationWobblePerLine;\n \n float maxLineHardness = clamp(smoothstep(0., 1., lineHardness - alphaWobblePerLine), 0., 1.);\n\n float lineRolloff = 0.0001;\n float alphaHardLineSpread = lineDistanceMax * 1.;\n float hardLineSS = smoothstep(alphaHardLineSpread + lineRolloff, alphaHardLineSpread - lineRolloff, lineDistance);\n\n float alphaHardLine = clamp(\n (hardLineSS * (1. - lineFineNoise) * (1. - lineFineNoise2)) * maxLineHardness,\n 0., 1.);\n\n float alphaSoftLine = 0.;\n\n if(!uIsShading) {\n float alphaSoftLineNoise = clamp((fbm(uv + currentLineNoiseOffset, 1, 800., 0.9) - 0.3), 0., 1.);\n\n\n float alphaSoftLineSpread = lineDistanceMax * 1.5;\n float softLineSS = smoothstep(alphaSoftLineSpread + lineRolloff, alphaSoftLineSpread - lineRolloff, lineDistance);\n\n alphaSoftLine = clamp(\n (step(lineDistance, alphaSoftLineSpread) * alphaSoftLineNoise) * maxLineHardness,\n 0., .7);\n }\n \n\n float lineAlpha = max(alphaSoftLine, alphaHardLine) * segmentDistanceAlphaMult;\n \n \n\n \n // if(alphaHardLine > alpha) {\n // if(alpha == 0.) {\n // alpha = lineAlpha;\n // }\n // if(uIsShading) {\n // // 0 is always the closest line, so use this as our based for subsequent accumulation\n // if(i == 0) {\n // alpha = lineAlpha * 0.7;\n // } else {\n // alpha = clamp(alpha + (1.0 - alpha) * lineAlpha * alphaIncrement, 0., 1.);\n // }\n // } else {\n // alpha = max(alpha, lineAlpha);\n // }\n \n // clamp(alpha, 0., 1.);\n accumulationValue = clamp(accumulationValue + (1.0 - accumulationValue) * lineAlpha * 0.1, 0., 5.);\n // alpha = clamp(alpha + (1.0 - alpha) * lineAlpha * alphaIncrement, 0., 1.);\n // alpha = clamp(alpha, 0., 1.);\n\n // if(alphaHardLine > alpha) {\n alpha = clamp(1.0 - (1.0 - alpha) * (1.0 - lineAlpha * alphaIncrement), 0., 1.);\n color.x = clamp(\n 1.0 - (1.0 - localColor.x) * (1.0 - lineAlpha * lightnessIncrement), \n originalColor.x - accumulationClamp.x, \n originalColor.x + accumulationClamp.x\n );\n if(!uDisableSaturationShift) {\n color.y = clamp(1.0 - (1.0 - localColor.y) * (1.0 - lineAlpha * chromaIncrement), \n originalColor.y - accumulationClamp.y, \n originalColor.y + accumulationClamp.y\n );\n }\n \n \n }\n\n if(alpha <= 0.) {\n return vec4(frameBuffer, 1.);\n }\n\n // accumulationValue *= (smoothstep(.08, .0, sdf) + .5);\n \n // if(uIsShading) {\n // float chromaIncrement = 0.07 * uAccumulationStrength; // adjust for subtlety\n // float lightnessIncrement = -0.07 * uAccumulationStrength;\n\n // // if(uIsShading) {\n // // accumulationValue = clamp(accumulationValue, 0., .1);\n // color.x += accumulationValue * lightnessIncrement;\n // color.y += accumulationValue * chromaIncrement;\n\n // color.x += 0.08;\n // color.y -= (chromaIncrement * 0.4);\n // }\n\n // alpha = clamp(alpha, 0., 1.);\n float brightnessNoiseInfluence = smoothstep(-1., 1., fbm(uv + uNoiseOffset, 2, 50., 0.9)) + 0.4;\n float brightnessNoise = smoothstep(0.1, 0.31, fbm(uv + uNoiseOffset, 2, 1800., 0.5)) * brightnessNoiseInfluence * 0.002;\n color.x += brightnessNoise;\n\n float alphaNoise2 = smoothstep(-1., 1., fbm(uv, 1, 1000., 0.1)) * 0.02;\n float alphaNoise = smoothstep(-0.6, 1., fbm(uv, 2, 1200., 0.1)) * 0.12;\n alpha -= (alphaNoise + alphaNoise2);\n alpha = clamp(alpha, 0., 1.);\n\n // float colourShift = (smoothstep(0.1, 0.4, fbm(uv + uNoiseOffset, 2, 5., 0.6)) - 0.5) * 0.0001;\n // color.x += colourShift;\n\n \n \n float colorBrightWobble = fbm(uv + uNoiseOffset, 2, 20., 0.9) * 0.001;\n float colorEase = (\n easeOut(smoothstep(.02, .0, sdf + colorBrightWobble), 1.) \n * (0.01 + (accumulationValue * 0.02))\n );\n\n float colorBrightNoise = smoothstep(-0.4, 0.4, fbm(uv + uNoiseOffset, 2, 700., 0.9));\n float darkenEdge = easeOut(smoothstep(.0035, .0, sdf - (colorBrightWobble * 4.)), 1.) \n * (0.06 + (accumulationValue * 0.02)) * colorBrightNoise;\n\n colorEase += darkenEdge;\n \n color.x -= colorEase;\n color.y += (colorEase * 0.4);\n\n // color.x += 0.005;\n // color.y -= 0.005;\n\n // color.x -= 0.01;\n // color.y -= 0.02;\n\n // LINE SDF\n \n // LINE BRIGHTNESS\n \n color.x = clamp(color.x, 0., .84);\n color.y = clamp(color.y, 0., .4); \n // float satWeight = 0.05;\n // color.y *= remap(uBrightness, 0., 2., 1. + satWeight + 0.3, 1. - satWeight);\n\n \n\n // LIGHTING\n vec3 lightDir = normalize(vec3(.6f, 1.6f, 1.6f));\n vec3 lightColor = vec3(1.0f) * 1.7f;\n \n vec3 paperTextureNormals = calculateNormals(screenSpaceUV + msaaOffset, 0.0002 * tileScaleFactor.x, 4.);\n vec3 diffuse = calculateDiffuse(paperTextureNormals, lightDir, lightColor);\n\n vec3 colorRGB = OKLCHtoP3LRGB(color) * diffuse;\n vec3 colorMult = (frameBuffer * colorRGB) * diffuse;\n\n colorRGB = mix(frameBuffer, mix(colorMult, colorRGB * diffuse, clamp(0.9, 1., alpha + 0.3)), alpha);\n // colorRGB\n\n // colorRGB = mix(frameBuffer, colorRGB, alpha);\n\n // if(uEnableFadeAtLineSegment) {\n // colorRGB = vec3(segmentDistanceAlphaMult);\n // }\n\n return vec4(colorRGB, 1.0);\n }\n\n void main() {\n const vec2 H2 = vec2(0.5698402909980532f, 0.7548776662466927f);\n vec2 px = 1.f / resolution;\n px *= 1.25;\n vec2 uv = vUv;\n\n \n // Check if this fragment is within the SDF\n vec2 uvOffset = lookupWarpSample(uv).xy;\n float texCheck = (texture(tPolyEdgeDistance, uv + uvOffset).r - 0.5) * 2.0;\n if(texCheck < -0.1) {\n discard;\n }\n\n vec3 frameBuffer = texture(tScreenBuffer, vUv).rgb;\n\n\n const float samples = 4.f;\n \n vec4 sumColour;\n vec2 d0 = vec2(randomNonDet(uv), randomNonDet(uv + 1.f));\n\n \n for(float i = 0.f; i < samples; i++) {\n vec2 d = (fract(i * H2 + d0) - .5f);\n\n vec2 localCoord = vUv + d * px; /* changed */\n vec2 screenCoord = uTileOffset + localCoord * uTileSize; /* changed */\n vec2 globalUV = screenCoord / resolution; /* changed */\n\n // vec4 sampleColor = render(globalUV, vUv, d * px);\n vec4 sampleColor = render(globalUV, vUv, d * px, frameBuffer);\n // sampleColor.rgb *= sampleColor.a; // Convert to premultiplied alpha\n sumColour += sampleColor;\n }\n \n vec4 averageColor = clamp(sumColour / samples, 0., 1.);\n \n outColor = averageColor;\n }\n `});let n=t.isShading?At:Et;n.updatePolylines(t.lines,t.closedPolyOrLine);let i=jt.uniforms;re(jt),Vt.material=jt,i.tScreenBuffer.value=Xt.getReadBuffer().texture;let l=t.lineColor;if(i.uLineColor.value=Ht(l),i.uDisableSaturationShift.value=t.disableSaturationShift||!1,i.uLineWeight.value=t.lineWeight,i.uLineHardness.value=t.linePressure,i.uMaterialHardness.value=t.materialHardness||1,i.uIsShading.value=t.isShading||!1,i.tWarpTex.value=t.canWarp?Ct.displacementMapWarped.target.texture:Ct.displacementMap.target.texture,i.uNoiseOffset.value=new le(...t.noiseOffset),i.uFaceIndex.value=_t++,i.uLineWeight.value=t.lineWeight,i.uTaperingFadeIn.value=t.lineTapering.fade.in.enabled?t.lineTapering.fade.in.length:0,i.uTaperingFadeOut.value=t.lineTapering.fade.out.enabled?t.lineTapering.fade.out.length:0,i.uTaperingScaleIn.value=t.lineTapering.scale.in.enabled?t.lineTapering.scale.in.length:0,i.uTaperingScaleOut.value=t.lineTapering.scale.out.enabled?t.lineTapering.scale.out.length:0,i.uBrightness.value=t.lineBrightness||1,i.uEdgeSharpness.value=t.edgeSharpness||1,i.uAccumulationStrength.value=t.accumulationStrength||1,t?.fadeAtLineSegment){let e=Ot(t.fadeAtLineSegment.segment);const n=i.uFadeAtLineSegmentVertices.value;n[0]=e[0][0],n[1]=e[0][1],n[2]=e[1][0],n[3]=e[1][1],i.uFadeAtLineSegmentDistance.value=t.fadeAtLineSegment.distance,i.uFadeAtLineSegmentStrength.value=t.fadeAtLineSegment.strength,i.uEnableFadeAtLineSegment.value=!0,jt.needsUpdate=!0}else i.uEnableFadeAtLineSegment.value=!1;if(!qt||$t!==n){const{cellsWide:e,cellsHigh:t,cellSize:l}=n,{segmentDataTexture:a,segmentMetaDataTexture:s,segmentIndexTexture:o}=n.getTextures();i.uSegmentDataTex.value=a,i.uSegmentMetaDataTex.value=s,i.uSegmentIndexTex.value=o,i.tPolyLineGrid.value={width:e*l,height:t*l,cellSize:l},qt=!0}i.uIsClosedPoly.value=t.closedPolyOrLine,X.setRenderTarget(Xt.getWriteBuffer()),Vt.render(),Xt.copyAndSwapBuffers(),$t=n}let tn=new e.Vector4;class nn{minX=1/0;minY=1/0;maxX=-1/0;maxY=-1/0;constructor(){}get width(){return this.maxX-this.minX}get height(){return this.maxY-this.minY}get center(){return new zt((this.minX+this.maxX)/2,(this.minY+this.maxY)/2)}get vertexList(){return[new zt(this.minX,this.minY),new zt(this.maxX,this.minY),new zt(this.maxX,this.maxY),new zt(this.minX,this.maxY)]}get area(){return this.width*this.height}reset(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}expand(e){this.minX=Math.min(e.x,this.minX),this.minY=Math.min(e.y,this.minY),this.maxX=Math.max(e.x,this.maxX),this.maxY=Math.max(e.y,this.maxY)}expands(e){for(let t=0,n=e.length;t<n;t++)this.expand(e[t]);return this}expandByPoint(e){return this.minX=Math.min(e[0],this.minX),this.minY=Math.min(e[1],this.minY),this.maxX=Math.max(e[0],this.maxX),this.maxY=Math.max(e[1],this.maxY),this}expandsByPoint(e){for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t])}intersects(e,t=b){return!(e.maxX<this.minX-t||e.minX>this.maxX+t||e.maxY<this.minY-t||e.minY>this.maxY+t)}expandByValue(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,this}containsPoint(e){return e.x<=this.maxX+b&&e.x>=this.minX-b&&e.y<=this.maxY+b&&e.y>=this.minY-b}distanceToPoint(e){const t=r(this.minX-e.x,0,e.x-this.maxX),n=r(this.minY-e.y,0,e.y-this.maxY);return d(t*t+n*n)}containsBB(e){return e.minX>=this.minX-b&&e.maxX<=this.maxX+b&&e.minY>=this.minY-b&&e.maxY<=this.maxY+b}containsPoints(e){for(let t=0,n=e.length;t<n;t++)if(!this.containsPoint(e[t]))return!1;return!0}size(){return{width:this.maxX-this.minX,height:this.maxY-this.minY}}}let ln,an=[];var sn,on;function rn(i){ln=ln||new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(B,Q)},tPositions:{value:new e.DataTexture},uPositionsCount:{value:0},...ce()},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n\t\t\tprecision highp int;\n \n uniform highp sampler2D tPositions;\n uniform vec2 resolution;\n uniform int uPositionsCount;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n \n varying vec2 vUv;\n out vec4 outColor;\n\n ${ne}\n\n float pointLineSegSDF(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\n return length(pa - ba * t);\n }\n \n bool isIntersecting(vec2 point, vec2 p1, vec2 p2) {\n if(p1.y == p2.y) {\n return false;\n }\n \n if(p1.y > point.y && p2.y > point.y) {\n return false;\n }\n \n if(p1.y < point.y && p2.y < point.y) {\n return false;\n }\n \n float intersectionX = p1.x + (point.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);\n return intersectionX > point.x;\n }\n\n vec2 fetchVertex(int vertexIndex) {\n int textureWidth = textureSize(tPositions, 0).x;\n int x = vertexIndex % textureWidth;\n int y = vertexIndex / textureWidth;\n return texelFetch(tPositions, ivec2(x, y), 0).rg;\n }\n \n float polyDistanceSDF(vec2 uv) {\n float minDist = 1e20;\n int intersections = 0;\n \n for(int i = 0; i < uPositionsCount; i++) {\n vec2 vertex1 = fetchVertex(i) / resolution.xy;\n vec2 vertex2 = fetchVertex((i + 1) % uPositionsCount) / resolution.xy;\n \n minDist = min(minDist, pointLineSegSDF(uv, vertex1, vertex2));\n \n if(isIntersecting(uv, vertex1, vertex2)) {\n intersections++;\n }\n }\n return float(intersections % 2 == 1 ? minDist : -minDist);\n // return float(intersections % 2 == 1 ? minDist : 1.5);\n }\n \n vec4 render(vec2 uv) {\n float dist = polyDistanceSDF(uv);\n return vec4(dist) * 0.5 + .5;\n }\n \n\n void main() {\n // A pseudo-random distribution for multi-sample\n const vec2 H2 = vec2(0.56984029, 0.75487766);\n // We do sub-pixel offsets relative to tile size, \n // because each tile is scaled to fill the entire local canvas\n vec2 px = 1.0 / resolution.xy;\n px *= 1.25;\n\n // We'll accumulate color across multiple samples\n const float samples = 4.0;\n vec4 sumColour = vec4(0.0);\n \n // Vary the random offset per pixel\n vec2 d0 = vec2(randomNonDet(vUv), randomNonDet(vUv + 1.0));\n\n for (float i = 0.0; i < samples; i++) {\n vec2 d = fract(i * H2 + d0) - 0.5;\n // localCoord in [0..1] in the local canvas\n vec2 sampleCoord = vUv + d * px;\n\n // Now map that to the large “full” coordinate space \n // subregion given by uTileOffset..uTileOffset+uTileSize\n vec2 screenCoord = uTileOffset + sampleCoord * uTileSize;\n\n // Next convert to [0..1] over the entire original geometry\n vec2 globalUV = screenCoord / resolution;\n\n vec4 sampleColor = render(globalUV);\n sumColour += sampleColor;\n }\n\n vec4 finalColor = clamp(sumColour / samples, 0.0, 1.0);\n outColor = finalColor;\n }\n `});let l=Ot(i.polygon);ln.uniforms.uPositionsCount.value=l.length;let a=function(t){const i=t.flat(),l=i.length/2,a=o(C,l),s=n(l/C),r=new Float32Array(a*s*2);for(let e=0;e<l;e++){const t=2*e;r[t]=i[t]||0,r[t+1]=i[t+1]||0}let c=new e.DataTexture(r,a,s,e.RGFormat,e.FloatType);return c.needsUpdate=!0,{texture:c,width:a,height:s}}(l);ln.uniforms.tPositions.value=a.texture,re(ln),Vt.material=ln,X.setRenderTarget(Ct.polyEdgeDistance.target),X.setClearColor(1,0),X.clear();let s=oe();var c;((e,i=5)=>{i/=U,X.setScissorTest(!0),X.setScissor(((e,i=5)=>{let l=i*U,a=o(...e.map((e=>e.x)))-l,s=r(...e.map((e=>e.x)))+l,c=o(...e.map((e=>e.y)))-l,d=r(...e.map((e=>e.y)))+l,u=s-a,h=d-c;return tn.set(kt(t(a),0,B),kt(t(Q-d),0,Q),n(o(u,B)),n(o(h,Q))).divideScalar(N).round()})(e,i))})((c=i.polygon.map((e=>new le(e.x,e.y))),c.map((e=>e.clone().multiplyScalar(U)))).map((e=>(e.x=t((e.x-s.xOff)*(B/s.width)),e.y=n((e.y-s.yOff)*(Q/s.height)),e))),n(10*U*(B/s.width))),Vt.render(),X.setScissorTest(!1)}!function(e){e[e.constructionLine=0]="constructionLine",e[e.detail=1]="detail",e[e.foreground=2]="foreground",e[e.background=3]="background",e[e.shadow=4]="shadow",e[e.walker=5]="walker",e[e.overlay=6]="overlay",e[e.overlayOutline=7]="overlayOutline"}(sn||(sn={})),function(e){e[e.regular=0]="regular",e[e.warped=1]="warped"}(on||(on={}));const cn=4095,dn=e=>.5*(1-l(e*g));let un;function hn(e){un=new Float32Array(4096);for(let e=0;e<4096;e++)un[e]=J.dec()}let mn=(e,n,i=0,l=5,a=0,s=1)=>Kt(function(e,n=0,i=0){un||hn(),e<0&&(e=-e),n<0&&(n=-n),i<0&&(i=-i);let l,a,s,o,r,c=t(e),d=t(n),u=t(i),h=e-c,m=n-d,p=i-u,g=0,b=.5;for(let e=0;e<3;e++){let e=c+(d<<4)+(u<<8);l=dn(h),a=dn(m),s=un[e&cn],s+=l*(un[e+1&cn]-s),o=un[e+16&cn],o+=l*(un[e+16+1&cn]-o),s+=a*(o-s),e+=256,o=un[e&cn],o+=l*(un[e+1&cn]-o),r=un[e+16&cn],r+=l*(un[e+16+1&cn]-r),o+=a*(r-o),s+=dn(p)*(o-s),g+=s*b,b*=.8,c<<=1,h*=2,d<<=1,m*=2,u<<=1,p*=2,h>=1&&(c++,h--),m>=1&&(d++,m--),p>=1&&(u++,p--)}return g}((e+100)/l,(n+100)/l,(i+100)/l),0,1,a,s);const pn=b;var gn;function bn(e,t,n=!1){if(0===t.length)return e;if(1===t.length)return t[0];let i,l=1/0,a=n?t.length:t.length-1;for(let n=0;n<a;n++){const a=t[n],s=t[(n+1)%t.length],o=xn(e,a,s);o<l&&(l=o,i=[a,s])}return i?function(e,t,n){const[i,l]=t,[a,s]=n,[o,r]=e,c=a-i,d=s-l,u=c*c+d*d;if(u<pn)return[i,l];let h=((o-i)*c+(r-l)*d)/u;return h<-1e-7?h=0:h>1+pn&&(h=1),[i+h*c,l+h*d]}(e,...i):e}function fn(e,t,n=!1){let i=1/0;const l=t.length,a=n?l:l-1;for(let n=0;n<a;n++){const a=Zn(e,t[n],n===l-1?t[0]:t[n+1]);if(a<pn)return 0;i=Math.min(i,a)}return Math.sqrt(i)}function xn(e,t,n){return d(Zn(e,t,n))}function Zn(e,t,n){const[i,l]=t,[a,s]=n,[o,r]=e,c=a-i,d=s-l,u=c*c+d*d;if(u<pn){const e=o-i,t=r-l;return e*e+t*t}let h=((o-i)*c+(r-l)*d)/u;h<-1e-7?h=0:h>1+pn&&(h=1);const m=o-(i+h*c),p=r-(l+h*d);return m*m+p*p}!function(e){e[e.intersecting=0]="intersecting",e[e.colinear=1]="colinear",e[e.parallel=2]="parallel"}(gn||(gn={}));let yn=0;class Gn{v1;v2;id=yn++;origin;angle;length;twin=null;nexthedge=null;prevhedge=null;face=null;constructor(e,t){this.v1=e,this.v2=t,this.id=yn++,this.origin=t,this.angle=function(e,t){let n=t.x-e.x,i=t.y-e.y;const l=d(n*n+i*i);return i>0?u(n/l):2*g-u(n/l)}(e,t),this.length=d(a(t.x-e.x,2)+a(t.y-e.y,2))}dispose(){this.origin=null,this.twin=null,this.nexthedge=null,this.prevhedge=null,this.face=null}getAABB(){let e=new nn;return e.expands([this.origin,this.twin.origin]),e}intersectWithLineSegment([e,t]){return function(e,t,n,i){const{x:l,y:a}=e,{x:s,y:o}=t,{x:r,y:c}=n,{x:d,y:u}=i,h=(u-c)*(s-l)-(d-r)*(o-a),m=(d-r)*(a-c)-(u-c)*(l-r),p=(s-l)*(a-c)-(o-a)*(l-r);if(Math.abs(h)<pn)return Math.abs(m)<pn&&Math.abs(p)<pn?{type:gn.colinear,point:null,ua:0,ub:0}:{type:gn.parallel,point:null,ua:0,ub:0};const g=m/h,b=p/h;return g>=-1e-7&&g<=1+pn&&b>=-1e-7&&b<=1+pn?{type:gn.intersecting,point:new zt(l+g*(s-l),a+g*(o-a)),ua:g,ub:b}:{type:null,point:null,ua:g,ub:b}}(this.origin,this.twin.origin,e,t)}}const Wn=b;class vn{tolerance;vertices=[];hedges=[];faces=[];vertexMap=new Map;constructor(e,t,n=Wn){this.tolerance=n,e&&t&&this.setDatas(e,t)}getVertexKey(e,t){const n=e/this.tolerance,i=t/this.tolerance;return`${Z(n,this.tolerance)},${Z(i,this.tolerance)}`}addVertex(e,t){const n=this.getVertexKey(e,t);let i=this.vertexMap.get(n);i||(i=[],this.vertexMap.set(n,i));for(const n of i)if(this.isClose(n.x,e)&&this.isClose(n.y,t))return n;const l=new zt(e,t);return this.vertices.push(l),i.push(l),l}deleteVertex(e){const t=this.getVertexKey(e.x,e.y),n=this.vertexMap.get(t);if(n){const i=n.indexOf(e);i>-1&&(n.splice(i,1),0===n.length&&this.vertexMap.delete(t))}const i=this.vertices.indexOf(e);i>-1&&this.vertices.splice(i,1),e.dispose()}findVertex(e,t){const n=this.getVertexKey(e,t),i=this.vertexMap.get(n);if(i)for(const n of i)if(this.isClose(n.x,e)&&this.isClose(n.y,t))return n;return null}verticesInPoly(e){let t=e.map((e=>(new zt).fromArray(e))),n=new nn;n.expands(t);let i=[],l=this.verticesInBB(n);for(let e of l)Tn(t,e)&&i.push(e);return i}verticesInBB(e){const t=[];for(let n of this.vertices)e.containsPoint(n)&&t.push(n);return t}setDatas(e,t){const{vertices:n,hedges:i,faces:l}=this;for(let t=0,n=e.length;t<n;t++){const n=e[t];this.addVertex(n[0],n[1])}for(let e=0,l=t.length;e<l;e++){const l=t[e],a=new Gn(n[l[0]],n[l[1]]),s=new Gn(n[l[1]],n[l[0]]);a.twin=s,s.twin=a,n[l[1]].hedgelist.push(a),n[l[0]].hedgelist.push(s),i.push(s),i.push(a)}for(let e=0,t=n.length;e<t;e++){const t=n[e];t.sortincident();const i=t.hedgelist.length;if(0!=i)if(i<2)t.hedgelist[0].prevhedge=t.hedgelist[0].twin,t.hedgelist[0].twin.nexthedge=t.hedgelist[0];else{for(let e=0;e<i-1;e++)t.hedgelist[e].twin.nexthedge=t.hedgelist[e+1],t.hedgelist[e+1].prevhedge=t.hedgelist[e].twin;t.hedgelist[i-1].twin.nexthedge=t.hedgelist[0],t.hedgelist[0].prevhedge=t.hedgelist[i-1].twin}}const a=i.slice(0);let s=i.length;for(;s>0;){let e=a.pop();if(s-=1,null==e.face){const t=new Rn(this);for(t.wedge=e,t.wedge.face=t;e.nexthedge!==t.wedge;)e=e.nexthedge,e.face=t;l.push(t)}}}internalFaces(){const e=[],t=this.faces;for(let n=0,i=t.length;n<i;n++){const i=t[n];i.internal&&e.push(i)}return e}externalFaces(){const e=[],t=this.faces;for(let n=0,i=t.length;n<i;n++){const i=t[n];i.external&&e.push(i)}return e}dispose(){const{vertices:e,hedges:t,faces:n}=this;for(let t=0,n=e.length;t<n;t++)e[t].dispose();for(let e=0,n=t.length;e<n;e++)t[e].dispose();for(let e=0,t=n.length;e<t;e++)n[e].dispose();e.length=0,t.length=0,n.length=0}isClose=(e,t)=>s(e-t)<this.tolerance;findHedge(e,t,n,i){const{isClose:l}=this,a=this.findVertex(e,t);if(a)for(const e of a.hedgelist){const t=e.twin.origin;if(l(t.x,n)&&l(t.y,i))return e}const s=this.findVertex(n,i);if(s)for(const n of s.hedgelist){const i=n.twin.origin;if(l(i.x,e)&&l(i.y,t))return n}return null}addEdge(e,t,n,i){const{vertices:l,hedges:a,faces:s}=this;let o=!1,r=!1,c=!1,d=this.findVertex(e,t);d||(d=this.addVertex(e,t),o=!0);let u=this.findVertex(n,i);u||(u=this.addVertex(n,i),r=!0);const h=new Gn(u,d);a.push(h),d.hedgelist.push(h),d.sortincident();const m=new Gn(d,u);if(a.push(m),u.hedgelist.push(m),u.sortincident(),h.twin=m,m.twin=h,o)h.
const{cellsWide:i,cellsHigh:l}=this;this.segmentMetaDataTexture={texture:new e.DataTexture(new Float32Array(i*l*2),i,l,e.RGFormat,e.FloatType),width:i,height:l},this.segmentMetaDataTexture.texture.needsUpdate=!0,this.segmentIndexTexture={texture:new Bt(n,n,e.RedFormat,e.FloatType,new Float32Array(n*n)),width:n,height:n},this.segmentIndexTexture.texture.setRenderer(X)}updatePolylines(e,t=!1){this.isClosed=t,this.polyLines=e,this.texturesInitialised||(this.initializeTextures(),this.texturesInitialised=!0),this.buildSegmentRecords(),this.buildSegmentCellIndex(),this.buildSegmentDataTextures()}buildSegmentRecords(){const e=this.polyLines.reduce(((e,t)=>{const n=this.isClosed?t.length:t.length-1;return n>0?e+n:e}),0);this._segmentRecords=new Float32Array(8*e);let t=0;this.polyLines.forEach(((e,n)=>{let i=0;for(let t=0;t<e.length-1;t++)i+=Qt(e[t],e[t+1]);this.isClosed&&e.length>1&&(i+=Qt(e[e.length-1],e[0]));let l=0;const a=this.isClosed?e.length:e.length-1;for(let s=0;s<a;s++){const a=e[s],o=e[(s+1)%e.length],r=Qt(a,o);this._segmentRecords[t++]=a[0],this._segmentRecords[t++]=a[1],this._segmentRecords[t++]=o[0],this._segmentRecords[t++]=o[1],this._segmentRecords[t++]=n,this._segmentRecords[t++]=l,this._segmentRecords[t++]=l+r,this._segmentRecords[t++]=i,l+=r}}))}buildSegmentCellIndex(){const e=this.cellsWide*this.cellsHigh;this._cellCounts=new Float32Array(e),this._cellOffsets=new Float32Array(e);const n=this._segmentRecords.length/8;let i=0;for(let e=0;e<n;e++){const e=this._segmentRecords[i+0],n=this._segmentRecords[i+1],l=this._segmentRecords[i+2],a=this._segmentRecords[i+3];i+=8;const o=t(e/this.cellSize),r=t(n/this.cellSize),c=t(l/this.cellSize),d=t(a/this.cellSize);let u=s(c-o),h=s(d-r),m=o,p=r,g=1+u+h;const b=c>o?1:-1,f=d>r?1:-1;let x=u-h;for(u*=2,h*=2;g--;){if(m>=0&&m<this.cellsWide&&p>=0&&p<this.cellsHigh){const e=p*this.cellsWide+m;this._cellCounts[e]++}if(x>0)m+=b,x-=h;else if(x<0)p+=f,x+=u;else{if(m+=b,p+=f,x+=u-h,g--,g<0)break;if(m>=0&&m<this.cellsWide&&p>=0&&p<this.cellsHigh){const e=p*this.cellsWide+m;this._cellCounts[e]++}}}}let l=0;for(let t=0;t<e;t++){const e=this._cellCounts[t];this._cellOffsets[t]=l,l+=e}this._indexData=new Float32Array(l),i=0;for(let e=0;e<n;e++){const n=this._segmentRecords[i+0],l=this._segmentRecords[i+1],a=this._segmentRecords[i+2],o=this._segmentRecords[i+3];i+=8;const r=t(n/this.cellSize),c=t(l/this.cellSize),d=t(a/this.cellSize),u=t(o/this.cellSize);let h=s(d-r),m=s(u-c),p=r,g=c,b=1+h+m;const f=d>r?1:-1,x=u>c?1:-1;let Z=h-m;for(h*=2,m*=2;b--;){if(p>=0&&p<this.cellsWide&&g>=0&&g<this.cellsHigh){const t=g*this.cellsWide+p,n=this._cellOffsets[t];this._indexData[n]=e,this._cellOffsets[t]=n+1}if(Z>0)p+=f,Z-=m;else if(Z<0)g+=x,Z+=h;else{if(p+=f,g+=x,Z+=h-m,b--,b<0)break;if(p>=0&&p<this.cellsWide&&g>=0&&g<this.cellsHigh){const t=g*this.cellsWide+p,n=this._cellOffsets[t];this._indexData[n]=e,this._cellOffsets[t]=n+1}}}}}buildSegmentDataTextures(){const e=this.segmentDataTexture.texture.texture.image.data,t=this.segmentDataTexture.width,n=this.segmentDataTexture.height,i=this._segmentRecords.length/8,l=o(2*i,t*n);let a=0,s=0;for(let t=0;t<i&&!(2*t+1>=l);t++){const n=2*t*4,i=4*(2*t+1),l=this._segmentRecords[a+0],o=this._segmentRecords[a+1],r=this._segmentRecords[a+2],c=this._segmentRecords[a+3],d=this._segmentRecords[a+4],u=this._segmentRecords[a+5],h=this._segmentRecords[a+6],m=this._segmentRecords[a+7];e[n+0]=l,e[n+1]=o,e[n+2]=r,e[n+3]=c,e[i+0]=d,e[i+1]=u,e[i+2]=h,e[i+3]=m,a+=8,s+=8}this.segmentDataTexture.texture.uploadSubData(s);const r=this.segmentMetaDataTexture.texture.image.data,c=this.segmentMetaDataTexture.width*this.segmentMetaDataTexture.height;for(let e=0;e<c;e++){const t=this._cellCounts[e],n=this._cellOffsets[e]-t,i=2*e;r[i+0]=n,r[i+1]=t}this.segmentMetaDataTexture.texture.needsUpdate=!0;const d=this.segmentIndexTexture.texture.texture.image.data,u=d.length,h=Math.min(this._indexData.length,u);d.set(this._indexData.subarray(0,h)),this.segmentIndexTexture.texture.uploadSubData(this._indexData.length)}getTextures(){return{segmentMetaDataTexture:this.segmentMetaDataTexture.texture,segmentDataTexture:this.segmentDataTexture.texture.texture,segmentIndexTexture:this.segmentIndexTexture.texture.texture}}reset(){this._segmentRecords=new Float32Array(0),this._cellCounts=new Float32Array(0),this._cellOffsets=new Float32Array(0),this._indexData=new Float32Array(0)}dispose(){this.segmentDataTexture.texture.texture.dispose(),this.segmentMetaDataTexture.texture.dispose(),this.segmentIndexTexture.texture.texture.dispose()}}let jt,At=new Jt(4),Et=new Jt(20),_t=0,qt=!1,$t=null;function en(t){if(0===t.lines.length)return;jt=jt||new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(B,Q)},uInternalResolution:{value:new e.Vector2(Y,P)},uFaceIndex:{value:0},tPaperTexture:{value:Ct.paperTexture.target.texture},uSegmentDataTex:{value:null},uSegmentIndexTex:{value:null},uSegmentMetaDataTex:{value:null},uBrightness:{value:1},...ce(),uAccumulationStrength:{value:1},uEdgeSharpness:{value:1},uTaperingFadeIn:{value:0},uTaperingFadeOut:{value:0},uTaperingScaleIn:{value:0},uTaperingScaleOut:{value:0},uFadeAtLineSegmentVertices:{value:new Float32Array([0,0,0,0])},uFadeAtLineSegmentDistance:{value:0},uFadeAtLineSegmentStrength:{value:1},uEnableFadeAtLineSegment:{value:!1},uIsShading:{value:!0},uDisableSaturationShift:{value:!1},uIsClosedPoly:{value:!1},tScreenBuffer:{value:Xt.getReadBuffer().texture},tPolyEdgeDistance:{value:Ct.polyEdgeDistance.target.texture},uNoiseOffset:{value:new le(0,0)},tWarpTex:{value:Ct.displacementMap.target.texture},uLineColor:{value:new e.Vector3(1,0,0)},uLineHardness:{value:1},uLineWeight:{value:1},uMaterialHardness:{value:1},uLighting:{value:{center:Ke.default,min:wt(Ke.default,Ke.min,Ke.influencesBrightnessMult),max:wt(Ke.default,Ke.max,Ke.influencesBrightnessMult)}},tPolyLineGrid:{value:{width:0,height:0,cellSize:0}}},vertexShader:ie,glslVersion:e.GLSL3,fragmentShader:`\n precision highp float;\n precision highp int;\n\n uniform highp sampler2D tWarpTex;\n uniform highp sampler2D tScreenBuffer;\n uniform highp sampler2D tPaperTexture;\n uniform highp sampler2D tPolyEdgeDistance;\n\n uniform highp sampler2D uSegmentDataTex;\n uniform highp sampler2D uSegmentMetaDataTex;\n uniform highp sampler2D uSegmentIndexTex;\n\n struct TPolyLineGrid {\n float width;\n float height;\n float cellSize;\n };\n\n uniform TPolyLineGrid tPolyLineGrid;\n\n\n struct Lighting {\n float center;\n float min;\n float max;\n };\n\n uniform Lighting uLighting;\n \n // uniform int uPositionsCount;\n uniform bool uIsClosedPoly;\n \n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n\n uniform vec2 uInternalResolution;\n uniform vec2 uNoiseOffset;\n uniform bool uIsShading;\n // uniform bool uBulge;\n\n uniform float uTaperingFadeIn;\n uniform float uTaperingFadeOut;\n uniform float uTaperingScaleIn;\n uniform float uTaperingScaleOut;\n\n uniform bool uEnableFadeAtLineSegment;\n uniform vec2 uFadeAtLineSegmentVertices[2];\n uniform float uFadeAtLineSegmentDistance;\n uniform float uFadeAtLineSegmentStrength;\n\n uniform float uBrightness;\n uniform float uEdgeSharpness;\n uniform float uAccumulationStrength;\n uniform float uMaterialHardness;\n uniform vec3 uLineColor;\n uniform float uLineHardness;\n uniform float uLineWeight;\n uniform float uFaceIndex;\n uniform bool uDisableSaturationShift;\n\n // Max number of lines to consider for this fragment\n const int MAX_LINE_COUNT = 64;\n\n in vec2 vUv;\n out vec4 outColor;\n\n ${Dt}\n ${te}\n ${bt}\n ${gt}\n ${ee}\n ${ne}\n ${Ut}\n\n //-----------------------------------------\n \n\n vec2 pointLineSDFInfinite(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = dot(pa, ba) / dot(ba, ba);\n float dist = length(pa - ba * t);\n return vec2(dist, t);\n }\n\n // 1) Helper to fetch offset+count from segmentMetaDataTexture\n vec2 getSegmentMeta(ivec2 cellCoords) {\n // each pixel stores (offset, count)\n return texelFetch(uSegmentMetaDataTex, cellCoords, 0).rg;\n }\n \n ivec2 getCellCounts() {\n return ivec2(\n int(tPolyLineGrid.width / tPolyLineGrid.cellSize),\n int(tPolyLineGrid.height / tPolyLineGrid.cellSize)\n );\n }\n\n ivec2 getGridCoords(vec2 uv) {\n ivec2 cellCount = getCellCounts();\n \n // Flip Y so top-left is (0,0)\n float flippedY = 1.0 - uv.y;\n \n int x = int(floor(uv.x * float(cellCount.x)));\n int y = int(floor(flippedY * float(cellCount.y)));\n \n return ivec2(x, y);\n }\n\n\n // 2) Helper to read the segment ID from segmentIndexTexture\n int getSegmentID(int globalIndex) {\n ivec2 size = textureSize(uSegmentIndexTex, 0);\n // clamp the fetch\n globalIndex = clamp(globalIndex, 0, size.x*size.y - 1);\n int x = globalIndex % size.x;\n int y = globalIndex / size.x;\n return int(texelFetch(uSegmentIndexTex, ivec2(x,y), 0).r);\n }\n\n // 3) Helper to read the 2 texels for the given segment\n struct SegmentData {\n vec2 a; // x1,y1\n vec2 b; // x2,y2\n float lineIndex; \n float segStart;\n float segEnd;\n float totalLen;\n };\n\n SegmentData getSegmentData(int segmentID) {\n SegmentData seg;\n // float scaleFactor = (1. / uInternalResolution.x);\n\n // each segment uses 2 RGBA texels = 8 floats\n // texel1 => (x1, y1, x2, y2)\n // texel2 => (lineIndex, segStartLen, segEndLen, totalLineLen)\n int texelIndex1 = segmentID * 2;\n int texelIndex2 = segmentID * 2 + 1;\n\n ivec2 size = textureSize(uSegmentDataTex, 0);\n\n // clamp fetch\n int maxTexels = size.x * size.y;\n texelIndex1 = clamp(texelIndex1, 0, maxTexels-1);\n texelIndex2 = clamp(texelIndex2, 0, maxTexels-1);\n\n // decode coordinates\n int x1 = texelIndex1 % size.x;\n int y1 = texelIndex1 / size.x;\n int x2 = texelIndex2 % size.x;\n int y2 = texelIndex2 / size.x;\n\n vec4 d1 = texelFetch(uSegmentDataTex, ivec2(x1,y1), 0);\n vec4 d2 = texelFetch(uSegmentDataTex, ivec2(x2,y2), 0);\n\n seg.a = d1.xy / uInternalResolution;\n seg.b = d1.zw / uInternalResolution;\n\n seg.a = vec2(seg.a.x, 1.0 - seg.a.y);\n seg.b = vec2(seg.b.x, 1.0 - seg.b.y);\n\n seg.lineIndex = d2.x;\n seg.segEnd = d2.z / uInternalResolution.x;\n seg.segStart = d2.y / uInternalResolution.x;\n seg.totalLen = d2.w / uInternalResolution.x; // scale to pixel space\n\n return seg;\n }\n\n vec2 pointLineSegSDF(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float t = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\n float dist = length(pa - ba * t);\n return vec2(dist, t);\n }\n\n\n // This struct can store the final line-based result\n struct LineDistanceResult {\n float dist; // nearest distance for this line\n float lineT; // fraction along the entire line\n float lineIndex; // which line\n };\n \n const ivec2 offsets[9] = ivec2[](\n ivec2(-1,-1), ivec2(0,-1), ivec2(1,-1),\n ivec2(-1, 0), ivec2(0, 0), ivec2(1, 0),\n ivec2(-1, 1), ivec2(0, 1), ivec2(1, 1)\n );\n\n // This function will find the closest lines to the given uv coordinate\n void lineDistanceSDFSegments(\n vec2 uv,\n float distanceThreshold,\n out LineDistanceResult linesWithin[MAX_LINE_COUNT],\n out int linesCount\n ){\n linesCount = 0;\n \n // We'll keep track of each line's nearest distance in arrays,\n float lineDistances[MAX_LINE_COUNT];\n float lineTvalues[MAX_LINE_COUNT];\n int lineIDs[MAX_LINE_COUNT];\n \n // Initialize with defaults\n for (int i = 0; i < MAX_LINE_COUNT; i++) {\n lineDistances[i] = 1e20;\n lineTvalues[i] = 0.0;\n lineIDs[i] = -1;\n }\n \n // Figure out the base cell coords from uv\n ivec2 baseCellCoords = getGridCoords(uv);\n ivec2 cellCount = getCellCounts();\n \n // For each of the 9 offsets, gather segments from neighboring cells.\n for (int c = 0; c < 9; c++) {\n ivec2 cellCoords = baseCellCoords + offsets[c];\n \n // clamp cellCoords to grid boundaries\n if(cellCoords.x < 0 || cellCoords.x >= cellCount.x) continue;\n if(cellCoords.y < 0 || cellCoords.y >= cellCount.y) continue;\n \n // 1) fetch offset+count from the segmentMetaDataTexture\n vec2 meta = getSegmentMeta(cellCoords);\n int segOffset = int(meta.r);\n int segCount = int(meta.g);\n \n // 2) read each segment\n // same logic as before, but unify them into lineDistances\n for (int i = 0; i < 1024; i++) {\n if (i >= segCount) break;\n \n int segID = getSegmentID(segOffset + i);\n SegmentData seg = getSegmentData(segID);\n \n // compute distance to this segment\n vec2 dt = pointLineSegSDF(uv, seg.a, seg.b);\n float dist = dt.x;\n float localT = dt.y;\n \n float segLen = seg.segEnd - seg.segStart;\n float absoluteDistanceAlongLine = seg.segStart + localT * segLen;\n float fraction = (seg.totalLen > 0.0) ? (absoluteDistanceAlongLine / seg.totalLen) : 0.0;\n \n // if within threshold\n if (dist <= distanceThreshold) {\n int lineID = int(seg.lineIndex);\n \n // check if we already have that line\n int foundIndex = -1;\n for (int j = 0; j < MAX_LINE_COUNT; j++) {\n if (lineIDs[j] == lineID) {\n foundIndex = j;\n break;\n }\n }\n \n if (foundIndex == -1) {\n // new line\n for (int j = 0; j < MAX_LINE_COUNT; j++) {\n if (lineIDs[j] < 0) {\n lineIDs[j] = lineID;\n lineDistances[j] = dist;\n lineTvalues[j] = fraction;\n break;\n }\n }\n } else {\n // line already exists => keep closer distance\n if (dist < lineDistances[foundIndex]) {\n lineDistances[foundIndex] = dist;\n lineTvalues[foundIndex] = fraction;\n }\n }\n }\n }\n }\n \n // Final pass: gather valid lines into linesWithin\n int validCount = 0;\n for (int i = 0; i < MAX_LINE_COUNT; i++) {\n if (lineIDs[i] >= 0) {\n linesWithin[validCount].dist = lineDistances[i];\n linesWithin[validCount].lineT = lineTvalues[i];\n linesWithin[validCount].lineIndex = float(lineIDs[i]);\n validCount++;\n if (validCount >= MAX_LINE_COUNT) break;\n }\n }\n\n // Now 'validCount' lines are in linesWithin[0..validCount-1].\n // Sort them by dist ascending.\n for (int i = 0; i < MAX_LINE_COUNT - 1; i++) {\n // If 'i' >= validCount - 1, break\n if (i >= validCount - 1) break;\n\n for (int j = i + 1; j < MAX_LINE_COUNT; j++) {\n // If 'j' >= validCount, break\n if (j >= validCount) break;\n\n if (linesWithin[j].dist < linesWithin[i].dist) {\n // Swap\n LineDistanceResult tmp = linesWithin[i];\n linesWithin[i] = linesWithin[j];\n linesWithin[j] = tmp;\n }\n }\n }\n \n linesCount = validCount;\n }\n\n\n float easeOut(float t, float strength) {\n return 1.0 - pow(1.0 - t, strength);\n }\n\n // UV - Scene UV\n // screenSpaceUV - screen space UV\n // MSAA Offset - offset for the current sample\n vec4 render(vec2 uv, vec2 screenSpaceUV, vec2 msaaOffset, vec3 frameBuffer) {\n\n float scaleFactor = (1. / uInternalResolution.x);\n vec2 tileScaleFactor = resolution / uTileSize;\n \n \n vec2 uvWarp = lookupWarpSample(screenSpaceUV + msaaOffset).xy;\n vec2 ssLookupWarp = uvWarp * tileScaleFactor;\n\n uv += uvWarp;\n\n float sdf = (texture(tPolyEdgeDistance, screenSpaceUV + ssLookupWarp + msaaOffset).r - 0.5) * 2.0;\n\n // float flippedY = 1.0 - uv.y;\n vec3 color = uLineColor;\n\n // float shift = 0.02;\n // color.x += shift;\n // color.y -= shift * 0.4;\n\n float rampStart = 0.7; // Where ramping begins\n float rampEnd = 1.0; // Where ramping hits its max\n float lowValue = 0.015; // AccumulationIncrement below threshold\n float highValue = 0.06; // AccumulationIncrement if color.x approaches rampEnd\n\n // ‘t’ goes from 0.0 to 1.0 as color.x moves from rampStart to rampEnd\n float t = clamp((color.x - rampStart) / (rampEnd - rampStart), 0.0, 1.0);\n // float accumulationIncrement = mix(lowValue, highValue, t);\n \n float accumulationClampMax = 0.15;\n float accumulationIncrement = mix(lowValue, highValue, smoothstep(rampStart, rampEnd, color.x));\n vec2 accumulationClamp = vec2(accumulationClampMax, accumulationClampMax * 0.4);\n float chromaIncrement = (accumulationIncrement * 0.4) * uAccumulationStrength; // adjust for subtlety\n float lightnessIncrement = (-accumulationIncrement) * uAccumulationStrength; // adjust for subtlety\n float alphaIncrement = uIsShading ? .95 : 1.5; // adjust for subtlety\n \n // float brightnessRemap = remap(uBrightness, 0., 1., 0., 0.95);\n if(uIsShading) {\n float colorShift = uBrightness - uLighting.center;\n // Only scale down if colorShift is above 0\n float shiftFactor = (colorShift > 0. && color.x > 0.6) ? (1.0 - clamp(color.x / 0.82, 0., 1.)) : 1.0;\n float newMult = ((colorShift * 1.5 * shiftFactor) + 1.0);\n \n color.x *= newMult;\n \n // color.y = remap(\n // clamp(colorShift, 0., 1.),\n // 0.,\n // uLighting.max - uLighting.center,\n // color.y,\n // color.y - .02\n // );\n \n \n color.x -= 0.0;\n color.y -= 0.025;\n \n color.x = clamp(color.x, 0., 0.82);\n }\n // float satRemap = remap(uBrightness, 0.8, 1.2, 0.04, -0.02);\n // color.y -= (colorShift * 0.4);\n // }\n\n\n\n color.x = clamp(color.x, 0., .81);\n color.y = clamp(color.y, 0., .4);\n \n \n // float satShift = 1.0 - remap(uBrightness, 0.9, 1., 1.005, 1.);\n // color.y = clamp(color.y - satShift, 0., 1.);\n \n vec3 originalColor = color;\n // color.y = clamp(color.y - colourShift * 0.1, 0., 1.);\n // color.x *= uBrightness;\n // float satRemapAtHighBrightness = clamp(remap(uBrightness, 1., 1.2, 1., 0.8), 0.8, 1.);\n // color.y *= satRemapAtHighBrightness;\n\n \n\n\n \n\n // SHAPE SDF\n \n float alpha = 0.0;\n \n float segmentDistanceAlphaMult = 1.;\n\n if(uEnableFadeAtLineSegment) {\n vec2 fadeStartVert = uFadeAtLineSegmentVertices[0] / resolution.xy;\n vec2 fadeEndVert = uFadeAtLineSegmentVertices[1] / resolution.xy;\n float fadeDistance = uFadeAtLineSegmentDistance * scaleFactor;\n float fadeAlpha = pointLineSDFInfinite(uv, fadeStartVert, fadeEndVert).x;\n float fadeLerp = smoothstep(0., fadeDistance, fadeAlpha);\n fadeLerp = clamp(remap(fadeLerp, 0., 1., 1. - uFadeAtLineSegmentStrength, 1.), 0., 1.);\n segmentDistanceAlphaMult = fadeLerp;\n }\n\n float edgeSharpness = remap(uEdgeSharpness, 0., 1., -0.1, -0.0015);\n\n segmentDistanceAlphaMult *= smoothstep(edgeSharpness, -0.0, sdf);\n\n if(segmentDistanceAlphaMult <= 0.) {\n return vec4(frameBuffer, 1.);\n }\n\n\n float accumulationValue = 0.0;\n\n // Loop Setup\n // int linesInRangeCount;\n // vec3 linesInRange[MAX_LINE_COUNT];\n float lineSampleDistanceMax = scaleFactor * (uLineWeight * 2.);\n // lineDistanceSDF(uv + uvOffset, lineSampleDistanceMax, linesInRange, linesInRangeCount);\n\n LineDistanceResult linesWithin[MAX_LINE_COUNT];\n int linesCount;\n lineDistanceSDFSegments(uv, lineSampleDistanceMax, linesWithin, linesCount);\n\n // for(int i = MAX_LINE_COUNT; i >= 0; i--) {\n for(int i = 0; i < linesCount; i++) {\n vec3 localColor = color;\n // if(i >= linesInRangeCount) continue;\n // vec3 lineDistanceProps = linesInRange[i];\n\n float lineSDF = linesWithin[i].dist;\n float lineT = linesWithin[i].lineT;\n float lineIndex = linesWithin[i].lineIndex;\n\n float currentLineNoiseOffset = float(lineIndex) * 10.;\n\n // Line Tapering and Fade\n float fadeLineCap = 1.;\n float scaleLineCap = 1.;\n \n if(uTaperingFadeIn > 0. || uTaperingFadeOut > 0.) {\n float fadeWarp = abs(fbm(uv + uNoiseOffset + currentLineNoiseOffset, 1, 10., 0.9)) * 0.05;\n \n if(uTaperingFadeIn > 0.) {\n fadeLineCap = easeOut(smoothstep(0.0, (uTaperingFadeIn / 2.) - fadeWarp, lineT), 10.);\n }\n\n if(uTaperingFadeOut > 0.) {\n fadeLineCap *= easeOut(smoothstep(1., 1. - (uTaperingFadeOut / 2.) - fadeWarp, lineT), 10.);\n }\n }\n\n if(uTaperingScaleIn > 0. || uTaperingScaleOut > 0.) {\n float scaleWarp = abs(fbm(uv + uNoiseOffset + currentLineNoiseOffset, 1, 10., 0.9)) * 0.05;\n if(uTaperingScaleIn > 0.) {\n scaleLineCap = easeOut(smoothstep(0.0, (uTaperingScaleIn / 2.), lineT + scaleWarp), 1.);\n }\n\n if(uTaperingScaleOut > 0.) {\n scaleLineCap *= easeOut(smoothstep(1., 1. - (uTaperingScaleOut / 2.), lineT + scaleWarp), 1.);\n }\n }\n\n float lineHardness = uLineHardness * fadeLineCap;\n // float lineHardness = uLineHardness;\n\n // float lineWeight = uLineWeight + (fbm(uNoiseOffset + (lineIndex / 2.), 1, 10., 0.9) / 4.);\n float lineWeight = uLineWeight;\n \n float lineDistanceMax = (scaleFactor * lineWeight) * scaleLineCap;\n float lineWeightWobble = fbm(uv + currentLineNoiseOffset,
1,max:.2},out:{enabledChance:10,min:.1,max:.2}}},insetChance:0,styleChances:[[1,"outline"]],colorMap:[[[1,ye.line]]],spatialOverride:{[Ge.dominant]:{fillChance:100}}})},ut=new e.OrthographicCamera(-1,1,1,-1,0,1);class ht extends e.BufferGeometry{constructor(){super(),this.setAttribute("position",new e.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new e.Float32BufferAttribute([0,2,0,0,2,0],2))}}const mt=new ht;class pt{_mesh;constructor(t){this._mesh=new e.Mesh(mt,t)}dispose(){this._mesh.geometry.dispose()}render(e=X){e.render(this._mesh,ut)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}let gt="\n vec2 lookupWarpSample(const vec2 uv) {\n\n // vec2 offset = vec2(0.2);\n return ((texture(tWarpTex, uv).xy - 0.5) * 2.);\n }\n",bt="\n float remap(float t, float a1, float b1, float a2, float b2) {\n return a2 + (b2 - a2) * ((t - a1) / (b1 - a1));\n }\n";function ft(){return new e.ShaderMaterial({uniforms:{resolution:{value:new e.Vector2(B,Q)},noiseOffset:{value:new e.Vector2(We[0],We[1])},...ce(),wave:{value:{...De}},uWarpEnabled:{value:!1},grid:{value:{...ze}}},depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform vec2 resolution;\n uniform vec2 uTileOffset;\n uniform vec2 uTileSize;\n uniform vec2 noiseOffset;\n uniform bool uWarpEnabled;\n\n struct Wave {\n bool warpX;\n bool warpY;\n\n bool offAxisY;\n bool offAxisX;\n\n float warpXMult;\n float warpYMult;\n\n float displacementStrength;\n \n bool noiseMapEnabled;\n };\n \n uniform Wave wave;\n\n struct Grid {\n float countX;\n float countY;\n float marginX;\n float marginY;\n float w;\n float h;\n float scale;\n };\n\n uniform Grid grid;\n\n varying vec2 vUv;\n out vec4 outColor;\n\n // const float scale = 10.;\n\n #include <packing>\n\n ${ee}\n ${bt}\n ${te}\n \n // Third compomnent is the intersection\n // const float PI2 = acos(-1.);\n \n float noiseLookup(vec2 uv, float freq) {\n float influence = fbm(uv + noiseOffset, 2, freq + 0.2, 0.8);\n return smoothstep(0., 1., abs(fbm(uv - influence, 2, freq, 0.5)));\n }\n\n// vec2 warpTextureSampleUv(const vec2 uv) {\n// // Center of the drop\n// vec2 center = vec2(0.5, 0.5);\n// // Spacing between each ripple (distance in UV space)\n// float ringSpacing = 0.1;\n\n// // Thickness of each ripple peak\n// float ringThickness = 0.01;\n\n// // Overall ripple strength\n// float amplitude = 0.05;\n\n// // Distance from UV to the center\n// float dist = distance(uv, center);\n\n// // We compute the ripple shape by creating rings around the center at multiples of ringSpacing\n// // - sector is how far dist is from the last multiple of ringSpacing\n// // - ringDist is how far we are from the center of that ring\n// float sector = mod(dist, ringSpacing);\n// float ringDist = abs(sector - (ringSpacing * 0.5));\n\n// // Create a peak shape at the ring center\n// // wave is 1.0 near the ring center and 0.0 outside\n// float wave = 1.0 - smoothstep(0.0, ringThickness, ringDist);\n\n// // Convert wave to displacement strength\n// float offsetStrength = wave * amplitude;\n\n// // Direction outward from the center\n// vec2 direction = normalize(uv - center);\n\n// return direction * offsetStrength;\n// }\n \n vec2 warpTextureSampleUv(const vec2 uv) {\n\n float PI = acos(-1.);\n float gridSize = grid.w / 1000.;\n float strength = gridSize * .2;\n float edgeFalloff = 1.;\n\n // strength *= 50.; \n\n vec2 warpSpread = vec2(1.) * .1;\n\n float aspectRatio = resolution.x / resolution.y;\n\n vec2 offsetUV = uv + (noiseOffset * 2.);\n\n offsetUV.x *= 1.;\n offsetUV.y *= 1.2;\n\n // float noiseMask = snoise2D(offsetUV / .2) ;\n // float noiseMask2 = snoise2D(offsetUV / .18);\n // float noiseWarped = snoise2D(vec2((offsetUV.x + 1.) / .1 * noiseMask2, uv.y / 1.2 * noiseMask));\n // float noiseWarped2 = snoise2D(vec2((offsetUV.x + .8) / .25 * noiseMask2, uv.y / 1.2 * noiseMask));\n \n float freq = 10.1;\n float warpedDivisor = .5;\n\n float noiseMaskMask = smoothstep(0.95, 1., fbm(offsetUV, 1, freq * 3., 0.5));\n float noiseMask = (fbm(offsetUV, 1, freq + 0.001, 0.5) + 0.01) - fbm(offsetUV, 1, freq, 0.5);\n noiseMask *= 50.;\n noiseMask *= clamp(abs(noiseMaskMask), .5, 1e6);\n // float direction = smoothstep(-1., 1., fbm(offsetUV, 2, freq * .1, 0.5));\n\n // float noiseY = fbm(offsetUV * .5, 2, freq, 0.1);\n // float noiseX = fbm(offsetUV * .5, 3, freq/2., 0.2);\n\n float epsilon = 0.01;\n\n\n\n\n float noiseWarpedCenter = noiseLookup(offsetUV , warpedDivisor);\n float noiseWarpedY = noiseLookup(offsetUV + vec2(epsilon, 0.), warpedDivisor);\n float noiseWarpedX = noiseLookup(offsetUV + vec2(0., epsilon), warpedDivisor);\n\n // float dFdx = (noiseWarpedX - noiseWarpedCenter) / epsilon;\n // float dFdy = (noiseWarpedY - noiseWarpedCenter) / epsilon;\n\n // vec2 gradient = vec2(dFdx, dFdy);\n // gradient = vec2(-gradient.y, gradient.x);\n \n // gradient = normalize(gradient);\n\n // float projection = dot(uv, gradient);\n // float wave = sin(projection * .1); \n // gradient = vec2(-gradient.y, gradient.x);\n // float noiseWarped2 = fbm(offsetUV + vec2(freq/2.) * vec2(1.) * warpedUV, 1, freq * .5, 0.1);\n \n\n // float nNoise = snoise2D(offsetUV * .5);\n // float result = ((noiseWarped * 1.f) * (noiseWarped2 * 1.f)) * noiseMask;\n // float noiseSwirl = noiseMask;\n // float result = noiseWarped1 * 2. * PI - (PI * .5);\n\n vec2 divergence = vec2(0.);\n // divergence += vec2(cos(result), sin(result));\n // divergence += (result * strength) * noiseMask;\n divergence += noiseWarpedCenter * strength * noiseMask;\n // divergence *= screenEdgeDist(uv, edgeFalloff);\n \n // float simpleWarp = fbm(offsetUV, 6, 600.6, .9);\n\n // divergence += simpleWarp * .0003;\n\n return vec2(divergence); \n }\n\n\n const float PI = acos(-1.);\n\n const float waveWarpDivisor = 1.;\n // const int waveNoiseMapEnabled = 0;\n\n \n\n vec2 waveUv(vec2 uv) {\n\n vec2 margins = vec2(grid.marginX / resolution.x, grid.marginY / resolution.y);\n float width = grid.w / resolution.x;\n\n float lookupRemap = noiseOffset.x;\n \n // float influence = clamp(snoise2D((uv + lookupRemap)), 0.f, 1.f);\n float influence = grid.countX * wave.displacementStrength;\n \n // if(wave.noiseMapEnabled == 1)\n // influence = .9f + (influence / 10.f);\n \n float strength = (width / (waveWarpDivisor * PI) - 2.f) * (width / grid.countX) * influence;\n float sinX = sin(wave.warpXMult * PI * ((uv.x / width) + margins.x) - PI /2.) * strength;\n float sinY = sin(wave.warpYMult * PI * ((uv.y / width) + margins.y) - PI /2.) * strength;\n \n vec2 result = vec2(0.);\n \n if(wave.warpX)\n result.x += sinX;\n \n if(wave.warpY)\n result.y += sinY;\n \n if(wave.offAxisY)\n result.y += sinX;\n \n if(wave.offAxisX)\n result.x += sinY;\n \n // result.y = sin(waveWarpXMult * PI * ((uv.x + margins.y) / width)) * strength;\n // result.x = sin(waveWarpYMult * PI * ((uv.x + margins.x) / width)) * strength;\n\n return result;\n }\n\n // vec2 calculatePerspectiveOffset(vec2 uv) {\n // // Store the original UV coordinates\n // vec2 originalUv = uv;\n \n // // Define perspective depth factors\n // float perspectiveStrength = .0; // Controls the overall perspective effect\n // float tiltX = -0.3; // Controls the leftward skew\n // float tiltY = 0.2; // Controls the backward tilt\n \n // // Shift UVs to the center of the texture\n // uv -= 0.5;\n \n // // Apply perspective transformation\n // float depth = 1.0 - perspectiveStrength * (tiltX * uv.x + tiltY * uv.y);\n // uv /= depth;\n \n // // Calculate the min and max bounds of the transformed UVs\n // vec2 minBounds = vec2(-0.5) / (1.0 - perspectiveStrength * vec2(-tiltX, -tiltY));\n // vec2 maxBounds = vec2(0.5) / (1.0 - perspectiveStrength * vec2(tiltX, tiltY));\n \n // // Normalize the UV coordinates to the [0, 1] range\n // uv = (uv - minBounds) / (maxBounds - minBounds);\n \n // // Apply scaling to fill the scene\n // uv = uv * (maxBounds - minBounds);\n \n // // Calculate the offset by subtracting the original UV from the transformed and normalized UV\n // vec2 offset = uv - originalUv;\n \n // return offset;\n // }\n\n vec4 render(vec2 uv, vec2 screenSpaceUV, vec2 msaaOffset) {\n vec2 offset = uWarpEnabled ? warpTextureSampleUv(uv) : vec2(0.);\n vec2 warpedUv = waveUv(uv);\n offset += warpedUv;\n // offset += calculatePerspectiveOffset(uv);\n return(vec4(offset * 0.5 + 0.5, 0., 1.0));\n }\n\n float randomNonDet(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n\n void main() {\n const vec2 H2 = vec2(0.5698402909980532f, 0.7548776662466927f);\n vec2 px = 1.f / resolution;\n px *= 1.25;\n vec2 uv = vUv;\n\n \n // Check if this fragment is within the SDF\n // vec2 uvOffset = lookupWarpSample(uv).xy;\n // float texCheck = (texture(tPolyEdgeDistance, uv + uvOffset).r - 0.5) * 2.0;\n // if(texCheck < -0.1) {\n // discard;\n // }\n\n\n const float samples = 6.f;\n \n vec4 sumColour;\n vec2 d0 = vec2(randomNonDet(uv), randomNonDet(uv + 1.f));\n\n \n for(float i = 0.f; i < samples; i++) {\n vec2 d = (fract(i * H2 + d0) - .5f);\n\n vec2 localCoord = vUv + d * px; /* changed */\n vec2 screenCoord = uTileOffset + localCoord * uTileSize; /* changed */\n vec2 globalUV = screenCoord / resolution; /* changed */\n\n // vec4 sampleColor = render(globalUV, vUv, d * px);\n vec4 sampleColor = render(globalUV, vUv, d * px);\n // sampleColor.rgb *= sampleColor.a; // Convert to premultiplied alpha\n sumColour += sampleColor;\n }\n \n vec4 averageColor = clamp(sumColour / samples, 0., 1.);\n \n outColor = averageColor;\n }\n `})}let xt="\n\n vec3 sCurve(vec3 c, float contrast, float midpoint) {\n // c in [0, 1], midpoint could be 0.5 or 0.18\n // contrast is how steep the curve is\n // A simple logistic-based S-curve\n return 1.0 / (1.2 + exp(-(c - midpoint) * contrast)) ;\n }\n\n vec4 adjustContrast(vec4 color, float factor) {\n float midpoint = 0.3; // 0.18\n // Factor is effectively the steepness of the slope\n vec3 curved = sCurve(color.rgb, factor, midpoint);\n return vec4(curved, color.a);\n }\n",Zt="\n const float l2p3alpha = 1.055;\n const float l2p3beta = 0.00304;\n const float l2p3gamma = 2.4;\n const float l2p3delta = 0.055;\n\n vec3 linear2P3(vec3 linearRgb) {\n vec3 a = l2p3alpha * pow(linearRgb, vec3(1.0 / l2p3gamma)) - l2p3delta;\n vec3 b = linearRgb / 12.92;\n vec3 mask = step(vec3(l2p3beta), linearRgb);\n\n return mix(b, a, mask);\n }\n";function yt(){return new e.ShaderMaterial({uniforms:{tTex:{value:null}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n in vec2 vUv;\n out vec4 outColor;\n\n ${Zt}\n ${xt}\n\n // vec4 desaturateRGBA(vec4 color, float factor) {\n // float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));\n // vec3 desaturatedColor = mix(color.rgb, vec3(gray), factor);\n // return vec4(desaturatedColor, color.a);\n // }\n\n void main() {\n vec4 color = vec4(texture2D(tTex, vUv).rgb, 1.);\n // vec4 contrasty = adjustContrast(color, 12.);\n // color = mix(color, contrasty, 0.05);\n // color = adjustBrightness(color, 1.001);\n // color *= 0.95;\n // color = desaturateRGBA(color, 0.001);\n outColor = vec4(linear2P3(vec3(color)), 1.);\n }\n `})}const Gt=yt(),Wt=new e.ShaderMaterial({uniforms:{tTex:{value:null},uChannel:{value:0}},colorWrite:!0,depthWrite:!1,depthTest:!1,glslVersion:e.GLSL3,vertexShader:ie,fragmentShader:`\n precision highp float;\n precision highp int;\n \n uniform highp sampler2D tTex;\n uniform int uChannel;\n\n in vec2 vUv;\n out vec4 outColor;\n\n // ${Zt}\n // ${xt}\n\n void main() {\n vec4 color = vec4(texture2D(tTex, vUv).rgba);\n if(uChannel == -1) {\n outColor = color;\n return;\n }\n float channelColor = color[ int(uChannel) ];\n outColor = vec4(vec3(channelColor), 1.0);\n }\n `}),vt=new pt(Gt);function Lt(e,t){vt.material=Gt,Gt.uniforms.tTex.value=e,X.setRenderTarget(t||null),vt.render(X)}class St{width;height;bufferIdx=0;textureCount=1;renderBuffers=[];renderBufferProps;maskEnabled=!1;constructor(t=B,n=Q,i){this.width=t,this.height=n;let l=w?e.LinearFilter:e.NearestFilter;this.renderBufferProps={anisotropy:V,minFilter:l,magFilter:l,stencilBuffer:!1,premultipliedAlpha:!0,alpha:!0,depthBuffer:!1,colorSpace:e.LinearDisplayP3ColorSpace,generateMipmaps:!1,format:e.RGBAFormat,type:e.FloatType,internalFormat:"RGBA32F",...i},this.setupFrameBuffers(),this.clearFrameBuffers(),X.autoClear=!1}setupFrameBuffers(){for(let t=0;t<2;t++)this.renderBuffers.push(new e.WebGLRenderTarget(this.width,this.height,this.renderBufferProps))}clearFrameBuffers(e=!0,t=!0,n=!0){X.setClearColor(16777215,0);const{stencil:i,color:l,depth:a}=X.state.buffers;this.renderBuffers.forEach((s=>{X.setRenderTarget(s),e&&l.setLocked(!1),t&&a.setLocked(!1),n&&i.setLocked(!1),X.clear(e,t,n)}))}enableMask(e=1){this.maskEnabled=!0;const{stencil:t}=X.state.buffers,n=X.getContext();t.setLocked(!1),t.setTest(!0),t.setFunc(n.EQUAL,e,4294967295),t.setOp(n.KEEP,n.KEEP,n.KEEP),t.setLocked(!0)}disableMask(){this.maskEnabled=!1;const{stencil:e}=X.state.buffers;e.setLocked(!1),e.setTest(!1),e.setLocked(!0)}renderMaterialAsMask(e,t=1){if(!this.renderBufferProps.stencilBuffer)throw Error("Stencil buffer not enabled in render buffer properties");const n=X.getContext(),{color:i,depth:l,stencil:a}=X.state.buffers;l.setMask(!1),l.setLocked(!0),i.setMask(!1),i.setLocked(!0),a.setLocked(!1),a.setTest(!0),a.setOp(n.KEEP,n.KEEP,n.REPLACE),a.setFunc(n.ALWAYS,t,4294967295),a.setClear(0),a.setLocked(!0),vt.material=e,X.setRenderTarget(this.getReadBuffer()),vt.render(),X.setRenderTarget(this.getWriteBuffer()),vt.render(),i.setLocked(!1),i.setMask(!0),l.setLocked(!1),l.setMask(!0)}getWriteBuffer(){return this.renderBuffers[(this.bufferIdx+1)%2]}getReadBuffer(){return this.renderBuffers[this.bufferIdx%2]}copyBufferChannelToScreen(e=0,t=this.getReadBuffer()){let n=this.maskEnabled;n&&this.disableMask(),X.setRenderTarget(null),vt.material=Wt,Wt.uniforms.tTex.value=t.texture,Wt.uniforms.uChannel.value=e,vt.render(),n&&this.enableMask()}copyBufferToBuffer(e){let t=this.maskEnabled;t&&this.disableMask(),X.setRenderTarget(e),X.copyFramebufferToTexture(this.getReadBuffer().texture),t&&this.enableMask()}copyAndSwapBuffers(){this.copyBufferToBuffer(this.getWriteBuffer()),this.bufferIdx++}copyBufferToScreen(e=this.getReadBuffer()){let t=this.maskEnabled;t&&this.disableMask(),Lt(e.texture),t&&this.enableMask()}}let Xt,Ct={},Vt=new pt(null);const wt=(e,t,n)=>(t-e)*n+e,Kt=(e,t,n,i,l)=>wt(i,l,((e,t,n)=>(n-e)/(t-e))(t,n,e));function Rt(e,t,n=b){if(0===t)return e;const i=n*Math.sign(e);return Math.round((e+i)/t)*t}function kt(e,t,n){return o(r(e,t),n)}const Tt=(e,t,n,i,l)=>kt(Kt(e,t,n,i,l),i,l);let Mt=0;class zt{x;y;id=Mt++;hedgelist=[];constructor(e=0,t=0){this.x=e,this.y=t}sortincident(){this.hedgelist&&this.hedgelist.sort(Yt)}subtract(e){return new zt(this.x-e.x,this.y-e.y)}addPolar(e,t){return new zt(this.x+t*l(e),this.y+t*i(e))}normalize(e=b){const t=d(this.x*this.x+this.y*this.y);return t<e?new zt(0,0):new zt(this.x/t,this.y/t)}multiply(e){return new zt(this.x*e,this.y*e)}add(e){return new zt(this.x+e.x,this.y+e.y)}toArray(){return[this.x,this.y]}fromArray(e){return this.x=e[0],this.y=e[1],this}distanceTo(e){return d(a(e.x-this.x,2)+a(e.y-this.y,2))}angleTo(e){return Math.atan2(e.y-this.y,e.x-this.x)}lerp(e,t){return new zt(this.x+(e.x-this.x)*t,this.y+(e.y-this.y)*t)}translate(e,t){this.x+=t*l(e),this.y+=t*i(e)}clone(){return new zt(this.x,this.y)}isEqualTo(e,t=b){const n=e.x-this.x,i=e.y-this.y;return n*n+i*i<=t*t}isCloseTo(e,t=b){return this.distanceTo(e)<t}dispose(){this.hedgelist.length=0}}function Yt(e,t){return t.angle-e.angle}function Pt(e,t=1){if(0===t)return e;let n=ze.w/t,i=ze.h/t,l=Rt(e.x,n),a=Rt(e.y,i);return new zt(l,a)}function It(e,t=1){return function(e){return new zt(e.x+ze.marginX,e.y+ze.marginY)}(Pt(new zt(e.x,e.y),t))}function Ht(e){return[e[0],e[1],e[2]*Math.PI/180]}function Ft(e){return(e%360+360)%360}function Nt(e){return[kt(e[0],0,1),kt(e[1],0,1),Ft(e[2])]}let Ut="\n float getPaperTexture( const vec2 screenPosition ) {\n return texture(tPaperTexture, screenPosition).x;\n }\n\n vec3 calculateNormals(vec2 uv, float offsetScale, float scale) {\n // float offsetScale = .5;\n vec2 offset = vec2(offsetScale, offsetScale);\n // float scale = 1.;\n\n float left = getPaperTexture(vec2(uv.x + offset.x, uv.y));\n float right = getPaperTexture(vec2(uv.x - offset.x, uv.y));\n float up = getPaperTexture(vec2(uv.x, uv.y + offset.y));\n float down = getPaperTexture(vec2(uv.x, uv.y - offset.y));\n\n vec3 dx = vec3(1.0, 0.0, (left - right) * scale);\n vec3 dy = vec3(0.0, 1.0, (up - down) * scale);\n\n vec3 normal = normalize(cross(dy, dx));\n\n return -normal;\n }\n\n vec3 calculateDiffuse(vec3 normal, vec3 lightDir, vec3 lightColor) {\n // Calculate the diffuse component\n float diff = max(dot(normal, lightDir), 0.0);\n float angleAttenuation = pow(diff, 1.);\n return angleAttenuation * lightColor;\n }\n",Dt="\n // Partially adapted from - https://github.com/yum-food/HLSL_OKLAB/blob/main/oklab.cginc\n const mat3 m1i = mat3(vec3(1.22700842, -0.5576564, 0.28111404), vec3(-0.04047048, 1.11219073, -0.07157255), vec3(-0.07643651, -0.42138367, 1.58625265));\n const mat3 m2i = mat3(vec3(1.00003964, 0.39638005, 0.21589049), vec3(0.99998945, -0.10553958, -0.06374665), vec3(0.99999105, -0.08946276, -1.291495));\n // XYZ -> linear RGB (p3) from colorjs.io - https://github.com/color-js/color.js/blob/main/src/spaces/p3-linear.js\n const mat3 xyz_to_rgb_p3 = mat3(vec3(2.493496911941425, -0.9313836179191239, -0.40271078445071684), vec3(-0.8294889695615747, 1.7626640603183463, 0.023624685841943577), vec3(0.03584583024378447, -0.07617238926804182, 0.9568845240076872));\n\n // Functions for matrix multiplication and power, as GLSL doesn't have built-in matrix multiplication for 3x3 matrices\n vec3 mat3_mul_vec3(mat3 m, vec3 v) {\n return vec3(dot(m[0], v), dot(m[1], v), dot(m[2], v));\n }\n\n vec3 vec3_pow(vec3 v, float p) {\n return vec3(pow(v.x, p), pow(v.y, p), pow(v.z, p));\n }\n\n // Converts OKLCH color to XYZ color space\n vec3 OKLCHtoXYZ(vec3 c) {\n // Convert OKLCH to OKLAB\n float a = c.y * cos(c.z);\n float b = c.y * sin(c.z);\n vec3 oklab = vec3(c.x, a, b);\n\n // Convert OKLAB to XYZ\n oklab = mat3_mul_vec3(m2i, oklab);\n oklab = vec3_pow(oklab, 3.0);\n return mat3_mul_vec3(m1i, oklab);\n }\n\n // Converts XYZ color to linear RGB color space (p3)\n vec3 XYZtoP3LRGB(vec3 c) {\n return mat3_mul_vec3(xyz_to_rgb_p3, c);\n }\n\n // Main function to convert OKLCH to Linear RGB\n vec3 OKLCHtoP3LRGB(vec3 oklchColor) {\n vec3 xyzColor = OKLCHtoXYZ(oklchColor);\n vec3 lrgbColor = XYZtoP3LRGB(xyzColor);\n return lrgbColor;\n }\n";const Ot=e=>e.map((({x:e,y:t})=>[e*U,Q-t*U]));class Bt{width;height;format;type;channels;texture;gl;_glFormat;_glType;_glTexture;renderer;constructor(t,n,i,l,a){if(this.width=t,this.height=n,this.format=i,this.type=l,i===e.RGBAFormat)this.channels=4;else if(i===e.RGFormat)this.channels=2;else{if(i!==e.RedFormat)throw Error("Unsupported format for PartialDataTexture.");this.channels=1}const s=t*n*this.channels,o=a||new Float32Array(s);if(o.length!==s)throw Error("Initial data length does not match texture dimensions.");this.texture=new e.DataTexture(o,t,n,i,l),this.texture.needsUpdate=!0,this.gl=null,this._glFormat=null,this._glType=null,this._glTexture=null}setRenderer(t){this.renderer=t;const n=t.getContext();if(this.gl=n,this.format===e.RGBAFormat)this._glFormat=n.RGBA;else if(this.format===e.RGFormat)this._glFormat=n.RG;else{if(this.format!==e.RedFormat)throw Error("Unsupported format for PartialDataTexture.");this._glFormat=n.RED}if(this.type!==e.FloatType)throw Error("PartialDataTexture currently only supports Float32 data type.");this._glType=n.FLOAT,t.initTexture(this.texture);const i=t.properties.get(this.texture);this._glTexture=i.__webglTexture}uploadSubData(e){if(!this.gl||!this._glTexture)throw Error("Renderer not set or texture not initialized. Call setRenderer() before updating.");const t=this.gl,n=Math.floor(e/this.channels);if(n<=0)return;const i=this.width*this.height,l=Math.min(n,i),a=Math.floor(l/this.width),s=l%this.width,o=this.texture.image.data,r=t.getParameter(t.TEXTURE_BINDING_2D);if(t.bindTexture(t.TEXTURE_2D,this._glTexture),a>0){const e=o.subarray(0,a*this.width*this.channels);t.texSubImage2D(t.TEXTURE_2D,0,0,0,this.width,a,this._glFormat,this._glType,e)}if(s>0){const e=a*this.width*this.channels,n=o.subarray(e,e+s*this.channels);t.texSubImage2D(t.TEXTURE_2D,0,0,a,s,1,this._glFormat,this._glType,n)}t.bindTexture(t.TEXTURE_2D,r)}}function Qt(e,t){const n=t[0]-e[0],i=t[1]-e[1];return d(n*n+i*i)}class Jt{polyLines=[];isClosed;cellSize;cellsWide;cellsHigh;_segmentRecords;_cellCounts;_cellOffsets;_indexData;segmentDataTexture;segmentIndexTexture;segmentMetaDataTexture;texturesInitialised=!1;constructor(e=1){this.cellSize=e}initializeTextures(){const n=o(C,1024);this.segmentDataTexture={texture:new Bt(n,n,e.RGBAFormat,e.FloatType,new Float32Array(n*n*4)),width:n,height:n},this.segmentDataTexture.texture.setRenderer(X),this.cellsWide=t(Y/this.cellSize),this.cellsHigh=t(P/this.cellSize);
tdDev:1},VVariance:{min:0,max:10,threshold:2,mean:1,stdDev:1},rects:{insetRectEnabled:!0,spiralRectsEnabled:!0},circles:{count:0,minRadius:2,maxRadius:30},wobble:{enabled:!1,count:1e10,layers:2,multiLayers:1,minLength:5,gridDivisions:1,warpFreq:{min:600,max:800},offsetMultiplier:1},perspectiveBox:{enabled:!0,threshold:2,mean:1,stdDev:1,count:1,firstFull:!0}},Fe=Xe,Ne=Ce,Ue={layers:1,renderLightChance:0,ignoreLighting:!0,renderAccentChance:0,insetMult:2,maxWidth:80,spread:4,widthRange:.3,maxDivergence:2,tension:{min:.9,max:1.2},maxPointUse:1,pointsToConsider:30,maxLinePoints:30},De={warpX:!0,warpY:!1,offAxisX:!0,offAxisY:!1,warpXMult:.05,warpYMult:.05,displacementStrength:.05,noiseMapEnabled:!0},Oe={maxAccents:4,mutation:"none",dominantIsAccentChance:50,useNoiseLookup:!0,samplesForComplimentary:3,samplesForPaletteOffset:2,addBGContrast:!1,freqMultiplier:10,usePolyIDColorOffset:!0,singleAccent:!1,darksOnly:!1},Be={cropToMargin:!0,cropBGShapesAtMargin:!0,cropToMarginFillDark:!1,margin:30},Qe={count:100,lineRemoveStrength:.1,polyOverfitting:.75,noiseOverfittingSpread:0,noiseOverfitFreq:100,excludeWeakSplits:!1,longestSplitOnlyChance:50,noiseFieldCategoryInfluence:1e3},Je=Ve,je=100,Ae=.1,Ee=0,_e="";const qe=(e,t)=>{ze.scale=J.int(e,t);const n=Y/ze.scale,i=P/ze.scale;ze.countX=Math.ceil(n),ze.countY=Math.ceil(i);const l=ze.countX*ze.scale,a=ze.countY*ze.scale;ze.marginX=(Y-l)/2,ze.marginY=(P-a)/2,ze.w=ze.scale,ze.h=ze.scale};var $e,et,tt,nt,it;function lt(e,t){return function(e){return void 0!==e[t]?e[t]:e.default}}!function(e){e.xs="xsmall",e.sm="small",e.md="medium",e.lg="large",e.xl="xlarge"}($e||($e={})),function(e){e.none="none",e.sparse="sparse",e.light="light",e.dense="dense",e.filled="filled",e.detailOnly="detailOnly"}(et||(et={})),function(e){e.light="light",e.medium="medium",e.heavy="heavy"}(tt||(tt={})),function(e){e.color="color",e.dark="dark",e.light="light"}(nt||(nt={})),function(e){e.objects="objects",e.curves="curves",e.angles="angles",e.grid="grid",e.mesh="mesh",e.all="all",e.random="random"}(it||(it={}));const at=()=>({[it.objects]:{splits:{[be.horizontal]:1,[be.vertical]:2,[be.perspective]:0,[be.circle]:2,[be.wobbles]:3,[be.objects]:15,[be.curves]:5,[be.rects]:1,[be.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:J.choice([10,0]),forceInsertObjectsChance:J.choice([30,0])}}},[it.grid]:{splits:{[be.horizontal]:2,[be.vertical]:4,[be.perspective]:0,[be.circle]:4,[be.wobbles]:1,[be.objects]:10,[be.curves]:0,[be.rects]:0,[be.borderRect]:0},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[it.curves]:{splits:{[be.horizontal]:1,[be.vertical]:2,[be.perspective]:0,[be.circle]:10,[be.wobbles]:10,[be.objects]:J.choice([10,1]),[be.curves]:10,[be.rects]:0,[be.borderRect]:1},meta:{usedLineReplayChance:10,forceSplit:{forceInsertCurvesChance:J.choice([0,20]),forceInsertObjectsChance:J.choice([0,20])}}},[it.angles]:{splits:{[be.horizontal]:2,[be.vertical]:3,[be.perspective]:3,[be.circle]:0,[be.wobbles]:0,[be.objects]:3,[be.curves]:2,[be.rects]:0,[be.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[it.mesh]:{splits:{[be.horizontal]:1,[be.vertical]:1,[be.perspective]:1,[be.circle]:1,[be.wobbles]:0,[be.objects]:1,[be.curves]:0,[be.rects]:0,[be.borderRect]:0},meta:{objectProps:{forceYUp:!0},forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:50}}},[it.all]:{splits:{[be.horizontal]:2,[be.vertical]:2,[be.perspective]:2,[be.circle]:2,[be.wobbles]:2,[be.objects]:4,[be.curves]:2,[be.rects]:1,[be.borderRect]:2},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}}});let st,ot;const rt=()=>{let e=at();_e="Pencils",qe(20,20),ot=J.weightedChoice([15,$e.sm],[15,$e.md],[10,$e.lg]);let n=lt(0,ot);st=J.weightedChoice([n({[$e.sm]:1,default:1}),et.light],[n({[$e.sm]:0,default:1}),et.dense],[n({[$e.sm]:2,[$e.md]:2,default:1}),et.filled],[1,et.detailOnly]);let i=lt(0,st),l=lt(0,J.weightedChoice([n({[$e.sm]:i({[et.none]:0,[et.sparse]:0,default:0}),default:0}),tt.light],[1,tt.medium],[1,tt.heavy])),a=J.weightedChoice([n({[$e.sm]:i({[et.filled]:5,default:1}),default:1}),it.objects],[n({[$e.sm]:0,default:2}),it.curves],[n({[$e.sm]:0,default:1}),it.angles],[n({[$e.sm]:0,default:1}),it.grid]),s=e[a];Fe=ge(Fe,s.splits),Te=ge(Te,s.meta.forceSplit),Qe=ge(Qe,{noiseOverfittingSpread:n({[$e.sm]:J.num(0,1),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:J.choice([1,J.num(.5,1.5)]),longestSplitOnlyChance:n({[$e.sm]:J.choice([0,50,100]),default:J.choice([50,100])}),noiseFieldCategoryInfluence:J.choice([1,4])}),Ee=n({default:s.meta?.usedLineReplayChance||4}),je=t(n({[$e.sm]:i({[et.filled]:J.int(190,180),[et.none]:J.int(190,230),[et.detailOnly]:J.int(200,230),default:J.int(190,230)}),[$e.md]:J.int(250,350),[$e.lg]:J.int(350,800)})),Ae=i({[et.filled]:n({[$e.lg]:J.num(0,.3),[$e.md]:J.num(0,.2),[$e.sm]:J.num(0,.01),default:J.num(0,.1)}),default:n({[$e.sm]:J.num(0,.01),[$e.md]:J.num(0,.1),[$e.lg]:J.num(0,.3)})});let o=J.weightedChoice([1,!1],[1,!0]);Oe={...Oe,mutation:J.weightedChoice([0,"offsetUp"],[0,"offsetDown"],[3,"none"]),addBGContrast:i({[et.detailOnly]:!1,default:!0}),useNoiseLookup:!0,samplesForComplimentary:J.int(1,3),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:n({default:o?J.num(300,600):J.num(300,400)}),usePolyIDColorOffset:o,maxAccents:n({default:J.weightedChoice([1,4],[1,6],[2,100])}),darksOnly:!1};let r=lt(0,J.weightedChoice([10,nt.color],[n({[$e.lg]:1,default:0}),nt.dark],[n({[$e.lg]:1,default:0}),nt.light]));Je={...Je,size:n({[$e.lg]:{min:4,max:5},[$e.md]:{min:5,max:6},[$e.sm]:{min:6,max:8}})},Ne=[be.horizontal,be.vertical],Ke={...Ke,default:1,clamp:.05,min:.6,max:1,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.2},st!=et.filled||ot!=$e.lg&&ot!=$e.md||!J.bool(10)||(Ke={...Ke,default:1,clamp:.05,min:.5,max:.55,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:0});let c=J.bool(40);Ue={...Ue,ignoreLighting:J.bool(50),maxWidth:.75*n({[$e.sm]:J.int(40,50),[$e.md]:J.int(40,50),default:J.num(35,45)}),renderLightChance:J.weightedChoice([1,0],[1,J.int(0,10)]),maxPointUse:1,maxDivergence:2,pointsToConsider:10};let d=J.num(.75,1.5);ke=ge({...ke,layers:2,layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:n({default:J.choice([xe.scene,xe.border,xe.none])}),forceYUp:a==it.grid||J.bool(30),clampVertsToGrid:n({[$e.sm]:!1,default:!1}),...n({[$e.sm]:{maxDist:200*d,minDist:130*d},[$e.md]:{maxDist:150*d,minDist:100*d},[$e.lg]:J.weightedChoice([5,{maxDist:130*d,minDist:80*d}])}),bnFreq:J.num(10,1e3),fieldFreq:n({[$e.lg]:J.int(4e3,1e4),[$e.sm]:J.int(1e3,2e3),default:J.choice([J.int(1e3,4e3),J.int(4e3,1e4)])}),clampRotationTo:J.weightedChoice([1,22.5],[4,1],[1,11.25]),minSizeMult:1,maxSizeMult:n({default:.75}),maxSides:5,minSides:3,perspective:2e4},s.meta?.objectProps||{});let u={edgeSharpness:{min:.8,max:1},fillChance:100,insetChance:J.choice([8,5,0]),wobbleFreq:{min:40,max:80},wobbleAmplitude:{min:1,max:3},accumulationStrength:{min:1,max:1},materialHardness:i({[et.light]:{min:.9,max:.97},default:{min:.93,max:.99}}),linePressure:i({default:{min:.65,max:.7}}),minDistanceMult:n({[$e.lg]:{min:.7,max:.8},[$e.sm]:{min:.7,max:.8},default:{min:.7,max:.8}}),lineTapering:{fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}},scale:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}}},layerCountChances:l({[tt.light]:[[1,2]],[tt.medium]:[[1,4]],[tt.heavy]:[[1,6]]}),lineWeight:n({[$e.sm]:{min:1.5,max:1.6},[$e.md]:{min:1.4,max:1.5},default:{min:1.4,max:1.5}}),layerOverride:[{fadeAtLineSegmentChance:0,lineTapering:{fade:{out:{enabledChance:n({[$e.sm]:50,[$e.md]:10,[$e.lg]:0,default:0}),min:1,max:2}}},wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:50,max:70},styleChances:[[1,"bnnoise"]],colorMap:"none"===Oe.mutation&&J.bool(30)?[[[100,J.choice([ye.offsetDown,ye.offset,ye.offsetUp])],[J.weightedChoice([2,0],[1,J.int(0,15)]),ye.color]]]:[[[100,ye.color],[J.weightedChoice([2,0],[1,J.int(0,15)]),ye.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:40,max:100}},J.weightedChoice([0,{scribbleChance:100,scribbleStrength:{min:.2,max:.4},colorMap:[[[1,ye.offset]]],styleChances:[[1,"bnnoise"]],linePressure:{min:.9,max:.95},lineTapering:{scale:{out:{enabledChance:100,min:0,max:.2},in:{enabledChance:100,min:0,max:.2}}}}],[2,{scribbleChance:0,colorMap:[[[1,ye.offsetUp]]],wobbleAmplitude:{min:1,max:1},styleChances:[[1,"bnnoise"]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:.6,max:1},fadeAtLineSegmentStrengthMult:{min:1,max:1.1},linePressure:{min:1.2,max:1.25},materialHardness:{min:.9,max:.95},lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:100,min:3,max:8}}}}]),{styleChances:[[1,"directional"],[1,"bnnoise"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:4,max:8},wobbleFreq:{min:40,max:60}},{colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:1.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},materialHardness:{min:.7,max:.8},linePressure:{min:1.3,max:1.4},minDistanceMult:{min:.5,max:.6},wobbleAmplitude:{min:1,max:2},wobbleFreq:{min:50,max:100},styleChances:[[1,"bnnoise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"],[0,"edgefill"]],lineTapering:{fade:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:100,min:2,max:4}}}},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:80,max:200}}]};Pe=ge(Pe,{ignoreLightingChance:0,wobbleAmplitude:{min:2,max:2},wobbleFreq:{min:35,max:45},materialHardness:i({default:{min:.8,max:.85}}),linePressure:{min:.7,max:.9},minDistanceMult:i({[et.sparse]:{min:2.7,max:3.8},default:{min:1.4,max:1.5}}),spatialOverride:{[Ge.notInCurveOrObject]:{fillChance:100,colorMap:[[[1,ye.offset]]],colorPalette:"fg",ignoreLightingChance:100,insetChance:100,scribbleChance:0,insetDistance:{min:10,max:20},minDistanceMult:{min:2.5,max:5},linePressure:{min:.8,max:.9},lineWeight:{min:.8,max:1.6},fadeAtLineSegmentChance:0},[Ge.nonDominant]:i({[et.light]:ge(u,{colorPalette:"bg",fillChance:100,layerCountChances:[[1,2]],minDistanceMult:{min:1,max:1.3},lineWeight:{min:1.1,max:1.2},layerOverride:[ge(u.layerOverride[0],{colorPalette:"bg",colorMap:[[[1,ye.color]]],linePressure:{min:.15,max:.2},styleChances:[[1,"bnnoise"]]}),ge(u.layerOverride[1],{linePressure:{min:.5,max:.6},colorMap:[[[1,ye.previous]]],styleChances:[[1,"edgefill"]]})]}),[et.detailOnly]:{fillChance:0},default:u}),[Ge.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:{0:{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},1:{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}}},[i({default:n({[$e.lg]:c?Ge.inCurveOrObject:Ge.dominant,[$e.md]:c?Ge.inCurveOrObject:Ge.dominant,default:Ge.dominant})})]:ge(u,{fillChance:100,insetDistance:{min:6,max:12}})}}),Ye=ge(Ye,{insetChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,fillChance:0,layerCountChances:[[1,2],[1,1]],colorMap:i({[et.detailOnly]:[[[1,ye.color]],[[1,ye.previous]]],default:[[[1,ye.line]]]}),lineTapering:{fade:{out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.9,max:.95},materialHardness:{min:.9,max:.95},lineWeight:{min:.6,max:1.5},minDistanceMult:{min:3,max:5},spatialOverride:{[Ge.nonDominant]:{scribbleChance:0,lineWeight:{min:1,max:1.5},colorMap:[J.choice([[[100,ye.line]]])],colorPalette:J.choice(["bg","fg"]),insetChance:100,insetDistance:{min:7,max:12},fillChance:i({[et.detailOnly]:100,default:0}),linePressure:i({[et.light]:{min:.5,max:.6},default:{min:.5,max:.6}}),minDistanceMult:n({[$e.sm]:{min:5,max:7},default:{min:4,max:6}}),styleChances:J.weightedChoice([1,[[1,"directional"]]],[1,[[1,"bnnoise"]]],[1,[[2,"bnnoise"],[2,"directional"],[0,"wobbles"],[0,"bluenoise"]]],[1,[[1,"bluenoise"]]])},[Ge.dominant]:{ignoreLightingChance:100,fillChance:n({[$e.sm]:i({[et.detailOnly]:J.int(30,40),default:J.int(40,50)}),default:J.weightedChoice([1,30],[3,J.num(40,70)])}),layerCountChances:[[2,2],[1,1]],linePressure:{min:.7,max:.9},styleChances:[[5,"bnnoise"],[5,"directional"],[1,"wobbles"],[4,"bluenoise"]],materialHardness:{min:.8,max:.9},colorMap:[[[100,ye.randomAccent]],[[100,ye.previous]]],minDistanceMult:{min:6,max:15},lineWeight:n({[$e.lg]:{min:1,max:1.25},default:{min:1,max:1.25}})}}}),Re=ge(Re,{count:10,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let h=n({[$e.sm]:J.int(95,100),[$e.lg]:i({[et.light]:J.weightedChoice([2,J.int(55,70)],[1,J.int(65,90)]),[et.detailOnly]:J.weightedChoice([2,J.int(55,70)],[1,J.int(65,90)]),default:J.int(80,90)}),default:J.int(70,100)}),m=J.num(.75,1.25);Me=ge(Me,{meshInsetMuliplier:0,lineFilter:h<80?"none":J.weightedChoice([1,"curves"],[1,"straight"],[3,"none"]),meshDensity:h,skipLongest:n({[$e.lg]:J.int(0,10),default:0}),percentage:n({[$e.lg]:i({[et.filled]:J.weightedChoice([1,J.int(0,1)],[1,J.int(50,80)]),default:h>70?J.weightedChoice([1,J.int(40,70)],[1,J.int(0,0)]):J.int(40,70)}),[$e.md]:i({[et.filled]:J.weightedChoice([1,J.int(0,0)],[1,J.int(50,80)]),default:h>70?J.weightedChoice([1,J.int(40,70)],[1,J.int(0,5)]):J.int(40,70)}),[$e.sm]:i({[et.filled]:J.weightedChoice([1,J.int(0,0)],[1,J.int(50,80)]),default:J.int(40,70)}),default:J.int(50,80)}),cropToDominantShape:!1,colors:r({[nt.color]:!0,default:!1}),backgroundColor:r({[nt.light]:!(st!==et.filled&&h<80),default:!1}),materialHardness:{min:.9,max:.96},linePressure:{min:.9,max:.95},thickness:n({[$e.lg]:{min:2.85*m,max:3*m},[$e.md]:{min:2.25*m,max:3.65*m},default:{min:2.25*m,max:4.25*m}})});let p=J.weightedChoice([1,J.int(0,1)],[1,J.int(2,10)]),g=n({[$e.sm]:J.int(4,4),[$e.md]:J.int(4,4),[$e.lg]:J.int(4,4),default:2});He=ge(He,{margin:g*ze.scale,HVariance:{min:-p,max:p,threshold:1,mean:1,stdDev:1},VVariance:{min:-p,max:p,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),Be={...Be,cropToMargin:!1,margin:6*ze.scale}},ct=()=>{_e="Sparse",qe(20,20);let e=lt(0,J.weightedChoice([1,$e.sm],[1,$e.md],[1,$e.lg]));J.weightedChoice([1,tt.heavy]);let t=J.weightedChoice([e({[$e.sm]:1,default:1}),it.objects],[e({[$e.sm]:0,default:2}),it.curves],[e({[$e.sm]:0,default:1}),it.angles],[e({[$e.sm]:0,default:1}),it.grid]),n=at()[t];n.splits[be.circle]=3,Fe=ge(Fe,n.splits),Te=ge(Te,n.meta.forceSplit),Qe=ge(Qe,{noiseOverfittingSpread:e({[$e.sm]:J.num(0,1),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:J.num(.5,1.5)}),Ee=e({default:n.meta?.usedLineReplayChance||4}),je=J.int(200,800),Ae=.1;let i=J.weightedChoice([1,!1],[1,!0]);Oe={...Oe,mutation:J.weightedChoice([0,"offsetUp"],[0,"offsetDown"],[3,"none"]),useNoiseLookup:!0,samplesForComplimentary:J.int(1,2),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:e({default:i?J.num(600,1e3):J.num(100,200)}),usePolyIDColorOffset:i,maxAccents:e({default:J.weightedChoice([0,4],[1,6],[2,100])}),darksOnly:!1};let l=lt(0,J.weightedChoice([e({[$e.lg]:1,default:1}),nt.dark]));Je={...Je,count:0},Ne=[be.horizontal,be.vertical],Ke={...Ke,default:1,clamp:.05,min:.9,max:1.1,influencesBrightnessMult:1,influencesMinDistanceMult:0,influencesPressureMult:0},Ue={...Ue,maxWidth:.75*e({[$e.sm]:J.int(40,50),[$e.md]:J.int(40,50),default:J.num(35,45)}),renderLightChance:100,maxPointUse:J.int(1,2),maxDivergence:J.int(2,4),pointsToConsider:10};let a=J.num(.75,1.5);ke=ge({...ke,layers:2,layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:e({default:J.choice([xe.scene,xe.border,xe.none])}),forceYUp:!0,clampVertsToGrid:e({[$e.sm]:!1,default:!1}),...e({[$e.sm]:{maxDist:200*a,minDist:130*a},[$e.md]:{maxDist:150*a,minDist:100*a},[$e.lg]:J.weightedChoice([5,{maxDist:150*a,minDist:100*a}])}),bnFreq:J.num(10,1e3),fieldFreq:e({[$e.lg]:J.int(4e3,1e4),[$e.sm]:J.int(1e3,2e3),default:J.choice([J.int(1e3,4e3),J.int(4e3,1e4)])}),clampRotationTo:J.weightedChoice([1,22.5],[4,1],[1,11.25]),minSizeMult:1,maxSizeMult:e({default:.75}),maxSides:5,minSides:3,perspective:2e4},n.meta?.objectProps||{}),Ie=ge(Ie,{});let s={edgeSharpness:{min:0,max:0},fillChance:90,insetChance:10,wobbleFreq:{min:30,max:60},wobbleAmplitude:{min:3,max:8},accumulationStrength:{min:10,max:10},materialHardness:{min:.4,max:.45},linePressure:{min:1.3,max:1.3},lineWeight:je<300?{min:1.9,max:2}:{min:1.6,max:1.7},minDistanceMult:{min:.45,max:.5},lineTapering:{scale:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:0,min:1.5,max:2}},fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:100,min:3,max:8}}},layerCountChances:[[1,3]],layerOverride:[{fadeAtLineSegmentChance:0,scribbleChance:10,scribbleStrength:{min:.2,max:.4},styleChances:[[1,"bnnoise"],[1,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:"none"===Oe.mutation&&J.bool(50)?[[[100,ye.offsetUp],[1,ye.color]]]:[[[100,ye.color],[1,ye.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[2,"bnnoise"],[2,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:[[[100,ye.previous]]]},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]]}]};Pe=ge(Pe,{ignoreLightingChance:0,spatialOverride:{[Ge.nonDominant]:s,[Ge.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:[{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},{fadeAtLineSegmentChance:0,styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest],[1,ye.darkest]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}]},[Ge.dominant]:ge(s,{fillChance:100,lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:50,min:6,max:8}}},insetChance:20,insetDistance:{min:6,max:12}})}}),Ye=ge(Ye,{insetChance:50,fillChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,layerCountChances:[[1,2],[1,1]],colorMap:[[[1,ye.line]]],lineTapering:{fade:{out:{enabledChance:50,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.8,max:1},materialHardness:{min:.65,max:.82},lineWeight:{min:1.25,max:1.5},ignoreLightingChance:100,styleChances:[[6,"bnnoise"],[6,"directional"],[1,"wobbles"],[1,"bluenoise"]],minDistanceMult:{min:4,max:8}}),Re=ge(Re,{count:0,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let o=e({[$e.sm]:J.int(95,100),[$e.lg]:J.int(65,90),default:J.int(70,100)});Me=ge(Me,{meshInsetMuliplier:0,lineFilter:"none",meshDensity:o,skipLongest:0,percentage:100,cropToDominantShape:!1,colors:l({default:!1}),backgroundColor:l({default:!1}),linePressure:{min:1.1,max:1.4},materialHardness:{min:.75,max:.82},lineTapering:{fade:{in:{enabledChance:0,min:0,max:1},out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.1,max:.5},out:{enabledChance:100,min:.1,max:.5}}},thickness:e({default:je<600?{min:2,max:2.5}:{min:1.5,max:2}})});let r=J.weightedChoice([1,J.int(0,1)],[1,J.int(2,10)]),c=e({[$e.sm]:J.int(4,4),[$e.md]:J.int(4,4),[$e.lg]:J.int(4,4),default:2});He=ge(He,{margin:c*ze.scale,HVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},VVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),Be={...Be,cropToMargin:!1,margin:6*ze.scale}},dt=()=>{qe(20,20),_e="Outlines";let e=at();Fe={[be.horizontal]:3,[be.vertical]:4,[be.perspective]:5,[be.circle]:1,[be.wobbles]:3,[be.objects]:1,[be.curves]:0,[be.rects]:0,[be.borderRect]:0};let t=e[J.weightedChoice([1,it.objects],[1,it.curves],[1,it.angles],[1,it.grid])];J.bool(50)&&(Fe=ge(Fe,t.splits)),Fe[be.curves]=0,Ee=1,je=J.int(2e3,6e3),Qe=ge(Qe,{noiseOverfittingSpread:J.num(0,5),noiseOverfitFreq:J.int(200,1200),polyOverfitting:J.num(.5,2),longestSplitOnlyChance:0}),Ae=0,He=ge(He,{margin:4*ze.scale}),Be={...Be,cropToMargin:!1,margin:4*ze.scale},Re=ge(Re,{count:0,isLineColor:!0}),Ue={...Ue,layers:1,renderLightChance:0,renderAccentChance:0,insetMult:2,maxWidth:80,spread:4,widthRange:.3,maxDivergence:2,tension:{min:.9,max:1.2},maxPointUse:1,pointsToConsider:30,maxLinePoints:30},ke={...ke,layers:1,clampVertsToGrid:!0,maxDist:100,minDist:50,bnFreq:100,clampRotationTo:1,minSizeMult:1,maxSizeMult:1.25,maxSides:5,minSides:3,perspective:1900},Je={...Je,count:0},Ke={...Ke,default:1,clamp:.05,min:.99,max:1},Oe={...Oe,samplesForComplimentary:1,singleAccent:!1,freqMultiplier:1,usePolyIDColorOffset:!0,maxAccents:100,darksOnly:!1};let n=J.bool(50),i=!n&&J.bool(50);Ue={...Ue,maxWidth:J.num(30,40),renderLightChance:J.weightedChoice([1,0],[1,J.int(10,30)]),maxPointUse:J.int(2,3),maxDivergence:J.int(2,3),pointsToConsider:J.int(5,10)};let l=J.num(.75,.85),a=J.num(.75,1);Me=ge(Me,{meshDensity:J.int(60,90),percentage:J.int(40,60),cropToDominantShape:!1,skipLongest:1,colors:!1,backgroundColor:!1,linePressure:{min:l,max:l+.1},materialHardness:{min:1.05,max:1.2},thickness:{min:1*a,max:2*a}}),Ye=ge(Ye,{fillChance:J.int(40,60),fadeAtLineSegmentChance:0,colorMap:[[[1,ye.line]]],minDistanceMult:{min:2,max:4},styleChances:[[1,"bnnoise"],[1,"directional"],[0,"wobbles"],[0,"bluenoise"]],spatialOverride:{[Ge.dominant]:{linePressure:{min:l-.1,max:l-.05}},[Ge.nonDominant]:{fillChance:n?50:100,linePressure:n?{min:l-.1,max:l-.05}:{min:.4,max:.5},minDistanceMult:i?{min:.5,max:1}:{min:2,max:4},styleChances:i?[[0,"bnnoise"],[0,"directional"],[0,"wobbles"],[1,"bluenoise"]]:[[1,"bnnoise"],[1,"directional"],[0,"wobbles"],[0,"bluenoise"]]}}}),Pe=ge(Pe,{fillChance:n?100:0,linePressure:{min:l,max:l+.1},fadeAtLineSegmentChance:0,ignoreLightingChance:100,lineWeight:{min:1.3,max:1.3},lineTapering:{fade:{in:{enabledChance:0,min:0,max:1},out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:10,min:.
import*as e from"three";const{floor:t,ceil:n,sin:i,cos:l,pow:a,abs:s,min:o,max:r,round:c,sqrt:d,acos:u,sign:h,log:m,random:p,PI:g}=Math,b=1e-7;function f(e,n=b){return t(e+n)}function x(e,t=b){return n(e-t)}function Z(e,t=b){const n=t*h(e);return c(e+n)}let y,G,W="#fff";const v=e=>{e.showUpdate?(!G&&(()=>{y=document.createElement("div"),y.id="loading";const e=y.style;e.position="absolute",e.fontSize="1vmax",e.top=e.left="0",e.width="100%",e.height="100%",e.zIndex="1000",G=document.createElement("div");const t=G.style;t.textTransform="uppercase",t.position="fixed",t.lineHeight="0",t.top=t.left="0",t.width="100vw",t.height="100vh",t.height="fill-available",t.display="flex",t.justifyContent=t.alignItems="center",t.flexDirection="column",t.color=W,t.fontFamily="system-ui",t.fontWeight="500",y.appendChild(G),document.body.appendChild(y)})(),G.innerHTML=(e=>{const{message:t="",value:n=0,isPercent:i=!1}=e;let l=`<p>${t}</p>`,a="";return a=i?`<div style="max-width: 15vmin; margin-top: 1.25em; width: 100%; border: .5px solid ${W}"><div style="width: ${e.value||0}%; height: .75vmin; background-color: ${W}; overflow: hidden;"></div>`:`<p style="margin-top: 1.5em">${n}</p>`,""+(l+a)})(e)):G&&L()},L=()=>{let e=document.getElementById("loading");e&&document.body.removeChild(e),G=null};let S,X,C,V,w,K,R=()=>{S.style.display="none"},k=()=>{S.style.display="block"};const T=performance.now.bind(performance);let M,z,Y,P,I=null,H=()=>{M.style.display="none"},F=.72;const N=r(window.devicePixelRatio,2);let U,D,O,B,Q,J,j=0;class A{useA;prngA;prngB;hash;constructor(e){this.useA=!1,this.hash=e;const t=globalThis.parseInt;let n=function(e){let n=t(e.substring(0,8),16),i=t(e.substring(8,16),16),l=t(e.substring(16,24),16),a=t(e.substring(24,32),16);return function(){n|=0,i|=0,l|=0,a|=0;let e=(n+i|0)+a|0;return a=a+1|0,n=i^i>>>9,i=l+(l<<3)|0,l=l<<21|l>>>11,l=l+e|0,(e>>>0)/4294967296}};this.prngA=n(this.hash.substring(2,34)),this.prngB=n(this.hash.substring(34,66))}dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}num(e,t){return e+(t-e)*this.dec()}int(e,n){return t(this.num(e,n+1))}bool(e=50){return this.dec()<e/100}choice(e){return e[this.int(0,e.length-1)]}easedDec(e){return e(this.dec())}easedInt(e,n,i){return t(this.easedNum(e,n,i))}easedNum(e,t,n){return t+(n-t)*this.easedDec(e)}weightedChoice(...e){const t=e.reduce(((e,[t])=>e+t),0);let n=this.dec()*t;for(const[t,i]of e)if((n-=t)<0)return i;return e[e.length-1][1]}gaussian(e=0,t=1){let n=0,i=0;for(;0===n;)n=this.dec();for(;0===i;)i=this.dec();return d(-2*m(n))*l(2*g*i)*t+e}gaussianBool(e=0,t=0,n=1){return this.gaussian(t,n)>=e}}function E(e=J){let t="0x";for(let n=0;n<64;n++)t+=Math.floor(16*e.dec()).toString(16);return t}let _,q=["0x79e4e7366d15206ce9f686aad9342df4022aae566689ccdd2616fef8eadf24fd","0xabb30680bfbc30d14af1884dc0078b201e00b9e56d79cf689a9b6c2466c9e7ce","0x6bfa2a5aa8879e7141f848ea3d18a43e5f808593890558a7ef5ee2c3f1f11047","0x2b6c8f8e2d35251cc72888786ac8592ab90c42ac4267c8c425326d87017bc345","0x9a74fc0b090bc985b238194988b07f5d14a866009c28f307703e20a1615f46fd","0xd50240d082091aa1290ff47dc8017677d42a5c42662d80c422745c1765598511","0x5f24d9d9c800b6e19b8ea9115514e59de6d0223b59bd7761e0abb28c1ddcf33f","0xfdad5657593d5aa53e307ea3fa4ca0b4b583a4819c11237e774a797788769d6b","0x25235c1d1ca4a672b1b5cefbd5bb734b27c66588fd5b9d891f4b8168a4661508","0x35cbb692c9572a3f83652fc351c11fd47a4bf86a39a3b5c1f66eb9548786f40f","0x62bacaa70cb1fd2f33f82cd56d14f5d59acb484d95d472a8c9ef051ca64a3dc6","0x7e555c7adee354f7998152001f3acb422219bf668bf185437da21cd5a30afb64"];function $(){let e="0x";for(var n=0;n<64;n++)e+=t(16*p()).toString(16);if("undefined"!=typeof tokenData&&tokenData?.tokenId){let e=tokenData.tokenId.slice(-3),t=parseInt(e,10);if(void 0!==q[t])return q[t]}return new URLSearchParams(globalThis.location.search).get("hash")||("undefined"!=typeof tokenData&&tokenData?.hash?tokenData.hash:e)}_=$();let ee="\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec2 mod289(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec3 permute(vec3 x) {\n return mod289(((x * 34.0) + 10.0) * x);\n }\n\n // Noise\n float snoise2D(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289(i);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));\n\n vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);\n m = m * m;\n m = m * m;\n\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n\n m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n }\n\n float fbm(const vec2 v, const int octaves, float frequency, float amplitude) {\n float total = 0.0;\n float maxAmplitude = 0.0;\n for(int i = 0; i < octaves; i++) {\n total += snoise2D(v * frequency) * amplitude;\n maxAmplitude += amplitude;\n frequency *= 2.0;\n amplitude *= 0.5;\n }\n return total / maxAmplitude;\n }\n\n",te="\n float screenEdgeDist(vec2 uv, const float falloff) {\n vec2 normalizedCoords = gl_FragCoord.xy / resolution;\n\n // Calculate distances to the nearest edges\n float distanceToLeftEdge = normalizedCoords.x;\n float distanceToRightEdge = 1.0 - normalizedCoords.x;\n float distanceToBottomEdge = normalizedCoords.y;\n float distanceToTopEdge = 1.0 - normalizedCoords.y;\n\n // Find the minimum distance to any edge\n float minDistanceToEdge = min(min(distanceToLeftEdge, distanceToRightEdge), min(distanceToBottomEdge, distanceToTopEdge));\n\n float scaledDistance = 1.0 - abs(2.0 * minDistanceToEdge - 1.0);\n\n // Apply customizable falloff\n float falloffEffect = pow(scaledDistance, falloff);\n\n return falloffEffect;\n }\n",ne="\n float randomNonDet(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n",ie="\n out vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n";const le=e.Vector2;let ae=!1,se={countX:1,countY:1,index:{x:0,y:0}},oe=(e=!1)=>{let t=e?P:Q,i=n((e?Y:B)/se.countX),l=n(t/se.countY);return{width:i,height:l,xOff:se.index.x*i,yOff:se.index.y*l,yOffFlippedY:(se.countY-1-se.index.y)*l}},re=t=>{let n=t.uniforms,{width:i,height:l,xOff:a,yOffFlippedY:s}=oe();n.uTileOffset.value=new e.Vector2(a,s),n.uTileSize.value=new e.Vector2(i,l)},ce=()=>(!ae&&(()=>{ae=!0;let e=new URL(window.location.href),t=e.searchParams.get("tileCount"),n=e.searchParams.get("index");if(t){let e=parseInt(t);se.countX=e,se.countY=e}if(n){let[e,t]=n.split(",").map((e=>parseInt(e)));se.index.x=o(e,se.countX-1),se.index.y=o(t,se.countY-1)}})(),{uTileOffset:{value:new e.Vector2(0,0)},uTileSize:{value:new e.Vector2(B,Q)}});var de=[{name:"Faces",bg:[[.7409,.0057,69.9871]],line:[[.12,0,68]],base:[[.7995,.0104,53.9144]],accent:[[.55,.092,133],[.37,.1,8],[.47,.124,28],[.7,.112,90],[.48,.088,247],[.59,.048,197],[.78,.012,56.581],[.12,0,68],[.52,.12,342],[.71,.068,44],[.44,.04,299],[.21,.004,329],[.7883,.0264,44]],commonPool:!0,solo:!1},{name:"Chalks",bg:[[.6919,.0323,69.9871]],line:[[.1285578041548887,4.7918630361524376e-9,null]],stroke:[[.9104718532196331,.02929501882422003,89.58052190776175]],base:[[.7968,.033,55.4365]],accent:[[.4391005470961144,.053143667197297274,179.45284673806202],[.7430751481851373,.0929,39.83760570859084],[.7703,.0895,64.56344067218811],[.6641410434441858,.15689118437280108,37.13690468980104],[.7559,.0178,222.564179724743]],disabled:!1,commonPool:!0,solo:!1},{name:"Beach",bg:[[.6835,.03883960001602766,67.25848906440592]],stroke:[[.9372288972261885,.020696467664658196,67.57155893750883]],line:[[.23356138751632896,.02729114952576314,246.90070685897228]],base:[[.8371,.0215,57.0279]],accent:[[.2774185198607467,.04318925551193144,167.75274001919718],[.42064998654759594,.03120177133138129,171.32246538045877],[.4311384415174281,.02336516751567073,241.2330314983908],[.6176019379584577,.1270253885540799,74.1805651416355],[.7260022319511451,.09724578337934522,55.06470317899317],[.7582608113288266,.02549172589125699,166.85185191796654],[.8204,.023,61.9891]],commonPool:!0,solo:!1},{name:"Morning Sun In A Dusty Room",bg:[[.25615282357231434,.011591200093299888,338.1519820725431]],line:[[.14287287327771095,.004143654188326715,345.4391631242127],[.8348,.02687,98.479]],stroke:[[.9136637420289497,.02687443532425364,80.24542314462997]],base:[[.7783871111844314,.042589978975680454,25.529877185969667]],accent:[[.2152,.011591200093299888,338.1519820725431],[.4974379254425503,.08269393625659356,333.938678657093],[.6377751669772775,.16624575588870555,29.858240404234152],[.7303722440997971,.14878423535567212,65.78690162717032],[.525648519572251,.044624199378743616,227.89564437801943],[.8348,.02687443532425364,98.4785]],commonPool:!0,solo:!1},{name:"Jazz",stroke:[[.2866006793419412,.021957785534446477,88.03909075711272]],bg:[[.7399,.0328,69.58004864146267]],base:[[.8051,.0372,74.6117]],line:[[.1285578041548887,4.7918630361524376e-9,null]],accent:[[.6315375414148215,.1752,34.478822707810366],[.5221231161993111,.109,231.97797627692054],[.7332,.1701,64.69716240181685],[.6904,.1463,32.65581391676761],[.8075,.0269,54.0471]],disabled:!1,commonPool:!0,solo:!1},{name:"Beige Box",bg:[[.2169,.004109954650405697,264.48855986171543]],line:[[.1921,.004109954650405697,264.48855986171543],[.7094,.004109954650405697,264.48855986171543]],base:[[.7044,.0027,264.3],[.2582,0,264.15]],stroke:[[.6451555150878627,.1324103074498338,351.3679204443482]],accent:[[.2944,0,264.1525],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.8436835998771347,.14145685075787068,96.14554462682747],[.71866,.13925,63.701],[.6861,.007,63.701]],commonPool:!0,solo:!1},{name:"Master",bg:[[.6936,.0211,82.40092539697929]],line:[[.2507780863015607,.009572580032197206,67.3680640985574]],base:[[.7269,.0162,157.61886984444504]],stroke:[[.9060102804608031,.012170144621286422,23.7150415636807]],accent:[[.6295566765037485,.1211519827044528,67.32018448430034],[.7605,.0195,238.616994352628],[.6174604546514465,.05042117055871639,256.5164449583005],[.4181072443550769,.072,173.90831954879036],[.6627,.1667,37.60803793025025],[.8234,.0071,74.2545],[.7783,.073,8.0298]],commonPool:!0,solo:!1},{name:"New York Autumn",bg:[[.7037,.0281,65.28937708039064]],stroke:[[.8626142182586253,.08537649420452362,82.03909126824601]],line:[[.19548782481388519,.00430705323020645,264.468763979492]],base:[[.7661,.0329,58.25082050504636]],accent:[[.45478156079252346,.039285338382841796,179.22836606186138],[.7553531036330657,.08130837219892006,99.24794847558877],[.5594780208031984,.07916054354499198,245.43994841186026],[.42899728927916636,.04922887943462986,76.52219098535193],[.8309661998821414,.04281039028933322,48.183040275461394],[.7850648916204185,.1273241170717795,79.558262732039],[.8022,.1082,91.79312487991842],[.5727044802833001,.1271825150640351,18.826326398068147],[.5371544884294275,.13634924860871195,21.160585432853736]],commonPool:!0,solo:!1},{name:"The Coast",bg:[[.6974,.0085,76.58691599832048]],stroke:[[.8444869430616695,.08523591444134622,87.01376484878972]],line:[[.22755957415683586,.0015428045966122382,17.270340681712298]],base:[[.7669770002469423,.0030391208463875215,84.56153889362372]],accent:[[.3779357986919375,.0535,176.4086979076003],[.6184542058002529,.0765,130.0878133972343],[.8444869430616695,.0863,87.01376484878972],[.8204404719119529,.0562,13.36293462743373],[.6466292227896673,.1007,248.2503623167608],[.6773,.0488,194.3393064675039],[.6163,.1335,21.160585432853736],[.7968000000000001,.01676,79.345]],commonPool:!0,solo:!1},{name:"Aged",bg:[[.7084,.0396,87.75614537114114]],stroke:[[.94095456060748,.015612821171329101,86.4264441546818]],line:[[.2703834919362128,.003498268640239951,48.59454667339406]],base:[[.7841,.021041287596747362,75.5028]],accent:[[.6599008372479219,.14410614712594896,43.767864491957255],[.5406041428443183,.0810794492722289,156.20612626175443],[.5030711080692698,.15264841257121137,26.608155858968416],[.7691417851736347,.1353050284474489,77.87710240074239],[.7874426063872318,.04659921665479499,51.68182155996902],[.467824859321765,.056096190272488924,217.56676918001241]],commonPool:!0,solo:!1},{name:"Ink & Colour",bg:[[.7601,.014,255.4795978283716]],stroke:[[.9553483843727791,.002877617626355211,84.55913178523588]],line:[[.23724829442832204,.009300030023333045,159.3038618360598]],base:[[.5326,.0294,169.58],[.5352,.1055,153.65],[.7482,.0675,265.537],[.5786,.1009,265.537]],accent:[[.3475,.065,169.58],[.4333,.08067410261737115,292.88016945552295],[.8007868908561364,.0333,7.942656494991638],[.6086666969575215,.1634,28.003190670134757],[.3195,.034575073883449464,254.02069392111645],[.6738,.1201,79.6718],[.8711,.00292,264.54],[.6613,.0632,169.58],[.5352,.1055,153.6549],[.6531,.1061,265.54]],disabled:!1,commonPool:!0,solo:!1},{name:"Oranges",bg:[[.705,.0354,65.1718]],stroke:[[.9912189562526743,.006931254927170287,88.6413010074412]],base:[[.7842,.0305,86.3684]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],accent:[[.35508002090426666,.043787467826530785,211.52484726500788],[.5510005837793092,.08755866639046411,103.27386758796968],[.691,.1582,47.266522185041936],[.7373,.1324,67.62887023877073],[.7999,.0316,88.72052641225343],[.7631,.0647,19.8072]],commonPool:!0,solo:!1},{name:"Henri",bg:[[.7213,.0319,80.6824944352112]],stroke:[[.7121124312829297,.09603422725607345,34.15613531599104]],line:[[.24303319779115856,.004923290798673418,355.16568727574077]],base:[[.8256,.0305,76.17859369988122]],accent:[[.4159,.0591,191.39940656052516],[.7920378039704564,.1352,73.45878915862028],[.7593,.0165,220.7288245953125],[.4637,.0738,237.7123227684075]],disabled:!1,commonPool:!0,solo:!1},{name:"Rand-ey",bg:[[.7426,.0171,87.52315695161104]],line:[[.19419793765469762,.0219,297.0814230776026]],stroke:[[.9076072420048279,.019870599528847212,87.51855970858247]],base:[[.595,.0433,247.9],[.7126,.0966,68.946],[.7791,0,64.059],[.5968,.1097,151.59]],accent:[[.575943267748716,.1486,29.4685],[.5129975835116938,.0741,305.527422000483],[.7538026010313094,.139,68.94572099685297],[.6147,.1332,247.9],[.8423,0,64.0592],[.53766,.1084,167.07]],disabled:!0,commonPool:!0,solo:!1},{name:"Olivetti",bg:[[.2222,.004109954650405697,264.48855986171543]],line:[[.234784254171478,.004109954650405697,264.48855986171543]],stroke:[[.7186588335782654,.1392507657144271,63.7012930132442]],base:[[.2551,0,34.30274488067005]],accent:[[.7186588335782654,.1392507657144271,63.7012930132442],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.8373623117765204,.15785248852128372,95.6270196002983],[.2582,.0037,275.8924],[.5803,.0037,275.8924]],disabled:!0,commonPool:!0,solo:!1},{name:"Toddler",bg:[[.7421,.0212,48.4352]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],stroke:[[.18797280274608968,.026745997001574016,159.25756384014687]],base:[[.6859848282821445,.008266766434931419,61.396302349703944],[.9349265127013049,.01153735356888476,84.57925253447382],[.7688,.0216,61.396302349703944]],accent:[[.3500879126177943,.0865,264.1433132212142],[.4453610930960556,.02928835497819446,336.8043193096847],[.569281111283594,.1860449489679648,25.02687693308303],[.5558543866168449,.054963958871380815,108.06205545681729],[.7052281079548163,.16337391917830385,43.93536507302679],[.8036,.1343,80.58696151433355],[.6763,.0745,108.06205545681729],[.7615,.0782,25.02687693308303]],disabled:!1,commonPool:!0,solo:!1}];let ue=(de.some((e=>e.solo))?de.filter((e=>e.solo)):de.filter((e=>!e.disabled))).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent}))),he=de.filter((e=>e.commonPool)).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent})));function me(e){return e*g/180}function pe(e){return function(e){return null!==e&&"object"==typeof e}(e)&&!Array.isArray(e)}function ge(...e){const t={};for(const n of e)if(n)for(const e of Object.keys(n)){const i=n[e];if(Array.isArray(i))t[e]=[...i];else if(pe(i)){const n=t[e];pe(n)?t[e]=ge(n,i):t[e]=ge({},i)}else t[e]=i}return t}var be,fe,xe;!function(e){e[e.horizontal=0]="horizontal",e[e.vertical=1]="vertical",e[e.perspective=2]="perspective",e[e.circle=3]="circle",e[e.wobbles=4]="wobbles",e[e.curves=5]="curves",e[e.rects=6]="rects",e[e.borderRect=7]="borderRect",e[e.triangle=8]="triangle",e[e.objects=9]="objects",e[e.used=10]="used"}(be||(be={})),function(e){e[e.front=0]="front",e[e.up=1]="up",e[e.right=2]="right",e[e.down=3]="down",e[e.left=4]="left"}(fe||(fe={})),function(e){e.border="border",e.scene="scene",e.none="none"}(xe||(xe={}));let Ze={layers:2,layerScaleMult:2.5,zDepthMaxMult:1,cropTo:xe.none,forceYUp:!0,clampVertsToGrid:!0,maxDist:200,minDist:130,bnFreq:500,fieldFreq:1500,clampRotationTo:1,minSizeMult:1,maxSizeMult:.75,maxSides:5,minSides:3,perspective:2e4};var ye,Ge;!function(e){e[e.color=0]="color",e[e.line=1]="line",e[e.palettecomplement=2]="palettecomplement",e[e.previous=3]="previous",e[e.base=4]="base",e[e.paletteOffset=5]="paletteOffset",e[e.shadow=6]="shadow",e[e.highlight=7]="highlight",e[e.randomAccent=8]="randomAccent",e[e.offset=9]="offset",e[e.offsetUp=10]="offsetUp",e[e.lightestOrDarkestBasedOnBg=11]="lightestOrDarkestBasedOnBg",e[e.brightnessBasedShadowOrHighlight=12]="brightnessBasedShadowOrHighlight",e[e.offsetDown=13]="offsetDown",e[e.darkest=14]="darkest",e[e.lightest=15]="lightest"}(ye||(ye={})),function(e){e.override="override",e.dominant="dominant",e.inCurveOrObject="inCurveOrObject",e.notInCurveOrObject="notInCurveOrObject",e.nonDominant="nonDominant",e.normalHigh="normalHigh",e.normalLow="normalLow",e.overlay="overlay",e.noop="noop"}(Ge||(Ge={}));let We,ve,Le={scribbleChance:0,edgeSharpness:{min:.2,max:.2},scribbleStrength:{min:.5,max:.5},accumulationStrength:{min:1,max:1},materialHardness:{min:1,max:1},fillChance:100,fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},minDistanceMult:{min:5,max:5},linePressure:{min:.8,max:.9},brightnessHighLowThreshold:.75,fadeAtLineSegmentChance:0,detailMinScaleDivisor:30,ignoreLightingChance:0,colorMap:[[[1,ye.color]],[[1,ye.color]]],dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:.5,max:1},wobbleFreq:{min:.5,max:1},layerCountChances:[[0,0],[1,1],[2,2]],styleChances:[[3,"noise"],[4,"directional"],[1,"wobbles"],[3,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},lineWeight:{min:1.1,max:1.1},spatialOverride:{[Ge.overlay]:{fillChance:0}}},Se={scribbleChance:0,edgeSharpness:{min:.5,max:.5},scribbleStrength:{min:.3,max:.3},fillChance:100,accumulationStrength:{min:1,max:1},fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},colorMap:[[[1,ye.color]]],fadeAtLineSegmentChance:100,brightnessHighLowThreshold:.75,ignoreLightingChance:0,detailMinScaleDivisor:30,minDistanceMult:{min:.75,max:.75},dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:2,max:3},wobbleFreq:{min:20,max:40},layerCountChances:[[1,1]],styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},linePressure:{min:1,max:1},materialHardness:{min:1,max:1},lineWeight:{min:1.1,max:1.1},spatialOverride:{[Ge.overlay]:{fillChance:100,lineWeight:{min:2.5,max:2.5},fadeAtLineSegmentChance:0,insetChance:0,ignoreLightingChance:100,styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],minDistanceMult:{min:.75,max:.75},lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},layerCountChances:[[1,2]]}}},Xe={[be.horizontal]:0,[be.vertical]:10,[be.perspective]:0,[be.circle]:10,[be.wobbles]:0,[be.objects]:8,[be.curves]:10,[be.rects]:5,[be.borderRect]:10},Ce=[be.horizontal,be.vertical,be.perspective],Ve={count:1,outline:!0,colors:[[0,ye.color],[0,ye.offset],[0,ye.base],[0,ye.line],[0,ye.darkest],[1,ye.lightest]],colorOffsets:!1,size:{min:4,max:9}},we=[],Ke={default:1,min:.45,max:1.12,clamp:.001,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.3,position:{x:-10005.5,y:-1e4,z:-12e3}},Re={colors:!1,isLineColor:!1,count:50,warpChance:100,lineTapering:{scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},length:{min:20,max:100},hardness:{min:1,max:1},thickness:{min:.5,max:5}},ke=Ze,Te={forceInsertCurvesChance:0,forceInsertObjectsChance:0},Me={meshDensity:80,lineFilter:"none",meshInsetMuliplier:1,dominantLineInsetMultiplier:1,percentage:50,skipLongest:3,cropToDominantShape:!1,materialHardness:{min:.9,max:.95},colors:!1,backgroundColor:!1,lineTapering:{scale:{in:{enabledChance:100,min:.3,max:.6},out:{enabledChance:100,min:.3,max:.6}},fade:{in:{enabledChance:50,min:.1,max:.2},out:{enabledChance:50,min:.1,max:.2}}},linePressure:{min:.9,max:.95},thickness:{min:.5,max:3}},ze={countX:0,countY:0,marginX:0,marginY:0,w:0,h:0,scale:0},Ye=Le,Pe=Se,Ie={enabled:!0,percentage:60,materialHardness:{min:.4,max:.4},lineTapering:{scale:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}},fade:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}}},linePressure:{min:.5,max:.5},lineWeight:{min:.6,max:.6}},He={margin:0,HVariance:{min:0,max:10,threshold:2,mean:1,s
tdDev:1},VVariance:{min:0,max:10,threshold:2,mean:1,stdDev:1},rects:{insetRectEnabled:!0,spiralRectsEnabled:!0},circles:{count:0,minRadius:2,maxRadius:30},wobble:{enabled:!1,count:1e10,layers:2,multiLayers:1,minLength:5,gridDivisions:1,warpFreq:{min:600,max:800},offsetMultiplier:1},perspectiveBox:{enabled:!0,threshold:2,mean:1,stdDev:1,count:1,firstFull:!0}},Fe=Xe,Ne=Ce,Ue={layers:1,renderLightChance:0,ignoreLighting:!0,renderAccentChance:0,insetMult:2,maxWidth:80,spread:4,widthRange:.3,maxDivergence:2,tension:{min:.9,max:1.2},maxPointUse:1,pointsToConsider:30,maxLinePoints:30},De={warpX:!0,warpY:!1,offAxisX:!0,offAxisY:!1,warpXMult:.05,warpYMult:.05,displacementStrength:.05,noiseMapEnabled:!0},Oe={maxAccents:4,mutation:"none",dominantIsAccentChance:50,useNoiseLookup:!0,samplesForComplimentary:3,samplesForPaletteOffset:2,addBGContrast:!1,freqMultiplier:10,usePolyIDColorOffset:!0,singleAccent:!1,darksOnly:!1},Be={cropToMargin:!0,cropBGShapesAtMargin:!0,cropToMarginFillDark:!1,margin:30},Qe={count:100,lineRemoveStrength:.1,polyOverfitting:.75,noiseOverfittingSpread:0,noiseOverfitFreq:100,excludeWeakSplits:!1,longestSplitOnlyChance:50,noiseFieldCategoryInfluence:1e3},Je=Ve,je=100,Ae=.1,Ee=0,_e="";const qe=(e,t)=>{ze.scale=J.int(e,t);const n=Y/ze.scale,i=P/ze.scale;ze.countX=Math.ceil(n),ze.countY=Math.ceil(i);const l=ze.countX*ze.scale,a=ze.countY*ze.scale;ze.marginX=(Y-l)/2,ze.marginY=(P-a)/2,ze.w=ze.scale,ze.h=ze.scale};var $e,et,tt,nt,it;function lt(e,t){return function(e){return void 0!==e[t]?e[t]:e.default}}!function(e){e.xs="xsmall",e.sm="small",e.md="medium",e.lg="large",e.xl="xlarge"}($e||($e={})),function(e){e.none="none",e.sparse="sparse",e.light="light",e.dense="dense",e.filled="filled",e.detailOnly="detailOnly"}(et||(et={})),function(e){e.light="light",e.medium="medium",e.heavy="heavy"}(tt||(tt={})),function(e){e.color="color",e.dark="dark",e.light="light"}(nt||(nt={})),function(e){e.objects="objects",e.curves="curves",e.angles="angles",e.grid="grid",e.mesh="mesh",e.all="all",e.random="random"}(it||(it={}));const at=()=>({[it.objects]:{splits:{[be.horizontal]:1,[be.vertical]:2,[be.perspective]:0,[be.circle]:2,[be.wobbles]:3,[be.objects]:15,[be.curves]:5,[be.rects]:1,[be.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:J.choice([10,0]),forceInsertObjectsChance:J.choice([30,0])}}},[it.grid]:{splits:{[be.horizontal]:2,[be.vertical]:4,[be.perspective]:0,[be.circle]:4,[be.wobbles]:1,[be.objects]:10,[be.curves]:0,[be.rects]:0,[be.borderRect]:0},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[it.curves]:{splits:{[be.horizontal]:1,[be.vertical]:2,[be.perspective]:0,[be.circle]:10,[be.wobbles]:10,[be.objects]:J.choice([10,1]),[be.curves]:10,[be.rects]:0,[be.borderRect]:1},meta:{usedLineReplayChance:10,forceSplit:{forceInsertCurvesChance:J.choice([0,20]),forceInsertObjectsChance:J.choice([0,20])}}},[it.angles]:{splits:{[be.horizontal]:2,[be.vertical]:3,[be.perspective]:3,[be.circle]:0,[be.wobbles]:0,[be.objects]:3,[be.curves]:2,[be.rects]:0,[be.borderRect]:1},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}},[it.mesh]:{splits:{[be.horizontal]:1,[be.vertical]:1,[be.perspective]:1,[be.circle]:1,[be.wobbles]:0,[be.objects]:1,[be.curves]:0,[be.rects]:0,[be.borderRect]:0},meta:{objectProps:{forceYUp:!0},forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:50}}},[it.all]:{splits:{[be.horizontal]:2,[be.vertical]:2,[be.perspective]:2,[be.circle]:2,[be.wobbles]:2,[be.objects]:4,[be.curves]:2,[be.rects]:1,[be.borderRect]:2},meta:{forceSplit:{forceInsertCurvesChance:0,forceInsertObjectsChance:0}}}});let st,ot;const rt=()=>{let e=at();_e="Pencils",qe(20,20),ot=J.weightedChoice([15,$e.sm],[15,$e.md],[10,$e.lg]);let n=lt(0,ot);st=J.weightedChoice([n({[$e.sm]:1,default:1}),et.light],[n({[$e.sm]:0,default:1}),et.dense],[n({[$e.sm]:2,[$e.md]:2,default:1}),et.filled],[1,et.detailOnly]);let i=lt(0,st),l=lt(0,J.weightedChoice([n({[$e.sm]:i({[et.none]:0,[et.sparse]:0,default:0}),default:0}),tt.light],[1,tt.medium],[1,tt.heavy])),a=J.weightedChoice([n({[$e.sm]:i({[et.filled]:5,default:1}),default:1}),it.objects],[n({[$e.sm]:0,default:2}),it.curves],[n({[$e.sm]:0,default:1}),it.angles],[n({[$e.sm]:0,default:1}),it.grid]),s=e[a];Fe=ge(Fe,s.splits),Te=ge(Te,s.meta.forceSplit),Qe=ge(Qe,{noiseOverfittingSpread:n({[$e.sm]:J.num(0,1),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:J.choice([1,J.num(.5,1.5)]),longestSplitOnlyChance:n({[$e.sm]:J.choice([0,50,100]),default:J.choice([50,100])}),noiseFieldCategoryInfluence:J.choice([1,4])}),Ee=n({default:s.meta?.usedLineReplayChance||4}),je=t(n({[$e.sm]:i({[et.filled]:J.int(190,180),[et.none]:J.int(190,230),[et.detailOnly]:J.int(200,230),default:J.int(190,230)}),[$e.md]:J.int(250,350),[$e.lg]:J.int(350,800)})),Ae=i({[et.filled]:n({[$e.lg]:J.num(0,.3),[$e.md]:J.num(0,.2),[$e.sm]:J.num(0,.01),default:J.num(0,.1)}),default:n({[$e.sm]:J.num(0,.01),[$e.md]:J.num(0,.1),[$e.lg]:J.num(0,.3)})});let o=J.weightedChoice([1,!1],[1,!0]);Oe={...Oe,mutation:J.weightedChoice([0,"offsetUp"],[0,"offsetDown"],[3,"none"]),addBGContrast:i({[et.detailOnly]:!1,default:!0}),useNoiseLookup:!0,samplesForComplimentary:J.int(1,3),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:n({default:o?J.num(300,600):J.num(300,400)}),usePolyIDColorOffset:o,maxAccents:n({default:J.weightedChoice([1,4],[1,6],[2,100])}),darksOnly:!1};let r=lt(0,J.weightedChoice([10,nt.color],[n({[$e.lg]:1,default:0}),nt.dark],[n({[$e.lg]:1,default:0}),nt.light]));Je={...Je,size:n({[$e.lg]:{min:4,max:5},[$e.md]:{min:5,max:6},[$e.sm]:{min:6,max:8}})},Ne=[be.horizontal,be.vertical],Ke={...Ke,default:1,clamp:.05,min:.6,max:1,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.2},st!=et.filled||ot!=$e.lg&&ot!=$e.md||!J.bool(10)||(Ke={...Ke,default:1,clamp:.05,min:.5,max:.55,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:0});let c=J.bool(40);Ue={...Ue,ignoreLighting:J.bool(50),maxWidth:.75*n({[$e.sm]:J.int(40,50),[$e.md]:J.int(40,50),default:J.num(35,45)}),renderLightChance:J.weightedChoice([1,0],[1,J.int(0,10)]),maxPointUse:1,maxDivergence:2,pointsToConsider:10};let d=J.num(.75,1.5);ke=ge({...ke,layers:2,layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:n({default:J.choice([xe.scene,xe.border,xe.none])}),forceYUp:a==it.grid||J.bool(30),clampVertsToGrid:n({[$e.sm]:!1,default:!1}),...n({[$e.sm]:{maxDist:200*d,minDist:130*d},[$e.md]:{maxDist:150*d,minDist:100*d},[$e.lg]:J.weightedChoice([5,{maxDist:130*d,minDist:80*d}])}),bnFreq:J.num(10,1e3),fieldFreq:n({[$e.lg]:J.int(4e3,1e4),[$e.sm]:J.int(1e3,2e3),default:J.choice([J.int(1e3,4e3),J.int(4e3,1e4)])}),clampRotationTo:J.weightedChoice([1,22.5],[4,1],[1,11.25]),minSizeMult:1,maxSizeMult:n({default:.75}),maxSides:5,minSides:3,perspective:2e4},s.meta?.objectProps||{});let u={edgeSharpness:{min:.8,max:1},fillChance:100,insetChance:J.choice([8,5,0]),wobbleFreq:{min:40,max:80},wobbleAmplitude:{min:1,max:3},accumulationStrength:{min:1,max:1},materialHardness:i({[et.light]:{min:.9,max:.97},default:{min:.93,max:.99}}),linePressure:i({default:{min:.65,max:.7}}),minDistanceMult:n({[$e.lg]:{min:.7,max:.8},[$e.sm]:{min:.7,max:.8},default:{min:.7,max:.8}}),lineTapering:{fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}},scale:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:0,min:0,max:0}}},layerCountChances:l({[tt.light]:[[1,2]],[tt.medium]:[[1,4]],[tt.heavy]:[[1,6]]}),lineWeight:n({[$e.sm]:{min:1.5,max:1.6},[$e.md]:{min:1.4,max:1.5},default:{min:1.4,max:1.5}}),layerOverride:[{fadeAtLineSegmentChance:0,lineTapering:{fade:{out:{enabledChance:n({[$e.sm]:50,[$e.md]:10,[$e.lg]:0,default:0}),min:1,max:2}}},wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:50,max:70},styleChances:[[1,"bnnoise"]],colorMap:"none"===Oe.mutation&&J.bool(30)?[[[100,J.choice([ye.offsetDown,ye.offset,ye.offsetUp])],[J.weightedChoice([2,0],[1,J.int(0,15)]),ye.color]]]:[[[100,ye.color],[J.weightedChoice([2,0],[1,J.int(0,15)]),ye.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:40,max:100}},J.weightedChoice([0,{scribbleChance:100,scribbleStrength:{min:.2,max:.4},colorMap:[[[1,ye.offset]]],styleChances:[[1,"bnnoise"]],linePressure:{min:.9,max:.95},lineTapering:{scale:{out:{enabledChance:100,min:0,max:.2},in:{enabledChance:100,min:0,max:.2}}}}],[2,{scribbleChance:0,colorMap:[[[1,ye.offsetUp]]],wobbleAmplitude:{min:1,max:1},styleChances:[[1,"bnnoise"]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:.6,max:1},fadeAtLineSegmentStrengthMult:{min:1,max:1.1},linePressure:{min:1.2,max:1.25},materialHardness:{min:.9,max:.95},lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:100,min:3,max:8}}}}]),{styleChances:[[1,"directional"],[1,"bnnoise"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:4,max:8},wobbleFreq:{min:40,max:60}},{colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]],fadeAtLineSegmentChance:100,fadeAtLineSegmentDistanceMult:{min:1.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},materialHardness:{min:.7,max:.8},linePressure:{min:1.3,max:1.4},minDistanceMult:{min:.5,max:.6},wobbleAmplitude:{min:1,max:2},wobbleFreq:{min:50,max:100},styleChances:[[1,"bnnoise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"],[0,"edgefill"]],lineTapering:{fade:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:100,min:2,max:4}}}},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.previous]]],wobbleAmplitude:{min:5,max:6},wobbleFreq:{min:80,max:200}}]};Pe=ge(Pe,{ignoreLightingChance:0,wobbleAmplitude:{min:2,max:2},wobbleFreq:{min:35,max:45},materialHardness:i({default:{min:.8,max:.85}}),linePressure:{min:.7,max:.9},minDistanceMult:i({[et.sparse]:{min:2.7,max:3.8},default:{min:1.4,max:1.5}}),spatialOverride:{[Ge.notInCurveOrObject]:{fillChance:100,colorMap:[[[1,ye.offset]]],colorPalette:"fg",ignoreLightingChance:100,insetChance:100,scribbleChance:0,insetDistance:{min:10,max:20},minDistanceMult:{min:2.5,max:5},linePressure:{min:.8,max:.9},lineWeight:{min:.8,max:1.6},fadeAtLineSegmentChance:0},[Ge.nonDominant]:i({[et.light]:ge(u,{colorPalette:"bg",fillChance:100,layerCountChances:[[1,2]],minDistanceMult:{min:1,max:1.3},lineWeight:{min:1.1,max:1.2},layerOverride:[ge(u.layerOverride[0],{colorPalette:"bg",colorMap:[[[1,ye.color]]],linePressure:{min:.15,max:.2},styleChances:[[1,"bnnoise"]]}),ge(u.layerOverride[1],{linePressure:{min:.5,max:.6},colorMap:[[[1,ye.previous]]],styleChances:[[1,"edgefill"]]})]}),[et.detailOnly]:{fillChance:0},default:u}),[Ge.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:{0:{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},1:{fadeAtLineSegmentChance:0,styleChances:[[1,"edgefill"]],colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}}},[i({default:n({[$e.lg]:c?Ge.inCurveOrObject:Ge.dominant,[$e.md]:c?Ge.inCurveOrObject:Ge.dominant,default:Ge.dominant})})]:ge(u,{fillChance:100,insetDistance:{min:6,max:12}})}}),Ye=ge(Ye,{insetChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,fillChance:0,layerCountChances:[[1,2],[1,1]],colorMap:i({[et.detailOnly]:[[[1,ye.color]],[[1,ye.previous]]],default:[[[1,ye.line]]]}),lineTapering:{fade:{out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.9,max:.95},materialHardness:{min:.9,max:.95},lineWeight:{min:.6,max:1.5},minDistanceMult:{min:3,max:5},spatialOverride:{[Ge.nonDominant]:{scribbleChance:0,lineWeight:{min:1,max:1.5},colorMap:[J.choice([[[100,ye.line]]])],colorPalette:J.choice(["bg","fg"]),insetChance:100,insetDistance:{min:7,max:12},fillChance:i({[et.detailOnly]:100,default:0}),linePressure:i({[et.light]:{min:.5,max:.6},default:{min:.5,max:.6}}),minDistanceMult:n({[$e.sm]:{min:5,max:7},default:{min:4,max:6}}),styleChances:J.weightedChoice([1,[[1,"directional"]]],[1,[[1,"bnnoise"]]],[1,[[2,"bnnoise"],[2,"directional"],[0,"wobbles"],[0,"bluenoise"]]],[1,[[1,"bluenoise"]]])},[Ge.dominant]:{ignoreLightingChance:100,fillChance:n({[$e.sm]:i({[et.detailOnly]:J.int(30,40),default:J.int(40,50)}),default:J.weightedChoice([1,30],[3,J.num(40,70)])}),layerCountChances:[[2,2],[1,1]],linePressure:{min:.7,max:.9},styleChances:[[5,"bnnoise"],[5,"directional"],[1,"wobbles"],[4,"bluenoise"]],materialHardness:{min:.8,max:.9},colorMap:[[[100,ye.randomAccent]],[[100,ye.previous]]],minDistanceMult:{min:6,max:15},lineWeight:n({[$e.lg]:{min:1,max:1.25},default:{min:1,max:1.25}})}}}),Re=ge(Re,{count:10,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let h=n({[$e.sm]:J.int(95,100),[$e.lg]:i({[et.light]:J.weightedChoice([2,J.int(55,70)],[1,J.int(65,90)]),[et.detailOnly]:J.weightedChoice([2,J.int(55,70)],[1,J.int(65,90)]),default:J.int(80,90)}),default:J.int(70,100)}),m=J.num(.75,1.25);Me=ge(Me,{meshInsetMuliplier:0,lineFilter:h<80?"none":J.weightedChoice([1,"curves"],[1,"straight"],[3,"none"]),meshDensity:h,skipLongest:n({[$e.lg]:J.int(0,10),default:0}),percentage:n({[$e.lg]:i({[et.filled]:J.weightedChoice([1,J.int(0,1)],[1,J.int(50,80)]),default:h>70?J.weightedChoice([1,J.int(40,70)],[1,J.int(0,0)]):J.int(40,70)}),[$e.md]:i({[et.filled]:J.weightedChoice([1,J.int(0,0)],[1,J.int(50,80)]),default:h>70?J.weightedChoice([1,J.int(40,70)],[1,J.int(0,5)]):J.int(40,70)}),[$e.sm]:i({[et.filled]:J.weightedChoice([1,J.int(0,0)],[1,J.int(50,80)]),default:J.int(40,70)}),default:J.int(50,80)}),cropToDominantShape:!1,colors:r({[nt.color]:!0,default:!1}),backgroundColor:r({[nt.light]:!(st!==et.filled&&h<80),default:!1}),materialHardness:{min:.9,max:.96},linePressure:{min:.9,max:.95},thickness:n({[$e.lg]:{min:2.85*m,max:3*m},[$e.md]:{min:2.25*m,max:3.65*m},default:{min:2.25*m,max:4.25*m}})});let p=J.weightedChoice([1,J.int(0,1)],[1,J.int(2,10)]),g=n({[$e.sm]:J.int(4,4),[$e.md]:J.int(4,4),[$e.lg]:J.int(4,4),default:2});He=ge(He,{margin:g*ze.scale,HVariance:{min:-p,max:p,threshold:1,mean:1,stdDev:1},VVariance:{min:-p,max:p,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),Be={...Be,cropToMargin:!1,margin:6*ze.scale}},ct=()=>{_e="Sparse",qe(20,20);let e=lt(0,J.weightedChoice([1,$e.sm],[1,$e.md],[1,$e.lg]));J.weightedChoice([1,tt.heavy]);let t=J.weightedChoice([e({[$e.sm]:1,default:1}),it.objects],[e({[$e.sm]:0,default:2}),it.curves],[e({[$e.sm]:0,default:1}),it.angles],[e({[$e.sm]:0,default:1}),it.grid]),n=at()[t];n.splits[be.circle]=3,Fe=ge(Fe,n.splits),Te=ge(Te,n.meta.forceSplit),Qe=ge(Qe,{noiseOverfittingSpread:e({[$e.sm]:J.num(0,1),default:J.num(0,1)}),noiseOverfitFreq:1200,polyOverfitting:J.num(.5,1.5)}),Ee=e({default:n.meta?.usedLineReplayChance||4}),je=J.int(200,800),Ae=.1;let i=J.weightedChoice([1,!1],[1,!0]);Oe={...Oe,mutation:J.weightedChoice([0,"offsetUp"],[0,"offsetDown"],[3,"none"]),useNoiseLookup:!0,samplesForComplimentary:J.int(1,2),samplesForPaletteOffset:1,singleAccent:!1,freqMultiplier:e({default:i?J.num(600,1e3):J.num(100,200)}),usePolyIDColorOffset:i,maxAccents:e({default:J.weightedChoice([0,4],[1,6],[2,100])}),darksOnly:!1};let l=lt(0,J.weightedChoice([e({[$e.lg]:1,default:1}),nt.dark]));Je={...Je,count:0},Ne=[be.horizontal,be.vertical],Ke={...Ke,default:1,clamp:.05,min:.9,max:1.1,influencesBrightnessMult:1,influencesMinDistanceMult:0,influencesPressureMult:0},Ue={...Ue,maxWidth:.75*e({[$e.sm]:J.int(40,50),[$e.md]:J.int(40,50),default:J.num(35,45)}),renderLightChance:100,maxPointUse:J.int(1,2),maxDivergence:J.int(2,4),pointsToConsider:10};let a=J.num(.75,1.5);ke=ge({...ke,layers:2,layerScaleMult:2.5,zDepthMaxMult:J.int(1,2),cropTo:e({default:J.choice([xe.scene,xe.border,xe.none])}),forceYUp:!0,clampVertsToGrid:e({[$e.sm]:!1,default:!1}),...e({[$e.sm]:{maxDist:200*a,minDist:130*a},[$e.md]:{maxDist:150*a,minDist:100*a},[$e.lg]:J.weightedChoice([5,{maxDist:150*a,minDist:100*a}])}),bnFreq:J.num(10,1e3),fieldFreq:e({[$e.lg]:J.int(4e3,1e4),[$e.sm]:J.int(1e3,2e3),default:J.choice([J.int(1e3,4e3),J.int(4e3,1e4)])}),clampRotationTo:J.weightedChoice([1,22.5],[4,1],[1,11.25]),minSizeMult:1,maxSizeMult:e({default:.75}),maxSides:5,minSides:3,perspective:2e4},n.meta?.objectProps||{}),Ie=ge(Ie,{});let s={edgeSharpness:{min:0,max:0},fillChance:90,insetChance:10,wobbleFreq:{min:30,max:60},wobbleAmplitude:{min:3,max:8},accumulationStrength:{min:10,max:10},materialHardness:{min:.4,max:.45},linePressure:{min:1.3,max:1.3},lineWeight:je<300?{min:1.9,max:2}:{min:1.6,max:1.7},minDistanceMult:{min:.45,max:.5},lineTapering:{scale:{in:{enabledChance:0,min:.1,max:.2},out:{enabledChance:0,min:1.5,max:2}},fade:{in:{enabledChance:0,min:0,max:0},out:{enabledChance:100,min:3,max:8}}},layerCountChances:[[1,3]],layerOverride:[{fadeAtLineSegmentChance:0,scribbleChance:10,scribbleStrength:{min:.2,max:.4},styleChances:[[1,"bnnoise"],[1,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:"none"===Oe.mutation&&J.bool(50)?[[[100,ye.offsetUp],[1,ye.color]]]:[[[100,ye.color],[1,ye.offsetUp]]]},{fadeAtLineSegmentChance:0,styleChances:[[2,"bnnoise"],[2,"directional"],[0,"edgefill"],[1,"bluenoise"]],colorMap:[[[100,ye.previous]]]},{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.brightnessBasedShadowOrHighlight]]]}]};Pe=ge(Pe,{ignoreLightingChance:0,spatialOverride:{[Ge.nonDominant]:s,[Ge.overlay]:{lineWeight:{min:1.6,max:1.7},materialHardness:{min:.6,max:.75},minDistanceMult:{min:1,max:1},layerCountChances:[[1,2]],linePressure:{min:.99,max:.99},layerOverride:[{styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest]]],fadeAtLineSegmentChance:0,scribbleChance:0},{fadeAtLineSegmentChance:0,styleChances:[[1,"bnnoise"]],colorMap:[[[1,ye.lightest],[1,ye.darkest]]],wobbleAmplitude:{min:6,max:8},wobbleFreq:{min:60,max:90}}]},[Ge.dominant]:ge(s,{fillChance:100,lineTapering:{fade:{in:{enabledChance:0,min:1,max:1},out:{enabledChance:50,min:6,max:8}}},insetChance:20,insetDistance:{min:6,max:12}})}}),Ye=ge(Ye,{insetChance:50,fillChance:50,detailMinScaleDivisor:10,insetDistance:{min:4,max:12},wobbleAmplitude:{min:2,max:4},wobbleFreq:{min:55,max:200},fadeAtLineSegmentChance:0,layerCountChances:[[1,2],[1,1]],colorMap:[[[1,ye.line]]],lineTapering:{fade:{out:{enabledChance:50,min:1,max:2}},scale:{in:{enabledChance:100,min:.01,max:.2},out:{enabledChance:100,min:.01,max:.2}}},linePressure:{min:.8,max:1},materialHardness:{min:.65,max:.82},lineWeight:{min:1.25,max:1.5},ignoreLightingChance:100,styleChances:[[6,"bnnoise"],[6,"directional"],[1,"wobbles"],[1,"bluenoise"]],minDistanceMult:{min:4,max:8}}),Re=ge(Re,{count:0,warpChance:100,length:{min:100,max:200},thickness:{min:1,max:1.5}});let o=e({[$e.sm]:J.int(95,100),[$e.lg]:J.int(65,90),default:J.int(70,100)});Me=ge(Me,{meshInsetMuliplier:0,lineFilter:"none",meshDensity:o,skipLongest:0,percentage:100,cropToDominantShape:!1,colors:l({default:!1}),backgroundColor:l({default:!1}),linePressure:{min:1.1,max:1.4},materialHardness:{min:.75,max:.82},lineTapering:{fade:{in:{enabledChance:0,min:0,max:1},out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:100,min:.1,max:.5},out:{enabledChance:100,min:.1,max:.5}}},thickness:e({default:je<600?{min:2,max:2.5}:{min:1.5,max:2}})});let r=J.weightedChoice([1,J.int(0,1)],[1,J.int(2,10)]),c=e({[$e.sm]:J.int(4,4),[$e.md]:J.int(4,4),[$e.lg]:J.int(4,4),default:2});He=ge(He,{margin:c*ze.scale,HVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},VVariance:{min:-r,max:r,threshold:1,mean:1,stdDev:1},circles:{count:5,minRadius:5,maxRadius:18},wobble:{enabled:!0,count:1e10,minLength:2,layers:4,multiLayers:1,gridDivisions:1,warpFreq:{min:800,max:2e3},offsetMultiplier:.6},perspectiveBox:{enabled:!0,threshold:4,mean:2,stdDev:8,firstFull:!0,count:1}}),Be={...Be,cropToMargin:!1,margin:6*ze.scale}},dt=()=>{qe(20,20),_e="Outlines";let e=at();Fe={[be.horizontal]:3,[be.vertical]:4,[be.perspective]:5,[be.circle]:1,[be.wobbles]:3,[be.objects]:1,[be.curves]:0,[be.rects]:0,[be.borderRect]:0};let t=e[J.weightedChoice([1,it.objects],[1,it.curves],[1,it.angles],[1,it.grid])];J.bool(50)&&(Fe=ge(Fe,t.splits)),Fe[be.curves]=0,Ee=1,je=J.int(2e3,6e3),Qe=ge(Qe,{noiseOverfittingSpread:J.num(0,5),noiseOverfitFreq:J.int(200,1200),polyOverfitting:J.num(.5,2),longestSplitOnlyChance:0}),Ae=0,He=ge(He,{margin:4*ze.scale}),Be={...Be,cropToMargin:!1,margin:4*ze.scale},Re=ge(Re,{count:0,isLineColor:!0}),Ue={...Ue,layers:1,renderLightChance:0,renderAccentChance:0,insetMult:2,maxWidth:80,spread:4,widthRange:.3,maxDivergence:2,tension:{min:.9,max:1.2},maxPointUse:1,pointsToConsider:30,maxLinePoints:30},ke={...ke,layers:1,clampVertsToGrid:!0,maxDist:100,minDist:50,bnFreq:100,clampRotationTo:1,minSizeMult:1,maxSizeMult:1.25,maxSides:5,minSides:3,perspective:1900},Je={...Je,count:0},Ke={...Ke,default:1,clamp:.05,min:.99,max:1},Oe={...Oe,samplesForComplimentary:1,singleAccent:!1,freqMultiplier:1,usePolyIDColorOffset:!0,maxAccents:100,darksOnly:!1};let n=J.bool(50),i=!n&&J.bool(50);Ue={...Ue,maxWidth:J.num(30,40),renderLightChance:J.weightedChoice([1,0],[1,J.int(10,30)]),maxPointUse:J.int(2,3),maxDivergence:J.int(2,3),pointsToConsider:J.int(5,10)};let l=J.num(.75,.85),a=J.num(.75,1);Me=ge(Me,{meshDensity:J.int(60,90),percentage:J.int(40,60),cropToDominantShape:!1,skipLongest:1,colors:!1,backgroundColor:!1,linePressure:{min:l,max:l+.1},materialHardness:{min:1.05,max:1.2},thickness:{min:1*a,max:2*a}}),Ye=ge(Ye,{fillChance:J.int(40,60),fadeAtLineSegmentChance:0,colorMap:[[[1,ye.line]]],minDistanceMult:{min:2,max:4},styleChances:[[1,"bnnoise"],[1,"directional"],[0,"wobbles"],[0,"bluenoise"]],spatialOverride:{[Ge.dominant]:{linePressure:{min:l-.1,max:l-.05}},[Ge.nonDominant]:{fillChance:n?50:100,linePressure:n?{min:l-.1,max:l-.05}:{min:.4,max:.5},minDistanceMult:i?{min:.5,max:1}:{min:2,max:4},styleChances:i?[[0,"bnnoise"],[0,"directional"],[0,"wobbles"],[1,"bluenoise"]]:[[1,"bnnoise"],[1,"directional"],[0,"wobbles"],[0,"bluenoise"]]}}}),Pe=ge(Pe,{fillChance:n?100:0,linePressure:{min:l,max:l+.1},fadeAtLineSegmentChance:0,ignoreLightingChance:100,lineWeight:{min:1.3,max:1.3},lineTapering:{fade:{in:{enabledChance:0,min:0,max:1},out:{enabledChance:0,min:1,max:2}},scale:{in:{enabledChance:10,min:.
import*as e from"three";const{floor:t,ceil:n,sin:i,cos:l,pow:a,abs:s,min:o,max:r,round:c,sqrt:d,acos:u,sign:h,log:m,random:p,PI:g}=Math,b=1e-7;function f(e,n=b){return t(e+n)}function x(e,t=b){return n(e-t)}function Z(e,t=b){const n=t*h(e);return c(e+n)}let y,G,W="#fff";const v=e=>{e.showUpdate?(!G&&(()=>{y=document.createElement("div"),y.id="loading";const e=y.style;e.position="absolute",e.fontSize="1vmax",e.top=e.left="0",e.width="100%",e.height="100%",e.zIndex="1000",G=document.createElement("div");const t=G.style;t.textTransform="uppercase",t.position="fixed",t.lineHeight="0",t.top=t.left="0",t.width="100vw",t.height="100vh",t.height="fill-available",t.display="flex",t.justifyContent=t.alignItems="center",t.flexDirection="column",t.color=W,t.fontFamily="system-ui",t.fontWeight="500",y.appendChild(G),document.body.appendChild(y)})(),G.innerHTML=(e=>{const{message:t="",value:n=0,isPercent:i=!1}=e;let l=`<p>${t}</p>`,a="";return a=i?`<div style="max-width: 15vmin; margin-top: 1.25em; width: 100%; border: .5px solid ${W}"><div style="width: ${e.value||0}%; height: .75vmin; background-color: ${W}; overflow: hidden;"></div>`:`<p style="margin-top: 1.5em">${n}</p>`,""+(l+a)})(e)):G&&L()},L=()=>{let e=document.getElementById("loading");e&&document.body.removeChild(e),G=null};let S,X,C,V,w,K,R=()=>{S.style.display="none"},k=()=>{S.style.display="block"};const T=performance.now.bind(performance);let M,z,Y,P,I=null,H=()=>{M.style.display="none"},F=.72;const N=r(window.devicePixelRatio,2);let U,D,O,B,Q,J,j=0;class A{useA;prngA;prngB;hash;constructor(e){this.useA=!1,this.hash=e;const t=globalThis.parseInt;let n=function(e){let n=t(e.substring(0,8),16),i=t(e.substring(8,16),16),l=t(e.substring(16,24),16),a=t(e.substring(24,32),16);return function(){n|=0,i|=0,l|=0,a|=0;let e=(n+i|0)+a|0;return a=a+1|0,n=i^i>>>9,i=l+(l<<3)|0,l=l<<21|l>>>11,l=l+e|0,(e>>>0)/4294967296}};this.prngA=n(this.hash.substring(2,34)),this.prngB=n(this.hash.substring(34,66))}dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}num(e,t){return e+(t-e)*this.dec()}int(e,n){return t(this.num(e,n+1))}bool(e=50){return this.dec()<e/100}choice(e){return e[this.int(0,e.length-1)]}easedDec(e){return e(this.dec())}easedInt(e,n,i){return t(this.easedNum(e,n,i))}easedNum(e,t,n){return t+(n-t)*this.easedDec(e)}weightedChoice(...e){const t=e.reduce(((e,[t])=>e+t),0);let n=this.dec()*t;for(const[t,i]of e)if((n-=t)<0)return i;return e[e.length-1][1]}gaussian(e=0,t=1){let n=0,i=0;for(;0===n;)n=this.dec();for(;0===i;)i=this.dec();return d(-2*m(n))*l(2*g*i)*t+e}gaussianBool(e=0,t=0,n=1){return this.gaussian(t,n)>=e}}function E(e=J){let t="0x";for(let n=0;n<64;n++)t+=Math.floor(16*e.dec()).toString(16);return t}let _,q=["0x79e4e7366d15206ce9f686aad9342df4022aae566689ccdd2616fef8eadf24fd","0xabb30680bfbc30d14af1884dc0078b201e00b9e56d79cf689a9b6c2466c9e7ce","0x6bfa2a5aa8879e7141f848ea3d18a43e5f808593890558a7ef5ee2c3f1f11047","0x2b6c8f8e2d35251cc72888786ac8592ab90c42ac4267c8c425326d87017bc345","0x9a74fc0b090bc985b238194988b07f5d14a866009c28f307703e20a1615f46fd","0xd50240d082091aa1290ff47dc8017677d42a5c42662d80c422745c1765598511","0x5f24d9d9c800b6e19b8ea9115514e59de6d0223b59bd7761e0abb28c1ddcf33f","0xfdad5657593d5aa53e307ea3fa4ca0b4b583a4819c11237e774a797788769d6b","0x25235c1d1ca4a672b1b5cefbd5bb734b27c66588fd5b9d891f4b8168a4661508","0x35cbb692c9572a3f83652fc351c11fd47a4bf86a39a3b5c1f66eb9548786f40f","0x62bacaa70cb1fd2f33f82cd56d14f5d59acb484d95d472a8c9ef051ca64a3dc6","0x7e555c7adee354f7998152001f3acb422219bf668bf185437da21cd5a30afb64"];function $(){let e="0x";for(var n=0;n<64;n++)e+=t(16*p()).toString(16);if("undefined"!=typeof tokenData&&tokenData?.tokenId){let e=tokenData.tokenId.slice(-3),t=parseInt(e,10);if(void 0!==q[t])return q[t]}return new URLSearchParams(globalThis.location.search).get("hash")||("undefined"!=typeof tokenData&&tokenData?.hash?tokenData.hash:e)}_=$();let ee="\n vec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec2 mod289(vec2 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n }\n\n vec3 permute(vec3 x) {\n return mod289(((x * 34.0) + 10.0) * x);\n }\n\n // Noise\n float snoise2D(vec2 v) {\n const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);\n vec2 i = floor(v + dot(v, C.yy));\n vec2 x0 = v - i + dot(i, C.xx);\n\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n\n // Permutations\n i = mod289(i);\n vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));\n\n vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);\n m = m * m;\n m = m * m;\n\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n\n m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n }\n\n float fbm(const vec2 v, const int octaves, float frequency, float amplitude) {\n float total = 0.0;\n float maxAmplitude = 0.0;\n for(int i = 0; i < octaves; i++) {\n total += snoise2D(v * frequency) * amplitude;\n maxAmplitude += amplitude;\n frequency *= 2.0;\n amplitude *= 0.5;\n }\n return total / maxAmplitude;\n }\n\n",te="\n float screenEdgeDist(vec2 uv, const float falloff) {\n vec2 normalizedCoords = gl_FragCoord.xy / resolution;\n\n // Calculate distances to the nearest edges\n float distanceToLeftEdge = normalizedCoords.x;\n float distanceToRightEdge = 1.0 - normalizedCoords.x;\n float distanceToBottomEdge = normalizedCoords.y;\n float distanceToTopEdge = 1.0 - normalizedCoords.y;\n\n // Find the minimum distance to any edge\n float minDistanceToEdge = min(min(distanceToLeftEdge, distanceToRightEdge), min(distanceToBottomEdge, distanceToTopEdge));\n\n float scaledDistance = 1.0 - abs(2.0 * minDistanceToEdge - 1.0);\n\n // Apply customizable falloff\n float falloffEffect = pow(scaledDistance, falloff);\n\n return falloffEffect;\n }\n",ne="\n float randomNonDet(vec2 st) {\n return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123);\n }\n",ie="\n out vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }\n";const le=e.Vector2;let ae=!1,se={countX:1,countY:1,index:{x:0,y:0}},oe=(e=!1)=>{let t=e?P:Q,i=n((e?Y:B)/se.countX),l=n(t/se.countY);return{width:i,height:l,xOff:se.index.x*i,yOff:se.index.y*l,yOffFlippedY:(se.countY-1-se.index.y)*l}},re=t=>{let n=t.uniforms,{width:i,height:l,xOff:a,yOffFlippedY:s}=oe();n.uTileOffset.value=new e.Vector2(a,s),n.uTileSize.value=new e.Vector2(i,l)},ce=()=>(!ae&&(()=>{ae=!0;let e=new URL(window.location.href),t=e.searchParams.get("tileCount"),n=e.searchParams.get("index");if(t){let e=parseInt(t);se.countX=e,se.countY=e}if(n){let[e,t]=n.split(",").map((e=>parseInt(e)));se.index.x=o(e,se.countX-1),se.index.y=o(t,se.countY-1)}})(),{uTileOffset:{value:new e.Vector2(0,0)},uTileSize:{value:new e.Vector2(B,Q)}});var de=[{name:"Faces",bg:[[.7409,.0057,69.9871]],line:[[.12,0,68]],base:[[.7995,.0104,53.9144]],accent:[[.55,.092,133],[.37,.1,8],[.47,.124,28],[.7,.112,90],[.48,.088,247],[.59,.048,197],[.78,.012,56.581],[.12,0,68],[.52,.12,342],[.71,.068,44],[.44,.04,299],[.21,.004,329],[.7883,.0264,44]],commonPool:!0,solo:!1},{name:"Chalks",bg:[[.6919,.0323,69.9871]],line:[[.1285578041548887,4.7918630361524376e-9,null]],stroke:[[.9104718532196331,.02929501882422003,89.58052190776175]],base:[[.7968,.033,55.4365]],accent:[[.4391005470961144,.053143667197297274,179.45284673806202],[.7430751481851373,.0929,39.83760570859084],[.7703,.0895,64.56344067218811],[.6641410434441858,.15689118437280108,37.13690468980104],[.7559,.0178,222.564179724743]],disabled:!1,commonPool:!0,solo:!1},{name:"Beach",bg:[[.6835,.03883960001602766,67.25848906440592]],stroke:[[.9372288972261885,.020696467664658196,67.57155893750883]],line:[[.23356138751632896,.02729114952576314,246.90070685897228]],base:[[.8371,.0215,57.0279]],accent:[[.2774185198607467,.04318925551193144,167.75274001919718],[.42064998654759594,.03120177133138129,171.32246538045877],[.4311384415174281,.02336516751567073,241.2330314983908],[.6176019379584577,.1270253885540799,74.1805651416355],[.7260022319511451,.09724578337934522,55.06470317899317],[.7582608113288266,.02549172589125699,166.85185191796654],[.8204,.023,61.9891]],commonPool:!0,solo:!1},{name:"Morning Sun In A Dusty Room",bg:[[.25615282357231434,.011591200093299888,338.1519820725431]],line:[[.14287287327771095,.004143654188326715,345.4391631242127],[.8348,.02687,98.479]],stroke:[[.9136637420289497,.02687443532425364,80.24542314462997]],base:[[.7783871111844314,.042589978975680454,25.529877185969667]],accent:[[.2152,.011591200093299888,338.1519820725431],[.4974379254425503,.08269393625659356,333.938678657093],[.6377751669772775,.16624575588870555,29.858240404234152],[.7303722440997971,.14878423535567212,65.78690162717032],[.525648519572251,.044624199378743616,227.89564437801943],[.8348,.02687443532425364,98.4785]],commonPool:!0,solo:!1},{name:"Jazz",stroke:[[.2866006793419412,.021957785534446477,88.03909075711272]],bg:[[.7399,.0328,69.58004864146267]],base:[[.8051,.0372,74.6117]],line:[[.1285578041548887,4.7918630361524376e-9,null]],accent:[[.6315375414148215,.1752,34.478822707810366],[.5221231161993111,.109,231.97797627692054],[.7332,.1701,64.69716240181685],[.6904,.1463,32.65581391676761],[.8075,.0269,54.0471]],disabled:!1,commonPool:!0,solo:!1},{name:"Beige Box",bg:[[.2169,.004109954650405697,264.48855986171543]],line:[[.1921,.004109954650405697,264.48855986171543],[.7094,.004109954650405697,264.48855986171543]],base:[[.7044,.0027,264.3],[.2582,0,264.15]],stroke:[[.6451555150878627,.1324103074498338,351.3679204443482]],accent:[[.2944,0,264.1525],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.8436835998771347,.14145685075787068,96.14554462682747],[.71866,.13925,63.701],[.6861,.007,63.701]],commonPool:!0,solo:!1},{name:"Master",bg:[[.6936,.0211,82.40092539697929]],line:[[.2507780863015607,.009572580032197206,67.3680640985574]],base:[[.7269,.0162,157.61886984444504]],stroke:[[.9060102804608031,.012170144621286422,23.7150415636807]],accent:[[.6295566765037485,.1211519827044528,67.32018448430034],[.7605,.0195,238.616994352628],[.6174604546514465,.05042117055871639,256.5164449583005],[.4181072443550769,.072,173.90831954879036],[.6627,.1667,37.60803793025025],[.8234,.0071,74.2545],[.7783,.073,8.0298]],commonPool:!0,solo:!1},{name:"New York Autumn",bg:[[.7037,.0281,65.28937708039064]],stroke:[[.8626142182586253,.08537649420452362,82.03909126824601]],line:[[.19548782481388519,.00430705323020645,264.468763979492]],base:[[.7661,.0329,58.25082050504636]],accent:[[.45478156079252346,.039285338382841796,179.22836606186138],[.7553531036330657,.08130837219892006,99.24794847558877],[.5594780208031984,.07916054354499198,245.43994841186026],[.42899728927916636,.04922887943462986,76.52219098535193],[.8309661998821414,.04281039028933322,48.183040275461394],[.7850648916204185,.1273241170717795,79.558262732039],[.8022,.1082,91.79312487991842],[.5727044802833001,.1271825150640351,18.826326398068147],[.5371544884294275,.13634924860871195,21.160585432853736]],commonPool:!0,solo:!1},{name:"The Coast",bg:[[.6974,.0085,76.58691599832048]],stroke:[[.8444869430616695,.08523591444134622,87.01376484878972]],line:[[.22755957415683586,.0015428045966122382,17.270340681712298]],base:[[.7669770002469423,.0030391208463875215,84.56153889362372]],accent:[[.3779357986919375,.0535,176.4086979076003],[.6184542058002529,.0765,130.0878133972343],[.8444869430616695,.0863,87.01376484878972],[.8204404719119529,.0562,13.36293462743373],[.6466292227896673,.1007,248.2503623167608],[.6773,.0488,194.3393064675039],[.6163,.1335,21.160585432853736],[.7968000000000001,.01676,79.345]],commonPool:!0,solo:!1},{name:"Aged",bg:[[.7084,.0396,87.75614537114114]],stroke:[[.94095456060748,.015612821171329101,86.4264441546818]],line:[[.2703834919362128,.003498268640239951,48.59454667339406]],base:[[.7841,.021041287596747362,75.5028]],accent:[[.6599008372479219,.14410614712594896,43.767864491957255],[.5406041428443183,.0810794492722289,156.20612626175443],[.5030711080692698,.15264841257121137,26.608155858968416],[.7691417851736347,.1353050284474489,77.87710240074239],[.7874426063872318,.04659921665479499,51.68182155996902],[.467824859321765,.056096190272488924,217.56676918001241]],commonPool:!0,solo:!1},{name:"Ink & Colour",bg:[[.7601,.014,255.4795978283716]],stroke:[[.9553483843727791,.002877617626355211,84.55913178523588]],line:[[.23724829442832204,.009300030023333045,159.3038618360598]],base:[[.5326,.0294,169.58],[.5352,.1055,153.65],[.7482,.0675,265.537],[.5786,.1009,265.537]],accent:[[.3475,.065,169.58],[.4333,.08067410261737115,292.88016945552295],[.8007868908561364,.0333,7.942656494991638],[.6086666969575215,.1634,28.003190670134757],[.3195,.034575073883449464,254.02069392111645],[.6738,.1201,79.6718],[.8711,.00292,264.54],[.6613,.0632,169.58],[.5352,.1055,153.6549],[.6531,.1061,265.54]],disabled:!1,commonPool:!0,solo:!1},{name:"Oranges",bg:[[.705,.0354,65.1718]],stroke:[[.9912189562526743,.006931254927170287,88.6413010074412]],base:[[.7842,.0305,86.3684]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],accent:[[.35508002090426666,.043787467826530785,211.52484726500788],[.5510005837793092,.08755866639046411,103.27386758796968],[.691,.1582,47.266522185041936],[.7373,.1324,67.62887023877073],[.7999,.0316,88.72052641225343],[.7631,.0647,19.8072]],commonPool:!0,solo:!1},{name:"Henri",bg:[[.7213,.0319,80.6824944352112]],stroke:[[.7121124312829297,.09603422725607345,34.15613531599104]],line:[[.24303319779115856,.004923290798673418,355.16568727574077]],base:[[.8256,.0305,76.17859369988122]],accent:[[.4159,.0591,191.39940656052516],[.7920378039704564,.1352,73.45878915862028],[.7593,.0165,220.7288245953125],[.4637,.0738,237.7123227684075]],disabled:!1,commonPool:!0,solo:!1},{name:"Rand-ey",bg:[[.7426,.0171,87.52315695161104]],line:[[.19419793765469762,.0219,297.0814230776026]],stroke:[[.9076072420048279,.019870599528847212,87.51855970858247]],base:[[.595,.0433,247.9],[.7126,.0966,68.946],[.7791,0,64.059],[.5968,.1097,151.59]],accent:[[.575943267748716,.1486,29.4685],[.5129975835116938,.0741,305.527422000483],[.7538026010313094,.139,68.94572099685297],[.6147,.1332,247.9],[.8423,0,64.0592],[.53766,.1084,167.07]],disabled:!0,commonPool:!0,solo:!1},{name:"Olivetti",bg:[[.2222,.004109954650405697,264.48855986171543]],line:[[.234784254171478,.004109954650405697,264.48855986171543]],stroke:[[.7186588335782654,.1392507657144271,63.7012930132442]],base:[[.2551,0,34.30274488067005]],accent:[[.7186588335782654,.1392507657144271,63.7012930132442],[.6471384357175027,.0950806296946004,146.09535186981566],[.6248985136009452,.08343861458985488,258.09336743754636],[.6419604611344321,.1604756929950665,39.9727943299859],[.6451555150878627,.1324103074498338,351.3679204443482],[.8373623117765204,.15785248852128372,95.6270196002983],[.2582,.0037,275.8924],[.5803,.0037,275.8924]],disabled:!0,commonPool:!0,solo:!1},{name:"Toddler",bg:[[.7421,.0212,48.4352]],line:[[.18797280274608968,.026745997001574016,159.25756384014687]],stroke:[[.18797280274608968,.026745997001574016,159.25756384014687]],base:[[.6859848282821445,.008266766434931419,61.396302349703944],[.9349265127013049,.01153735356888476,84.57925253447382],[.7688,.0216,61.396302349703944]],accent:[[.3500879126177943,.0865,264.1433132212142],[.4453610930960556,.02928835497819446,336.8043193096847],[.569281111283594,.1860449489679648,25.02687693308303],[.5558543866168449,.054963958871380815,108.06205545681729],[.7052281079548163,.16337391917830385,43.93536507302679],[.8036,.1343,80.58696151433355],[.6763,.0745,108.06205545681729],[.7615,.0782,25.02687693308303]],disabled:!1,commonPool:!0,solo:!1}];let ue=(de.some((e=>e.solo))?de.filter((e=>e.solo)):de.filter((e=>!e.disabled))).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent}))),he=de.filter((e=>e.commonPool)).map((e=>({name:e.name,disabled:e.disabled,commonPool:e.commonPool,base:e.base,bg:e.bg,line:e.line,accent:e.accent})));function me(e){return e*g/180}function pe(e){return function(e){return null!==e&&"object"==typeof e}(e)&&!Array.isArray(e)}function ge(...e){const t={};for(const n of e)if(n)for(const e of Object.keys(n)){const i=n[e];if(Array.isArray(i))t[e]=[...i];else if(pe(i)){const n=t[e];pe(n)?t[e]=ge(n,i):t[e]=ge({},i)}else t[e]=i}return t}var be,fe,xe;!function(e){e[e.horizontal=0]="horizontal",e[e.vertical=1]="vertical",e[e.perspective=2]="perspective",e[e.circle=3]="circle",e[e.wobbles=4]="wobbles",e[e.curves=5]="curves",e[e.rects=6]="rects",e[e.borderRect=7]="borderRect",e[e.triangle=8]="triangle",e[e.objects=9]="objects",e[e.used=10]="used"}(be||(be={})),function(e){e[e.front=0]="front",e[e.up=1]="up",e[e.right=2]="right",e[e.down=3]="down",e[e.left=4]="left"}(fe||(fe={})),function(e){e.border="border",e.scene="scene",e.none="none"}(xe||(xe={}));let Ze={layers:2,layerScaleMult:2.5,zDepthMaxMult:1,cropTo:xe.none,forceYUp:!0,clampVertsToGrid:!0,maxDist:200,minDist:130,bnFreq:500,fieldFreq:1500,clampRotationTo:1,minSizeMult:1,maxSizeMult:.75,maxSides:5,minSides:3,perspective:2e4};var ye,Ge;!function(e){e[e.color=0]="color",e[e.line=1]="line",e[e.palettecomplement=2]="palettecomplement",e[e.previous=3]="previous",e[e.base=4]="base",e[e.paletteOffset=5]="paletteOffset",e[e.shadow=6]="shadow",e[e.highlight=7]="highlight",e[e.randomAccent=8]="randomAccent",e[e.offset=9]="offset",e[e.offsetUp=10]="offsetUp",e[e.lightestOrDarkestBasedOnBg=11]="lightestOrDarkestBasedOnBg",e[e.brightnessBasedShadowOrHighlight=12]="brightnessBasedShadowOrHighlight",e[e.offsetDown=13]="offsetDown",e[e.darkest=14]="darkest",e[e.lightest=15]="lightest"}(ye||(ye={})),function(e){e.override="override",e.dominant="dominant",e.inCurveOrObject="inCurveOrObject",e.notInCurveOrObject="notInCurveOrObject",e.nonDominant="nonDominant",e.normalHigh="normalHigh",e.normalLow="normalLow",e.overlay="overlay",e.noop="noop"}(Ge||(Ge={}));let We,ve,Le={scribbleChance:0,edgeSharpness:{min:.2,max:.2},scribbleStrength:{min:.5,max:.5},accumulationStrength:{min:1,max:1},materialHardness:{min:1,max:1},fillChance:100,fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},minDistanceMult:{min:5,max:5},linePressure:{min:.8,max:.9},brightnessHighLowThreshold:.75,fadeAtLineSegmentChance:0,detailMinScaleDivisor:30,ignoreLightingChance:0,colorMap:[[[1,ye.color]],[[1,ye.color]]],dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:.5,max:1},wobbleFreq:{min:.5,max:1},layerCountChances:[[0,0],[1,1],[2,2]],styleChances:[[3,"noise"],[4,"directional"],[1,"wobbles"],[3,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},lineWeight:{min:1.1,max:1.1},spatialOverride:{[Ge.overlay]:{fillChance:0}}},Se={scribbleChance:0,edgeSharpness:{min:.5,max:.5},scribbleStrength:{min:.3,max:.3},fillChance:100,accumulationStrength:{min:1,max:1},fadeAtLineSegmentDistanceMult:{min:.5,max:1.5},fadeAtLineSegmentStrengthMult:{min:1,max:1},colorMap:[[[1,ye.color]]],fadeAtLineSegmentChance:100,brightnessHighLowThreshold:.75,ignoreLightingChance:0,detailMinScaleDivisor:30,minDistanceMult:{min:.75,max:.75},dominantMeshWeight:100,insetChance:0,insetDistance:{min:2,max:4},wobbleAmplitude:{min:2,max:3},wobbleFreq:{min:20,max:40},layerCountChances:[[1,1]],styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},linePressure:{min:1,max:1},materialHardness:{min:1,max:1},lineWeight:{min:1.1,max:1.1},spatialOverride:{[Ge.overlay]:{fillChance:100,lineWeight:{min:2.5,max:2.5},fadeAtLineSegmentChance:0,insetChance:0,ignoreLightingChance:100,styleChances:[[1,"noise"],[0,"directional"],[0,"wobbles"],[0,"bluenoise"]],minDistanceMult:{min:.75,max:.75},lineTapering:{scale:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:1,max:1}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},layerCountChances:[[1,2]]}}},Xe={[be.horizontal]:0,[be.vertical]:10,[be.perspective]:0,[be.circle]:10,[be.wobbles]:0,[be.objects]:8,[be.curves]:10,[be.rects]:5,[be.borderRect]:10},Ce=[be.horizontal,be.vertical,be.perspective],Ve={count:1,outline:!0,colors:[[0,ye.color],[0,ye.offset],[0,ye.base],[0,ye.line],[0,ye.darkest],[1,ye.lightest]],colorOffsets:!1,size:{min:4,max:9}},we=[],Ke={default:1,min:.45,max:1.12,clamp:.001,influencesPressureMult:0,influencesBrightnessMult:1,influencesMinDistanceMult:.3,position:{x:-10005.5,y:-1e4,z:-12e3}},Re={colors:!1,isLineColor:!1,count:50,warpChance:100,lineTapering:{scale:{in:{enabledChance:100,min:.5,max:.8},out:{enabledChance:100,min:.5,max:.8}},fade:{in:{enabledChance:0,min:.5,max:.8},out:{enabledChance:0,min:.5,max:.8}}},length:{min:20,max:100},hardness:{min:1,max:1},thickness:{min:.5,max:5}},ke=Ze,Te={forceInsertCurvesChance:0,forceInsertObjectsChance:0},Me={meshDensity:80,lineFilter:"none",meshInsetMuliplier:1,dominantLineInsetMultiplier:1,percentage:50,skipLongest:3,cropToDominantShape:!1,materialHardness:{min:.9,max:.95},colors:!1,backgroundColor:!1,lineTapering:{scale:{in:{enabledChance:100,min:.3,max:.6},out:{enabledChance:100,min:.3,max:.6}},fade:{in:{enabledChance:50,min:.1,max:.2},out:{enabledChance:50,min:.1,max:.2}}},linePressure:{min:.9,max:.95},thickness:{min:.5,max:3}},ze={countX:0,countY:0,marginX:0,marginY:0,w:0,h:0,scale:0},Ye=Le,Pe=Se,Ie={enabled:!0,percentage:60,materialHardness:{min:.4,max:.4},lineTapering:{scale:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}},fade:{in:{enabledChance:100,min:.01,max:.1},out:{enabledChance:100,min:.01,max:.1}}},linePressure:{min:.5,max:.5},lineWeight:{min:.6,max:.6}},He={margin:0,HVariance:{min:0,max:10,threshold:2,mean:1,s
Materialistic is a generative series of 92 works exploring surface, texture, and the boundaries of digital materiality. The project draws a parallel between Cubism and early computer graphics, as both use simplified forms and structured systems to reinterpret reality. Deconstruction and reconstruction are at the core of this project. Each composition begins with precise construction lines and multiple viewpoints, then is reassembled algorithmically into geometric structures and fragmented planes. The interplay of movement, surface, and texture is directly created through the code. This contract represents the 12 artist curated edition mints from the release. The associated physicals can be claimed via The Disruptive Gallery.
Materialistic is a generative series of 92 works exploring surface, texture, and the boundaries of digital materiality. The project draws a parallel between Cubism and early computer graphics, as both use simplified forms and structured systems to reinterpret reality. Deconstruction and reconstruction are at the core of this project. Each composition begins with precise construction lines and multiple viewpoints, then is reassembled algorithmically into geometric structures and fragmented planes. The interplay of movement, surface, and texture is directly created through the code. This contract represents the 80 long-form digital edition mints from the release.
0),o),Oo(r))};r()},tr=()=>{if(Io)return;Po(0,"Drawing");let e=()=>{const t=Fo();let o=!1;for(;!o&&Fo()-t<50;)o=Zo();o?or():(Po(s($o/qo.length*100),"Drawing"),Oo(e))};e()};document.complete=!1;Fo();const or=()=>{document.body.removeChild(document.getElementById("loading")),document.complete=!0,Fo()};var rr;((t=2150)=>{const{innerWidth:o,innerHeight:r}=window;Eo=document.createElement("canvas"),Eo.style.backgroundColor="#000",Wo=Eo.style,Ro=Eo.getContext("webgl2",{antialias:!1,depth:!1,preserveDrawingBuffer:!0,premultipliedAlpha:!1,alpha:!1}),Ro||Mo("🚨 No WebGL2 support detected 🚨"),"drawingBufferColorSpace"in Ro?Ro.drawingBufferColorSpace="display-p3":Mo("🚨 No P3 Colour support detected 🚨"),Ro.enable(Ro.BLEND),Ro.blendFunc(Ro.SRC_ALPHA,Ro.ONE_MINUS_SRC_ALPHA),Ro.clearColor(1,1,1,1),Ro.clear(Ro.COLOR_BUFFER_BIT),document.body.appendChild(Eo),Vo=e(t*zo),No=e(t),o<r*zo?(Go=e(1.5*o),To=e(o)):(Go=e(r-0),To=e((r-0)*zo)),Eo.width=e(To*Uo),Eo.height=e(Go*Uo),Wo.width=To+"px",Wo.height=Go+"px"})(),S=new C(rr||D),(()=>{let e=document.createElement("a");addEventListener("keydown",(t=>{if("s"===t.key){e.setAttribute("download",`${D}.png`);let t=Eo.toDataURL("image/png").replace(/^data:image\/png/,"data:application/octet-stream");e.setAttribute("href",t),e.click()}}))})(),(()=>{je=S.dec();for(let e=0;e<500;e++)dt.push(S.dec());$e=S.choice(x);let e=S.weightedChoice([3,yo],[4,xo],[5,Co],[5,wo]);Je.h=S.num(.9,1),Je.s=S.num(.9,1);for(let e of Object.keys(co)){const t=co[e]>0;"bg"!=e&&"front"!=e&&(co[e]=t?co[e]+.03:co[e]-.015)}It=Vo/8,e(),"upLeft"==qe&&ho(),Ht=$e.suitability==p.generative||S.bool(50),$t[Ve.base]=So(),$t[Ve.alt]=10==$t[Ve.base]&&S.bool(50)?10:So(),go=S.int(1,3),lo&&(pt=.1,gt=0,ao||(co={up:0,down:0,left:0,right:0,upLeft:0,upRight:0,downLeft:0,downRight:0,front:0,bg:0})),Dt||(Ke=Ke.filter((([e,t])=>!(t%1))))})(),Oo&&Oo((()=>{Bo(),er()}));
1:0),A("lineColor","3f",b),A("highlightColor","3f",Pe($e.stroke[0])),A("gridWidth","1f",y),A("gridMarginX","1f",C),A("gridMarginY","1f",D),A("randomValues","1fv",this.randomValues),A("randomValuesLength","1i",this.randomValues.length),A("randomSeed","1f",v),A("drawGrid","1i",po?1:0),A("gridLineWeight","1f",vo),A("drawGridDivisions","1i",go),A("shadingStrength","1f",p),A("waveNoiseMapEnabled","1i",Mt?1:0),A("waveWarpX","1i",Ot?1:0),A("waveWarpY","1i",Ft?1:0),A("waveOffAxisY","1i",Vt?1:0),A("waveOffAxisX","1i",Nt?1:0),A("waveWarpXMult","1f",zt),A("waveWarpYMult","1f",Ut),A("waveWarpDivisor","1f",Tt),A("uvSpiralMap","1fv",Ho)),A("paletteSwapWarpEnabled","1i",Jt?1:0),A("paletteSwapWarpScale","1f",Kt),A("paletteSwapArmWidth","1f",Qt),A("paletteSwapNoiseOffset","1f",Zt),A("paletteSwapInverted","1i",0),A("warpLayer","1i",f?1:0),A("uvWarpScale","1f",Bt),A("uvWarpStrength","1f",Pt),A("uvGlitchEnabled","1i",0),A("uvSpiralizeEnabled","1i",Et?1:0),A("uvSpiralizeStrength","1f",Rt),A("uvSpiralizeNoiseMapEnabled","1i",1),A("uvSpiralizeScale","1f",Wt),A("drawFaces","1i",c?1:0),A("drawOutlines","1i",h?1:0),A("strokeBorder","1i",m?1:0),A("gridBleedThrough","1i",l?1:0),A("depthInScene","1f",s),A("detailSwitch","1i",u),A("detailArray","1iv",d),A("isBackground","1i",g?1:0),A("paletteAccentArray","3fv",r.flat()),A("paletteAccentArrayLength","1i",r.length),A("altPaletteAccentArray","3fv",n.flat()),A("altPaletteAccentArrayLength","1i",n.length);const k=o.reduce(((e,t)=>e+t.length),0),L=new Float32Array(2*k),B=new Uint32Array(2*o.length),P=o.length;let E=0,W=0;for(let t of o){let o=t.flat();L.set(o,E),B.set([e(E/2),e(o.length/2)],W),W+=2,E+=o.length}if(A("polyVertices","2fv",L),A("polyIndices","2uiv",B),A("numPolygons","1i",P),S.drawArrays(S.TRIANGLE_FAN,0,4),this.renderCount%10==0){const e=new Uint8Array(4);S.readPixels(0,0,1,1,S.RGBA,S.UNSIGNED_BYTE,e)}this.renderCount++}}let jo,qo=[],Ho=[],$o=0,{parse:Jo,stringify:Ko}=JSON,Qo=e=>Jo(Ko(e));const Zo=()=>{let e=qo[$o];if(!e)return!0;let t=!1;if(st||vt>0){let o=!1;e:for(let r of e)if("bg"!==r.label){if(st)for(let e of r.poly){const[o,r]=e;let n=ke(ft),i=R(X(o/ft,r/ft,0),n.min,n.max,-Xe*ut,Xe*ut);if(o<ct-tt+i||o>Vo-ct+tt+i||r<0+ct-ot+i||r>No-ct+ot+i||o<ct-tt||o>Vo-ct+tt||r<0+ct-ot||r>No-ct+ot){t=!0;break e}}}else o=!0;t||o||(t=S.bool(vt))}if(0===e.length||t)return $o++,!1;let o=S.bool(ht);const r=j(e.map((e=>e.poly)).flat()),n=S.bool(to)?r:null;let{palette:i,isBackground:s}=Te(e,Ve.base,n),{palette:f,isBackground:c}=Te(e,Ve.alt,n),u=s||c;const d=e.map((e=>e.poly)).map((e=>e.map((e=>[e[0],No-e[1]])))).map((e=>e.map((e=>[E(e[0],1),E(e[1],1)])))),h=function(e,t=0){if(0===e.length)throw new Error("Polygons array cannot be empty.");let o=1/0,r=1/0,n=-1/0,i=-1/0;for(const t of e)for(const[e,s]of t)o=l(o,e),r=l(r,s),n=a(n,e),i=a(i,s);return[[o-t,r-t],[n+t,r-t],[n+t,i+t],[o-t,i+t]]}(d,3*rt);let p=Lt&&$o%1==0;u&&(p=!1);let g=e.map((e=>e.detail));return jo.render({polygons:d,isBackground:u,backgroundColor:We[Ve.base].bg[0],gridBleedThrough:S.bool(mo),shadingStrength:pt,lineColor:We[Ve.base].line[0],paletteByIdx:i,paletteByIdx2:f,outerPolygon:h,details:g,depthInScene:$o/qo.length,warpLayer:p,drawFaces:!0,drawOutlines:o,strokeBorder:at,lineThickness:jt,lineContrast:qt}),$o++,!1},er=()=>{if(Io)return;const t=function*(){jo=new _o(Ro,"#version 300 es\nprecision highp float;precision highp int;\n#define GLSLIFY 1\nin vec2 a_position;uniform vec2 resolution;uniform vec2 scaledResolution;void main(){vec2 rescaledPosition=a_position*(resolution/scaledResolution);vec2 clipSpacePosition=rescaledPosition/(resolution/2.0)-1.0;gl_Position=vec4(clipSpacePosition,.0,1.0);}","#version 300 es\nprecision highp float;precision highp int;\n#define GLSLIFY 1\nuniform vec3 highlightColor;uniform vec3 backgroundColor;uniform vec3 paletteAccentArray[50];uniform int paletteAccentArrayLength;uniform int desaturate;uniform float margin;uniform int numPolygons;uniform vec2 polyVertices[128];uniform uvec2 polyIndices[128];uniform float gridWidth;uniform float gridMarginX;uniform float gridMarginY;uniform int drawGrid;uniform float gridLineWeight;uniform int drawGridDivisions;uniform int gridBleedThrough;uniform int detailArray[50];uniform int warpLayer;uniform float uvWarpScale;uniform float uvWarpStrength;uniform int waveNoiseMapEnabled;uniform int waveWarpX;uniform int waveWarpY;uniform int waveOffAxisY;uniform int waveOffAxisX;uniform float waveWarpXMult;uniform float waveWarpYMult;uniform float waveWarpDivisor;uniform int uvSpiralizeEnabled;uniform int uvSpiralizeNoiseMapEnabled;uniform float uvSpiralizeStrength;uniform float uvSpiralizeScale;uniform float uvSpiralMap[256];uniform int paletteSwapWarpEnabled;uniform int paletteSwapInverted;uniform float paletteSwapWarpScale;uniform float paletteSwapNoiseOffset;uniform float paletteSwapArmWidth;uniform int isBackground;uniform int drawOutlines;uniform int strokeBorder;uniform float shadingStrength;uniform float lineContrast;uniform float lineThickness;uniform vec3 lineColor;uniform float randomValues[256];uniform vec2 resolution;uniform vec2 scaledResolution;uniform vec3 altPaletteAccentArray[50];uniform int altPaletteAccentArrayLength;out vec4 outColor;const float pixelAA=1.5f;vec3 mod289(vec3 x){return x-floor(x*(1.0f/289.0f))*289.0f;}vec2 mod289(vec2 x){return x-floor(x*(1.0f/289.0f))*289.0f;}vec3 permute(vec3 x){return mod289(((x*34.0f)+10.0f)*x);}float snoise2D(vec2 v){const vec4 C=vec4(0.211324865405187f,0.366025403784439f,-0.577350269189626f,0.024390243902439f);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0f,0.0f): vec2(0.0f,1.0f);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0f,i1.y,1.0f))+i.x+vec3(0.0f,i1.x,1.0f));vec3 m=max(0.5f-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0f);m=m*m;m=m*m;vec3 x=2.0f*fract(p*C.www)-1.0f;vec3 h=abs(x)-0.5f;vec3 ox=floor(x+0.5f);vec3 a0=x-ox;m*=1.79284291400159f-0.85373472095314f*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0f*dot(m,g);}const float PI=acos(-1.f);float remap(float t,float a1,float b1,float a2,float b2){return a2+(b2-a2)*((t-a1)/(b1-a1));}float aastep(float threshold,float value){float afwidth=length(vec2(dFdx(value),dFdy(value)))*0.70710678118654757f;return smoothstep(threshold-afwidth,threshold+afwidth,value);}float hue2rgb(float p,float q,float t){if(t<0.0f)t+=1.0f;if(t>1.0f)t-=1.0f;if(t<1.0f/6.0f)return p+(q-p)*6.0f*t;if(t<1.0f/2.0f)return q;if(t<2.0f/3.0f)return p+(q-p)*(2.0f/3.0f-t)*6.0f;return p;}vec3 rgb2hsl(vec3 color){float fmin=min(min(color.r,color.g),color.b);float fmax=max(max(color.r,color.g),color.b);float delta=fmax-fmin;vec3 hsl;hsl.z=(fmax+fmin)/2.0f;if(delta==0.0f){hsl.x=0.0f;hsl.y=0.0f;}else{hsl.y=hsl.z>0.5f ? delta/(2.0f-fmax-fmin): delta/(fmax+fmin);float deltaR=(((fmax-color.r)/6.0f)+(delta/2.0f))/delta;float deltaG=(((fmax-color.g)/6.0f)+(delta/2.0f))/delta;float deltaB=(((fmax-color.b)/6.0f)+(delta/2.0f))/delta;if(color.r==fmax)hsl.x=deltaB-deltaG;else if(color.g==fmax)hsl.x=(1.0f/3.0f)+deltaR-deltaB;else if(color.b==fmax)hsl.x=(2.0f/3.0f)+deltaG-deltaR;if(hsl.x<0.0f)hsl.x+=1.0f;if(hsl.x>1.0f)hsl.x-=1.0f;}return hsl;}vec3 hsl2rgb(vec3 hsl){if(hsl.y==0.0f){return vec3(hsl.z);}else{float q=hsl.z<0.5f ? hsl.z*(1.0f+hsl.y): hsl.z+hsl.y-hsl.z*hsl.y;float p=2.0f*hsl.z-q;return vec3(hue2rgb(p,q,hsl.x+1.0f/3.0f),hue2rgb(p,q,hsl.x),hue2rgb(p,q,hsl.x-1.0f/3.0f));}}float fbm(vec2 v,int octaves,float frequency,float amplitude){float total=0.0f;float maxAmplitude=0.0f;for(int i=0;i<octaves;i++){total+=snoise2D(v*frequency)*amplitude;maxAmplitude+=amplitude;frequency*=2.0f;amplitude*=0.5f;}return total/maxAmplitude;}float pointLineSegSDF(vec2 p,vec2 a,vec2 b){vec2 pa=p-a;vec2 ba=b-a;float t=clamp(dot(pa,ba)/dot(ba,ba),0.0f,1.0f);return length(pa-ba*t);}bool isIntersecting(vec2 point,vec2 p1,vec2 p2){if(p1.y==p2.y){return false;}if(p1.y>point.y&&p2.y>point.y){return false;}if(p1.y<point.y&&p2.y<point.y){return false;}float intersectionX=p1.x+(point.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y);return intersectionX>point.x;}vec3 drawGridLines(vec2 uv,vec3 color,float gridDivisions,float brightness,vec3 lineBaseColor,bool bleedThrough){if(drawGrid==0)return color;brightness=1.05f-brightness;vec2 bounds=scaledResolution;float intensity=(bleedThrough||isBackground==1)? 0.28f : 0.42f;vec2 pos=uv-vec2(gridMarginX,gridMarginY)+gridLineWeight;float lineWeightNoise=snoise2D((pos+randomValues[10])/50.f)*.07f;float motionNoise=snoise2D((pos+randomValues[12])/9e1f)*.3f;pos+=motionNoise;float opacityNoise=clamp(snoise2D((pos+randomValues[13]))*0.25f,-1.f,0.1f);float offsetNoise=snoise2D((pos+randomValues[11])/20.f)*.1f;pos+=(offsetNoise);float borderDist=min(min(uv.x,bounds.x-uv.x),min(uv.y,bounds.y-uv.y));float lineDist=min(mod(pos.x,gridWidth/gridDivisions),mod(pos.y,gridWidth/gridDivisions));float lineWeight=gridLineWeight-lineWeightNoise;float borderWarp=(snoise2D((pos+randomValues[15])/50.f)-1.f)*40.f;float edgeFactor=smoothstep(30.f-borderWarp,10.f,borderDist);float colorLerp=remap(edgeFactor,0.f,1.f,clamp(0.6f+lineWeightNoise-opacityNoise+intensity+brightness,0.f,1.f),1.f);vec3 lineColor=mix(hsl2rgb(lineBaseColor),hsl2rgb((color)),colorLerp);float lineFactor=aastep(lineWeight*2.f,lineDist);return rgb2hsl(mix(lineColor,hsl2rgb(color),lineFactor));}vec2 pinchUV(vec2 uv){vec2 center=vec2(scaledResolution.x/2.f,scaledResolution.y/2.f);vec2 toCenter=center-uv;float distance=length(toCenter);float influence=remap(pow(distance,1.35f),0.f,scaledResolution.y/2.f,0.001f,.0f);return uv-(toCenter*influence);}vec2 lightBend(vec2 uv){if(isBackground==1)return uv;vec2 warpOffset=vec2(remap(randomValues[18],0.f,1.f,-1e3f,1e3f),remap(randomValues[19],0.f,1.f,-1e3f,1e3f));vec2 warpOffset2=vec2(remap(randomValues[20],0.f,1.f,-1e1f,1e1f),remap(randomValues[21],0.f,1.f,-1e1f,1e1f));vec2 pos=((uv+warpOffset)/1e4f);float direction=snoise2D((pos*4.f)+warpOffset2)*(2.f*PI);vec2 vector=vec2(cos(direction),sin(direction));float warpAmount=randomValues[22]*2.f;pos+=(vector*warpAmount);uv+=pos;return uv;}vec2 warpUvSimple(vec2 uv){float warpStrength=8e1f*uvWarpStrength;vec2 warpSpread=vec2(1.f)*uvWarpScale;vec2 warpOffset=vec2(remap(randomValues[1],0.f,1.f,-2e3f,2e3f),remap(randomValues[2],0.f,1.f,-2e3f,2e3f));float noiseMask=snoise2D((uv/warpSpread+warpOffset)/2.6e2f)+0.2f;float noiseMask2=snoise2D((uv/warpSpread+warpOffset)/6.5e2f);float noiseWarped=snoise2D(vec2(uv.x/3e1f*noiseMask2,uv.y/12e2f*noiseMask));float noiseWarped2=snoise2D(vec2(uv.x/3e2f*noiseMask2,uv.y/12e2f*noiseMask));noiseMask=clamp(noiseMask,0.f,1e10f);float result=((noiseWarped*1.f)*(noiseWarped2*1.f))*noiseMask;uv+=result*warpStrength;return uv;}vec2 warpChoice(vec2 uv){if(isBackground!=1){uv+=(fbm(uv,2,.004f,1.f)*2.f);}if(warpLayer==0)return uv;return warpUvSimple(uv);}vec2 rotateUvs(vec2 uv,vec2 lensCenter,float lensRadius,float magnification,float rotation){if(isBackground==1)return uv;vec2 translated=uv-lensCenter;float dist=length(translated);float normalizedDist=dist/lensRadius;if(normalizedDist>1.f)return uv;float angle=rotation*pow((1.f-normalizedDist),3.f);mat2 rot=mat2(cos(angle),-sin(angle),sin(angle),cos(angle));vec2 rotatedTranslated=(rot*translated)+lensCenter;return rotatedTranslated;}float getColourPaletteSwapWarp(vec2 uv){if(paletteSwapWarpEnabled==0)return 0.f;float warpOffset=remap(randomValues[10],0.f,1.f,-1e4f,1e4f);float noiseOffset=paletteSwapNoiseOffset*1e2f;float noiseMult=snoise2D((uv+warpOffset)/6e1f*paletteSwapWarpScale);float noiseMult2=snoise2D((uv+warpOffset)/(6e1f+noiseOffset)*paletteSwapWarpScale);float warpOffsetNoise=noiseMult*noiseMult2;warpOffsetNoise=smoothstep(0.f,paletteSwapArmWidth,warpOffsetNoise);float result=aastep(0.01f,warpOffsetNoise);if(paletteSwapInverted==1){return result;}else{return 1.f-result;}}vec3 noisePass(vec2 uv,vec3 color,float influence,int index){uv=uv+remap(randomValues[10+index],0.f,1.f,1.f,1e6f);float noiseMask=smoothstep(0.f,0.3f,fbm(uv,3,.01f,1.0f));float noiseMaskLarge=smoothstep(0.f,0.1f,fbm(uv,7,.04f,1.0f));float bigMask=noiseMask*noiseMaskLarge;float genericNoiseDivisor=4.f;float lumDarkDivisor=isBackground==1 ? 40.f : 35.f;float lumLightDivisor=isBackground==1 ? 30.f : 20.f;float subtleLuminanceWarpDark=fbm(uv,10,0.004f,.01f)/lumDarkDivisor;float subtleLuminanceWarpLight=fbm(uv,12,0.003f,.01f)/lumLightDivisor;float detailedLuminanceWarpDark=(fbm(uv,5,0.01f,.00001f)*bigMask)/20.f;float detailedLuminanceWarpLight=(fbm(uv,8,0.02f,.00001f)*bigMask)/25.f;float noisierValueLight=aastep(0.4f,fbm(uv,4,0.28f,1.0f))/11.f;float noisierValueDark=aastep(0.4f,fbm(uv,4,0.24f,1.0f))/15.f;float genericNoiseLight=aastep(0.6f,fbm(uv,6,0.35f,1.0f))/genericNoiseDivisor;float genericNoiseDark=aastep(0.6f,fbm(uv,12,0.33f,1.0f))/(genericNoiseDivisor*2.f);float luminanceShift=-subtleLuminanceWarpDark;luminanceShift-=subtleLuminanceWarpLight;luminanceShift-=detailedLuminanceWarpDark;luminanceShift+=detailedLuminanceWarpLight;luminanceShift+=noisierValueLight;luminanceShift-=noisierValueDark;luminanceShift+=genericNoiseLight;luminanceShift-=genericNoiseDark;float saturationShift=(subtleLuminanceWarpDark/2.f);vec3 outColor=vec3(color.x,color.y+saturationShift,color.z+luminanceShift);vec3 noisyBackground=vec3(backgroundColor.x,backgroundColor.y+saturationShift,backgroundColor.z+luminanceShift);float nastyMarksMoiseMask=smoothstep(0.4f,0.41f,fbm(uv,20,.005f*noiseMask,.0001f));float nastyMarks=aastep(-0.54f,fbm(uv*nastyMarksMoiseMask,12,.04f,0.001f)*nastyMarksMoiseMask);outColor=rgb2hsl(mix(hsl2rgb(noisyBackground),hsl2rgb(outColor),clamp(nastyMarks,0.8f,1.f)));return outColor;}vec3 addMarksAndScratches(vec2 uv,vec3 color,int offset){float warpOffset=remap(randomValues[offset+26],0.f,1.f,0.1f,0.15f);float warpSpread=remap(randomValues[offset+1],0.f,1.f,20.f,30.f);vec3 warpColor=highlightColor;vec2 warpOffsetOffsets=vec2(remap(randomValues[offset+24],0.f,1.f,-1e2f,1e2f),remap(randomValues[offset+28],0.f,1.f,-1e2f,1e2f));float warpSlide=-2.7f;float spreadInfluce=remap(randomValues[offset+27],0.f,1.f,40.f,50.f);float warpOffsetNoiseInfluence=snoise2D((uv+warpOffsetOffsets)/warpSpread/spreadInfluce)-warpSlide;vec2 uvOffset=(uv*warpOffsetNoiseInfluence);float warpOffsetNoise=snoise2D((uvOffset+remap(randomValues[offset+25],0.f,1.f,-1e2f,1e2f))/warpSpread)-warpOffset-(warpSlide/2.f);vec3 colorLerp=mix(hsl2rgb(warpColor),hsl2rgb(color),0.1f);return rgb2hsl(mix(colorLerp,hsl2rgb(color),aastep(.025f,warpOffsetNoise)));}vec2 waveUv(vec2 uv){if(isBackground==1){return uv;}float lookupRemap=remap(randomValues[10],0.f,1.f,-1e3f,1e3f);float influence=clamp(snoise2D((uv+lookupRemap)/1e3f),0.f,1.f);if(waveNoiseMapEnabled==0)influence=.9f+(influence/10.f);float strength=(gridWidth/(waveWarpDivisor*PI)-2.f)*influence;float sinX=sin(waveWarpXMult*PI*((uv.x-gridMarginX)/gridWidth))*strength;float sinY=sin(waveWarpYMult*PI*((uv.y-gridMarginY)/gridWidth))*strength;vec2 result=vec2(uv);if(waveWarpX==1)result.x=uv.x+sinX;if(waveWarpY==1)result.y=uv.y+sinY;if(waveOffAxisY==1)result.y=uv.y+sinX;if(waveOffAxisX==1)result.x=uv.x+sinY;return result;}vec2 spiralizeUV(vec2 uv){if(uvSpiralizeEnabled==0){return uv;}int count=0;bool useMap=uvSpiralizeNoiseMapEnabled==1;for(float x=gridWidth/2.f;x<scaledResolution.x;x+=gridWidth*4.f){for(float y=gridWidth/2.f;y<scaledResolution.y;y+=gridWidth*4.f){vec2 pos=vec2(x+gridMarginX+(gridWidth/2.f),y+gridMarginY+(gridWidth/2.f));float lookup=useMap ? uvSpiralMap[count]: randomValues[count];if(lookup>0.625f){float radius=remap(randomValues[count+2],0.f,1.f,gridWidth*2.f,gridWidth*6.f)*uvSpiralizeScale;float strength=remap(randomValues[count+6],0.f,1.f,-6.f,6.f)*uvSpiralizeStrength;uv=rotateUvs(uv,pos,radius,0.f,strength);}count++;}}return uv;}vec4 mainRender(vec2 screenUv){vec2 uv=warpChoice(screenUv);vec2 px=1.f/resolution*scaledResolution;uv=spiralizeUV(uv);uv=pinchUV(uv);uv=lightBend(uv);uv=waveUv(uv);float minDist=1e20f;float prevPolygonDist=1e20f;float minSelfDist=1e20f;float currDist;float alphaBlend=0.f;int secondClosestPolyEdgeIndex=-1;int closestPolyEdgeIndex=-1;int insidePolyIndex=-1;const float distanceThreshold=1.f/9.f;for(int i=0;i<numPolygons;i++){uvec2 polygonIndicies=polyIndices[i];int offset=int(polygonIndicies.x);int vertexCount=int(polygonIndicies.y);int intersections=0;currDist=1e20f;for(int j=0;j<vertexCount;j++){vec2 lineStart=polyVertices[j+offset];vec2 lineEnd=polyVertices[((j+1)% vertexCount)+offset];currDist=min(currDist,pointLineSegSDF(uv,lineStart,lineEnd));if(isIntersecting(uv,lineStart,lineEnd)){intersections++;}}if(intersections % 2==1){insidePolyIndex=i;minSelfDist=currDist;}if(currDist<minDist+distanceThreshold){prevPolygonDist=minDist;secondClosestPolyEdgeIndex=closestPolyEdgeIndex;minDist=currDist;closestPolyEdgeIndex=i;}}int currPolyIndex=insidePolyIndex % paletteAccentArrayLength;vec3 currentColor=currPolyIndex>=0 ? paletteAccentArray[currPolyIndex]: backgroundColor;vec3 closestOtherColor=closestPolyEdgeIndex>=0 ? paletteAccentArray[closestPolyEdgeIndex % paletteAccentArrayLength]: backgroundColor;vec3 currentColorAlt=insidePolyIndex>=0 ? altPaletteAccentArray[insidePolyIndex % altPaletteAccentArrayLength]: backgroundColor;vec3 closestOtherColorAlt=closestPolyEdgeIndex>=0 ? altPaletteAccentArray[closestPolyEdgeIndex % altPaletteAccentArrayLength]: backgroundColor;int currentDetail=detailArray[insidePolyIndex % numPolygons];int closestOtherDetail=detailArray[closestPolyEdgeIndex % numPolygons];bool skipPolyDraw=currentDetail==3;bool skipPolyDrawClosestOtherDetail=closestOtherDetail==3;float offsetWarp=getColourPaletteSwapWarp(screenUv);currentColor=rgb2hsl(mix(hsl2rgb(currentColor),hsl2rgb(currentColorAlt),offsetWarp));closestOtherColor=rgb2hsl(mix(hsl2rgb(closestOtherColor),hsl2rgb(closestOtherColorAlt),offsetWarp));vec3 color=currentColor;if(skipPolyDraw||isBackground==1){currentColor=backgroundColor;}if(skipPolyDrawClosestOtherDetail||isBackground==1){closestOtherColor=backgroundColor;}bool isInsidePoly=insidePolyIndex>-1;float sdfBlendDist=.1f;float lineWeight=lineThickness+((snoise2D(uv/60.f)+.5f)*.2f);float lineFactor=aastep(lineWeight,minDist);if(isInsidePoly){alphaBlend=1.f;float dist=prevPolygonDist>(minDist+sdfBlendDist)? sdfBlendDist : minSelfDist;float colorBlend=clamp(aastep(sdfBlendDist,dist),0.f,1.f);color=rgb2hsl(mix(hsl2rgb(closestOtherColor),hsl2rgb(currentColor),colorBlend));}else{color=closestOtherColor;alphaBlend=aastep(-(drawOutlines==1 ? 1.f-lineFactor :(px.y*(pixelAA))),-minDist);}if(drawOutlines==1){float lineLerp=clamp(lineContrast+snoise2D(uv/.2f)*0.15f,0.f,1.f);vec3 lineMixRGB=mix(hsl2rgb(color),hsl2rgb(lineColor),lineLerp);color=rgb2hsl(mix(hsl2rgb(color),lineMixRGB,1.f-lineFactor));}if(alphaBlend<=0.f){outColor=vec4(0.f);return outColor;}bool isInMargin=false;if(margin>0.f){float marginLinePos=margin+(lineThickness*2.f);if(strokeBorder==1){if(screenUv.x<marginLinePos||screenUv.x>scaledResolution.x-marginLinePos||screenUv.y<marginLinePos||screenUv.y>scaledResolution.y-marginLinePos){vec3 lineMixRGB=mix(backgroundColor,hsl2rgb(lineColor),lineContrast+0.2f);color=lineMixRGB;}}if(screenUv.x<margin||screenUv.x>scaledResolution.x-margin||screenUv.y<margin||screenUv.y>scaledResolution.y-margin){isInMargin=true;color=backgroundColor;}}float shadeWarp=snoise2D(screenUv/1.5e2f)*8.f;float shadeFactor=minSelfDist==1e20f ? 0.f : minSelfDist;float innerShadeFactor=skipPolyDraw ? 0.f : smoothstep(30.f,0.0f,shadeFactor+shadeWarp);float innerShadeFactorEdges=skipPolyDraw ? 0.f : smoothstep(10.f,0.0f,shadeFactor+(shadeWarp/1.2f));float innerShadeComposite=max(innerShadeFactor*0.1f,innerShadeFactorEdges*0.13f)*shadingStrength;float brightnessOffset=shadingStrength*0.05f;float saturationOffset=-0.025f;color=vec3(color.x,color.y+saturationOffset+(innerShadeComposite*.02f),color.z-(innerShadeComposite)+brightnessOffset);for(int i=0;i<3;i++){if(isBackground!=1&&!isInMargin&&!skipPolyDraw){color=addMarksAndScratches(screenUv,color,i+3);}}int noiseOffsetIndex=margin>0.f||skipPolyDraw ? 0 : currPolyIndex;bool gridBleedThroughEnabled=gridBleedThrough==1||skipPolyDraw;if(drawGridDivisions>0){color=drawGridLines(screenUv,color,1.f,1.f,lineColor,gridBleedThroughEnabled);}if(drawGridDivisions>1){color=drawGridLines(screenUv,color,2.f,.89f,lineColor,gridBleedThroughEnabled);}if(drawGridDivisions>2){color=drawGridLines(screenUv,color,4.f,.84f,lineColor,gridBleedThroughEnabled);}color=noisePass(screenUv,color,minSelfDist,noiseOffsetIndex);return mix(vec4(hsl2rgb(color),0.f),vec4(hsl2rgb(color),1.f),alphaBlend);}float randomNonDet(vec2 st){return fract(sin(dot(st.xy,vec2(12.9898f,78.233f)))*43758.5453123f);}vec4 adjustContrast(vec4 color,float factor){vec3 adjustedColor=(color.rgb-0.5f)*factor+0.5f;return vec4(adjustedColor,color.a);}vec4 desaturateRGBA(vec4 color,float factor){float gray=dot(color.rgb,vec3(0.299f,0.587f,0.114f));vec3 desaturatedColor=mix(color.rgb,vec3(gray),factor);return vec4(desaturatedColor,color.a);}vec4 postProcess(vec4 color){if(desaturate==1){vec4 newColor=color;newColor=desaturateRGBA(newColor,.98f);newColor=adjustContrast(newColor,1.2f);vec3 lumClamp=rgb2hsl(newColor.rgb);lumClamp=clamp(lumClamp,0.f,1.f);lumClamp.z=remap(lumClamp.z,0.f,1.f,0.1f,.95f);newColor=vec4(hsl2rgb(lumClamp),color.a);color=newColor;}else{color=adjustContrast(color,1.025f);}return color;}void main(){const vec2 H2=vec2(0.5698402909980532f,0.7548776662466927f);vec2 px=1.f/resolution*scaledResolution;px*=pixelAA;vec2 uv=gl_FragCoord.xy/resolution*scaledResolution;const float samples=6.f;vec4 sumColour;vec2 d0=vec2(randomNonDet(uv),randomNonDet(uv+1.f));for(float i=0.f;i<samples;i++){vec2 d=fract(i*H2+d0)-.5f;vec4 sampleColor=mainRender(d*px+uv);sampleColor.rgb*=aastep(0.5f,sampleColor.a);sumColour+=sampleColor;}vec4 averageColor=sumColour/samples;if(averageColor.a>0.01f){averageColor.rgb/=averageColor.a;}else{discard;}float gammaRemap=desaturate==1 ? 0.95f : 1.05f;vec4 result=vec4(pow(clamp(averageColor,0.f,1.f),vec4(1.f/gammaRemap)));vec4 postProcssed=clamp(postProcess(result),0.f,1.f);outColor=postProcssed;}");let t=ke(It,100,0),o=0;for(let e=Xe/2;e<Vo;e+=4*Xe)for(let r=Xe/2;r<No;r+=4*Xe)Ho[o]=R(X(e/It,r/It,0),t.min,t.max,0,1),o++;let r=1e8,n=he(qo),l=Ge*Ye,a=B(Z,S.int(0,Q.length-2)),s=[];for(;(l-n.length)/l<Ct/100&&r-- >0;){let t=pe(!0),o=0,r=S.weightedChoice([t.length?8:0,t[o]],[t.length>0?0:1,{pt:[S.int(0,Ge),S.int(0,Ye)],dir:S.choice(Z)}]),i=S.weightedChoice([Yt,fe],[Gt,se],[Xt,ce]),f=250,c=ke(_t,a.length,f),u=a[e(R(X(ne(r.pt[0])/_t,ie(r.pt[1])/_t,f),c.min,c.max,0,a.length-1))%a.length];s[u]?s[qe||u]++:s[qe||u]=1;let d=100,h=ke(Ze,St,d),p=ke(et,10*d),g=E(r.pt[0],1),m=E(r.pt[1],1),v=e(R(X(g/Ze,m/Ze,d),h.min,h.max,1,St)),b=e(R(X(g/et,m/et,10*d),p.min,p.max,1,At)),w={gx:g,gy:m,extrusionDirection:qe||u,extrusionLength:S.weightedChoice(...Ke),gw:v,gh:b,stepCount:S.int(2,kt),stepDirection:He||u};i==ce&&(w.gw=1,w.gh=1),i==se&&(w.gw=2,w.gh=1);let x=i(w),y=[];if(S.bool(xt)){const e=te(S.choice(a),oe(S.choice([2,4])));for(let t=S.int(1,yt),o=0;o<=t;o++){let t=Qo(x);t=t.map((t=>(t.poly=t.poly.map((t=>{const[r,n]=t,[i,l]=e;return[r+i*o,n+l*o]})),t.id=$(),t))),y.push(t)}}[x,...y].map((t=>{if(S.bool(wt)&&t.length>1)for(let o=0;o<e(t.length-1);o++)t.splice(S.int(0,t.length-1),1)})),qo=[...qo,x,...y.reverse()],n=he(qo);let C=(l-n.length)/l;yield C}let f=Object.values(s).reduce(((e,t)=>e+t),0)/Object.keys(s).length;if(s?.upLeft>f&&ho(),nt){let[e,t]=it,o=0,r=0,n=be(qo,J.none,ve.gridCoords,[[0,0],[e,t]]);n=k(n).slice(0,e*t);let l=[];for(let a=o;a<=Ge+i(2*e);a+=e)for(let e=r;e<=Ye+i(2*t);e+=t)B(n,a+e).map((t=>{let o=Qo(t);o.map((t=>(t.poly=t.poly.map((t=>{const[o,r]=t;return[o+oe(a),r+oe(e)]})),t.id=$(),t))),l.push(o)}));qo=l}qo=qo.filter((e=>{for(let t of e)if(ae(t.poly))return!0;return!1})),qo=qo.filter((e=>e.length>0)),ro&&be(qo,J.remove);const c=nt?qo:k(qo);qo=[[le()],...c]}();let o="Computing";Po(0,o);let r=()=>{const e=Fo();let n=!1,i=0;for(;!n&&Fo()-e<50;){const e=t.next();i=e.value||0,n=e.done}n?tr():(Po(W(s(100*i),0,10
// Inc a modified version of 2D Simplex Noise by Ian McEwan - MIT License: https://github.com/ashima/webgl-noise/blob/master/LICENSE const{floor:e,ceil:t,sin:o,cos:r,pow:n,abs:i,min:l,max:a,round:s,sqrt:f,acos:c,log:u,random:d,PI:h}=Math;var p;!function(e){e[e.generative=0]="generative"}(p||(p={}));let g="Calm",m="Assertive",v="Rich",b="Toasty",w="Chilled",x=[{name:"Chalks",theme:g,bg:["#e9e1cc"],highlight:["#e9e1cc"],lowlight:["#070707"],line:["#070707"],stroke:["#e9e1cc"],base:["#e9e1cc"],accent:["#2e5c53","#d69c88","#f8b97c","#e26b48","#9fbfcb"]},{name:"Morning Sun In A Dusty Room",theme:b,bg:["#272125"],line:["#0B090A"],stroke:["#ece1cf"],highlight:["#ece1cf"],lowlight:["#0B090A"],base:["#d1ada9"],accent:["#272125","#7f5076","#de5c4b","#e6922b","#ece1cf","#4f707f","#ece1cf","#ece1cf"]},{name:"Jazz",suitability:p.generative,theme:v,stroke:["#2F2A1E"],bg:["#E9DCCE"],lowlight:["#2F2A1E"],highlight:["#E9DCCE"],base:["#e9e1cc"],line:["#070707"],accent:["#dc5b3d","#08739b","#e69335","#e08572"]},{name:"Beach",bg:["#DDC7B1"],theme:g,stroke:["#F4E8DC"],line:["#131F2A"],highlight:["#ffffff"],lowlight:["#05080B"],base:["#ece1cf"],accent:["#0f2f24","#3c534b","#45525c","#b2780f","#d6966a","#a2b6ad"]},{name:"Beige Box",theme:m,bg:["#1d1e20"],line:["#1d1e20"],highlight:["#ffffff"],lowlight:["#05080B"],base:["#e08f38"],stroke:["#C96997"],accent:["#7f716c","#679e6b","#6889ba","#db6438","#C96997","#E7CB52"]},{name:"Master",theme:v,bg:["#d7d2c9"],line:["#25211d"],highlight:["#ffffff"],lowlight:["#05080B"],base:["#98aea0"],stroke:["#e8dddc"],accent:["#b9792a","#9fc6e1","#7287a4","#25574a","#98aea0","#e35a2e"]},{name:"New York Autumn",theme:g,bg:["#e4d7cb"],stroke:["#EECD91"],line:["#141517"],highlight:["#ffffff"],lowlight:["#000000"],base:["#e6d4c7","#ebe1d1"],accent:["#3e5e57","#bcb174","#4b79a0","#5f4c30","#e0c0b0","#e4af50","#eecc61","#b7555a","#af474a"]},{name:"The Coast",theme:g,bg:["#CDC8C1"],stroke:["#e4c98b"],line:["#1D1C1C"],highlight:["#ffffff"],lowlight:["#000000"],base:["#DFD8CD","#B4B3B1"],accent:["#244a41","#739154","#e4c98b","#e2b8bb","#d3eaf1","#5c93c7","#72a09f","#af474a"]},{name:"Aged",theme:b,bg:["#eadcbb"],stroke:["#F0EBE0"],line:["#282625"],highlight:["#F0EBE0"],lowlight:["#000000"],base:["#EBE5D6","#eadcbb","#DBCCA9","#C0B291"],accent:["#d97142","#447d5b","#AA3631","#e3a841","#d3b29f","#32626f"]},{name:"Ink & Colour",theme:m,bg:["#d0d3d7"],stroke:["#F1F0EE"],line:["#1b201d"],highlight:["#F1F0EE"],lowlight:["#000000"],base:["#DFE0E2"],accent:["#4e4374","#e8abb5","#33584b","#d94c41","#1e2b3b","#b5843c","#C4C9CF"]},{name:"Oranges",theme:v,bg:["#f8ecd2"],stroke:["#fefcf7"],base:["#F3B0AF"],highlight:["#F3B0AF"],lowlight:["#050f0a"],line:["#08170F"],accent:["#1D4249","#7b7432","#E87737","#E39226","#F5EFE0"]},{name:"Henri",theme:w,bg:["#E7DECF"],stroke:["#d78c7a"],line:["#221f20"],highlight:["#f4f3e7"],lowlight:["#221f20"],base:["#f1dfc6"],accent:["#2a646f","#1e4c4a","#e9af5f","#8cacb7","#295d7c"]},{name:"Rand-ey",theme:m,bg:["#d8d2c4"],line:["#151418"],highlight:["#ffffff"],lowlight:["#14171e"],stroke:["#e6e0d2"],base:["#e9d9d2"],accent:["#CB4343","#2B5F8D","#745892","#F0990F","#138161","#686e6e"]},{name:"Olivetti",theme:v,bg:["#1d1e20"],line:["#1d1e20"],highlight:["#f4f3e7"],lowlight:["#231e1a"],stroke:["#e08f38"],base:["#726e6d","#E2DDCD"],accent:["#e08f38","#679e6b","#6889ba","#db6438","#C96997","#e9c835"]},{name:"Toddler",theme:v,bg:["#d5c4be"],line:["#08170F"],highlight:["#ede9e1"],lowlight:["#08170F"],stroke:["#08170F"],base:["#9e9995","#ede9e1"],accent:["#1C3673","#5F4E5A","#CE393A","#767650","#F17941","#E9AB25"]}];const y=[["#066278","#e28a91","#eac4c5","#d94939","#e9aa26","#0b2732","#065773","#e7d4da"],["#F4C1C4","#2963A2","#ECAA13","#DB4D2C","#088969"],["#d14434","#dd924c","#d6a146","#1a4249"],["#F0EDE6","#d8d2c4","#22252A","#2F3237","#62646A"],["#35695f"],["#d9c8af"],["#e4d4ca"],["#894f65","#677885","#e7a33e"]];class C{useA;prngA;prngB;hash;constructor(e){this.useA=!1,this.hash=e;const t=globalThis.parseInt;let o=function(e){let o=t(e.substr(0,8),16),r=t(e.substr(8,8),16),n=t(e.substr(16,8),16),i=t(e.substr(24,8),16);return function(){o|=0,r|=0,n|=0,i|=0;let e=(o+r|0)+i|0;return i=i+1|0,o=r^r>>>9,r=n+(n<<3)|0,n=n<<21|n>>>11,n=n+e|0,(e>>>0)/4294967296}};this.prngA=o(this.hash.substr(2,32)),this.prngB=o(this.hash.substr(34,32));for(let e=0;e<1e6;e+=2)this.prngA(),this.prngB()}dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}num(e,t){return e+(t-e)*this.dec()}int(t,o){return e(this.num(t,o+1))}bool(e=50){return this.dec()<e/100}choice(e){return e[this.int(0,e.length-1)]}easedDec(e){return e(this.dec())}easedInt(t,o,r){return e(this.easedNum(t,o,r))}easedNum(e,t,o){return t+(o-t)*this.easedDec(e)}weightedChoice(...e){let t=0,o=[];for(t=0;t<e.length;t++)o[t]=e[t][0]+(o[t-1]||0);const r=this.dec()*o[o.length-1];for(t=0;t<o.length&&!(o[t]>r);t++);return e[t][1]}}let D,S;D="undefined"!=typeof tokenData?"string"==typeof tokenData?tokenData:tokenData.hash:function(){let t=new URLSearchParams(globalThis.location.search).get("hash");if(t)return t;let o="0x";for(var r=0;r<64;r++)o+=e(16*d()).toString(16);return window.tokenData={hash:o},o}();function A(e,t,o){return 1===t.length?(e[t[0]]||(e[t[0]]=o()),e):(e[t[0]]||(e[t[0]]=[]),A(e[t[0]],t.slice(1),o))}function k(t){const o=t.slice();for(let t=o.length-1;t>0;t--){const r=e(S.dec()*(t+1));[o[t],o[r]]=[o[r],o[t]]}return o}function L(e,t="right"){const o=e.slice();if("right"===t){const e=o.pop();void 0!==e&&o.unshift(e)}else if("left"===t){const e=o.shift();void 0!==e&&o.push(e)}return o}function B(e,t,o="right"){let r=e.slice();for(let e=0;e<t;e++)r=L(r,o);return r}const P=(e,t,o,r,n)=>((e,t,o)=>(t-e)*o+e)(r,n,((e,t,o)=>(o-e)/(t-e))(t,o,e)),E=(e,t)=>s(e/t)*t;function W(e,t,o){return l(a(e,t),o)}const R=(e,t,o,r,n)=>W(P(e,t,o,r,n),r,n),I=e=>e,M=e=>-(r(h*e)-1)/2,O=4,F=1<<O,V=8,N=1<<V,z=8190;let U=3,T=.8;const G=e=>.5*(1-r(e*h));let Y;function X(t,o=0,r=0){if(null==Y){Y=new Array(z+1);for(let e=0;e<z+1;e++)Y[e]=S.dec()}t<0&&(t=-t),o<0&&(o=-o),r<0&&(r=-r);let n,i,l,a,s,f=e(t),c=e(o),u=e(r),d=t-f,h=o-c,p=r-u,g=0,m=.5;for(let e=0;e<U;e++){let e=f+(c<<O)+(u<<V);n=G(d),i=G(h),l=Y[e&z],l+=n*(Y[e+1&z]-l),a=Y[e+F&z],a+=n*(Y[e+F+1&z]-a),l+=i*(a-l),e+=N,a=Y[e&z],a+=n*(Y[e+1&z]-a),s=Y[e+F&z],s+=n*(Y[e+F+1&z]-s),a+=i*(s-a),l+=G(p)*(a-l),g+=l*m,m*=T,f<<=1,d*=2,c<<=1,h*=2,u<<=1,p*=2,d>=1&&(f++,d--),h>=1&&(c++,h--),p>=1&&(u++,p--)}return g}function _(e,t){let o=e[0],r=e[1],n=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){let l=t[e][0],a=t[e][1],s=t[i][0],f=t[i][1];a>r!=f>r&&o<(s-l)*(r-a)/(f-a)+l&&(n=!n)}return n}function j(e){const t=e.reduce(((e,t)=>[e[0]+t[0],e[1]+t[1]]),[0,0]);return[t[0]/e.length,t[1]/e.length]}const q=e=>f(e[0]*e[0]+e[1]*e[1]);let H=0;function $(){return H++}var J;!function(e){e[e.none=0]="none",e[e.dots=1]="dots",e[e.lines=2]="lines",e[e.remove=3]="remove",e[e.null=4]="null"}(J||(J={}));const K={up:["up","upLeft","upRight"],down:["down","downLeft","downRight"],left:["left","upLeft","downLeft"],right:["right","upRight","downRight"],upLeft:["up","upLeft","left"],upRight:["up","upRight","right"],downLeft:["down","left","downLeft"],downRight:["down","right","downRight"]},Q=["up","down","left","right","upLeft","upRight","downLeft","downRight"],Z=["downRight","downLeft","upLeft","upRight"],ee=(e,t)=>522133279*e^t,te=(e,t)=>({up:[0,-t],down:[0,t],left:[-t,0],right:[t,0],upLeft:[-t,-t],upRight:[t,-t],downLeft:[-t,t],downRight:[t,t]}[e]),oe=e=>e*Xe,re=e=>e*_e,ne=e=>oe(e)+tt,ie=e=>re(e)+ot,le=()=>({poly:[[0,0],[oe(Ge),0],[oe(Ge),re(Ye)],[0,re(Ye)]],id:$(),label:"bg"}),ae=e=>{let t=le().poly;for(let o of e)if(_(o,t))return!0;return!1},se=e=>{let{gx:t=0,gy:o=0,gw:r=1,gh:n=1,extrusionDirection:i,stepDirection:l="upLeft",extrusionLength:a=1,stepCount:s=3}=e,f={upLeft:["upRight","downLeft"],upRight:["upLeft","downRight"],downLeft:["upLeft","downRight"],downRight:["upRight","downLeft"]};f[l].includes(i)||(i=S.choice(f[l]));const c=we([t,o],r,n,s,l);let u=[];a>0&&(u=De(c.poly,i,a));let d=[...u];return c.extrusionDirection=i,d.push(c),d},fe=e=>{let{gx:t=0,gy:o=0,gw:r=1,gh:n=1,extrusionDirection:i="downLeft",extrusionLength:l=1}=e;const a=xe(t,o,r,n,0,0);let s=[];return l>0&&(s=De(a.poly,i,l)),a.extrusionDirection=i,[...s,a]},ce=e=>{const{gx:t=0,gy:o=0,gw:r=1,gh:n=1,extrusionLength:i=1,extrusionDirection:l="upLeft"}=e;const a=ye(t,o,r,r,l);let s=[];return i>0&&(s=De(a.poly,l,i)),a.extrusionDirection=l,[...s,a]},ue=new Map,de=new Map,he=e=>{let t=[],o=Q.map((e=>te(e,.3))),r=e.flat().filter((e=>!de.get(e.id)));for(let e=-2;e<Ge+2;e++)for(let n=-2;n<Ye+2;n++){let i=!1;if(ue.get(ee(e,n)))i=!0;else e:for(let t of r){let r=0;for(let i of o)_(ge([e+i[0],n+i[1]]),t.poly)&&r++;if(r===o.length){i=!0,ue.set(ee(e,n),!0);break e}}i||t.push([e,n])}return r.map((e=>de.set(e.id,!0))),t},pe=(e=!0,t=ue)=>{const o=[],r=Q.map((e=>({pt:te(e,1),dir:e}))),n=(e,o)=>e>=-2&&o>=-2&&e<Ge+2&&o<Ye+2&&!t.get(ee(e,o));for(let t=-2;t<Ge+2;t++)for(let i=-2;i<Ye+2;i++)if(!n(t,i))e:for(const l of r){let[r,a]=l.pt;if(n(t+r,i+a)){if(!e){o.push({pt:[t,i],dir:l.dir});break e}o.push({pt:[t+r,i+a],dir:l.dir})}}return o},ge=e=>{const[t,o]=e;return[ne(t)+oe(.5),ie(o)+re(.5)]};var me,ve;!function(e){e[e.X=0]="X",e[e.Y=1]="Y"}(me||(me={})),function(e){e[e.noise=0]="noise",e[e.gridCoords=1]="gridCoords"}(ve||(ve={}));const be=(e,t,o=ve.noise,r=[])=>{let n=[],i=Q.map((e=>te(e,.3))),l=io,a=1-no,s=ke(l);e:for(let f of e)t:for(let e of f)if(o==ve.noise)for(let o=0;o<Ye;o++)for(let r=0;r<Ge;r++){if(P(X(ne(r)/l,ie(o)/l),s.min,s.max,0,1)>a)for(let l of i){if(_(ge([r+l[0],o+l[1]]),e.poly)){e.detail=t,n.push(e);continue t}}}else if(o==ve.gridCoords){let t=r[0][0],o=r[1][0],l=r[0][1],a=r[1][1];for(let r=l;r<a;r++)for(let l=t;l<o;l++)for(let t of i){if(_(ge([l+t[0],r+t[1]]),e.poly)){n.push(f);continue e}}}return n},we=(e,t=4,o=2,r=3,n="downRight")=>{let i=[],[l,a]=e,s=ne(l),f=ie(a),c=oe(t),u=re(o),d=n.toLowerCase().endsWith("left"),h=n.startsWith("up"),p=!d&&h,g=d&&h,m=0,v=s,b=f;(d&&!g||p)&&(c=-c);for(let e=0;e<r;e++){i.push([v,b]);let t=0==e?c:c/2;m+=t,v+=t,i.push([v,b]),b+=u,i.push([v,b])}for(let e=0;e<r;e++)v-=0==e?c:c/2,i.push([v,b]),b-=u,i.push([v,b]);return(d&&!g||p)&&(i=i.reverse()),(h||p)&&(i=Se(i,"up",o*(r-1)),i=Se(i,"left",m/Xe)),{poly:i,id:$(),label:"front"}},xe=(e,t,o,r,n=0,i=0)=>{const l=ne(e),a=ie(t),s=oe(o),f=re(r),c=s/2*n,u=f/2*i;return{poly:[[l+c,a+u],[l+c+s,a-u],[l-c+s,a-u+f],[l-c,a+u+f]],id:$(),label:"front"}},ye=(e,t,o,r,n="upLeft")=>{let i=xe(e,t,o,r),l=Z.indexOf(n);return i.poly.splice(l,1),i},Ce=(e,t)=>{const o=te(t,1);return e.map(((t,o)=>[t,e[o+1]||e[0]])).filter((e=>{const[t,r]=e,n=[r[0]-t[0],r[1]-t[1]];return((e,t)=>{const o=((e,t)=>e[0]*t[0]+e[1]*t[1])(e,t),r=q(e)*q(t);return c(o/r)})(o,[n[1],-n[0]])<=.7}))},De=(e,t,o)=>{let r=[];const n=K[t];let l=(e=>{const t={};for(const o of Q)t[o]=Ce(e,o);return t})(e);for(let e of n)l[e].map((n=>{let i=Se(n,t,o).reverse(),l={id:$(),label:e,poly:[...n,...i]};r.push(l)}));return r=r.filter((e=>function(e){let t=0;const o=e.length;for(let r=0;r<o;r++){const[n,i]=e[r],[l,a]=e[(r+1)%o];t+=n*a-l*i}return i(t)/2}(e.poly)>.3)),r},Se=(e,t,o)=>{let r=o*rt,n=e.map((e=>[...e])),i=te(t,r);return n.forEach((e=>{e[0]+=i[0],e[1]+=i[1]})),n};let Ae={};const ke=(t,o=5,r=0,n=I)=>{const i=`${t}-${r}`;if(Ae[i]?.min)return Ae[i];let l=0,a=-1/0,s=1/0,f=0,c=[];for(let e=0;e<Ge;e++)for(let o=0;o<Ye;o++){let i=n(X(ne(e)/t,ie(o)/t,r));l+=i,f+=1,i>a&&(a=i),i<s&&(s=i),c.push(i)}let u={max:a,min:s,mean:l/f,indexValues:[],mostCommonIndex:0,leastCommonIndex:0};return c.map((t=>{let r=e(R(t,u.min,u.max,0,o-1));u.indexValues[r]=u.indexValues[r]?u.indexValues[r]+1:1})),u.mostCommonIndex=u.indexValues.reduce(((e,t,o)=>t>u.indexValues[e]?o:e),0),u.leastCommonIndex=u.indexValues.reduce(((e,t,o)=>t<u.indexValues[e]?o:e),0),Ae[i]=u,u};var Le;!function(e){e[e.h=0]="h",e[e.s=1]="s",e[e.l=2]="l"}(Le||(Le={}));let Be=[];const Pe=e=>function(e){let t,o,r=e[0]/255,n=e[1]/255,i=e[2]/255,s=a(r,n,i),f=l(r,n,i),c=(s+f)/2;if(s==f)t=o=0;else{var u=s-f;switch(o=c>.5?u/(2-s-f):u/(s+f),s){case r:t=(n-i)/u+(n<i?6:0);break;case n:t=(i-r)/u+2;break;case i:t=(r-n)/u+4}t/=6}return[t,o,c]}(function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)throw new Error(`${e}`);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}(e));let Ee=[],We=[];const Re=(e,t,o)=>{const r={h:1,s:0,l:0,...o},n=(e[Le.h]-t[Le.h])*r.h,i=(e[Le.s]-t[Le.s])*r.s,l=(e[Le.l]-t[Le.l])*r.l;return f(n*n+i*i+l*l)},Ie=(e,t,o,r=1)=>{let n=[];for(const i of e){const e=Re(t,i,o);n.length<r?(n.push({color:i,distance:e}),n.sort(((e,t)=>e.distance-t.distance))):e<n[n.length-1].distance&&(n.pop(),n.push({color:i,distance:e}),n.sort(((e,t)=>e.distance-t.distance)))}return n.map((e=>e.color))},Me=(e,t=Le.l,o=.2)=>function(e){const t=e.length,o=e.reduce(((e,t)=>e+t))/t;return f(e.map((e=>n(e-o,2))).reduce(((e,t)=>e+t))/t)}(e.map((e=>e[t])))>=o;let Oe=0;const Fe=e=>{if(!We[e]){let t=We[e]={};for(let e of Object.keys($e))"name"!==e&&"suitability"!==e&&"theme"!==e&&(t[e]=$e[e].map((e=>Pe(e))))}let t=We[e];if(Ee[e])return k(Ee[e]);{let o,r,n=[];if(Ht){let e=x.map((e=>e.name===$e.name?[]:[...e.accent,...e.line,...e.base,...e.bg,...y.flat()])).flat().map(Pe);o=[...t.base,...t.accent,...t.line].map((t=>S.choice(Ie(e,t,Je,4))));let r=x.map((e=>e.name===$e.name?[]:[...e.bg])).flat().map(Pe);We[Ve.base].bg=[S.choice(Ie(r,t.bg[0],Je,2))];let n=x.map((e=>e.name===$e.name?[]:[...e.line])).flat().map(Pe);We[Ve.base].line=[S.choice(Ie(n,t.line[0],Je,2))]}else o=[...t.accent,...t.base,...t.line];r=W(s(o.length/100*$t[e]),3,1e4);for(let e=0;e<r;e++){let t;t=0==e?o[ze(o)]:S.choice(o),t&&n.push(t),o=o.filter((e=>{return r=t,!((o=e)[Le.h]===r[Le.h]&&o[Le.s]===r[Le.s]&&o[Le.l]===r[Le.l]);var o,r}))}let i=Me(n,Le.l,.2);return Oe<=100&&n.length<=3&&!i?(Oe++,Fe(e)):(Ee[e]=n,k(Ee[e]))}};var Ve;!function(e){e[e.base=0]="base",e[e.alt=1]="alt",e[e.alt2=2]="alt2",e[e.alt3=3]="alt3"}(Ve||(Ve={}));const Ne=t=>{let o=M,{pos:r=[0,0],tension:n=50,paletteVariant:i=0,offsetPerVariant:l=50,divisonsX:a=so,divisonsY:s=fo,paletteCategory:f=Ve.base}=t;const c=W(e(r[0]/(Vo/(a+1))),0,a),u=W(e(r[1]/(No/(s+1))),0,s);A(Be,[c,u,f,i],Fe.bind(null,f));let d=Be[c][u][f][i];n-=l,0==n&&(n=.1);let h=ke(n,d.length,0,o);if(Ue(d)==h.mostCommonIndex){let e=k(d),t=Ue(e),o=0;for(;(t==h.mostCommonIndex||t==h.leastCommonIndex)&&o<100;)e=k(d),t=ze(e),o++;Be[c][u][f][i]=e}return d[e(R(o(X(r[0]/n,r[1]/n,0)),h.min,h.max,0,d.length-1))%d.length]},ze=e=>e.reduce(((t,o,r)=>o[Le.l]>e[t][Le.l]?r:t),0),Ue=e=>e.reduce(((t,o,r)=>o[Le.l]<e[t][Le.l]?r:t),0),Te=(e,t,o)=>{let r=!1,n=e.map((e=>{let n;"bg"===e.label&&(r=!0);let i=j(e.poly),l=Ne({pos:o||i,paletteCategory:t,tension:eo,paletteVariant:oo?0:Q.indexOf(e.label)+1});n=r?We[Ve.base].bg[0]:[...l];let a=ke(mt),s=R(X(i[0]/mt,i[1]/mt,0),a.min,a.max,-gt,gt),f=r?0:s;return n[Le.l]+=f,((e,t)=>{let o=[...e];return o[Le.l]+=co[t],o[Le.h]+=S.num(-.01,.01),o[Le.l]+=S.num(-.01,.01),o.map(((e,t)=>{const o=t==Le.l;return W(e,o?.1:0,o?.81:1)}))})(n,e.label)}));return{isBackground:r,palette:n}};let Ge,Ye,Xe,_e,je,qe,He,$e,Je={h:1,s:.9,l:.7},Ke=[[2,0],[4,1],[1,.5],[1,1.5],[2,2],[1,3]],Qe=[[2,10],[1,40],[2,70],[5,100]],Ze=10,et=10,tt=0,ot=0,rt=100,nt=!1,it=[4,6],lt=0,at=!1,st=!1,ft=40,ct=100,ut=1,dt=[],ht=100,pt=.6,gt=.15,mt=50,vt=0,bt=!1,wt=20,xt=10,yt=2,Ct=99.5,Dt=!0,St=2,At=2,kt=5,Lt=!1,Bt=1,Pt=1,Et=!1,Wt=1,Rt=1,It=1e3,Mt=!0,Ot=!1,Ft=!1,Vt=!1,Nt=!1,zt=1,Ut=1,Tt=1,Gt=1,Yt=2,Xt=2,_t=10,jt=0,qt=1,Ht=!1,$t=[100,100],Jt=!1,Kt=1,Qt=.1,Zt=.001,eo=200,to=80,oo=!1,ro=!0,no=.1,io=1,lo=!1,ao=!1,so=2,fo=0,co={up:.1,down:-.12,left:.05,right:-.12,upLeft:.06,upRight:.1,downLeft:-.08,downRight:-.11,front:0,bg:0},uo={up:.1,down:-.12,right:.05,left:-.12,upLeft:.1,upRight:.3,downLeft:-.11,downRight:-.08,front:0,bg:0},ho=()=>{co=uo},po=!0,go=2,mo=10,vo=1;const bo=()=>{if(rt<30)return;let e=S.choice(["Left","Right"]),t=S.bool(50);qe=(t?"up":"down")+e,He=(t?"down":"up")+e},wo=()=>{let t=30,o=65;S.bool(10)?(t=15,o=35,Do(25,35)):Do(t,o),lt=0,Ke=Ke.splice(0,S.int(3,Ke.length-(rt>50?2:1))),S.int(1e3,2e3),S.num(6,10);let r=S.bool(3);at=r,r?(jt=.9,qt=1):(ht=0,jt=0,qt=0),vt=0,Ct=99.5,xt=S.choice([0,30,80]),yt=S.int(2,5),vo=S.num(.7,1),kt=S.int(3,5),St=S.int(2,3),At=S.int(2,rt<=35?6:3),Ze=S.num(150,250),et=S.num(120,220),At>=3&&(St=1),pt=S.bool(80)?S.num(.65,.8):S.num(.2,.65),S.bool(4)&&(pt=.2),Lt=lo||S.bool(r?10:65),Et=S.bool(Lt?80:60),Rt=S.num(.3,.8),Wt=rt<36?S.num(.8,1.1):S.num(.6,1),It=rt>36?Vo/8:Vo/4,wt=Lt||Et?20:50,nt=!(!Lt&&!Et)&&S.bool(20),Bt=R(rt,t,o,1.65,1.8),S.bool(25)?Bt*=1.5:Bt*=S.num(.9,1.1),Pt=S.num(1,1),Jt=S.bool(50),Kt=S.num(.01,.1),Qt=S.num(0,.8),Zt=S.num(0,.001),eo=S.choice([10,50,100]),to=S.choice([0,50,70,80]),S.choice([10,50,100]),S.choice([0,50,80]),so=S.int(0,rt<=35?8:4),fo=S.int(0,rt<=35?8:4),oo=S.bool(70),S.bool(40),_t=S.int(.1,80),ro=!0,no=S.num(rt>50?.16:.2,rt>50?.18:.23),Lt||Et||(no*=.75),io=(80-rt)*S.num(1,1.15),st=!0,ct=rt<=38?1.8*Xe:Xe*S.num(1.1,1.6),ut=rt>50?1:4,ft=S.int(60,150),Lt||Et||(ct=Xe,ut=1),Dt=S.bool(0),mo=30,Ut=1,Ft=!r&&S.bool(Lt||Et?40:90),Ot=!r&&Ft&&S.bool(40),zt=Ut,Tt=Ut,!r&&S.bool(20)&&bo(),it=[e(Ge/S.int(2,4)),e(Ye/S.int(2,6))],bt=S.bool(5),Qe[0]=[1,10],Qe[1]=[0,40]},xo=()=>{S.bool(10)?Do(25,35):Do(70,120),Qe[0]=[0,100],$e.accent.length<=4&&(Qe[1]=[1,50]),nt=S.bool(20),po=S.bool(70),lo=S.bool(35),ao=lo&&S.bool(50),lt=tt>10?tt:ot,lt=tt>100?tt/2:lt,tt<ot&&ot-tt<rt/6&&(lt=ot);let t=S.bool(100);lt<10&&(lt*=4),lt=t?lt:0,ht=100;let o=S.bool(10);if(at=o,o?(jt=1.1,qt=1):(jt=0,qt=0),Lt=S.bool(o?5:15),Bt=S.num(1.8,4),Pt=S.num(.3,2),Et=!Lt&&S.bool(20),Rt=S.num(.6,1.1),rt>90&&(Wt=.7),Et&&S.bool(5)&&(Rt=S.num(1.2,1.6),Wt*=1.1),Ct=99,xt=S.int(0,10),yt=S.int(1,4),pt=S.num(.5,.8),wt=S.int(20,70),vo=S.num(.9,1),Jt=S.bool(50),Kt=S.num(.01,.04),Qt=S.num(0,.4),Zt=S.num(0,.01),st=!0,ct=10*-Xe,vt=10,S.int(600,1200),S.num(3,12),St=rt<=35?S.int(6,12):S.int(1,5),At=rt<=35?S.int(6,12):S.bool(20)?6:S.int(1,6),At>=4&&(St=1),St>=4&&(At=1),Dt=!1,mo=S.int(0,15),eo=S.choice([10,50,100]),to=S.choice(lo||rt>100?[0,50,70]:[0,40,65,80]),S.choice([10,50,100]),S.choice([0,50,80]),oo=S.bool(rt>100?30:60),S.bool(30),rt<=35&&(eo/=2),so=S.int(0,S.weightedChoice([1,0],[2,3])),fo=S.int(0,S.weightedChoice([1,0],[2,3])),ro=!0,no=S.num(.05,.16),io=S.num(.7,1),kt=S.int(2,5),it=[e(Ge/S.int(2,4)),e(Ye/S.int(2,4))],Gt=2,Xt=1,Yt=1,Ut=1,Mt=S.bool(50),o){let e=S.bool(50);Ft=e,Ot=!e}else Ft=S.bool(Lt||Et?80:99),Ot=Ft&&S.bool(60);zt=Ut,Tt=Ut,S.bool(50)&&(Tt*=2),_t=S.int(1,1e3),Ke=[[S.bool(10)?2:S.int(0,1),0],[1,.5],[2,1],[1,1.5],[S.choice([1,0,.5]),2]],S.bool(35)&&bo(),bt=S.bool(5)},yo=()=>{S.bool(5)?Do(25,35):Do(70,95),st=!0,_t=S.int(1,40),ct=1*Xe,St=2,At=S.int(3,rt<=35?6:4),vt=0,wt=30,Et=S.bool(0),Wt=.6,Jt=S.bool(0),Kt=.1,Qt=.1,Zt=.001,S.int(1800,2e3),S.num(8,10),eo=S.int(10,180),to=S.choice([0,50,70,80]),S.int(10,180),S.choice([0,50,80]),oo=S.bool(0),S.bool(30),rt<=35&&(eo/=2);let e=S.bool(50)?2:0;so=S.int(0,rt<=35?8:e),fo=S.int(0,rt<=35?8:e),pt=S.num(.1,.7),mo=30,vo=S.num(.8,1),Lt=S.bool(rt<=80&&rt>=35?20:5),Bt=S.num(2,4),Pt=S.num(.8,1.2);let t=S.bool(30);Lt||Et||!t?(ht=0,jt=0,qt=0):(ht=100,at=!0,jt=1.5,qt=1),Gt=2,kt=S.int(2,rt<=35?4:2),yt=S.int(2,4),ro=!0,no=S.num(.1,.17),io=S.num(.7,1.5),Dt=S.bool(0),Mt=S.bool(30),Nt=Mt&&S.bool(20),Vt=!Nt&&Mt&&S.bool(20),Tt=S.weightedChoice([2,1],[1,2]),Ut=S.choice([.5,1]),zt=Ut,Ft=S.bool(80),Ot=1==Tt&&!t&&S.bool(70),ut=0,Ke=[[1,0],[.25,.5],[1,1],[Dt?.25:0,1.5]],Qe[0]=[0,100]},Co=()=>{let t=S.bool(35);Do(t?130:70,t?150:140),nt=S.bool(20);let o=!t&&S.bool(5);at=o;let r=S.bool(30);_t=S.int(r?1:1e3,r?100:2e3),o?(jt=1.2,qt=1):(jt=0,qt=0),vo=S.num(.8,1.1),Et=S.bool(t?55:40),Wt=t?S.num(1,1.6):S.num(.7,1.1),Rt=S.num(.3,t?.3:1),Et&&S.bool(5)&&(Rt=S.num(1.2,2.7)),Jt=S.bool(30),Kt=S.num(.015,.01),Qt=S.num(0,.4),Zt=S.num(0,.001),wt=70,St=t?2:3,At=rt>90?6:8,Lt=!o&&S.bool(30),Bt=S.num(rt<90?2:3,rt<90?3.2:5),Pt=S.num(.4,1.1),mo=20,eo=S.choice([10,50,100,200]),to=S.choice(rt>100?[10,30,50,60]:[10,50,70,80]),S.choice([10,50,100,200]),S.choice([10,50,70,80]),so=S.int(0,S.weightedChoice([1,0],[2,3])),fo=S.int(0,S.weightedChoice([1,0],[2,3])),oo=S.bool(50),ro=!0,no=S.num(0,rt>120?0:rt>90?.01:.1),io=S.num(.7,1),lt=tt>10?tt:ot,lt=tt>100?tt/2:lt,tt<ot&&ot-tt<rt/6&&(lt=ot),lt<10&&(lt*=4),Gt=2,Mt=S.bool(50),Ut=1,Ft=S.bool(85),Ot=S.bool(60),o&&Ft&&(Ot=!1),zt=Ut,Tt=Ut,lo=S.bool(t?50:30),ao=lo&&S.bool(50),pt=S.bool(70)?S.num(.6,.75):S.num(.3,.6),kt=rt>120?3:4,xt=S.int(90,100),it=[e(Ge/S.int(2,3)),e(Ye/S.int(2,6))],Qe.splice(0,2),Ke=[[2,0],[4,1],[4,2],[!t&&S.bool(90)?1:0,3],[rt<60&&S.bool(50)?1:0,4],[rt<60&&S.bool(50)?1:0,5]],bt=S.bool(5)},Do=(e,t)=>{rt=S.int(e,t),Ge=Vo/rt,Ye=No/rt,Xe=Vo/Ge,_e=No/Ye,tt=Vo%rt/2,ot=No%rt/2},So=()=>(lo&&(Qe[0]=[0,100]),bt&&(Qe=[[1,100]]),S.weightedChoice(...Qe));let Ao,ko,Lo="#fff";const Bo=()=>{Ao=document.createElement("div"),Ao.id="loading";const e=Ao.style;e.position="absolute",e.fontSize="1.25vmin",e.top=e.left="0",e.width="100%",e.height="100%",e.zIndex="1000",ko=document.createElement("div");const t=ko.style;t.backgroundColor="rgba(0, 0, 0, 0.91)",t.textTransform="uppercase",t.position="fixed",t.lineHeight="0",t.top=t.left="0",t.width="100vw",t.height="100vh",t.height="fill-available",t.display="flex",t.justifyContent=t.alignItems="center",t.flexDirection="column",t.color=Lo,t.fontFamily="system-ui",t.fontWeight="400",Ao.appendChild(ko),document.body.appendChild(Ao)},Po=(e,t="Preparing")=>{ko||Bo(),ko.innerHTML=((e,t="Preparing")=>`<p>${t}</p><div style="max-width: 15vmin; margin-top: 1.25em; width: 100%; border: .5px solid ${Lo}"><div style="width: ${e||0}%; height: .75vmin; background-color: ${Lo}; overflow: hidden;"></div>`)(e,t)};let Eo,Wo,Ro,Io=!1,Mo=e=>{Po(0,e),Io=!0};const Oo=window.requestAnimationFrame,Fo=performance.now.bind(performance);let Vo,No,zo=4/6;const Uo=a(window.devicePixelRatio,2);let To,Go;class Yo{gl;renderCount;shaderProgram;positionAttribute;positionBuffer;framebuffer;renderbuffer;setUniform(e,t,o){const r=this.gl,n=r.getUniformLocation(this.shaderProgram.program,e),i="uniform"+t;if(t.endsWith("fv")||t.endsWith("iv"))r[i](n,o);else{const e=[n].concat(o);r[i].apply(r,e)}return this}constructor(e,t,o){this.gl=e,this.renderCount=0,this.shaderProgram=new Xo(e,t,o)}}class Xo{program;constructor(e,t,o){const r=this.compileShader(e,t,e.VERTEX_SHADER),n=this.compileShader(e,o,e.FRAGMENT_SHADER);if(this.program=e.createProgram(),e.attachShader(this.program,r),e.attachShader(this.program,n),e.linkProgram(this.program),!e.getProgramParameter(this.program,e.LINK_STATUS))throw new Error("Error: "+e.getProgramInfoLog(this.program))}compileShader(e,t,o){const r=e.createShader(o);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("An error occurred compiling the shaders: "+e.getShaderInfoLog(r));return r}}class _o extends Yo{randomValues=dt;render(t){const{polygons:o,paletteByIdx:r,paletteByIdx2:n,backgroundColor:i,gridBleedThrough:l=!1,outerPolygon:a=[[0,0],[Vo,0],[0,No],[Vo,No]],depthInScene:s=0,warpLayer:f=!1,drawFaces:c=!0,detail:u,details:d,drawOutlines:h=!0,shadingStrength:p=1,isBackground:g=!1,strokeBorder:m=!0,randomSeed:v=je,lineColor:b=Pe($e.line[0]),lineContrast:w=.5,lineThickness:x=1,gridWidth:y=Xe,gridMX:C=tt,gridMY:D=ot}=t,S=this.gl,A=this.setUniform.bind(this);this.positionBuffer=this.positionBuffer||S.createBuffer(),S.bindBuffer(S.ARRAY_BUFFER,this.positionBuffer),S.bufferData(S.ARRAY_BUFFER,new Float32Array(a.map((e=>[e[0],e[1]])).flat()),S.STATIC_DRAW),this.positionAttribute=this.positionAttribute||S.getAttribLocation(this.shaderProgram.program,"a_position"),S.bindBuffer(S.ARRAY_BUFFER,this.positionBuffer),S.enableVertexAttribArray(this.positionAttribute),S.vertexAttribPointer(this.positionAttribute,2,S.FLOAT,!1,0,0),0==this.renderCount&&(S.viewport(0,0,To*Uo,Go*Uo),S.useProgram(this.shaderProgram.program),A("resolution","2f",[To*Uo,Go*Uo]),A("scaledResolution","2f",[Vo,No]),A("margin","1f",lt),A("lineContrast","1f",w),A("lineThickness","1f",x),A("backgroundColor","3f",i),A("desaturate","1i",bt?
**Trichro-matic** meditates on perception. As you explore the piece, your perception of the structure shifts. Elements change their relationships - what is out turns in; what is flat deepens. What stood adjacent now occludes. The piece uses rhythmic color and form, displacement, and juxtaposition to create structures that invite interpretation and exploration. Some outputs challenge our depth perception conventions, while others manipulate explicit structural cues and emphasize intentional imperfections. From this concept, the piece gets its name - Trichro-matic - denoting the ability to perceive using all three primary colors. The hyphenated "o-matic" denotes fictional machinery, hinting at the generative system supporting the piece. Both hand-selected and algorithmically-generated color palettes feature, with the latter aiming to elicit emotions akin to the former. When you explore an output from different starting points, you understand the elements' relationships differently. In these changing interpretations, no answer is definitive. Each perspective, whether your first, your last, or someone else's, is valid. Prints will be available for Trichro-matic owners. For more details, visit [this link](https://www.mountvitruvius.art). Note: Renders might take longer on lower-end or mobile devices. This piece is my most technically complex release to date, relying on a custom GPU render process which can demand significant resources, even if outputs appear simple. Finally, I dedicate this piece to my father, who suffered vision loss from a stroke in September 2023.
Renders Game is a note to myself on creativity. I will often believe strongly in an idea, yet, once realised, and I'm confronted with the reality of the output, it leaves me unsatisfied. So I take it apart, find a detail that I love, and grow something new from that tiny piece. It's a constant process of discovery. Eventually, I'll find a result that feels right — but only once it's staring back at me. The name of this piece is a tongue-in-cheek nod to Orson Scott Card’s 1985 science fiction novel, *Ender’s Game*, as well as to the countless outputs I’ve produced during this creative process. In the book, Ender trains relentlessly. Only once he's completed his final exam (what he believes to be another simulation) does he discover that it was actually real — the final battle to save humanity. In my own creative process, most of the steps along the path likewise feel like practise, with the satisfaction of achievement only revealing itself after the work stares back at me, complete. This has been one of my longest running creative processes to date, having been re-written and re-conceived many times over. It's worthy of the name. ## About This piece treads a balance between the abstract and the literal. The generative structure draws inspiration from cubism - procedurally generated curves of various complexity are grown, layered, intersected, and then broken into fragments of constantly shifting scale. Painting each fragment in turn reveals an abstraction of the original curves and lines, viewed through the algorithm's interpretation. Each fragment is illustrated using prominent, simple lines - a nod to the literal. These are rendered using ink-like outlines and bold, loose colour application. It draws inspiration from contemporary ink illustration, balanced against the natural precision of digital tools. Not completely organic, yet not completely digital. ## Keys: Number keys 1-4 - Debug views Number key 5 - Re-render from seed s - Download rendered image
**Please Note: The Dutch Auction will end with 13 tokens still remaining.** These are reserved for a collectors allow list that will remain open for 24 hours after the DA is complete. Renders Game is a note to myself on creativity. I will often believe strongly in an idea, yet, once realised, and I'm confronted with the reality of the output, it leaves me unsatisfied. So I take it apart, find a detail that I love, and grow something new from that tiny piece. It's a constant process of discovery. Eventually, I'll find a result that feels right — but only once it's staring back at me. The name of this piece is a tongue-in-cheek nod to Orson Scott Card’s 1985 science fiction novel, *Ender’s Game*, as well as to the countless outputs I’ve produced during this creative process. In the book, Ender trains relentlessly. Only once he's completed his final exam (what he believes to be another simulation) does he discover that it was actually real — the final battle to save humanity. In my own creative process, most of the steps along the path likewise feel like practise, with the satisfaction of achievement only revealing itself after the work stares back at me, complete. This has been one of my longest running creative processes to date, having been re-written and re-conceived many times over. It's worthy of the name. ## About This piece treads a balance between the abstract and the literal. The generative structure draws inspiration from cubism - procedurally generated curves of various complexity are grown, layered, intersected, and then broken into fragments of constantly shifting scale. Painting each fragment in turn reveals an abstraction of the original curves and lines, viewed through the algorithm's interpretation. Each fragment is illustrated using prominent, simple lines - a nod to the literal. These are rendered using ink-like outlines and bold, loose colour application. It draws inspiration from contemporary ink illustration, balanced against the natural precision of digital tools. Not completely organic, yet not completely digital. ## Keys: Number keys 1-4 - Debug views Number key 5 - Re-render from seed s - Download rendered image
Renders Game is a note to myself on creativity. I will often believe strongly in an idea, yet, once realised, and I'm confronted with the reality of the output, it leaves me unsatisfied. So I take it apart, find a detail that I love, and grow something new from that tiny piece. It's a constant process of discovery. Eventually, I'll find a result that feels right — but only once it's staring back at me. The name of this piece is a tongue-in-cheek nod to Orson Scott Card’s 1985 science fiction novel, *Ender’s Game*, as well as to the countless outputs I’ve produced during this creative process. In the book, Ender trains relentlessly. Only once he's completed his final exam (what he believes to be another simulation) does he discover that it was actually real — the final battle to save humanity. In my own creative process, most of the steps along the path likewise feel like practise, with the satisfaction of achievement only revealing itself after the work stares back at me, complete. This has been one of my longest running creative processes to date, having been re-written and re-conceived many times over. It's worthy of the name. ## About This piece treads a balance between the abstract and the literal. The generative structure draws inspiration from cubism - procedurally generated curves of various complexity are grown, layered, intersected, and then broken into fragments of constantly shifting scale. Painting each fragment in turn reveals an abstraction of the original curves and lines, viewed through the algorithm's interpretation. Each fragment is illustrated using prominent, simple lines - a nod to the literal. These are rendered using ink-like outlines and bold, loose colour application. It draws inspiration from contemporary ink illustration, balanced against the natural precision of digital tools. Not completely organic, yet not completely digital. ## Keys: Number keys 1-4 - Debug views Number key 5 - Re-render from seed s - Download rendered image
lerpColor(b,me?p:B?k:u,t+(me?0:l.num(-.1,.17)));o.strokeCap(l.choice([o.PROJECT,o.SQUARE,o.ROUND])),o.strokeWeight(m*a),o.stroke(c)}else o.strokeCap(o.ROUND),o.strokeWeight(m),o.stroke(b);o.beginShape(),o.vertex(a[0]+d,a[1]+d),o.vertex(g[0]+d,g[1]+d),o.endShape()})),o.strokeWeight(c),o.strokeCap(o.ROUND),e.poly[0].map(((l,r)=>{const s=e.poly[0][r+1]||e.poly[0][0],h=Ke(l,_e(t),P),c=i(o.constrain(-(h-a)*n,0,1)),g=o.lerpColor(d,me?p:u,c);o.stroke(g),o.beginShape(),o.vertex(...l),o.vertex(...s),o.endShape()})),o.colorMode(o.HSL)})(e,t),(e=>{let t=o.color(D.line[0]),n=l.num(-.4,.6);for(const i of e.triangles){if(i.drawFill){let e=te+-2;o.strokeJoin(o.ROUND),o.strokeWeight(ee+n),o.beginShape(),o.fill(t),o.noStroke(),i.tri.map((t=>o.vertex(t[0]+e,t[1]+e))),o.endShape(o.CLOSE)}if(i.drawFill){const e=-2+l.num(-.2,.2);o.noStroke(),o.fill(i.color),o.beginShape(),i.tri.map((t=>o.vertex(t[0]+e,t[1]+e))),o.endShape(o.CLOSE)}if((i.drawStroke||i.drawFill)&&(o.noFill(),o.stroke(D.line[0]),i.drawFill||o.strokeWeight(.75*ee+n),o.beginShape(),i.tri.map((e=>o.vertex(...e))),o.endShape(o.CLOSE)),i.decoration){let e=1;const t=l.num(.07,.15);for(;e>.01;){let l=Re(i.tri.map((e=>o.createVector(...e))),e);e-=t,o.noFill(),o.stroke(D.line[0]),o.strokeWeight(.75*ee+.75*n),o.beginShape(),l.map((e=>o.vertex(e.x,e.y))),o.endShape(o.CLOSE)}}}})(e)})),L&&(o.fill(X&&!N?D.base[D.base.length>1?1:0]:G||W?F:D.stroke[0]),o.noStroke(),o.rect(0,0,a,10.6),o.rect(0,0,10.6,s),o.rect(a-10.6,0,10.6,s),o.rect(0,s-10.6,a,20.6)),(()=>{const e=o.color(D.lowlight[0]),t=o.color(D.highlight[0]),n=200,i=[0,1100,10,.56],r=o.max(a,s)/2;for(let h=-200;h<s+n;h++)for(let c=-200;c<a+n;c++)if(l.bool(97)){l.bool(90)?o.blendMode(o.BLEND):l.bool(50)?o.blendMode(o.MULTIPLY):o.blendMode(o.SCREEN);const g=$e(c,h,0,50,4,.9),f=$e(c,h,...i)*n,d=$e(c,h,...i)*n,b=o.dist(c,h,a/2,s/2),u=o.map(b,0,.6*r,0,1,!0),m=[c+f-100,h+d-100],p=.63+l.num(-.18,.19);if(Oe(m,p)){const n=o.map(g,0,.7,.04,.05+.09*u,!0);e.setAlpha(n+.02),t.setAlpha(n-.02),o.fill(l.bool(40+25*u)?e:t),o.noStroke(),o.circle(...m,p)}}o.blendMode(o.BLEND)})(),!0)];Date.now(),document.complete=!1,new e((e=>{let r=0;l=new t(n),c=l.num(0,1e9),(e=>{e.noiseSeed(c),e.randomSeed(c),o=e})(e),Xe(),o.noiseSeed(A),Ue=[0,q,0==q?20:5,.6],qe=[0,q,8,.3],Ge=[0,200,8,.9],ze=[1e3,Ce,De,Fe],e.keyPressed=()=>{((e,t)=>{49===t&&(e.background(D.lowlight[0]),i.obj.map((e=>{(e=>{let t=o.color(D.lowlight[0]);t.setAlpha(.2),o.stroke(D.highlight[0]),o.fill(t),e.map((e=>{o.strokeWeight(.1),o.circle(e.x,e.y,2*e.r),o.strokeWeight(2),o.stroke(D.highlight[0]),o.point(e.x,e.y)}))})(e.packingCirlces)}))),50===t&&(e.background(D.lowlight[0]),i.obj.map(((e,t)=>{((e,t=1,n=l.choice(D.accent))=>{o.stroke(n),o.strokeWeight(t),o.noFill(),o.beginShape(),e.map((e=>o.vertex(...e))),o.endShape(o.CLOSE)})(e.hobbyVerts.map((e=>[e.x,e.y])),.2*t,D.highlight[0])}))),51===t&&(e.background(D.lowlight[0]),((e=Ke,t=[],n=2,l=0)=>{const i=o.color(D.highlight[0]);for(let r=0;r<s;r++)for(let s=0;s<a;s++){const a=e([s,r],...t);i.setAlpha(a/n-l/2),o.stroke(i),o.strokeWeight(.8),o.point(s,r)}})()),52===t&&(()=>{o.background(D.lowlight[0]);const e=Qe(...ze),t=e.max-e.min,n=t/2*Ae,l=-t*Me,i=e.mean-n+l,r=e.mean+n+l;console.table(e),console.table({dynamicRange:t,compression:n,highlowpass:l,min:i,max:r});const h=o.color(D.highlight[0]);o.strokeWeight(.4);for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=x(o.map($e(t,e,...ze),i,r,0,1,!0));h.setAlpha(n),o.stroke(h),o.point(t,e)}})(),53===t&&window.location.reload(),80==t&&console.table(Xe()),83==t&&e.saveCanvas(h,n,"png")})(e,e.keyCode)},e.setup=()=>{var t;t=e.createCanvas(g,f,e.P2D),h=t,e.pixelDensity(2),e.colorMode(e.HSL)},e.draw=()=>{e.scale(g/a),ht[r]()&&(r+1<ht.length?r++:(e.noLoop(),document.complete=!0))}}));
t n=0;n<e.length;n++)t+=e[n][0]*e[(n+1)%e.length][1],t-=e[n][1]*e[(n+1)%e.length][0];return o.abs(t)/2}const{stringify:Te}=JSON;let Ue,qe,Ge,ze,Je={};function $e(e,t,n=0,l=10,i=3,r=.6,a=0){return o.noiseDetail(i,r),o.noise((e+0+a)/l,(t+0+a)/l,(n+0+a)/l)}function Qe(e=0,t=10,n=3,l=.6,o=0){if(Je[Te(arguments)])return Je[Te(arguments)];let i=[],r={mean:null,average:0,max:-1,min:1};for(let e=a;e--;)for(let t=s;t--;){let n=$e(e,t,...arguments);n>r.max&&(r.max=n),n<r.min&&(r.min=n),i.push(n),r.average+=n}i.sort(((e,t)=>e-t));const h=Math.floor(i.length/2);return r.mean=i.length%2?i[h]:(i[h-1]+i[h])/2,r.average/=i.length,Je[Te(arguments)]=r,r}const _e=e=>G>0?(i.obj.length-(e+1))/i.obj.length*z:0,Ke=(e,t=0,n=!0,l=Ue)=>{const i=Qe(...l);0==ne&&(n=!1);let r=Ze(e,t);const a=o.map($e(...e,...l),o.lerp(i.min,i.mean,ne+.2),o.lerp(i.mean,i.max,ne-.2),0,1,!0);return n?o.min(r,a):r},Ze=(e,t=0,n=!0)=>{if(0==G)return 1;const l=o.dist(e[0],0,a/2,0)+t,i=o.dist(e[1],0,s/2,0)+t,r=[0,50,1,.5],h=2.2+.5*G,c=o.map(o.constrain($e(0,e[1],...r),0,1),0,1,0,40),g=o.map(o.constrain($e(e[0],0,...r),0,1),0,1,0,40),f=E(o.map(l+(n?c:0),a/h,a/1.5,1,0,!0)),d=E(o.map(i+(n?g:0),s/h,s/1.5,1,0,!0));return Math.min(f*d,f,d)};function et(e,t){if(0===t)return e;const n=e.length,l=e.map(((t,l)=>[[.75*t[0]+.25*e[(l+1)%n][0],.75*t[1]+.25*e[(l+1)%n][1]],[.25*t[0]+.75*e[(l+1)%n][0],.25*t[1]+.75*e[(l+1)%n][1]]])).flat();return 1===t?l:et(l,t-1)}function tt(e,t,n,l){var o,i,r,a,s,h,c,g,f,d,b=e[t][0],u=e[t][1],m=e[n][0],p=e[n][1],k=e[l][0],w=e[l][1],E=Math.abs(u-p),x=Math.abs(p-w);return E<9.5367431640625e-7?i=(a=-(k-m)/(w-p))*((o=(m+b)/2)-(h=(m+k)/2))+(g=(p+w)/2):x<9.5367431640625e-7?i=(r=-(m-b)/(p-u))*((o=(k+m)/2)-(s=(b+m)/2))+(c=(u+p)/2):(o=((r=-(m-b)/(p-u))*(s=(b+m)/2)-(a=-(k-m)/(w-p))*(h=(m+k)/2)+(g=(p+w)/2)-(c=(u+p)/2))/(r-a),i=E>x?r*(o-s)+c:a*(o-h)+g),{i:t,j:n,k:l,x:o,y:i,r:(f=m-o)*f+(d=p-i)*d}}function nt(e){let t,n,l,o,i,r;for(n=e.length;n;)for(o=e[--n],l=e[--n],t=n;t;)if(r=e[--t],i=e[--t],l===i&&o===r||l===r&&o===i){e.splice(n,2),e.splice(t,2);break}}const lt=function(e,t,n){const l=1/t,o=1/n;return Math.min(4,((3-l)*l**2*e+o**3)/(l**3*e+(3-o)*o**2))},ot=(e,t,n,l,o)=>Math.min(4,(2+Math.sqrt(2)*(e-n/16)*(n-e/16)*(t-l))/(1.5*o*(2+(Math.sqrt(5)-1)*t+(3-Math.sqrt(5))*l))),it=(e,t)=>{const n=Math.sin(e.theta),l=Math.cos(e.theta),o=Math.sin(t.phi),i=Math.cos(t.phi),r=t.leftY,a=e.rightY,s=ot(n,l,o,i,r),h=ot(o,i,n,l,a);e.rightX=e.x+(e.deltaX*l-e.deltaY*n)*s,e.rightY=e.y+(e.deltaY*l+e.deltaX*n)*s,t.leftX=t.x-(e.deltaX*i+e.deltaY*o)*h,t.leftY=t.y-(e.deltaY*i-e.deltaX*o)*h};function rt(e,t=D.lowlight[0],n=a/2,l=s/2,i=13/r,h=D.highlight[0]){t&&o.background(D.lowlight[0]),o.textFont("Helvetica Neue"),o.textSize(i);const c=o.textWidth(e);o.fill(h),o.text(e,n-c/2,l-i/2)}let at=0,st=0,ht=[()=>{for(let e=0;e<le;e++)i.obj.push({});return!0},()=>{rt(`Dreaming ${o.floor((at+1)/le*100)}%`);const e=i.obj[at],t=at;J&&($&&t>=i.obj.length-Q-1||!$&&t<=i.obj.length-Q-1)&&(e.lineType=1);let n=[],r=[];const h=o.lerp(re,ae,t/i.obj.length)/2,c=o.floor(o.lerp(oe,ie,t/(i.obj.length-1)));let g=0,f=0;const d=a/pe,b=(s-a)/2;for(;r.length<c&&f<d*ke;){const e=d-f,t=l.int(-h-b,a+h+b),i=l.int(-h,s+h);let c=!0;g++;for(const n of r)if(o.dist(t,i,n.x,n.y)<e+n.r){c=!1;break}g>4e3&&(f+=5,g=0),c&&(g=0,r.push({x:t,y:i,r:e}),n.push(o.createVector(t,i)))}let u=[];for(let e=0;e<de;e++){const e=l.int(15,30),t=l.int(a*be,a*ue),n=-t/2,i=l.int(0+n,a-n),r=l.int(0+n,s-n),h=l.num(t/20,t/2),c=l.num(.5,2);for(let n=0;n<e;n++){const a=t+o.map(l.dec(),0,1,-h,h);u.push(Ne(i,r,a,a*c,o.map(n,0,e,0,o.TWO_PI)))}}return e.line=[...n,...u],we&&(e=>{if(e.length<=1)return e;for(let t=0;t<e.length;t++){const n=l.int(t,e.length-1);[e[t],e[n]]=[e[n],e[t]]}})(e.line),e.packingCirlces=r,at++,at>=i.obj.length},()=>(rt("Preparing"),!0),()=>{rt(`Sketching ${o.floor((st+1)/le*100)}%`);const e=Qe(...qe),t=Qe(...Ge),n=st,r=i.obj[n];let a=1==r.lineType?-Z/(1e5*K):l.num(ce,ge);r.hobbyCurves=((e,{tension:t=1,cyclic:n=!1}={})=>{const l=((e,t=1,n=!1)=>{const l=e.map((({x:e,y:n})=>((e,t,n)=>({x:e,y:t,leftY:n,rightY:n,leftX:n,rightX:n,deltaX:0,deltaY:0,delta:0,theta:0,phi:0,psi:0}))(e,n,t))),o=l[0],i=l[l.length-1];for(let e=0;e<l.length;e++)l[e].next=l[e+1]??o,l[e].prev=l[e-1]??i;((e,t)=>{const n=t?e.length:e.length-1;for(let t=0;t<n;t++){const n=e[t],l=e[t+1]??e[0];n.deltaX=l.x-n.x,n.deltaY=l.y-n.y,n.delta=Math.hypot(n.deltaX,n.deltaY)}})(l,n),((e,t)=>{const[n,l]=t?[0,e.length]:[1,e.length-1];for(let t=n;t<l;t++){const n=e[t],l=n.prev,o=l.deltaY/l.delta,i=l.deltaX/l.delta;n.psi=Math.atan2(n.deltaY*i-n.deltaX*o,n.deltaX*i+n.deltaY*o)}})(l,n),function(e,t){const n=[],l=[],o=[],i=e[0],r=e[1],a=e[e.length-1],s=t?e.length+1:e.length;if(t)n[0]=0,o[0]=0,l[0]=1;else{const e=i.next,t=i.rightX,a=Math.abs(e.leftY),s=Math.abs(i.rightY);n[0]=lt(t,s,a),o[0]=-r.psi*n[0],l[0]=0}for(let r=1;r<s;r++){const h=e[r]??i,c=h.next,g=h.prev,f=r===s-1;if(!t&&f){const e=h.leftX,t=Math.abs(h.leftY),l=Math.abs(g.rightY),i=lt(e,t,l);a.theta=-o[s-2]*i/(1-i*n[s-2]);break}{let e=1/(3*Math.abs(g.rightY)-1),a=h.delta*(3-1/Math.abs(g.rightY)),d=1/(3*Math.abs(c.leftY)-1),b=g.delta*(3-1/Math.abs(c.leftY));const u=1-n[r-1]*e;a*=u;const m=Math.abs(h.leftY),p=Math.abs(h.rightY);m<p?a*=(m/p)**2:b*=(p/m)**2;let k=b/(b+a);n[r]=k*d;let w=-c.psi*n[r];if(k=(1-k)/u,w-=h.psi*k,k*=e,o[r]=w-o[r-1]*k,l[r]=-l[r-1]*k,t&&f){let e=0,t=1;for(let i=r-1;i>=0;i--){const r=0===i?s-1:i;e=o[r]-e*n[r],t=l[r]-t*n[r]}e/=1-t,i.theta=e,o[0]=e;for(let t=1;t<s-1;t++)o[t]=o[t]+e*l[t];break}}}for(let t=s-2;t>=0;t-=1)e[t].theta=o[t]-e[t].next.theta*n[t]}(l,n),(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.phi=-n.psi-n.theta}})(l);const r=n?l.length:l.length-1;for(let e=0;e<r;e++)it(l[e],l[e].next);return l})(e,t,n),o=[],i=n?l.length:l.length-1;for(let e=0;e<i;e++){const t=l[e];o.push({sc:{x:t.rightX,y:t.rightY},ec:{x:t.next.leftX,y:t.next.leftY},pt:{x:t.next.x,y:t.next.y}})}return o})(r.line,{tension:a,cyclic:!0}),r.hobbyVerts=((e,t=10,n=ye,l=ze)=>{let i,r=[];const a=Qe(...l),s=a.max-a.min,h=s/2*Ae,c=-s*Me,g=a.mean-h+c,f=a.mean+h+c;for(let a=0;a<e.length;a++){const s=e[a],h=a>=e.length-1?e[0]:e[a+1];let c=[];for(let e=0;e<1;e+=n){let r=o.bezierPoint(h.pt.x,h.ec.x,h.sc.x,s.pt.x,e),a=o.bezierPoint(h.pt.y,h.ec.y,h.sc.y,s.pt.y,e);const d=$e(r,a,...l),b=x(o.map(d,g,f,xe,Ee,!0));(i&&o.dist(r,a,i.x,i.y)>t*b||null==i)&&(i=o.createVector(r,a),c.push(i)),Oe([r,a],250)||(e+=10*n)}i=null,r=[...r,...c.reverse()]}return r})(r.hobbyCurves,o.lerp(1==r.lineType?he/2:he,se,(i.obj.length-n)/i.obj.length)),r.drawOutline=1==r.lineType?l.bool(_):n<i.obj.length-3?l.bool(R):l.bool(V),r.layerColour=l.choice(D.base);const s=r.hobbyVerts.map((e=>[e.x,e.y])),h=[[...s,s[0]]];let c=function(e,t){let n,l,o,i,r,a,s,h,c,g,f,d=e.length,b=[];if(d<3)return[];for(e=e.slice(0),n=d;n--;)b[n]=n;for(b.sort((function(t,n){var l=e[n][0]-e[t][0];return 0!==l?l:t-n})),o=function(e){let t,n,l,o,i,r=0,a=0,s=0,h=0;for(let t=e.length;t--;)e[t][0]<r&&(r=e[t][0]),e[t][0]>s&&(s=e[t][0]),e[t][1]<a&&(a=e[t][1]),e[t][1]>h&&(h=e[t][1]);return t=s-r,n=h-a,l=Math.max(t,n),o=r+.5*t,i=a+.5*n,[[o-20*l,i-l],[o,i+20*l],[o+20*l,i-l]]}(e),e.push(o[0],o[1],o[2]),i=[tt(e,d+0,d+1,d+2)],r=[],a=[],n=b.length;n--;a.length=0){for(f=b[n],l=i.length;l--;)s=e[f][0]-i[l].x,s>0&&s*s>i[l].r?(r.push(i[l]),i.splice(l,1)):(h=e[f][1]-i[l].y,s*s+h*h-i[l].r>9.5367431640625e-7||(a.push(i[l].i,i[l].j,i[l].j,i[l].k,i[l].k,i[l].i),i.splice(l,1)));for(nt(a),l=a.length;l;)g=a[--l],c=a[--l],i.push(tt(e,c,g,f))}for(n=i.length;n--;)r.push(i[n]);for(i.length=0,n=r.length;n--;)r[n].i<d&&r[n].j<d&&r[n].k<d&&i.push([r[n].i,r[n].j,r[n].k]);return i}(s).map((e=>e.map((e=>[s[e][0],s[e][1]])))).filter((e=>!fe||function(e,t){let n=0,l=0,o=0,i=0,r=0,a=0,s=0,h=0,c=null,g=null;const f=e[0],d=e[1],b=t.length;for(;n<b;n++){l=0;const b=t[n].length-1,u=t[n];if(c=u[0],c[0]!==u[b][0]&&c[1]!==u[b][1])throw new Error("First and last coordinates in a ring must be the same");for(r=c[0]-f,a=c[1]-d;l<b;l++)if(g=u[l+1],h=g[1]-d,a<0&&h<0||a>0&&h>0)c=g,a=h,r=c[0]-f;else{if(s=g[0]-e[0],h>0&&a<=0){if(i=r*h-s*a,i>0)o+=1;else if(0===i)return 0}else if(a>0&&h<=0){if(i=r*h-s*a,i<0)o+=1;else if(0===i)return 0}else if(0===h&&a<0){if(i=r*h-s*a,0===i)return 0}else if(0===a&&h<0){if(i=r*h-s*a,0===i)return 0}else if(0===a&&0===h){if(s<=0&&r>=0)return 0;if(r<=0&&s>=0)return 0}c=g,a=h,r=s}}return o%2!=0}(Ve(e),h)));return r.poly=h,r.triangles=c.map((i=>{const a=Ve(i),s=Ze(a,_e(n)),h=$e(...a,...qe),c=$e(...a,...Ge);return{tri:i.map((e=>{const t=5*$e(...e,0,q,3,.5),n=5*$e(...e,0,1.1*q,3,.5);return[e[0]+t-2.5,e[1]+n-2.5]})),color:D.base[o.round(o.map(c,t.min+.1,t.max-.1,0,D.base.length-1,!0))],drawStroke:l.bool(o.map(h,o.lerp(e.min,e.mean,ne-.2),o.lerp(e.mean,e.max,ne+.2),0,v*s,!0)),drawFill:l.bool(o.map(Ke(a),0,1,0,j*s*(1==r.lineType?10:1),!0))}})),st++,st>=i.obj.length},()=>{rt("Illustrating");const e=[0,q,6,.9,1e3],t=Qe(...e),n=Re;return i.obj.map(((r,a)=>{N&&(r.triangles=r.triangles.filter((e=>{let t=!0;for(let n of e.tri)if(!Oe(n,-10.6*O)){t=!1;break}return t}))),r.drawOutline&&(r.poly=[et(r.poly[0],1)],o.color(D.highlight[0]).setAlpha(o.map(a,0,i.obj.length-1,.05,.9,!0))),r.triangles.map((i=>{const r=Ve(i.tri);i.tri=n(i.tri.map((e=>o.createVector(...e))),l.num(.98,1)).map((e=>[e.x,e.y]));const a=$e(...r,...e);return a>t.max-Se&&(i.tri=et(i.tri,o.floor(o.map(a,t.min,t.max,4,5,!0)))),i}))})),!0},()=>{let e=[];for(let t=0;t<o.min(i.obj.length,5);t++)e=[...e,...i.obj[i.obj.length-t-1].triangles];const t=e.filter((e=>e.drawFill&&Oe(Ve(e.tri)))).sort(((e,t)=>He(e.tri)-He(t.tri)));for(let e=0;e<T;e++){const n=t[t.length-1-e];n&&(e<5||l.bool(U)?n.color=l.choice(D.accent):n.decoration=!0)}return!0},()=>(o.background(F),i.obj.map(((e,t)=>{e.drawOutline&&((e,t)=>{if(0==t)return;const n=me?2.5:2,i=w,r=.84-l.num(-.01,.01),a=.82-l.num(-.01,.01),s=me?1:B?.6:.92,h=B?.8:.86;let c=ee*l.num(3,H);const g=l.choice(D.line),f=l.choice(D.stroke),d=o.color(f),b=o.color(g),u=o.color(F),m=c+ee+te,p=o.color(f),k=o.color(D.highlight[0]);p.setAlpha(0),o.stroke(b),o.strokeWeight(m),o.noFill(),o.colorMode(o.RGB),e.poly[0].map(((a,c)=>{const g=e.poly[0][c+1]||e.poly[0][0],f=Ke(a,_e(t),P);let d=.3;if(f<=r){const e=-(f-r)*n,t=i(o.constrain(e,0,s)),a=o.map(e,.4,1,1,h,!0);d=o.map(e,.5,1,.3,.15,!0);const c=o.
let e=window.p5;class t{constructor(e){this.useA=!1,this.hash=e;let t=function(e){let t=parseInt(e.substr(0,8),16),n=parseInt(e.substr(8,8),16),l=parseInt(e.substr(16,8),16),o=parseInt(e.substr(24,8),16);return function(){t|=0,n|=0,l|=0,o|=0;let e=(t+n|0)+o|0;return o=o+1|0,t=n^n>>>9,n=l+(l<<3)|0,l=l<<21|l>>>11,l=l+e|0,(e>>>0)/4294967296}};console.log("Using hash: "+this.hash),this.prngA=t(this.hash.substr(2,32)),this.prngB=t(this.hash.substr(34,32));for(let e=0;e<1e6;e+=2)this.prngA(),this.prngB()}dec(){return this.useA=!this.useA,this.useA?this.prngA():this.prngB()}num(e,t){return e+(t-e)*this.dec()}int(e,t){return Math.floor(this.num(e,t))}bool(e=50){return this.dec()<e/100}choice(e){return e[this.int(0,e.length)]}easedDec(e){return e(this.dec())}easedInt(e,t,n){return Math.floor(this.easedNum(e,t,n))}easedNum(e,t,n){return t+(n-t)*this.easedDec(e)}weightedChoice(...e){let t=0,n=[];for(t=0;t<e.length;t++)n[t]=e[t][0]+(n[t-1]||0);const l=this.dec()*n[n.length-1];for(t=0;t<n.length&&!(n[t]>l);t++);return e[t][1]}}let n;n="undefined"!=typeof tokenData?"string"==typeof tokenData?tokenData:tokenData.hash:function(){const e=new URLSearchParams(globalThis.location.search).get("hash");if(e)return e;let t="0x";for(var n=0;n<64;n++)t+=Math.floor(16*Math.random()).toString(16);return window.tokenData={hash:t},t}();let l=null,o=null,i={obj:[]},r=null,a=null,s=null,h=null,c=null,g=null,f=null,d=[{name:"Sin",bg:["#ece1cf"],stroke:["#ece1cf"],line:["#131F2A"],highlight:["#fff"],lowlight:["#05080B"],base:["#ece1cf"],accent:["#ece1cf","#ece1cf","#be2a19"]},{name:"Beach",bg:["#DDC7B1"],stroke:["#F4E8DC"],line:["#131F2A"],highlight:["#fff"],lowlight:["#05080B"],base:["#e9d2bc"],accent:["#3c534b","#45525c","#b2780f","#d6966a","#a2b6ad"]},{name:"Citronello",bg:["#BBB7A5"],stroke:["#f3efdd"],line:["#162022"],highlight:["#E6E3D6"],lowlight:["#05080B"],base:["#E6E3D6","#DAD7C8","#D2CEBC","#efd492"],accent:["#f8d46e","#86A2BB","#95333c"]},{name:"Poster",bg:["#8b8b89"],stroke:["#F2F1ED"],line:["#162022"],highlight:["#fff"],lowlight:["#05080B"],base:["#dddbd1","#dddbd1","#babfb6","#B0B4AC"],accent:["#f8d46e","#de786f","#70955a","#505b7f"]},{name:"Dark Crystals",bg:["#C3BFB1"],stroke:["#dddbd1"],line:["#16232C"],highlight:["#fff"],lowlight:["#000"],base:["#dddbd1","#e3e0d5","#d2d6e2"],accent:["#066278","#e28a91","#eac4c5","#f2cd43","#d94939","#e9aa26","#0b2732","#065773","#e7d4da"]},{name:"Stone",bg:["#9e9995"],stroke:["#F0EDE6"],line:["#0D0F12"],highlight:["#F0EDE6"],lowlight:["#000"],base:["#F0EDE6","#9e9995","#b4b0a7","#d8d2c4","#F0EDE6"],accent:["#1A191F","#443F3F"]},{name:"Charcoal",bg:["#C1C3C8"],stroke:["#E1E4EA"],line:["#000"],highlight:["#fff"],lowlight:["#000"],base:["#E1E4EA","#E1E4EA","#62646A","#62646A","#2F3237"],accent:["#14171E","#22252A"]},{name:"Accents",bg:["#2963A2"],stroke:["#2963A2"],line:["#14171E"],highlight:["#fff"],lowlight:["#000"],base:["#2963A2","#2963A2"],accent:["#14171E","#F4C1C4","#ECAA13","#DB4D2C","#088969"]},{name:"Frank Minimal",bg:["#C3BAAC"],line:["#1F2228"],highlight:["#fff"],lowlight:["#05080B"],base:["#d7d2c9","#edeae2"],stroke:["#edeae2"],accent:["#181e3e","#1d3359","#dfa82e","#be2a19","#e0a453","#2d5d7d"]},{name:"Beige Box",bg:["#E2DDCD"],line:["#1d1e20"],highlight:["#fff"],lowlight:["#05080B"],base:["#E2DDCD"],stroke:["#C96997"],accent:["#7f716c","#e08f38","#679e6b","#6889ba","#e9c835"]},{name:"Master",bg:["#d7d2c9"],suitability:["Giant","Deconstruct"],line:["#25211d"],highlight:["#fff"],lowlight:["#05080B"],base:["#d7d2c9"],stroke:["#e8dddc"],accent:["#b9792a","#9fc6e1","#7287a4","#25574a","#98aea0","#e35a2e"]},{name:"Aubergine Mono",bg:["#7858A2"],stroke:["#7858A2"],line:["#1A191F"],highlight:["#fff"],lowlight:["#000"],base:["#9377B5","#8B6EB0","#7858A2","#684c8c"],accent:["#684c8c"]},{name:"New York Autumn",bg:["#e4d7cb"],stroke:["#EECD91"],line:["#141517"],highlight:["#fff"],lowlight:["#000"],base:["#e6d4c7","#ebe1d1"],accent:["#3e5e57","#bcb174","#4b79a0","#5f4c30","#e0c0b0","#e4af50","#eecc61","#b7555a","#af474a"]},{name:"Aged",bg:["#eadcbb"],stroke:["#F0EBE0"],line:["#282625"],highlight:["#F0EBE0"],lowlight:["#000"],base:["#EBE5D6","#eadcbb","#DBCCA9","#C0B291"],accent:["#d97142","#447d5b","#AA3631","#e3a841","#d3b29f","#32626f"]},{name:"Ink & Colour",bg:["#d0d3d7"],stroke:["#F1F0EE"],line:["#1b201d"],highlight:["#F1F0EE"],lowlight:["#000"],base:["#DFE0E2","#d0d3d7","#C4C9CF"],accent:["#d94c41","#4e4374","#e8abb5","#33584b","#1e2b3b","#b5843c"]},{name:"Flare",bg:["#ecdac3"],stroke:["#d6d3d1"],line:["#1F1E1E"],highlight:["#FFFDF4"],lowlight:["#060102"],base:["#eae9dd","#ecdac3"],accent:["#2d68a5","#e3bc48","#35695f","#d04b29"]},{name:"Screenprint",bg:["#d9c8af"],stroke:["#e4d4ca"],line:["#37252A"],highlight:["#FFFDF4"],lowlight:["#271D20"],base:["#c18596","#9c5a72","#894f65"],accent:["#677885","#e7a33e"]},{name:"Henri",bg:["#eee5d7"],stroke:["#8b93c1"],line:["#221f20"],highlight:["#f4f3e7"],lowlight:["#221f20"],base:["#f4f3e7","#ebdecc"],accent:["#d14434","#dd924c","#d6a146","#1a4249","#e7b4a6"]},{name:"Henri Dark",bg:["#eee5d7"],stroke:["#d78c7a"],line:["#221f20"],highlight:["#f4f3e7"],lowlight:["#221f20"],base:["#f1dfc6"],accent:["#2a646f","#1e4c4a","#e9af5f","#8cacb7","#295d7c"]},{name:"Olivetti",bg:["#1d1e20"],darkBg:!0,line:["#231e1a"],highlight:["#f4f3e7"],lowlight:["#231e1a"],stroke:["#e08f38"],base:["#E2DDCD","#b9b5aa","#726e6d"],accent:["#e08f38","#679e6b","#6889ba","#db6438","#C96997","#e9c835"]},{name:"Rand-ey",bg:["#14171e"],darkBg:!0,line:["#151418"],highlight:["#fff"],lowlight:["#14171e"],stroke:["#e6e0d2"],base:["#686e6e","#e9d9d2","#e6e0d2"],accent:["#c03145","#295b86","#6e548b","#e8940e","#077152"]},{name:"Fisherprice",bg:["#9e9995"],highlight:["#fff"],lowlight:["#0D0F12"],line:["#1A191F"],stroke:["#F0EDE6"],base:["#b4b0a7","#d8d2c4","#F0EDE6","#9e9995"],accent:["#F4C1C4","#2963A2","#ECAA13","#DB4D2C","#088969"]}];const{pow:b,cos:u,sin:m,sqrt:p,PI:k}=Math,w=e=>e*e*e,E=e=>e*e*e*e*e,x=e=>1-u(e*k/2),y=e=>m(e*k/2);function C(e,t){let n=null;for(const l in t){let t=parseFloat(l);t<=e&&(n=t)}return t[n]}let D,F,A,M,S={},B=!1,Y="default",j=60,v=60,I=!0,L=!1,W=!1,X=!1,N=!0,O=1,R=80,P=!1,V=100,H=16,T=0,U=70,q=200,G=1,z=140,J=!1,$=!1,Q=1,_=0,K=6,Z=700,ee=1.5,te=1.9,ne=0,le=10,oe=6,ie=6,re=2e3,ae=1e3,se=15,he=10,ce=1,ge=1,fe=!0,de=0,be=.35,ue=1.2,me=!1,pe=2.5,ke=.99,we=!1,Ee=1,xe=1,ye=.0013,Ce=800,De=3,Fe=.6,Ae=1,Me=0,Se=0;const Be=()=>{let e=l.num(-.4,-.15);const t=l.num(-.05,.05);ce=e,ge=e+t,I||(ce=Math.abs(ce),ge=Math.abs(ge))},Ye=e=>{M=e,le=Math.floor(le/e*1.5),Z*=.6*e,T*=e,ie*=.8*e,oe*=.8*e,be/=.8*e,ue/=.8*e,he/=2.5*e,se/=e,ee+=e/5,te+=e/5,pe*=e,ye*=.8*e},je=()=>{Ce=l.num(40,100),De=2,Fe=.7,Ee=l.num(.21,1.1),xe=l.num(.19,.21),Ae=l.num(.5,.1),Me=l.easedNum(x,-.21,-.12),I||(xe*=2.75,Ee*=1.9)};let ve=e=>{Y="Filled",I=l.bool(50),Be(),je(),U=l.int(20,80),T=l.bool(4)?0:l.easedInt(y,150,500),le=l.int(8,14),z=100,he=9,se=9,de=l.bool(30)?0:l.easedInt(x,1,3),ie=l.int(15,25)-de,oe=l.int(15,25)-de,H=6,Z=l.int(560,710),q=l.int(100,1e3),Se=l.num(0,.25),me=l.bool(35),me&&(N=!0),G=l.bool(30)?l.num(.05,.4):0,re=l.int(100,300),ae=l.int(100,300),P=!1,ne=l.bool(5)?l.num(.03,.1):0,v=0,j=500,me||(L=!0),G>0&&!me&&l.bool(60)&&(G*=1.8),0==G&&(N=l.bool(35),N&&(L=!0)),!e&&l.bool(20)&&Ye(l.num(2,2.5))},Ie=()=>{ve(!0),Be(),Y="Giant",we=!0,de=0,T=l.easedInt(y,100,400),U=l.int(30,60),Z=710,ie=l.int(15,20),oe=l.int(8,15),ae=l.num(300,1e3),re=600,G=0,R=0,V=0,H=10,Ee=l.num(10,15),xe=l.num(.17,.2),Ce=l.int(30,150),Me=-.1,he=l.int(100,210),se=l.int(500,800),j=93,v=30,fe=l.bool(90),ne=0,L=l.bool(50),W=!0,N=!1,he<190&&l.bool(60)&&(L=!1,N=!0,O=1.25,V=0),X=!0,l.bool(30)&&!M&&(le*=1.5,Ye(l.num(1.9,2.1)))},Le=()=>{Y="Deconstruct",Be(),pe=l.num(2,4),J=!0,$=!0,_=0,Q=l.int(3,5),K=l.num(1,2.7),U=l.int(30,60),T=l.easedInt(y,100,250),le=8,ie=l.int(8,10),oe=l.int(8,10),de=1,R=10,H=4,Z=l.int(700,710),Se=l.num(0,.3),me=!0,G=l.num(.6,1.35),N=!0,O=1.5,re=l.easedInt(x,0,800),ae=l.easedInt(x,0,450),P=G>0,ne=l.bool(50)?0:.01,q=l.num(100,1200),j=500,v=5,Ee=50,xe=.15,Ce=l.int(80,200),Me=-.15,he=l.num(80,150),se=l.num(80,150),0==G&&(L=l.bool(50)),fe=l.bool(87),l.bool(30)&&Ye(l.num(1.7,2))},We=()=>{je(),Be(),Y="Fragment",N=!1,U=l.int(30,90),T=l.bool(5)?0:l.int(100,250),le=l.int(7,10),de=l.bool(20)?0:l.int(0,2),ie=l.easedInt(x,15,25)-1.5*de,oe=l.easedInt(x,15,25)-1.5*de,V=80,Ee=l.num(.8,1.8),xe=l.num(.5,.8),H=5,Z=l.int(690,700),q=l.int(400,1e3),Se=l.num(0,.3),me=!1,G=0,re=l.int(0,600),ae=l.int(0,600),P=G>0,ne=0,v=5,j=l.bool(5)?l.num(40,50):l.num(65,90),L=!0,Me=l.num(-.18,-.05),fe=l.bool(95),l.bool(40)&&(ee-=.5,te-=.5,Ye(l.num(2,2.1)))};function Xe(){A=l.int(0,9e9);let e=l.weightedChoice([50,ve],[15,We],[25,Ie],[20,Le]);pe=l.num(3,6),ke=l.num(.2,.4),e();let t=d.filter((e=>!e.suitability||!e.suitability.includes(Y)));D=l.choice(t),D.darkBg&&(B=!0,me&&(me=!1,L=!0),"Filled"==Y&&G>0&&(G/=2),"Deconstruct"==Y&&(R=0)),F=l.choice(D.bg),((e=700)=>{o&&(a=o.floor(.72*e),s=o.floor(e),o.windowWidth<.72*o.windowHeight?(f=o.ceil(o.windowWidth*(1/.72)),g=o.windowWidth+1):(f=o.ceil(o.windowHeight-0),g=o.ceil(.72*(o.windowHeight-0))+1),r=g/a)})(Z);let n="High",i="Medium",h="Tiny",c="Small",b="Large",u="Huge",m="Very High";return S={"Genome Base":Y,Palette:D.name,"Colours & Details":C(T,{0:"None",1:"Few",50:"Some",150:i,200:n,300:m,350:"Loads"}),"Pen Weight":C(Z,{500:b,600:i,700:c,730:h}),"Fragment Scale":C(he*xe,{0:h,2:c,5:i,15:b,8e3:u}),"Fragment Range":C(he*Ee,{0:h,2:c,5:i,15:b,30:u}),Scale:M?C(M,{0:i,2.1:c,2.3:h}):"Regular",Border:(()=>{let e="None";return G>0&&me?e="Natural":G>0&&!me?e="Construction lines":0==G&&L?e="Margin":N&&(e="Detail gap"),e})(),Tension:C(Math.abs(ce),{0:"Very Low",.2:"Low",.3:i,.4:n,.6:m}),"Contrast Range":C(Math.abs(Me),{0:"Light",.12:i,.18:"Strong",.25:"Mega"})},fe||(S.Straussian=!0),S}function Ne(e,t,n,l,i){let r=e+n/2*o.cos(i),a=t+l/2*o.sin(i);return o.createVector(r,a)}function Oe(e,t=0){return e[0]>-t&&e[0]<a+t&&e[1]>-t&&e[1]<s+t}function Re(t,n=1){let l=Pe(t),o=[];for(let i of t)o.push(e.Vector.lerp(l,i,n));return o}function Pe(e){let t=o.createVector(0,0);for(let n of e)t.add(n);return t.div(e.length)}function Ve(e){let t=Pe(function(e){let t=[];for(let n of e)t.push(o.createVector(n[0],n[1]));return t}(e));return[t.x,t.y]}function He(e){let t=0;for(le
0x85582125…5972·#16,306,059·0x5a86d10a…a8d5ce
MountVitruvius - 1/1'sAddress: call to non-contractAddress: call to non-contractAddress: low-level delegate call failedAddress: low-level delegate call failed
1-50 of 53