@joy-ride/joy-ride 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,7 +45,7 @@ vec3 scatterVehicleLight(vec3 baseColor, float density, vec2 canvasPoint, bool d
45
45
  float scattering = 1.0 - exp(-illumination * transmission * 1.28);
46
46
  return mix(ambient, lit, scattering * 0.65) + radiance * 0.045 * transmission;
47
47
  }
48
- `,bc=new Map,xc=0,Sc=96,Cc=new Map;function wc(){return[...bc.values()].reduce((e,t)=>e+t.bytes,0)+Cc.size*Sc*Sc*4}function Tc(e){let t=Cc.get(e);if(t)return t;let n=new Float32Array(9216),r=new Float32Array(1024);for(let t=0;t<r.length;t++)r[t]=us(e+71,t);let i=(e,t)=>{let n=Math.floor(e),i=Math.floor(t),a=e-n,o=t-i,s=a*a*(3-2*a),c=o*o*(3-2*o),l=(e,t)=>r[(e&31)+(t&31)*32];return(l(n,i)*(1-s)+l(n+1,i)*s)*(1-c)+(l(n,i+1)*(1-s)+l(n+1,i+1)*s)*c};for(let e=0;e<Sc;e++)for(let t=0;t<Sc;t++){let r=(t+.5)/Sc,a=(e+.5)/Sc,o=i(r*3+2,a*3+4)*.52+i(r*7+7,a*7+3)*.3+i(r*17,a*17)*.18,s=(r-.5)*2,c=(a-.5)*2,l=Math.hypot(s+(i(r*4,a*4)-.5)*.27,c+(i(r*4+5,a*4)-.5)*.27),u=Math.max(0,Math.min(1,(1-l)*3.5)),d=Math.max(0,o-.24)**1.4*u*u*(3-2*u);n[e*Sc+t]=d}return Cc.set(e,n),n}function Ec(e,t,n){let r=`${t}:${n}`,i=bc.get(r);if(i)return i.used=++xc,i.canvas;let a;if(typeof OffscreenCanvas<`u`)a=new OffscreenCanvas(Sc,Sc);else if(typeof document<`u`)a=document.createElement(`canvas`),a.width=a.height=Sc;else try{a=new e.canvas.constructor(Sc,Sc)}catch{return null}let o=a.getContext(`2d`);if(!o)return null;o.fillStyle=t,o.fillRect(0,0,1,1);let s=o.getImageData(0,0,1,1).data,c=o.createImageData(Sc,Sc),l=Tc(n);for(let e=0;e<l.length;e++)c.data[e*4]=s[0],c.data[e*4+1]=s[1],c.data[e*4+2]=s[2],c.data[e*4+3]=Math.round(l[e]*255);if(o.putImageData(c,0,0),bc.size>=64){let e=``,t=1/0;for(let[n,r]of bc)r.used<t&&(e=n,t=r.used);bc.delete(e)}return bc.set(r,{canvas:a,used:++xc,bytes:36864}),a}function Dc(e,t,n,r,i,a=[]){let o=t.dust??ds(t.x,t.y,t.size,t.seed),s=e.globalAlpha;for(let c of o.parcels){let o=c.radius*c.spread,l=c.z*.22;if(c.x+o*2<n.x||c.x-o*2>n.x+n.width||c.y+o*2<n.y||c.y-l-o*2>n.y+n.height)continue;let u=Math.max(0,Math.min(1,(c.z-1)/7)),d=i===`ground`?1-u:u;if(d===0)continue;let f=r?.12:.7,p=-2.3;for(let e of a){let t=vc(e,c);t>f&&(f=t,p=Math.atan2(e.point.y-c.y,e.point.x-c.x))}let m=Ec(e,t.color,c.seed&3);e.save(),e.translate(c.x,c.y-l);let h=Math.hypot(c.vx,c.vy),g=Math.atan2(Math.sin(Math.atan2(c.vy,c.vx)-c.angle),Math.cos(Math.atan2(c.vy,c.vx)-c.angle));e.rotate(c.angle+g*Math.min(.6,h/100));let _=Math.sqrt(1+Math.min(.8,h/220));if(e.globalAlpha=s*t.opacity*d*(c.mass*9)*.55/(c.spread*c.spread),m)e.drawImage(m,-o*_,-o/_,o*2*_,o*2/_);else{let n=e.createRadialGradient(0,0,0,0,0,o);n.addColorStop(0,t.color),n.addColorStop(1,`transparent`),e.fillStyle=n,e.fillRect(-o,-o,o*2,o*2)}m&&f>.8&&(e.globalCompositeOperation=`screen`,e.globalAlpha*=Math.min(.6,(f-.8)*.2),e.drawImage(m,-o*_,-o/_,o*2*_,o*2/_),e.globalCompositeOperation=`source-over`),e.restore();let v=t.glint??.12;if(v<=0||us(c.seed,45)>.42)continue;let y=Math.max(0,Math.cos(c.angle*2+p+us(c.seed,47)*6.28))**48,b=Math.min(1,v*5)*y*Math.min(1,f)*d*s*t.opacity;if(b<.035)continue;let x=c.x+(us(c.seed,49)-.5)*o*.7,S=c.y-l+(us(c.seed,51)-.5)*o*.7,C=.35+b*.7;e.save(),e.globalAlpha=b,e.fillStyle=r?`#fff2ce`:`#fffefa`,e.beginPath(),e.ellipse(x,S,C,C,0,0,Math.PI*2),e.fill(),b>.45&&(e.lineWidth=.35,e.strokeStyle=`#fff5d7`,e.beginPath(),e.moveTo(x-C*2.5,S),e.lineTo(x+C*2.5,S),e.moveTo(x,S-C*2.5),e.lineTo(x,S+C*2.5),e.stroke()),e.restore()}}function Oc(e,t,n){let r=e.size,i=r*.74,a=0,o=0,s=0;for(let c=0;c<6;c++){let l=t*(c+.5)/6*2,u=n*(c+.5)/6*2,d=e.curlX*l*l*l+e.twist*n*2*l*l,f=e.curlY*u*u*u-e.twist*t*1.3*u*u;a+=Math.cos(d)*r*t/6,o+=Math.cos(f)*i*n/6,s+=Math.sin(d)*r*t/6+Math.sin(f)*i*n/6}let c=Math.max(0,t+n-.62);s+=c*c*r*(.35+e.fold);let l=Math.cos(e.tilt),u=Math.sin(e.tilt);return{x:a,y:o*l-s*u,z:o*u+s*l}}var kc=(e,t)=>{let n=Math.imul((e|0)&15^Math.imul(t+17,374761393),668265263);return n=Math.imul(n^n>>>13,1274126177),((n^n>>>16)>>>0)/4294967296},Ac=new Map,jc=new Map;function Mc(e){let t=Ac.get(e);if(t)return t;let n=e.replace(/^#/,``),r=/^[\da-f]{3}$/i.test(n)?[...n].map(e=>e+e).join(``):n,i=/^[\da-f]{6}$/i.test(r)?[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)):e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/)?.slice(1,4).map(Number)??[195,190,174];return Ac.size>=128&&Ac.delete(Ac.keys().next().value),Ac.set(e,i),i}function Nc(e,t){let n=Math.round(t),r=`${e}:${n}`,i=jc.get(r);if(i)return i;let a=`rgb(${Mc(e).map(e=>Math.max(0,Math.min(255,e+n))).join(` `)})`;return jc.size>=512&&jc.delete(jc.keys().next().value),jc.set(r,a),a}function Pc(e,t){e.beginPath(),t.forEach(([t,n],r)=>{r?e.lineTo(t,n):e.moveTo(t,n)}),e.closePath()}function Fc(e,t,n){let r=Math.max(0,t.z),i=1+Math.min(.65,r/90);e.save(),e.translate(t.x+r*.13,t.y+r*.1),e.rotate(t.angle),e.fillStyle=`#000`,e.globalAlpha=t.opacity*(n?.12:.15)/(1+r/26),e.beginPath(),e.ellipse(0,0,t.size*.46*i,t.size*.27*i,0,0,Math.PI*2),e.fill(),r<5&&(e.globalAlpha*=(1-r/5)*.6,e.beginPath(),e.ellipse(0,0,t.size*.36,t.size*.19,0,0,Math.PI*2),e.fill()),e.restore()}function Ic(e,t){let n=[];for(let e=0;e<=2;e++)n.push(Array.from({length:9},(n,r)=>Oc(t,r/8-.5,e/2-.5)));let r=t.z<.5?Math.max(0,-Math.min(...n.flat().map(e=>e.z))):0,i=e=>[e.x,e.y-(e.z+r)*.48],a=[];for(let e=0;e<2;e++)for(let t=0;t<8;t++){let r=n[e][t],i=n[e][t+1],o=n[e+1][t+1],s=n[e+1][t],c=i.x-r.x,l=i.y-r.y,u=i.z-r.z,d=s.x-r.x,f=s.y-r.y,p=s.z-r.z,m=l*p-u*f,h=u*d-c*p,g=c*f-l*d,_=Math.max(.001,Math.hypot(m,h,g)),v=g+h*.48>0,y=(m*-.35+h*-.45+Math.abs(g)*.7)/_;a.push({a:r,b:i,c:o,d:s,col:t,row:e,front:v,light:y,depth:(r.z+i.z+o.z+s.z)/4})}a.sort((e,t)=>e.depth-t.depth);for(let n of a){let{a:r,b:a,c:o,d:s,front:c,light:l,row:u,col:d}=n;if(Pc(e,[i(r),i(a),i(o),i(s)]),e.fillStyle=Nc(t.color,(c?0:-32)+(l-.7)*45),e.fill(),c&&d>0&&d<(u===0?6:8)&&u<3){e.strokeStyle=Nc(t.color,-100),e.lineWidth=t.size*(u===0?.027:.013);let n=i({x:(r.x+s.x)*.5,y:(r.y+s.y)*.5,z:(r.z+s.z)*.5}),c=i({x:(a.x+o.x)*.5,y:(a.y+o.y)*.5,z:(a.z+o.z)*.5});if(e.beginPath(),e.moveTo(...n),e.lineTo(...c),e.stroke(),u>0){let t=i({x:r.x*.2+s.x*.8,y:r.y*.2+s.y*.8,z:r.z*.2+s.z*.8}),n=i({x:a.x*.2+o.x*.8,y:a.y*.2+o.y*.8,z:a.z*.2+o.z*.8});e.beginPath(),e.moveTo(...t),e.lineTo(...n),e.stroke()}}}}function Lc(e,t){let n=[],r=.72+Math.abs(Math.cos(t.tilt))*.28;for(let e=0;e<9;e++){let i=e/9*Math.PI*2,a=t.size*(.32+kc(t.seed,e+20)*.18);n.push([Math.cos(i)*a,Math.sin(i)*a*r])}let i=[(kc(t.seed,33)-.5)*t.size*.17,(kc(t.seed,34)-.5)*t.size*.18];for(let r=0;r<n.length;r++){Pc(e,[i,n[r],n[(r+1)%n.length]]);let a=(kc(t.seed,r+40)-.45)*72+Math.sin(t.tilt+r)*9;e.fillStyle=Nc(t.color,a),e.fill()}e.strokeStyle=Nc(t.color,-45),e.lineWidth=.35,e.globalAlpha*=.3;for(let r of[1,4,6])e.beginPath(),e.moveTo(...n[r]),e.lineTo(i[0]+t.size*.08,i[1]),e.stroke()}function Rc(e,t){let n=t.size,r=t.size*(.35+kc(t.seed,51)*.25),i=Math.cos(t.tilt);e.scale(1,Math.abs(i)<.1?.1:i),Pc(e,[[-n*.5,-r*.5],[-n*.43,-r*.31],[-n*.49,-r*.08],[-n*.42,r*.12],[-n*.48,r*.48],[-n*.28,r*.38],[n*.3,r*.43],[n*.5,r*.52],[n*.44,r*.21],[n*.5,-r*.02],[n*.43,-r*.22],[n*.49,-r*.52],[n*.28,-r*.38],[-n*.28,-r*.4]]),e.fillStyle=i<0?`#b9c1c3`:Nc(t.color,24),e.fill(),Pc(e,[[-n*.3,-r/2],[n*.3,-r*.43],[n*.21,r*.35],[-n*.2,r*.4]]),e.fillStyle=Nc(t.color,-16),e.fill(),e.fillStyle=`#e4decd`,e.fillRect(-n*.15,-r*.14,n*.27,r*.19),e.strokeStyle=Nc(t.color,65),e.lineWidth=.45,e.globalAlpha*=.45;for(let t of[-1,1])e.beginPath(),e.moveTo(t*n*.3,-r*.35),e.lineTo(t*n*.38,r*.15),e.lineTo(t*n*.27,r*.35),e.stroke()}function zc(e,t){let n=t.size,r=t.size*(.35+kc(t.seed,61)*.2),i=Math.cos(t.tilt);if(e.scale(1,Math.abs(i)<.08?.08:i),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.bezierCurveTo(n*.12,r*.65,-n*.25,r*.45,-n*.48,0),e.fillStyle=Nc(t.color,i<0?14:0),e.fill(),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.quadraticCurveTo(0,-r*t.fold*.2,-n*.48,0),e.fillStyle=Nc(t.color,-13-t.fold*9),e.fill(),e.strokeStyle=Nc(t.color,-35),e.lineWidth=.45,e.globalAlpha*=.55,e.beginPath(),e.moveTo(-n*.63,r*.08),e.quadraticCurveTo(-n*.08,-r*t.fold*.2,n*.46,-r*.07),e.stroke(),n>10){e.lineWidth=.3;for(let t of[-.18,.08])e.beginPath(),e.moveTo(n*t,0),e.lineTo(n*(t+.1),-r*.3),e.moveTo(n*t,0),e.lineTo(n*(t-.03),r*.28),e.stroke()}}var Bc=new Map,Vc=0,Hc=0,Uc=()=>({sprites:Bc.size,bytes:Vc+wc()});function Wc(e,t){t.kind===`paper`?Ic(e,t):t.kind===`crumpled-paper`?Lc(e,t):t.kind===`trash`?Rc(e,t):t.kind===`leaf`&&zc(e,t)}function Gc(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);if(typeof document>`u`||typeof HTMLCanvasElement>`u`)return null;let t=document.createElement(`canvas`);return!(t instanceof HTMLCanvasElement)||!t.getContext?null:(t.width=t.height=e,t)}function Kc(e,t,n){if(t.kind===`dust`||t.z>.1||Math.abs(t.vz)>.1||Math.hypot(t.vx,t.vy)>.75||t.kind===`paper`&&Math.abs(t.curlVelocityX)+Math.abs(t.curlVelocityY)+Math.abs(t.twistVelocity)>.03)return!1;let r=Math.max(4,Math.round(t.size/4)*4),i=Math.round(t.fold*5)/5,a=t.kind===`crumpled-paper`?(Math.round(t.tilt/(Math.PI/4))%8+8)%8:Math.cos(t.tilt)<0?4:0,o=a*Math.PI/4;if(t.kind!==`crumpled-paper`&&Math.abs(Math.sin(t.tilt))>.015)return!1;let s=Math.round(t.curlX*4)/4,c=Math.round(t.curlY*4)/4,l=Math.round(t.twist*4)/4,u=`${s}:${c}:${l}:${t.kind}:${t.seed&15}:${t.color}:${r}:${i}:${a}:${n}`,d=Bc.get(u),f={...t,size:r,fold:i,tilt:o,curlX:s,curlY:c,twist:l,opacity:1};if(!d){let e=r*1.4+4,t=Math.ceil(e*n),i=t*t*4;if(Bc.size>=128||Vc+i>8388608){for(let[e,t]of Bc)if(!(Hc-t.used<120)&&(Bc.delete(e),`close`in t.canvas&&t.canvas.close(),Vc-=t.bytes,Bc.size<128&&Vc+i<=8388608))break}if(Bc.size<128&&Vc+i<=8388608){let r=Gc(t),a=r?.getContext(`2d`);r&&a&&(a.scale(n,n),a.translate(e/2,e/2),Wc(a,f),d={canvas:`transferToImageBitmap`in r?r.transferToImageBitmap():r,extent:e,bytes:i,used:Hc},Bc.set(u,d),Vc+=i)}}return e.scale(t.size/r,t.size/r),d?(d.used=Hc,e.drawImage(d.canvas,-d.extent/2,-d.extent/2,d.extent,d.extent)):(e.save(),Wc(e,f),e.restore()),!0}function qc(e,t,n,r,i=`ground`,a=[]){i===`ground`&&Hc++;let o=e.getTransform(),s=Math.min(8,Math.max(1,Math.ceil(Math.hypot(o.a,o.b)))),c=n.x+n.width,l=n.y+n.height;for(let o of t){if(o.opacity<=0)continue;let t=(o.dust?.radius??o.size)+Math.max(0,o.z)*.35;o.x+t<n.x||o.x-t>c||o.y+t<n.y||o.y-t>l||(o.kind===`dust`?Dc(e,o,n,r,i,a):(i===`ground`&&Fc(e,o,r),i===`ground`==o.z<4&&(e.save(),e.translate(o.x,o.y-Math.max(0,o.z)*.22),e.rotate(o.angle),e.globalAlpha=o.opacity,Kc(e,o,s)||Wc(e,o),e.restore())))}}function Jc(e){let{tireLengthM:t,tireWidthM:n}=e.geometry;return e.image?{length:t*(e.image.wheelVisualScale?.length??.64),width:n*(e.image.wheelVisualScale?.width??.82)}:{length:t,width:n}}function Yc(e,t,n,r,i){let a=Kt(t,e.naturalWidth,e.naturalHeight),o=Math.min(1,512/Math.max(a.source.width,a.source.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(a.source.width*o)),s.height=Math.max(1,Math.round(a.source.height*o));let c=s.getContext(`2d`);if(!c)return null;n?c.drawImage(n,0,0,s.width,s.height):c.drawImage(e,a.source.x,a.source.y,a.source.width,a.source.height,0,0,s.width,s.height),c.globalCompositeOperation=`source-in`,c.fillStyle=`#101916`,c.fillRect(0,0,s.width,s.height);let l=e=>{let t=Math.ceil(e*4),n=a.lengthM*r,o=a.widthM*r,c=document.createElement(`canvas`);c.width=Math.max(1,Math.ceil((n+t*2)*i)),c.height=Math.max(1,Math.ceil((o+t*2)*i));let l=c.getContext(`2d`);return l?(l.filter=`blur(${e*i}px)`,l.drawImage(s,t*i,t*i,n*i,o*i),{canvas:c,padding:t}):null};return{soft:l(6),close:l(1.5),pixelsPerMeter:r,lengthM:a.lengthM,widthM:a.widthM}}var Xc={width:128,height:60},Zc=8,Qc=14;function $c(e,t,n,r=Zc){let{width:i,height:a}=Xc,o=i/2,s=a/2,c=e.x-t.width/2,l=e.y-t.height/2,u=Math.hypot(c,l)||1,d={x:c/u,y:l/u},f=Math.max(0,t.width/2-o-Qc-Zc),p=Math.max(0,t.height/2-s-Qc-(l<0?r:Zc)),m=Math.min(Math.abs(c)?f/Math.abs(c):1/0,Math.abs(l)?p/Math.abs(l):1/0),h={x:t.width/2+c*(Number.isFinite(m)?m:0),y:t.height/2+l*(Number.isFinite(m)?m:0)},g=Math.min(Math.abs(d.x)?o/Math.abs(d.x):1/0,Math.abs(d.y)?s/Math.abs(d.y):1/0),_={x:d.x*g,y:d.y*g},v={x:_.x+d.x*Qc,y:_.y+d.y*Qc},y=Math.hypot(Math.max(0,-e.x,e.x-t.width),Math.max(0,-e.y,e.y-t.height))/Math.max(.001,n);return{center:h,direction:d,edge:_,tip:v,distance:y>=1e3?`${(y/1e3).toFixed(1)} km away`:`${Math.max(1,Math.round(y))} m away`,width:i,height:a}}var el=class{camera;constructor(e){this.camera=e}captureState(){return E({previousCarVelocity:this.previousCarVelocity,poseOffset:this.poseOffset,poseVelocity:this.poseVelocity,poseForce:this.poseForce,wheelPhase:this.wheelPhase})}restoreState(e){let t=E(e);this.previousCarVelocity=t.previousCarVelocity,this.poseOffset=t.poseOffset,this.poseVelocity=t.poseVelocity,this.poseForce=t.poseForce,this.wheelPhase=t.wheelPhase,this.clearMaterials()}clearMaterials(){this.carImages.clear(),this.pristineShadows=new WeakMap,this.deformedShadows=new WeakMap}reset(){this.markers=[],this.previousCarVelocity=null,this.poseOffset=D(),this.poseVelocity=D(),this.poseForce=D(),this.wheelPhase=[0,0,0,0]}carImages=new Map;pristineShadows=new WeakMap;deformedShadows=new WeakMap;previousCarVelocity=null;poseOffset=D();poseVelocity=D();poseForce=D();wheelPhase=[0,0,0,0];carVisualOffset(e){return A(N(D(this.poseOffset.x,-this.poseOffset.y),-e.body.angle),this.camera.zoom)}updateCarPose(e,t){if(e.mode!==`car`){this.previousCarVelocity=null,this.poseOffset=D(),this.poseVelocity=D(),this.poseForce=D();return}let n=e.body.velocity,r=this.previousCarVelocity?A(k(n,this.previousCarVelocity),1/Math.max(t,1e-4)):D();this.previousCarVelocity={...n};let i=N(r,-e.body.angle),a=1-Math.exp(-t/.11);this.poseForce=O(this.poseForce,A(k(D(P(i.x,-15,15),P(i.y,-15,15)),this.poseForce),a));let o=D(P(-this.poseForce.x*.006,-.055,.055),0);this.poseVelocity=O(this.poseVelocity,A(k(A(k(o,this.poseOffset),65),A(this.poseVelocity,15)),t)),this.poseOffset=O(this.poseOffset,A(this.poseVelocity,t)),e.car.tires.forEach((n,r)=>{this.wheelPhase[r]=(this.wheelPhase[r]+t*Math.abs(n.wheelSurfaceSpeedMps)/Math.max(.18,e.car.preset.geometry.tireLengthM*.45))%1})}line(e,t,n,r,i=1){let a=this.camera.screen(t),o=this.camera.screen(n);e.strokeStyle=r,e.lineWidth=i,e.beginPath(),e.moveTo(a.x,a.y),e.lineTo(o.x,o.y),e.stroke()}outline(e,t,n){e.beginPath(),t.forEach((t,n)=>{let r=this.camera.screen(t);n?e.lineTo(r.x,r.y):e.moveTo(r.x,r.y)}),e.closePath(),e.fillStyle=`${n}15`,e.fill(),e.strokeStyle=n,e.lineWidth=2,e.stroke()}imageFor(e){let t=e.image?.src;if(!t)return null;let n=this.carImages.get(t);return n||(n=new Image,n.crossOrigin=`anonymous`,n.src=t,this.carImages.set(t,n)),n.complete&&n.naturalWidth?n:null}markers=[];markerAt(e){return[...this.markers].reverse().find(t=>Math.abs(e.x-t.x)<=t.width/2+3&&Math.abs(e.y-t.y)<=t.height/2+3)?.vehicle??null}drawVehicleMarkers(e,t,n,r){if(this.markers=[],n)for(let n of t){let{sim:i}=n;if(i.mode!==`car`||i.car.explodedAt!==null)continue;let a=O(this.camera.screen(i.body.position),n===t[0]?this.carVisualOffset(i):D()),o=Math.max(i.car.preset.geometry.lengthM,i.car.preset.geometry.widthM)*this.camera.zoom*.5;if(a.x+o>=0&&a.x-o<=this.camera.width&&a.y+o>=0&&a.y-o<=this.camera.height)continue;let s=$c(a,this.camera,this.camera.zoom,this.camera.overlay?84:8),{width:c,height:l}=s,{x:u,y:d}=s.center;this.markers.push({vehicle:n,x:u,y:d,width:c,height:l});let f=n===r,p=f?`#f05a4f`:`#a9c5d4`;e.save(),e.translate(u,d),e.shadowColor=`#0000004a`,e.shadowBlur=16,e.shadowOffsetY=4,e.fillStyle=`#192126f5`,e.beginPath(),e.roundRect(-c/2,-l/2,c,l,l/2),e.fill(),e.shadowColor=`transparent`,e.strokeStyle=`#ffffff40`,e.lineWidth=1,e.stroke(),e.save(),e.beginPath(),e.arc(-38,0,23,0,Math.PI*2),e.clip(),e.fillStyle=`#313c42`,e.fillRect(-61,-23,46,46),e.strokeStyle=`#ffffff68`,e.lineWidth=1.2,e.setLineDash([5,5]),e.beginPath(),e.moveTo(-38,-23),e.lineTo(-38,23),e.stroke(),e.setLineDash([]);let m=this.imageFor(i.car.preset);if(e.save(),e.translate(-38,0),e.rotate(-i.body.angle),m){let t=Kt(i.car.preset,m.naturalWidth,m.naturalHeight),n=39*t.widthM/t.lengthM;e.drawImage(m,t.source.x,t.source.y,t.source.width,t.source.height,-39/2,-n/2,39,n)}else e.fillStyle=`#edf2f2`,e.beginPath(),e.roundRect(-14,-6,28,12,5),e.fill();e.restore(),e.restore(),e.strokeStyle=`#ffffffa8`,e.lineWidth=1.3,e.beginPath(),e.arc(-38,0,23,0,Math.PI*2),e.stroke(),e.fillStyle=`#f7f9fa`,e.font=`700 10px ui-sans-serif, system-ui, sans-serif`,e.textAlign=`left`,e.textBaseline=`middle`,e.fillText(f?`YOUR CAR`:`AI CAR`,-7,-9),e.fillStyle=`#b6c4c9`,e.font=`500 9px ui-sans-serif, system-ui, sans-serif`,e.fillText(s.distance,-7,8);let{direction:h,edge:g,tip:_}=s;e.strokeStyle=p,e.lineWidth=2.5,e.lineCap=`round`,e.beginPath(),e.moveTo(g.x+h.x*2,g.y+h.y*2),e.lineTo(_.x-h.x*5,_.y-h.y*5),e.stroke(),e.fillStyle=p,e.beginPath(),e.moveTo(_.x,_.y),e.lineTo(_.x-h.x*9-h.y*5,_.y-h.y*9+h.x*5),e.lineTo(_.x-h.x*9+h.y*5,_.y-h.y*9-h.x*5),e.closePath(),e.fill(),e.restore()}}shadowFor(e,t,n){let r=this.imageFor(e);if(!r)return null;let i=Kt(e,r.naturalWidth,r.naturalHeight),a=t?.spriteFor(r,i)??null,o=Math.max(1,Math.round(this.camera.zoom/2)*2),s=`${JSON.stringify(e.image?.crop)}|${e.image?.scale}|${e.geometry.lengthM}:${e.geometry.widthM}|${o}:${n}`;if(t&&a){let i=`${s}|${t.geometryRevision}`,c=this.deformedShadows.get(t);if(c?.image===r&&c.key===i)return c.shadow;let l=Yc(r,e,a,o,n);return this.deformedShadows.set(t,{image:r,key:i,shadow:l}),l}let c=this.pristineShadows.get(r);c||(c=new Map,this.pristineShadows.set(r,c));let l=c.get(s);return l||(l=Yc(r,e,a,o,n),c.set(s,l),c.size>12&&c.delete(c.keys().next().value)),l}vehicleBodyPath(e,t,n,r,i){if(!i?.hasDamage){e.roundRect(-t/2,-n/2,t,n,r);return}let a=Math.min(r,n/2),o=[{x:t/2-a,y:-n/2+a,start:-Math.PI/2},{x:t/2-a,y:n/2-a,start:0},{x:-t/2+a,y:n/2-a,start:Math.PI/2},{x:-t/2+a,y:-n/2+a,start:Math.PI}],s=!0;for(let t of o)for(let n=0;n<=8;n++){let r=t.start+n*Math.PI/16,o=D(t.x+Math.cos(r)*a,t.y+Math.sin(r)*a),c=i.point(A(o,1/this.camera.zoom)),l=c.x*this.camera.zoom,u=c.y*this.camera.zoom;s?(e.moveTo(l,u),s=!1):e.lineTo(l,u)}e.closePath()}carGround(e,t,n,r,i){performance.now();let a=t.body,o=t.car.preset.geometry,s=this.camera.screen(a.position),c=o.lengthM*this.camera.zoom,l=o.widthM*this.camera.zoom,u=P(M(this.poseForce)/13,0,1),d=e.globalAlpha;e.save(),e.translate(s.x,s.y),e.rotate(-a.angle),e.save(),e.translate(-this.poseOffset.x*this.camera.zoom*.2+2,this.poseOffset.y*this.camera.zoom*.2+4);let f=i?this.shadowFor(t.car.preset,n,r):null;if(f){let t=f.lengthM*this.camera.zoom,n=f.widthM*this.camera.zoom,r=this.camera.zoom/f.pixelsPerMeter,i=(i,a)=>{let o=i.padding*r;e.drawImage(i.canvas,-t/2-o,-n/2+a-o,t+o*2,n+o*2)};e.globalAlpha=d*(.43+u*.05),f.soft&&i(f.soft,3),e.globalAlpha=d*.14,f.close&&i(f.close,2)}else if(i){e.fillStyle=`rgba(13, 20, 20, ${.18+u*.045})`,e.shadowColor=`rgba(8, 14, 16, 0.43)`,e.shadowBlur=12+u*5,e.shadowOffsetY=2,e.beginPath();let r=t.car.preset.visual,i=r?l*.86:l*.84,a=r?r.shape===`suv`?9:r.shape===`supercar`?24:19:l*.34;this.vehicleBodyPath(e,r?c:c*.96,i,a,n),e.fill()}e.restore(),t.car.tires.forEach((n,r)=>{let i=Jc(t.car.preset),o=i.length*this.camera.zoom,s=i.width*this.camera.zoom;e.save(),e.translate(n.local.x*this.camera.zoom,-n.local.y*this.camera.zoom),e.rotate(-n.angle),e.fillStyle=`#121719`,e.beginPath(),e.roundRect(-o/2,-s/2,o,s,Math.min(3.5,s*.33)),e.fill(),e.save(),e.beginPath(),e.roundRect(-o/2+1,-s/2+1,o-2,s-2,Math.min(3,s*.3)),e.clip();let c=this.wheelPhase[r]??0,l=n.spinning?1:P(M(a.velocity)/24,0,.65),u=Math.max(4.2,o/4);e.strokeStyle=n.spinning?`rgba(170, 181, 178, 0.38)`:`rgba(125, 139, 137, 0.34)`,e.lineWidth=n.spinning?2:1.25;for(let t=-3;t<=4;t++){let n=t*u+c*u;e.beginPath(),e.moveTo(n-l*2,-s*.31),e.lineTo(n+l*2,s*.31),e.stroke()}l>.2&&(e.fillStyle=`rgba(137, 150, 147, ${.08+l*.1})`,e.fillRect(-o*.4,-s*.09,o*.8,s*.18)),e.restore(),e.strokeStyle=`rgba(6, 10, 11, 0.8)`,e.lineWidth=1.2,e.beginPath(),e.roundRect(-o/2,-s/2,o,s,Math.min(3.5,s*.33)),e.stroke(),e.restore()}),e.restore()}car(e,t,n,r,i){let a=n.car.preset,o=a.geometry,s=this.imageFor(a);if(s){let n=this.camera.screen(t.position),o=Kt(a,s.naturalWidth,s.naturalHeight),c=r?.spriteFor(s,o);e.save(),e.translate(n.x,n.y),e.rotate(-t.angle),qa(e,a,this.camera.zoom,o.lengthM,o.widthM,i),c?e.drawImage(c,-o.lengthM*this.camera.zoom/2,-o.widthM*this.camera.zoom/2,o.lengthM*this.camera.zoom,o.widthM*this.camera.zoom):e.drawImage(s,o.source.x,o.source.y,o.source.width,o.source.height,-o.lengthM*this.camera.zoom/2,-o.widthM*this.camera.zoom/2,o.lengthM*this.camera.zoom,o.widthM*this.camera.zoom),e.restore();return}if(a.visual){this.styledCar(e,t,n,r);return}let c=o.lengthM/2,l=o.widthM/2,u=[D(-c,-l),D(c,-l),D(c,l),D(-c,l)].map(e=>t.world(e));this.outline(e,u,`#8ce6c5`),this.line(e,t.world(D(o.wheelbaseM/4,-o.trackWidthM/2)),t.world(D(o.wheelbaseM/4,o.trackWidthM/2)),`#8ce6c5`,2),this.center(e,t,`#8ce6c5`)}exhaustOutlets(e){let t=e.car.preset,n=this.imageFor(t),r=n?Kt(t,n.naturalWidth,n.naturalHeight).lengthM:t.geometry.lengthM,i=t.exhaust.layout,a=t.geometry.widthM*.3;return(i===`left-right`?[-a,a]:i===`left`?[-a]:i===`right`?[a]:[0]).map(e=>D(-r/2-.025,e))}exhaust(e,t){let n=this.camera.screen(t.body.position);e.save(),e.translate(n.x,n.y),e.rotate(-t.body.angle);let r=this.exhaustOutlets(t);for(let t of r)e.fillStyle=`rgba(25, 31, 33, 0.62)`,e.beginPath(),e.ellipse(t.x*this.camera.zoom,-t.y*this.camera.zoom,Math.max(1.3,this.camera.zoom*.065),Math.max(1.2,this.camera.zoom*.055),0,0,Math.PI*2),e.fill();e.restore()}styledCar(e,t,n,r){let{geometry:i,visual:a}=n.car.preset;if(!a)return;let o=this.camera.screen(t.position),s=i.lengthM*this.camera.zoom,c=i.widthM*this.camera.zoom*.86,l=a.shape===`suv`?9:a.shape===`supercar`?24:19;e.save(),e.translate(o.x,o.y),e.rotate(-t.angle),e.beginPath(),this.vehicleBodyPath(e,s,c,l,r),e.fillStyle=a.color,e.fill(),e.strokeStyle=`rgba(18, 29, 27, 0.72)`,e.lineWidth=2,e.stroke(),e.fillStyle=`rgba(16, 32, 36, 0.8)`;let u=s*(a.shape===`suv`?.52:a.shape===`supercar`?.32:.4),d=c*(a.shape===`suv`?.72:.64),f=a.shape===`supercar`?-s*.08:-s*.015;e.beginPath(),e.roundRect(f-u/2,-d/2,u,d,a.shape===`suv`?7:14),e.fill(),e.strokeStyle=`rgba(235, 245, 241, 0.58)`,e.lineWidth=2,e.beginPath(),e.moveTo(f+u*.16,-d/2+3),e.lineTo(f+u*.16,d/2-3),e.stroke(),e.fillStyle=`rgba(255, 246, 205, 0.9)`;let p=tt(n.car.preset);for(let t of[-1,1])e.beginPath(),e.ellipse(p.headlights.xM*this.camera.zoom,t*p.headlights.yM*this.camera.zoom,4,3,0,0,Math.PI*2),e.fill();e.fillStyle=`rgba(139, 28, 21, 0.88)`;for(let t of[-1,1])e.fillRect(p.taillights.xM*this.camera.zoom-2,t*p.taillights.yM*this.camera.zoom-3,4,6);e.restore()}ship(e,t,n){let r=n.ship,i=r.craft,a=t.world(r.counterweight);this.line(e,t.world(O(r.counterweight,D(r.radius))),t.world(O(i,D(-.6))),`#ff6262`,2);let o=this.camera.screen(a);e.beginPath(),e.arc(o.x,o.y,r.radius*this.camera.zoom,0,Math.PI*2),e.fillStyle=`#ff626215`,e.fill(),e.strokeStyle=`#ff6262`,e.lineWidth=2,e.stroke();let s=[D(1.2),D(-.6,-.8),D(-.6,.8)].map(e=>t.world(O(i,N(e,r.headAngle))));this.outline(e,s,`#ff6262`),this.center(e,t,`#ff6262`)}brick(e,t){this.outline(e,[D(-2,-1),D(2,-1),D(2,1),D(-2,1)].map(e=>t.world(e)),`#f6bd79`),this.center(e,t,`#f6bd79`)}center(e,t,n){let r=this.camera.screen(t.position);e.fillStyle=n,e.beginPath(),e.arc(r.x,r.y,3,0,Math.PI*2),e.fill(),!this.camera.overlay&&M(t.velocity)>.1&&this.line(e,t.position,O(t.position,A(t.velocity,.35)),`#658da0`)}};function tl(e,t,n){return n?D(n.x+n.width/2,n.y+n.height/2):D(e/2,t/2)}function nl(e,t,n){let r=tl(e,t,n);return Math.ceil(2*Math.hypot(Math.max(r.x,e-r.x),Math.max(r.y,t-r.y)))}function rl(e,t,n,r){return O(n,N(k(e,t),r))}function il(e,t,n,r){return O(t,N(k(e,n),-r))}function al(e,t,n){return A(D(e,t),n/2)}function ol(e,t,n,r){return e+Math.atan2(Math.sin(t-e),Math.cos(t-e))*(r<=0?1:1-Math.exp(-Math.max(0,n)/r))}function sl(e,t,n){return{x:e.x<n?e.x-n:e.x>t.width-n?e.x-(t.width-n):0,y:e.y<n?e.y-n:e.y>t.height-n?e.y-(t.height-n):0}}var cl={};function ll(e,t={x:0,y:0},n=1){let r=Go();return{x:e.left/n+r.x+t.x,y:e.top/n+r.y+t.y,width:e.width/n,height:e.height/n}}var ul={scale:1,viewportRectToDocument:ll},dl=`[data-jr-overlay],[data-jr-ui],[data-jr-touch-controls],[data-jr-embed],script,style,link`,fl=class{scale=1;signature=``;originals=new Map;viewportRectToDocument(e,t={x:0,y:0}){return ll(e,t,this.scale)}apply(e,t){let n=Go(),r=`${e}:${t.x}:${t.y}:${n.x}:${n.y}:${document.body.children.length}`;if(r!==this.signature||cl.owner!==this){this.signature=r;for(let r of Array.from(document.body.children))if(r instanceof HTMLElement&&!r.matches(dl)){if(!this.originals.has(r)){this.originals.set(r,{translate:r.style.translate,scale:r.style.scale,origin:r.style.transformOrigin});let e=0,t=0;for(let n=r;n;n=n.offsetParent)e+=n.offsetLeft,t+=n.offsetTop;r.style.transformOrigin=`${-e}px ${-t}px`}r.style.scale=String(e),r.style.translate=`${n.x-t.x*e}px ${n.y-t.y*e}px`}this.scale=e,cl.owner=this}}clear(){for(let[e,t]of this.originals)e.style.translate=t.translate,e.style.scale=t.scale,e.style.transformOrigin=t.origin;this.originals.clear(),this.signature=``,this.scale=1,cl.owner===this&&(cl.owner=void 0)}};function pl(e,t,n){let r=Math.min(Math.max(1,t.width-32)/Math.max(1,e.width+160),Math.max(1,t.height-32)/Math.max(1,e.height+160));return Math.max(.1,Math.min(3,n??r))}function ml(e,t){let n=null;for(let r of e){let e=r.bounds;t.x<e.x||t.y<e.y||t.x>=e.x+e.width||t.y>=e.y+e.height||(!n||n.element.contains(r.element)||!r.element.contains(n.element)&&e.width*e.height<n.bounds.width*n.bounds.height)&&(n=r)}return n}var hl=class{projection;regions=[];measuredAt=-1/0;constructor(e=ul){this.projection=e}at(e,t,n){return n-this.measuredAt>120&&(this.measuredAt=n,this.regions=Array.from(document.querySelectorAll(`[data-jr-camera],[data-jr-camera-zoom]`)).filter(e=>!e.closest(`[data-jr-ui],[data-jr-overlay]`)).flatMap(e=>{let n=e.getAttribute(`data-jr-camera`);if(n!==null&&n!==`fixed`&&n!==`follow`)return[];let r=this.projection.viewportRectToDocument(e.getBoundingClientRect(),t);if(r.width<=0||r.height<=0)return[];let i=e.getAttribute(`data-jr-camera-zoom`),a=i?.trim()?Number(i):NaN;return n===null&&(!Number.isFinite(a)||a<=0)?[]:[{element:e,bounds:r,fixed:n===`fixed`,zoom:Number.isFinite(a)&&a>0?a:void 0}]})),ml(this.regions.filter(e=>e.element.isConnected),e)}reset(){this.regions=[],this.measuredAt=-1/0}},gl={minimumScale:.58,startsAtMps:3,fullAtMps:20,responsePerSecond:4};function _l(e,t,n,r,i){return e===`auto`?t&&!n&&(r.x<0||r.y<0||r.x>i.width||r.y>i.height):e}var vl=class{overlay;canvasWorld;requestResize;constructor(e,t,n){this.overlay=e,this.canvasWorld=t,this.requestResize=n,e&&(this.originScroll=D(window.scrollX,window.scrollY),this.observedScroll={...this.originScroll},this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight})}resize(){this.requestResize()}get pixelSpace(){return this.overlay||this.canvasWorld}get timeSeconds(){return this.lastFrame/1e3}rebaseTime(e){this.lastFrame=e}captureState(){return E({outputWidth:this.outputWidth,outputHeight:this.outputHeight,cameraRotation:this.cameraRotation,cameraLock:this.cameraLock,cameraSmoothing:this.cameraSmoothing,cameraLockInitialized:this.cameraLockInitialized,width:this.width,height:this.height,dpr:this.dpr,smokeMargin:this.smokeMargin,regionScale:this.regionScale,canvasWorldScale:this.canvasWorldScale,cameraFrame:this.cameraFrame,camera:this.camera,zoom:this.zoom,baseZoom:this.baseZoom,speedScale:this.speedScale,slowMoScale:this.slowMoScale,zoomAnchor:this.zoomAnchor,pageSize:this.pageSize,lastFrame:this.lastFrame,speedSamples:this.speedSamples,originScroll:this.originScroll,observedScroll:this.observedScroll,virtualScroll:this.virtualScroll,followInterrupted:this.followInterrupted,deadZone:this.deadZone,speedZoom:this.speedZoom,speedZoomMinimumScale:this.speedZoomMinimumScale})}restoreState(e){let t=E(e);this.vehicleReveal=null,this.outputWidth=t.outputWidth,this.outputHeight=t.outputHeight,this.cameraRotation=t.cameraRotation,this.cameraLock=t.cameraLock,this.cameraSmoothing=t.cameraSmoothing,this.cameraLockInitialized=t.cameraLockInitialized,this.width=t.width,this.height=t.height,this.dpr=t.dpr,this.smokeMargin=t.smokeMargin,this.regionScale=t.regionScale,this.canvasWorldScale=t.canvasWorldScale,this.cameraFrame=t.cameraFrame,this.camera=t.camera,this.zoom=t.zoom,this.baseZoom=t.baseZoom,this.speedScale=t.speedScale,this.slowMoScale=t.slowMoScale,this.zoomAnchor=t.zoomAnchor,this.pageSize=t.pageSize,this.lastFrame=t.lastFrame,this.speedSamples=t.speedSamples,this.originScroll=t.originScroll,this.observedScroll=t.observedScroll,this.virtualScroll=t.virtualScroll,this.followInterrupted=t.followInterrupted,this.deadZone=t.deadZone,this.speedZoom=t.speedZoom,this.speedZoomMinimumScale=t.speedZoomMinimumScale}restorePresentation(){this.setVirtualScroll({...this.virtualScroll}),this.overlay&&(window.scrollTo(this.observedScroll.x,this.observedScroll.y),Ko(),this.resize(),this.cameraRegions.reset(),this.activeCameraRegion||this.regionScale!==1?this.pageScene.apply(this.regionScale,this.sceneScroll()):this.pageScene.clear())}reset(){this.vehicleReveal=null,this.camera=D(),this.cameraLockInitialized=!1,this.speedScale=1,this.slowMoZoom=1,this.zoomAnchor=D(),this.overlay&&(this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight}),this.pageScene.clear(),this.activeCameraRegion=null,this.cameraRegions.reset(),this.regionScale=this.canvasWorld?this.canvasWorldScale:1,this.resize(),this.setVirtualScroll(D()),this.speedSamples=[]}vehicleReveal=null;revealVehicle(e,t=550){this.overlay&&(this.syncScroll(),this.followInterrupted=!0,this.vehicleReveal={sim:e,start:this.sceneScroll(),started:null,duration:t})}advanceVehicleReveal(e,t){let n=this.vehicleReveal;if(!n)return;n.started??=e;let r=n.duration<=0?1:P((e-n.started)/n.duration,0,1),i=r*r*(3-2*r),a=k(this.documentPoint(n.sim.body.position),D(this.width/2,this.height/2));!this.virtualScroll.x&&a.x>=-this.width/2&&a.x<=this.pageSize.width-this.width/2&&(a.x=P(a.x,0,Math.max(0,this.pageSize.width-this.width))),!this.virtualScroll.y&&a.y>=-this.height/2&&a.y<=this.pageSize.height-this.height/2&&(a.y=P(a.y,0,Math.max(0,this.pageSize.height-this.height))),this.moveSceneTo(O(n.start,A(k(a,n.start),i))),r===1&&(this.vehicleReveal=null,n.sim===t&&(this.followInterrupted=!1))}resetFollow(){this.vehicleReveal=null,this.overlay&&(this.originScroll=D(window.scrollX,window.scrollY),this.observedScroll={...this.originScroll},this.followInterrupted=!1)}dispose(){this.vehicleReveal=null,this.pageScene.clear(),this.setVirtualScroll(D()),Ko()}resizeLayout(e,t,n){this.outputWidth=e,this.outputHeight=t;let r=this.canvasWorld&&this.cameraLock,i=r?nl(e,t,this.cameraFrame):0,a=(r?i:e)/this.regionScale,o=(r?i:t)/this.regionScale;this.overlay&&this.width>1&&(a!==this.width||o!==this.height)&&(this.originScroll.x+=(this.width-a)/2,this.originScroll.y+=(this.height-o)/2),this.width=a,this.height=o;let s=Math.min(e,t);this.baseZoom=this.canvasWorld?28:this.overlay?Math.max(14,Math.min(28,s/11)):Math.max(1,Math.min(s<600?32:28,(s-32)/10,s/25)),this.zoom=this.baseZoom*(this.canvasWorld?1:this.speedScale*(this.overlay?1:this.slowMoZoom)),this.overlay&&this.regionScale===1&&!this.virtualScroll.x&&!this.virtualScroll.y&&this.speedScale>.999&&(this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight}),this.smokeMargin=this.canvasWorld?96/this.regionScale:this.pixelSpace?Math.min(112,Math.max(72,Math.min(this.width,this.height)*.1)):0;let c=this.width*this.height;this.dpr=Math.min(2*(this.canvasWorld?this.regionScale:1),n*this.regionScale,Math.sqrt(24e6/c),16384/Math.max(this.width,this.height))}outputWidth=1;outputHeight=1;cameraRotation=0;cameraLock=!1;cameraSmoothing=.25;cameraLockInitialized=!1;width=1;height=1;dpr=1;smokeMargin=0;pageScene=new fl;cameraRegions=new hl(this.pageScene);get documentProjection(){return this.pageScene}activeCameraRegion=null;regionScale=1;canvasWorldScale=1;cameraFrame=null;camera=D();zoom=28;baseZoom=28;speedScale=1;slowMoScale=1;get slowMoZoom(){return this.slowMoScale??1}set slowMoZoom(e){this.slowMoScale=e}zoomAnchor=D();pageSize={width:1,height:1};lastFrame=0;speedSamples=[];originScroll=D();observedScroll=D();virtualScroll=D();followInterrupted=!1;deadZone=!0;speedZoom=`auto`;speedZoomMinimumScale=gl.minimumScale;screen(e){return D(this.width/2+(e.x-this.camera.x)*this.zoom,this.height/2-(e.y-this.camera.y)*this.zoom)}world(e){return D(this.camera.x+(e.x-this.width/2)/this.zoom,this.camera.y-(e.y-this.height/2)/this.zoom)}vehicleViewportPosition(e){return this.overlay&&this.syncScroll(),this.screen(e)}sceneScroll(){return this.canvasWorld?D(this.camera.x*28-this.width/2,-this.camera.y*28-this.height/2):O(Go(),this.virtualScroll)}virtualOffset(){return{...this.virtualScroll}}documentPoint(e){return this.canvasWorld?an(e):(this.overlay&&this.syncScroll(),O(this.screen(e),this.sceneScroll()))}worldFromDocument(e){return this.canvasWorld?on(e):(this.overlay&&this.syncScroll(),this.world(k(e,this.sceneScroll())))}documentScale(){return this.canvasWorld?28:this.zoom}particlePoint(e){return this.pixelSpace?this.documentPoint(e):{...e}}particleScale(){return this.pixelSpace?this.documentScale():1}viewportSize(){return{width:this.width,height:this.height}}presentationScale(){return this.regionScale}setCanvasWorldScale(e,t=1.5){if(!this.canvasWorld)return;this.canvasWorldScale=Math.max(.2,Math.min(Math.max(.2,Math.min(4,Number.isFinite(t)?t:1.5)),Number.isFinite(e)?e:1));let n=this.canvasWorldScale*this.speedScale*this.slowMoZoom;this.regionScale!==n&&(this.regionScale=n,this.resize())}setCameraFrame(e){this.cameraFrame=e,this.canvasWorld&&this.cameraLock&&this.resize()}setCameraLock(e){this.canvasWorld&&this.cameraLock!==e&&(this.cameraLock=e,this.cameraLockInitialized=!1,e||(this.cameraRotation=0),this.resize())}viewportFromDocument(e){let t=A(k(e,this.sceneScroll()),this.regionScale);return this.canvasWorld&&this.cameraLock?rl(t,al(this.width,this.height,this.regionScale),tl(this.outputWidth,this.outputHeight,this.cameraFrame),this.cameraRotation):t}documentFromViewport(e){return O(A(this.canvasWorld&&this.cameraLock?il(e,al(this.width,this.height,this.regionScale),tl(this.outputWidth,this.outputHeight,this.cameraFrame),this.cameraRotation):e,1/this.regionScale),this.sceneScroll())}bounds(){this.overlay&&this.syncScroll();let e=this.width/(2*this.zoom)-3/this.zoom,t=this.height/(2*this.zoom)-3/this.zoom;return{left:this.camera.x-e,right:this.camera.x+e,bottom:this.camera.y-t,top:this.camera.y+t}}setVirtualScroll(e){if(!this.overlay)return;this.virtualScroll=D(Math.abs(e.x)<.01?0:e.x,Math.abs(e.y)<.01?0:e.y);let t=document.body;this.virtualScroll.x||this.virtualScroll.y?(t.dataset.jrVirtualCamera===void 0&&(t.dataset.jrVirtualCamera=``),t.style.setProperty(`--joy-ride-scene-x`,`${-this.virtualScroll.x}px`),t.style.setProperty(`--joy-ride-scene-y`,`${-this.virtualScroll.y}px`)):(t.dataset.jrVirtualCamera!==void 0&&delete t.dataset.jrVirtualCamera,t.style.removeProperty(`--joy-ride-scene-x`),t.style.removeProperty(`--joy-ride-scene-y`))}syncScroll(e=!1){let t=D(Go().x,Go().y);e||M(k(t,this.observedScroll))>.5&&(this.followInterrupted=!0),this.observedScroll=t,(this.activeCameraRegion||this.regionScale!==1)&&this.pageScene?.apply(this.regionScale,this.sceneScroll());let n=O(t,this.virtualScroll);this.camera=D((n.x-this.originScroll.x-this.zoomAnchor.x*(this.baseZoom-this.zoom))/this.zoom,-(n.y-this.originScroll.y+this.zoomAnchor.y*(this.baseZoom-this.zoom))/this.zoom)}resumeFollow(){this.vehicleReveal=null,this.overlay&&(this.syncScroll(),this.followInterrupted=!1)}interruptFollow(){this.vehicleReveal=null,this.overlay&&(this.followInterrupted=!0)}restorePage(e){if(!this.overlay||!this.virtualScroll.x&&!this.virtualScroll.y&&!this.activeCameraRegion&&this.regionScale===1)return!1;this.syncScroll(!0);let t=A(this.screen(e.body.position),this.regionScale??1);return(this.activeCameraRegion||this.regionScale!==1)&&(this.slowMoZoom=1,this.pageScene.clear(),this.activeCameraRegion=null,this.regionScale=1,this.resize()),this.setVirtualScroll(D()),this.syncScroll(!0),e.body.position=this.world(t),!0}followDocument(e){if(!this.overlay)return!1;if(this.vehicleReveal||this.activeCameraRegion?.fixed)return!0;if(this.zoomAnchor={...e.body.position},this.syncScroll(),this.followInterrupted)return!1;let t=this.screen(e.body.position),n=Math.max(e.car.preset.geometry.lengthM*this.zoom/2+12,Math.min(this.width,this.height)*.25),r=sl(t,{width:this.width,height:this.height},n);if(r.x||r.y){if(e.barrier)window.scrollBy({left:r.x,top:r.y,behavior:`instant`}),Ko();else{let e=D(r.x*this.virtualScroll.x<0?Math.sign(r.x)*Math.min(Math.abs(r.x),Math.abs(this.virtualScroll.x)):0,r.y*this.virtualScroll.y<0?Math.sign(r.y)*Math.min(Math.abs(r.y),Math.abs(this.virtualScroll.y)):0);this.setVirtualScroll(O(this.virtualScroll,e));let t=k(r,e),n=Go();(t.x||t.y)&&(window.scrollBy({left:t.x,top:t.y,behavior:`instant`}),Ko());let i=k(Go(),n);this.setVirtualScroll(O(this.virtualScroll,k(t,i)))}}return this.syncScroll(!0),!0}moveSceneTo(e){window.scrollBy({left:e.x-Go().x,top:e.y-Go().y,behavior:`instant`}),Ko(),this.setVirtualScroll(D(e.x-Go().x,e.y-Go().y)),this.syncScroll(!0)}updateCameraRegion(e,t){let n=this.cameraFrame??{x:0,y:0,width:window.innerWidth,height:window.innerHeight},r=this.activeCameraRegion!==null&&!e,i=e!==null&&this.activeCameraRegion?.element!==e.element,a=(e?e.fixed?pl(e.bounds,n,e.zoom):Math.max(.1,Math.min(3,e.zoom??1)):1)*this.slowMoZoom,o=this.regionScale,s=A(k(t,this.sceneScroll()),o);if(this.activeCameraRegion=e,r&&this.pageScene.clear(),Math.abs(a-this.regionScale)>1e-4&&(this.regionScale=a,this.resize()),e?.fixed){this.speedScale=1,this.zoom=this.baseZoom;let t=e.bounds;this.moveSceneTo(D(t.x+t.width/2-(n.x+n.width/2)/this.regionScale,t.y+t.height/2-(n.y+n.height/2)/this.regionScale))}else(r||i)&&(this.followInterrupted=!1,this.moveSceneTo(D(t.x-this.width/2,t.y-this.height/2)));!e?.fixed&&!r&&!i&&Math.abs(a-o)>1e-4&&this.moveSceneTo(k(t,A(s,1/a))),e||a!==1?this.pageScene.apply(this.regionScale,this.sceneScroll()):this.pageScene.clear()}cameraStep(e,t){let n=this.lastFrame?P((t-this.lastFrame)/1e3,0,.1):1/60;this.lastFrame=t;let r=e.body;if(this.canvasWorld){if(this.cameraLock){let e=r.angle-Math.PI/2,t=!this.cameraLockInitialized||M(k(r.position,this.camera))>40;this.cameraRotation=t?e:ol(this.cameraRotation,e,n,this.cameraSmoothing),t&&(this.camera={...r.position}),this.cameraLockInitialized=!0}else this.cameraRotation=0}let i=M(r.velocity);for(this.speedSamples.push({time:t,speed:i});this.speedSamples.length>2&&this.speedSamples[1].time<t-1e3;)this.speedSamples.shift();let a=0,o=0;for(let e=0;e<this.speedSamples.length-1;e++){let n=Math.max(t-1e3,this.speedSamples[e].time),r=this.speedSamples[e+1].time;a+=this.speedSamples[e].speed*(r-n),o+=r-n}let s=o>0?a/o:i,c=D(this.width/2+r.position.x*this.baseZoom+this.originScroll.x,this.height/2-r.position.y*this.baseZoom+this.originScroll.y),l=this.overlay?this.cameraRegions.at(c,this.virtualScroll,t):null;this.overlay&&this.updateCameraRegion(l,c);let u=!l&&(this.canvasWorld?this.speedZoom===!0:_l(this.speedZoom,this.overlay,e.barrier,c,this.pageSize))?1-(1-(this.speedZoomMinimumScale??gl.minimumScale))*P((s-gl.startsAtMps)/(gl.fullAtMps-gl.startsAtMps),0,1):1;this.speedScale+=(u-this.speedScale)*(1-Math.exp(-gl.responsePerSecond*n));let d=this.zoom;if(this.canvasWorld){let e=this.canvasWorldScale*this.speedScale*this.slowMoZoom;Math.abs(this.regionScale-e)>1e-4&&(this.regionScale=e,this.resize()),this.zoom=this.baseZoom}else this.zoom=this.baseZoom*this.speedScale*(this.overlay?1:this.slowMoZoom);if(this.overlay){this.zoomAnchor={...r.position},this.syncScroll(),this.advanceVehicleReveal(t,e);return}if(e.barrier)return;let f=d/this.zoom;if(this.camera=D(r.position.x-(r.position.x-this.camera.x)*f,r.position.y-(r.position.y-this.camera.y)*f),this.canvasWorld&&this.cameraLock){let e=this.cameraSmoothing<=0?1:1-Math.exp(-n/this.cameraSmoothing);this.camera=O(this.camera,A(k(r.position,this.camera),e));return}if(!this.deadZone){let e=this.canvasWorld&&!this.cameraLock?this.cameraFrame:null;this.camera=e?D(r.position.x-((e.x+e.width/2)/this.regionScale-this.width/2)/this.zoom,r.position.y+((e.y+e.height/2)/this.regionScale-this.height/2)/this.zoom):{...r.position};return}let p=this.width*.18/this.zoom,m=this.height*.18/this.zoom,h=D(r.position.x-P(r.position.x-this.camera.x,-p,p),r.position.y-P(r.position.y-this.camera.y,-m,m));this.camera=O(this.camera,A(k(h,this.camera),1-Math.exp(-16*n)))}},yl=class{canvas;camera;overlay;canvasWorld;sceneCanvas=null;sceneContext;constructor(e,t,n,r){this.canvas=e,this.camera=t,this.overlay=n,this.canvasWorld=r;let i=e.getContext(`2d`);if(!i)throw Error(`Joy Ride requires a 2D canvas context.`);this.sceneContext=i}get context(){return this.sceneContext}resize(){let e=Math.max(1,this.overlay?window.innerWidth:this.canvas.clientWidth),t=Math.max(1,this.overlay?window.innerHeight:this.canvas.clientHeight),n=e/this.camera.regionScale!==this.camera.width||t/this.camera.regionScale!==this.camera.height;this.camera.resizeLayout(e,t,window.devicePixelRatio||1);let r=this.canvasWorld&&this.camera.cameraLock;r?(this.sceneCanvas??=document.createElement(`canvas`),this.sceneContext=this.sceneCanvas.getContext(`2d`)):this.sceneCanvas&&(this.sceneContext=this.canvas.getContext(`2d`)),this.overlay&&(n||this.canvas.style.width!==`${this.camera.width}px`)&&(this.canvas.style.width=`${this.camera.width}px`,this.canvas.style.height=`${this.camera.height}px`,this.canvas.style.transformOrigin=`0 0`,this.canvas.style.scale=String(this.camera.regionScale));let i=Math.round(this.camera.width*this.camera.dpr),a=Math.round(this.camera.height*this.camera.dpr),o=r?this.sceneCanvas:this.canvas;if((o.width!==i||o.height!==a)&&(o.width=i,o.height=a),r){let n=this.camera.dpr/this.camera.regionScale,r=Math.round(e*n),i=Math.round(t*n);this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}return this.sceneContext.setTransform(this.camera.dpr,0,0,this.camera.dpr,0,0),this.canvasWorld?this.camera.dpr:void 0}clear(){this.sceneContext.setTransform(this.camera.dpr,0,0,this.camera.dpr,0,0),this.sceneContext.clearRect(0,0,this.camera.width,this.camera.height)}presentLockedCamera(){if(!this.canvasWorld||!this.camera.cameraLock||!this.sceneCanvas)return;let e=this.canvas.getContext(`2d`),t=this.camera.dpr/this.camera.regionScale,n=tl(this.camera.outputWidth,this.camera.outputHeight,this.camera.cameraFrame);e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.save(),e.translate(n.x*t,n.y*t),e.rotate(this.camera.cameraRotation),e.drawImage(this.sceneCanvas,-this.sceneCanvas.width/2,-this.sceneCanvas.height/2),e.restore()}dispose(){this.sceneCanvas&&=(this.sceneCanvas.width=1,this.sceneCanvas.height=1,null),this.canvas.style.scale=``,this.canvas.style.transformOrigin=``}},bl=class{frameRate=new qo;captureState(){return this.frameRate.captureState()}restoreState(e){this.frameRate.restoreState(e)}draw(e,t,n,r,i){let a=e,o=t.body,s=this.frameRate.sample(n);a.save();let c=Jc(t.car.preset);for(let e of t.car.tires){let t=r(o.world(e.local));a.strokeStyle=e.front?`#00dcff`:`#ffae31`,a.lineWidth=2;let n=[D(-c.length/2,-c.width/2),D(c.length/2,-c.width/2),D(c.length/2,c.width/2),D(-c.length/2,c.width/2)].map(t=>r(o.world(O(e.local,N(t,e.angle)))));a.beginPath(),n.forEach((e,t)=>t?a.lineTo(e.x,e.y):a.moveTo(e.x,e.y)),a.closePath(),a.stroke(),a.beginPath(),a.arc(t.x,t.y,4,0,Math.PI*2),a.stroke(),a.beginPath(),a.moveTo(t.x-7,t.y),a.lineTo(t.x+7,t.y),a.moveTo(t.x,t.y-7),a.lineTo(t.x,t.y+7),a.stroke(),a.font=`bold 10px ui-monospace, SFMono-Regular, monospace`,a.fillStyle=e.front?`#007e91`:`#895000`,a.fillText(`${e.front?`F`:`R`}${e.local.y>0?`L`:`R`}${e.skidding?` SKID`:``}`,t.x+8,t.y-8)}let l=r(o.position),u=(e,t,n)=>{let r=O(l,A(e,n));a.strokeStyle=t,a.fillStyle=t,a.lineWidth=2.5,a.beginPath(),a.moveTo(l.x,l.y),a.lineTo(r.x,r.y),a.stroke();let i=Math.atan2(e.y,e.x);a.beginPath(),a.moveTo(r.x,r.y),a.lineTo(r.x-Math.cos(i-.5)*9,r.y-Math.sin(i-.5)*9),a.lineTo(r.x-Math.cos(i+.5)*9,r.y-Math.sin(i+.5)*9),a.closePath(),a.fill()};u(D(Math.cos(o.angle),-Math.sin(o.angle)),`#00c4df`,67);let d=M(o.velocity);d>.2&&u(D(o.velocity.x/d,-o.velocity.y/d),`#f05bd6`,48+Math.min(32,d));let f=Math.atan2(o.velocity.y,o.velocity.x),p=Math.atan2(Math.sin(o.angle-f),Math.cos(o.angle-f)),m=Math.max(...t.car.tires.filter(e=>e.front).map(e=>e.gripUtilization)),h=Math.max(...t.car.tires.filter(e=>!e.front).map(e=>e.gripUtilization)),g=t.car.tires.map(e=>`${e.front?`F`:`R`}${e.local.y>0?`L`:`R`} ${e.slipSpeedMps.toFixed(1)}${e.skidding?`*`:``}`).join(` `),_=[`${t.car.preset.name} · ${(d*3.6).toFixed(0)} km/h · ${Math.round(s)} FPS`,`input T ${t.lastInput.throttle} S ${t.lastInput.steer} brake ${Number(t.lastInput.action)}`,`body ${Math.round(o.angle*180/Math.PI)}° travel ${Math.round(f*180/Math.PI)}° slip ${Math.round(p*180/Math.PI)}°`,`front load ${(t.car.frontLoadFraction*100).toFixed(0)}% burnout ${Number(t.car.burnout)} charge ${t.car.boostCharge.toFixed(2)}`,`grip use F ${m.toFixed(2)} R ${h.toFixed(2)} drift ${Number(t.car.drifting)} donut ${Number(t.car.donuting)}`,`drift ${Number(t.car.fastDrifting)} countersteer ${Number(t.car.countersteering)}`,`roof rocket ${i.rocketState}`,`side guns ${i.gunState} · ${i.bulletCount} bullets`,`tire slip m/s ${g}`,`fluid ${i.fluidEngine} ${i.quality} ${i.fluidCols}×${i.fluidRows}`,`shared fire ${i.fireCols}×${i.fireRows} · ${i.groundedFireCount} grounded sources`,`cyan = nose/shape pink = travel amber = walls`,`wheel cyan = front wheel amber = rear violet = letters`];a.fillStyle=`rgba(10, 21, 24, 0.87)`,a.fillRect(12,88,Math.min(430,i.width-24),_.length*18+18),a.font=`12px ui-monospace, SFMono-Regular, monospace`,a.fillStyle=`#f1f5f3`,_.forEach((e,t)=>a.fillText(e,22,110+t*18)),a.restore()}},xl=[.82,.91,1],Sl=[1,.045,.018],Cl=e=>Math.max(0,Math.min(1,e));function wl(e){let t=/^#([\da-f]{6})$/i.exec(e);if(!t)return[.4,.9,1];let n=parseInt(t[1],16);return[(n>>16)/255,(n>>8&255)/255,(n&255)/255]}function Tl(e,t,n){let r=Math.cos(e.angle),i=Math.sin(e.angle);return{x:e.center.x+r*t-i*n,y:e.center.y+i*t+r*n}}var El=class{sprites=new WeakMap;halos=new WeakMap;beam=null;sprite(e){let t=e.image;if(!t||!t.complete||!t.naturalWidth)return null;let n=e.source??{x:0,y:0,width:t.naturalWidth,height:t.naturalHeight},r=e.mounts.taillights.map(t=>`${Math.round(t.x/e.width*1e4)},${Math.round(t.y/e.height*1e4)}`).join(`;`),i=`${n.x},${n.y},${n.width},${n.height}|${r}`,a=this.sprites.get(t);if(a||(a=new Map,this.sprites.set(t,a)),a.has(i))return a.get(i)??null;let o=document.createElement(`canvas`);o.width=192,o.height=Math.max(24,Math.round(192*n.height/n.width));let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return a.set(i,null),null;s.drawImage(t,n.x,n.y,n.width,n.height,0,0,o.width,o.height);let c;try{c=s.getImageData(0,0,o.width,o.height)}catch{return a.set(i,null),null}let l=s.createImageData(o.width,o.height),u=0;for(let t=0;t<o.height;t++)for(let n=0;n<o.width;n++){let r=(t*o.width+n)*4,i=c.data[r],a=c.data[r+1],s=c.data[r+2],d=c.data[r+3];n<o.width*.27&&i>100&&i>a*1.6&&i>s*1.5&&d>100&&e.mounts.taillights.some(r=>{let i=n-(.5+r.x/e.width)*o.width,a=t-(.5+r.y/e.height)*o.height;return i*i+a*a<(o.height*.18)**2})&&(l.data[r]=255,l.data[r+1]=22,l.data[r+2]=5,l.data[r+3]=Math.min(235,d),u++),c.data[r]=255,c.data[r+1]=255,c.data[r+2]=255,c.data[r+3]=d>90?255:0}s.putImageData(c,0,0);let d=null;u>1&&u<o.width*o.height*.055&&(d=document.createElement(`canvas`),d.width=o.width,d.height=o.height,d.getContext(`2d`)?.putImageData(l,0,0));let f={silhouette:o,brakes:d};return a.size>=8&&a.clear(),a.set(i,f),f}halo(e,t){let n=this.halos.get(e);n||(n=new Map,this.halos.set(e,n));let r=n.get(t);if(r)return r;let i=document.createElement(`canvas`);i.width=e.width+64,i.height=e.height+64;let a=i.getContext(`2d`);a.drawImage(e,32,32),a.globalCompositeOperation=`source-in`,a.fillStyle=t,a.fillRect(0,0,i.width,i.height),a.globalCompositeOperation=`source-over`;let o=document.createElement(`canvas`);o.width=i.width,o.height=i.height,o.getContext(`2d`).drawImage(i,0,0),a.clearRect(0,0,i.width,i.height),a.filter=`blur(14px)`,a.globalAlpha=.92,a.drawImage(o,-2,-5,o.width+4,o.height+10),a.filter=`blur(7px)`,a.globalAlpha=.9,a.drawImage(o,0,0),a.filter=`blur(3px)`,a.globalAlpha=.8,a.strokeStyle=t,a.lineWidth=3,a.lineCap=`round`;for(let t of[-1,1])a.beginPath(),a.moveTo(32+e.width*.18,32+e.height*(.5+t*.34)),a.lineTo(32+e.width*.82,32+e.height*(.5+t*.34)),a.stroke();return a.filter=`none`,a.globalAlpha=1,n.size>8&&n.clear(),n.set(t,i),i}beamImage(){if(this.beam)return this.beam;let e=document.createElement(`canvas`);e.width=256,e.height=128;let t=e.getContext(`2d`),n=t.createImageData(e.width,e.height);for(let t=0;t<e.height;t++)for(let r=0;r<e.width;r++){let i=r/e.width,a=(t/e.height-.5)*2,o=.035+i*.94,s=Cl((1-i)/.4),c=Math.exp(-a*a/(o*o))*s*s*(3-2*s),l=(t*e.width+r)*4;n.data[l]=210,n.data[l+1]=230,n.data[l+2]=255,n.data[l+3]=Math.round(c*255)}return t.putImageData(n,0,0),this.beam=e,e}ground(e,t){let n=t.opacity??1,r=t.options.brakeLights?Cl(t.braking):0;if(!(n<=0||t.width<=0)){if(e.save(),e.translate(t.center.x,t.center.y),e.rotate(t.angle),e.globalCompositeOperation=`screen`,t.dark&&t.options.underglow&&t.options.underglowOpacity>0){let r=this.sprite(t);if(e.globalAlpha=Cl(t.options.underglowOpacity)*n,r){let n=this.halo(r.silhouette,t.options.underglowColor),i=32/r.silhouette.width*t.width,a=32/r.silhouette.height*t.height;e.drawImage(n,-t.width/2-i,-t.height/2-a,t.width+i*2,t.height+a*2)}else e.shadowColor=t.options.underglowColor,e.shadowBlur=t.height*.5,e.fillStyle=t.options.underglowColor,e.beginPath(),e.roundRect(-t.width*.43,-t.height*.38,t.width*.86,t.height*.76,t.height*.22),e.fill(),e.shadowBlur=0}if(t.dark&&t.options.headlights)for(let r of t.mounts.headlights)e.globalAlpha=.085*n,e.drawImage(this.beamImage(),r.x,r.y-t.width*.68,t.width*5.7,t.width*1.36);if(t.dark&&t.options.taillights||r>0){let i=r;for(let{x:r,y:a}of t.mounts.taillights){let o=t.height*(.48+i*.38),s=e.createRadialGradient(r,a,0,r,a,o),c=(t.dark?.12+i*.19:i*.13)*n;s.addColorStop(0,`rgba(255,30,8,${c})`),s.addColorStop(1,`rgba(255,20,4,0)`),e.fillStyle=s,e.fillRect(r-o,a-o,o*2,o*2)}}e.restore()}}glints(e,t){e.save(),e.translate(t.center.x,t.center.y),e.rotate(t.angle),e.globalCompositeOperation=`screen`;let n=t.opacity??1,r=t.options.brakeLights?Cl(t.braking):0;if(r>0){let i=this.sprite(t)?.brakes;i&&(e.globalAlpha=r*n*(t.dark?.9:.52),e.shadowColor=`#ff250d`,e.shadowBlur=t.height*(t.dark?.16:.055),e.drawImage(i,-t.width/2,-t.height/2,t.width,t.height))}for(let i of[!0,!1])if(!(i?!(t.dark&&t.options.headlights):!(t.dark&&t.options.taillights||r>0)))for(let a of t.mounts[i?`headlights`:`taillights`]){e.globalAlpha=n*(i?.75:t.dark?.34+r*.6:r*.45);let o=t.height*(i?.15:.12),s=e.createRadialGradient(a.x,a.y,0,a.x,a.y,o);s.addColorStop(0,i?`#e6f1ffd9`:`#ff3518c0`),s.addColorStop(.28,i?`#c1dcff70`:`#ff230760`),s.addColorStop(1,i?`#c1dcff00`:`#ff230700`),e.fillStyle=s,e.beginPath(),e.arc(a.x,a.y,o,0,Math.PI*2),e.fill()}e.restore()}smokeLights(e){let t=[],n={x:Math.cos(e.angle),y:Math.sin(e.angle)},r=e.opacity??1,i=e.options.brakeLights?Cl(e.braking):0;if(e.dark&&e.options.headlights)for(let i of e.mounts.headlights)t.push({point:Tl(e,i.x,i.y),direction:n,color:xl,range:e.width*6.2,radius:e.height*.075,spread:.14,intensity:1.7*r});if(e.dark&&e.options.taillights||i>0)for(let a of e.mounts.taillights)t.push({point:Tl(e,a.x,a.y),direction:{x:-n.x,y:-n.y},color:Sl,range:e.width*(i>0?1.6:.9),radius:e.height*.15,spread:.46,intensity:r*(e.dark?.24+i*.85:i*.42)});if(e.dark&&e.options.underglow&&e.options.underglowOpacity>0)for(let n of[-.27,0,.27])t.push({point:Tl(e,e.width*n,0),direction:{x:0,y:0},color:wl(e.options.underglowColor),range:e.height,radius:e.height*.8,spread:0,intensity:r*e.options.underglowOpacity*.8});return t}},Dl=Object.freeze({underglow:!1,underglowColor:`#66e6ff`,underglowOpacity:.6,headlights:!0,taillights:!0,brakeLights:!0});function Ol(e={}){return{underglow:typeof e.underglow==`boolean`?e.underglow:Dl.underglow,underglowColor:/^#[\da-f]{6}$/i.test(e.underglowColor??``)?e.underglowColor:Dl.underglowColor,underglowOpacity:Number.isFinite(e.underglowOpacity)?Math.max(0,Math.min(1,e.underglowOpacity)):Dl.underglowOpacity,headlights:typeof e.headlights==`boolean`?e.headlights:Dl.headlights,brakeLights:typeof e.brakeLights==`boolean`?e.brakeLights:Dl.brakeLights,taillights:typeof e.taillights==`boolean`?e.taillights:Dl.taillights}}var kl={light:{ink:`#161c17`,alphaScale:1},dark:{ink:`#a9adb0`,alphaScale:1.7}};function Al(e){let t=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(!t)return!1;let[,n,r,i]=t.map(Number);return n*.2126+r*.7152+i*.0722<112}var jl=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},Ml={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Nl=e=>jl(Ml[e.toLowerCase()],6),Pl=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,Fl=e=>{let t;return(t=e.match(Pl))?jl(parseInt(t[1],16),t[1].length):void 0},Il=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`,Ll=`${Il}%`,Rl=`(?:${Il}%|${Il})`,zl=`(?:${Il}%|${Il}|none)`,Bl=`(?:${Il}(deg|grad|rad|turn)|${Il})`,Vl=`\\s*,\\s*`;RegExp(`^`+zl+`$`);var Hl=RegExp(`^rgba?\\(\\s*${Il}${Vl}${Il}${Vl}${Il}\\s*(?:,\\s*${Rl}\\s*)?\\)$`),Ul=RegExp(`^rgba?\\(\\s*${Ll}${Vl}${Ll}${Vl}${Ll}\\s*(?:,\\s*${Rl}\\s*)?\\)$`),Wl=e=>{let t={mode:`rgb`},n;if(n=e.match(Hl))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Ul))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},Gl=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:mu(e),Kl=(e=`rgb`)=>t=>(t=Gl(t,e))===void 0?void 0:t.mode===e?t:ql[t.mode][e]?ql[t.mode][e](t):e===`rgb`?ql[t.mode].rgb(t):ql.rgb[e](ql[t.mode].rgb(t)),ql={},Jl={},Yl=[],Xl={},Zl=e=>e,Ql=e=>(ql[e.mode]={...ql[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{ql[t]||(ql[t]={}),ql[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Zl)}),Jl[e.mode]=e,(e.parse||[]).forEach(t=>{eu(t,e.mode)}),Kl(e.mode)),$l=e=>Jl[e],eu=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);Xl[e]=t}else typeof e==`function`&&Yl.indexOf(e)<0&&Yl.push(e)},tu=/[^\x00-\x7F]|[a-zA-Z_]/,nu=/[^\x00-\x7F]|[-\w]/,I={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},L=0;function ru(e){let t=e[L],n=e[L+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[L+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function iu(e){if(L>=e.length)return!1;let t=e[L];if(tu.test(t))return!0;if(t===`-`){if(e.length-L<2)return!1;let t=e[L+1];return!!(t===`-`||tu.test(t))}return!1}var au={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function ou(e){let t=``;if((e[L]===`-`||e[L]===`+`)&&(t+=e[L++]),t+=su(e),e[L]===`.`&&/\d/.test(e[L+1])&&(t+=e[L++]+su(e)),(e[L]===`e`||e[L]===`E`)&&((e[L+1]===`-`||e[L+1]===`+`)&&/\d/.test(e[L+2])?t+=e[L++]+e[L++]+su(e):/\d/.test(e[L+1])&&(t+=e[L++]+su(e))),iu(e)){let n=cu(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:I.Hue,value:t*au[n]}:void 0}return e[L]===`%`?(L++,{type:I.Percentage,value:+t}):{type:I.Number,value:+t}}function su(e){let t=``;for(;/\d/.test(e[L]);)t+=e[L++];return t}function cu(e){let t=``;for(;L<e.length&&nu.test(e[L]);)t+=e[L++];return t}function lu(e){let t=cu(e);return e[L]===`(`?(L++,{type:I.Function,value:t}):t===`none`?{type:I.None,value:void 0}:{type:I.Ident,value:t}}function uu(e=``){let t=e.trim(),n=[],r;for(L=0;L<t.length;)if(r=t[L++],r===`
48
+ `,bc=new Map,xc=0,Sc=96,Cc=new Map;function wc(){return[...bc.values()].reduce((e,t)=>e+t.bytes,0)+Cc.size*Sc*Sc*4}function Tc(e){let t=Cc.get(e);if(t)return t;let n=new Float32Array(9216),r=new Float32Array(1024);for(let t=0;t<r.length;t++)r[t]=us(e+71,t);let i=(e,t)=>{let n=Math.floor(e),i=Math.floor(t),a=e-n,o=t-i,s=a*a*(3-2*a),c=o*o*(3-2*o),l=(e,t)=>r[(e&31)+(t&31)*32];return(l(n,i)*(1-s)+l(n+1,i)*s)*(1-c)+(l(n,i+1)*(1-s)+l(n+1,i+1)*s)*c};for(let e=0;e<Sc;e++)for(let t=0;t<Sc;t++){let r=(t+.5)/Sc,a=(e+.5)/Sc,o=i(r*3+2,a*3+4)*.52+i(r*7+7,a*7+3)*.3+i(r*17,a*17)*.18,s=(r-.5)*2,c=(a-.5)*2,l=Math.hypot(s+(i(r*4,a*4)-.5)*.27,c+(i(r*4+5,a*4)-.5)*.27),u=Math.max(0,Math.min(1,(1-l)*3.5)),d=Math.max(0,o-.24)**1.4*u*u*(3-2*u);n[e*Sc+t]=d}return Cc.set(e,n),n}function Ec(e,t,n){let r=`${t}:${n}`,i=bc.get(r);if(i)return i.used=++xc,i.canvas;let a;if(typeof OffscreenCanvas<`u`)a=new OffscreenCanvas(Sc,Sc);else if(typeof document<`u`)a=document.createElement(`canvas`),a.width=a.height=Sc;else try{a=new e.canvas.constructor(Sc,Sc)}catch{return null}let o=a.getContext(`2d`);if(!o)return null;o.fillStyle=t,o.fillRect(0,0,1,1);let s=o.getImageData(0,0,1,1).data,c=o.createImageData(Sc,Sc),l=Tc(n);for(let e=0;e<l.length;e++)c.data[e*4]=s[0],c.data[e*4+1]=s[1],c.data[e*4+2]=s[2],c.data[e*4+3]=Math.round(l[e]*255);if(o.putImageData(c,0,0),bc.size>=64){let e=``,t=1/0;for(let[n,r]of bc)r.used<t&&(e=n,t=r.used);bc.delete(e)}return bc.set(r,{canvas:a,used:++xc,bytes:36864}),a}function Dc(e,t,n,r,i,a=[]){let o=t.dust??ds(t.x,t.y,t.size,t.seed),s=e.globalAlpha;for(let c of o.parcels){let o=c.radius*c.spread,l=c.z*.22;if(c.x+o*2<n.x||c.x-o*2>n.x+n.width||c.y+o*2<n.y||c.y-l-o*2>n.y+n.height)continue;let u=Math.max(0,Math.min(1,(c.z-1)/7)),d=i===`ground`?1-u:u;if(d===0)continue;let f=r?.12:.7,p=-2.3;for(let e of a){let t=vc(e,c);t>f&&(f=t,p=Math.atan2(e.point.y-c.y,e.point.x-c.x))}let m=Ec(e,t.color,c.seed&3);e.save(),e.translate(c.x,c.y-l);let h=Math.hypot(c.vx,c.vy),g=Math.atan2(Math.sin(Math.atan2(c.vy,c.vx)-c.angle),Math.cos(Math.atan2(c.vy,c.vx)-c.angle));e.rotate(c.angle+g*Math.min(.6,h/100));let _=Math.sqrt(1+Math.min(.8,h/220));if(e.globalAlpha=s*t.opacity*d*(c.mass*9)*.55/(c.spread*c.spread),m)e.drawImage(m,-o*_,-o/_,o*2*_,o*2/_);else{let n=e.createRadialGradient(0,0,0,0,0,o);n.addColorStop(0,t.color),n.addColorStop(1,`transparent`),e.fillStyle=n,e.fillRect(-o,-o,o*2,o*2)}m&&f>.8&&(e.globalCompositeOperation=`screen`,e.globalAlpha*=Math.min(.6,(f-.8)*.2),e.drawImage(m,-o*_,-o/_,o*2*_,o*2/_),e.globalCompositeOperation=`source-over`),e.restore();let v=t.glint??.12;if(v<=0||us(c.seed,45)>.42)continue;let y=Math.max(0,Math.cos(c.angle*2+p+us(c.seed,47)*6.28))**48,b=Math.min(1,v*5)*y*Math.min(1,f)*d*s*t.opacity;if(b<.035)continue;let x=c.x+(us(c.seed,49)-.5)*o*.7,S=c.y-l+(us(c.seed,51)-.5)*o*.7,C=.35+b*.7;e.save(),e.globalAlpha=b,e.fillStyle=r?`#fff2ce`:`#fffefa`,e.beginPath(),e.ellipse(x,S,C,C,0,0,Math.PI*2),e.fill(),b>.45&&(e.lineWidth=.35,e.strokeStyle=`#fff5d7`,e.beginPath(),e.moveTo(x-C*2.5,S),e.lineTo(x+C*2.5,S),e.moveTo(x,S-C*2.5),e.lineTo(x,S+C*2.5),e.stroke()),e.restore()}}function Oc(e,t,n){let r=e.size,i=r*.74,a=0,o=0,s=0;for(let c=0;c<6;c++){let l=t*(c+.5)/6*2,u=n*(c+.5)/6*2,d=e.curlX*l*l*l+e.twist*n*2*l*l,f=e.curlY*u*u*u-e.twist*t*1.3*u*u;a+=Math.cos(d)*r*t/6,o+=Math.cos(f)*i*n/6,s+=Math.sin(d)*r*t/6+Math.sin(f)*i*n/6}let c=Math.max(0,t+n-.62);s+=c*c*r*(.35+e.fold);let l=Math.cos(e.tilt),u=Math.sin(e.tilt);return{x:a,y:o*l-s*u,z:o*u+s*l}}var kc=(e,t)=>{let n=Math.imul((e|0)&15^Math.imul(t+17,374761393),668265263);return n=Math.imul(n^n>>>13,1274126177),((n^n>>>16)>>>0)/4294967296},Ac=new Map,jc=new Map;function Mc(e){let t=Ac.get(e);if(t)return t;let n=e.replace(/^#/,``),r=/^[\da-f]{3}$/i.test(n)?[...n].map(e=>e+e).join(``):n,i=/^[\da-f]{6}$/i.test(r)?[0,2,4].map(e=>parseInt(r.slice(e,e+2),16)):e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/)?.slice(1,4).map(Number)??[195,190,174];return Ac.size>=128&&Ac.delete(Ac.keys().next().value),Ac.set(e,i),i}function Nc(e,t){let n=Math.round(t),r=`${e}:${n}`,i=jc.get(r);if(i)return i;let a=`rgb(${Mc(e).map(e=>Math.max(0,Math.min(255,e+n))).join(` `)})`;return jc.size>=512&&jc.delete(jc.keys().next().value),jc.set(r,a),a}function Pc(e,t){e.beginPath(),t.forEach(([t,n],r)=>{r?e.lineTo(t,n):e.moveTo(t,n)}),e.closePath()}function Fc(e,t,n){let r=Math.max(0,t.z),i=1+Math.min(.65,r/90);e.save(),e.translate(t.x+r*.13,t.y+r*.1),e.rotate(t.angle),e.fillStyle=`#000`,e.globalAlpha=t.opacity*(n?.12:.15)/(1+r/26),e.beginPath(),e.ellipse(0,0,t.size*.46*i,t.size*.27*i,0,0,Math.PI*2),e.fill(),r<5&&(e.globalAlpha*=(1-r/5)*.6,e.beginPath(),e.ellipse(0,0,t.size*.36,t.size*.19,0,0,Math.PI*2),e.fill()),e.restore()}function Ic(e,t){let n=[];for(let e=0;e<=2;e++)n.push(Array.from({length:9},(n,r)=>Oc(t,r/8-.5,e/2-.5)));let r=t.z<.5?Math.max(0,-Math.min(...n.flat().map(e=>e.z))):0,i=e=>[e.x,e.y-(e.z+r)*.48],a=[];for(let e=0;e<2;e++)for(let t=0;t<8;t++){let r=n[e][t],i=n[e][t+1],o=n[e+1][t+1],s=n[e+1][t],c=i.x-r.x,l=i.y-r.y,u=i.z-r.z,d=s.x-r.x,f=s.y-r.y,p=s.z-r.z,m=l*p-u*f,h=u*d-c*p,g=c*f-l*d,_=Math.max(.001,Math.hypot(m,h,g)),v=g+h*.48>0,y=(m*-.35+h*-.45+Math.abs(g)*.7)/_;a.push({a:r,b:i,c:o,d:s,col:t,row:e,front:v,light:y,depth:(r.z+i.z+o.z+s.z)/4})}a.sort((e,t)=>e.depth-t.depth);for(let n of a){let{a:r,b:a,c:o,d:s,front:c,light:l,row:u,col:d}=n;if(Pc(e,[i(r),i(a),i(o),i(s)]),e.fillStyle=Nc(t.color,(c?0:-32)+(l-.7)*45),e.fill(),c&&d>0&&d<(u===0?6:8)&&u<3){e.strokeStyle=Nc(t.color,-100),e.lineWidth=t.size*(u===0?.027:.013);let n=i({x:(r.x+s.x)*.5,y:(r.y+s.y)*.5,z:(r.z+s.z)*.5}),c=i({x:(a.x+o.x)*.5,y:(a.y+o.y)*.5,z:(a.z+o.z)*.5});if(e.beginPath(),e.moveTo(...n),e.lineTo(...c),e.stroke(),u>0){let t=i({x:r.x*.2+s.x*.8,y:r.y*.2+s.y*.8,z:r.z*.2+s.z*.8}),n=i({x:a.x*.2+o.x*.8,y:a.y*.2+o.y*.8,z:a.z*.2+o.z*.8});e.beginPath(),e.moveTo(...t),e.lineTo(...n),e.stroke()}}}}function Lc(e,t){let n=[],r=.72+Math.abs(Math.cos(t.tilt))*.28;for(let e=0;e<9;e++){let i=e/9*Math.PI*2,a=t.size*(.32+kc(t.seed,e+20)*.18);n.push([Math.cos(i)*a,Math.sin(i)*a*r])}let i=[(kc(t.seed,33)-.5)*t.size*.17,(kc(t.seed,34)-.5)*t.size*.18];for(let r=0;r<n.length;r++){Pc(e,[i,n[r],n[(r+1)%n.length]]);let a=(kc(t.seed,r+40)-.45)*72+Math.sin(t.tilt+r)*9;e.fillStyle=Nc(t.color,a),e.fill()}e.strokeStyle=Nc(t.color,-45),e.lineWidth=.35,e.globalAlpha*=.3;for(let r of[1,4,6])e.beginPath(),e.moveTo(...n[r]),e.lineTo(i[0]+t.size*.08,i[1]),e.stroke()}function Rc(e,t){let n=t.size,r=t.size*(.35+kc(t.seed,51)*.25),i=Math.cos(t.tilt);e.scale(1,Math.abs(i)<.1?.1:i),Pc(e,[[-n*.5,-r*.5],[-n*.43,-r*.31],[-n*.49,-r*.08],[-n*.42,r*.12],[-n*.48,r*.48],[-n*.28,r*.38],[n*.3,r*.43],[n*.5,r*.52],[n*.44,r*.21],[n*.5,-r*.02],[n*.43,-r*.22],[n*.49,-r*.52],[n*.28,-r*.38],[-n*.28,-r*.4]]),e.fillStyle=i<0?`#b9c1c3`:Nc(t.color,24),e.fill(),Pc(e,[[-n*.3,-r/2],[n*.3,-r*.43],[n*.21,r*.35],[-n*.2,r*.4]]),e.fillStyle=Nc(t.color,-16),e.fill(),e.fillStyle=`#e4decd`,e.fillRect(-n*.15,-r*.14,n*.27,r*.19),e.strokeStyle=Nc(t.color,65),e.lineWidth=.45,e.globalAlpha*=.45;for(let t of[-1,1])e.beginPath(),e.moveTo(t*n*.3,-r*.35),e.lineTo(t*n*.38,r*.15),e.lineTo(t*n*.27,r*.35),e.stroke()}function zc(e,t){let n=t.size,r=t.size*(.35+kc(t.seed,61)*.2),i=Math.cos(t.tilt);if(e.scale(1,Math.abs(i)<.08?.08:i),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.bezierCurveTo(n*.12,r*.65,-n*.25,r*.45,-n*.48,0),e.fillStyle=Nc(t.color,i<0?14:0),e.fill(),e.beginPath(),e.moveTo(-n*.48,0),e.bezierCurveTo(-n*.15,-r*.7,n*.18,-r*.6,n*.5,-r*.08),e.quadraticCurveTo(0,-r*t.fold*.2,-n*.48,0),e.fillStyle=Nc(t.color,-13-t.fold*9),e.fill(),e.strokeStyle=Nc(t.color,-35),e.lineWidth=.45,e.globalAlpha*=.55,e.beginPath(),e.moveTo(-n*.63,r*.08),e.quadraticCurveTo(-n*.08,-r*t.fold*.2,n*.46,-r*.07),e.stroke(),n>10){e.lineWidth=.3;for(let t of[-.18,.08])e.beginPath(),e.moveTo(n*t,0),e.lineTo(n*(t+.1),-r*.3),e.moveTo(n*t,0),e.lineTo(n*(t-.03),r*.28),e.stroke()}}var Bc=new Map,Vc=0,Hc=0,Uc=()=>({sprites:Bc.size,bytes:Vc+wc()});function Wc(e,t){t.kind===`paper`?Ic(e,t):t.kind===`crumpled-paper`?Lc(e,t):t.kind===`trash`?Rc(e,t):t.kind===`leaf`&&zc(e,t)}function Gc(e){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,e);if(typeof document>`u`||typeof HTMLCanvasElement>`u`)return null;let t=document.createElement(`canvas`);return!(t instanceof HTMLCanvasElement)||!t.getContext?null:(t.width=t.height=e,t)}function Kc(e,t,n){if(t.kind===`dust`||t.z>.1||Math.abs(t.vz)>.1||Math.hypot(t.vx,t.vy)>.75||t.kind===`paper`&&Math.abs(t.curlVelocityX)+Math.abs(t.curlVelocityY)+Math.abs(t.twistVelocity)>.03)return!1;let r=Math.max(4,Math.round(t.size/4)*4),i=Math.round(t.fold*5)/5,a=t.kind===`crumpled-paper`?(Math.round(t.tilt/(Math.PI/4))%8+8)%8:Math.cos(t.tilt)<0?4:0,o=a*Math.PI/4;if(t.kind!==`crumpled-paper`&&Math.abs(Math.sin(t.tilt))>.015)return!1;let s=Math.round(t.curlX*4)/4,c=Math.round(t.curlY*4)/4,l=Math.round(t.twist*4)/4,u=`${s}:${c}:${l}:${t.kind}:${t.seed&15}:${t.color}:${r}:${i}:${a}:${n}`,d=Bc.get(u),f={...t,size:r,fold:i,tilt:o,curlX:s,curlY:c,twist:l,opacity:1};if(!d){let e=r*1.4+4,t=Math.ceil(e*n),i=t*t*4;if(Bc.size>=128||Vc+i>8388608){for(let[e,t]of Bc)if(!(Hc-t.used<120)&&(Bc.delete(e),`close`in t.canvas&&t.canvas.close(),Vc-=t.bytes,Bc.size<128&&Vc+i<=8388608))break}if(Bc.size<128&&Vc+i<=8388608){let r=Gc(t),a=r?.getContext(`2d`);r&&a&&(a.scale(n,n),a.translate(e/2,e/2),Wc(a,f),d={canvas:`transferToImageBitmap`in r?r.transferToImageBitmap():r,extent:e,bytes:i,used:Hc},Bc.set(u,d),Vc+=i)}}return e.scale(t.size/r,t.size/r),d?(d.used=Hc,e.drawImage(d.canvas,-d.extent/2,-d.extent/2,d.extent,d.extent)):(e.save(),Wc(e,f),e.restore()),!0}function qc(e,t,n,r,i=`ground`,a=[]){i===`ground`&&Hc++;let o=e.getTransform(),s=Math.min(8,Math.max(1,Math.ceil(Math.hypot(o.a,o.b)))),c=n.x+n.width,l=n.y+n.height;for(let o of t){if(o.opacity<=0)continue;let t=(o.dust?.radius??o.size)+Math.max(0,o.z)*.35;o.x+t<n.x||o.x-t>c||o.y+t<n.y||o.y-t>l||(o.kind===`dust`?Dc(e,o,n,r,i,a):(i===`ground`&&Fc(e,o,r),i===`ground`==o.z<4&&(e.save(),e.translate(o.x,o.y-Math.max(0,o.z)*.22),e.rotate(o.angle),e.globalAlpha=o.opacity,Kc(e,o,s)||Wc(e,o),e.restore())))}}function Jc(e){let{tireLengthM:t,tireWidthM:n}=e.geometry;return e.image?{length:t*(e.image.wheelVisualScale?.length??.64),width:n*(e.image.wheelVisualScale?.width??.82)}:{length:t,width:n}}function Yc(e,t,n,r,i){let a=Kt(t,e.naturalWidth,e.naturalHeight),o=Math.min(1,512/Math.max(a.source.width,a.source.height)),s=document.createElement(`canvas`);s.width=Math.max(1,Math.round(a.source.width*o)),s.height=Math.max(1,Math.round(a.source.height*o));let c=s.getContext(`2d`);if(!c)return null;n?c.drawImage(n,0,0,s.width,s.height):c.drawImage(e,a.source.x,a.source.y,a.source.width,a.source.height,0,0,s.width,s.height),c.globalCompositeOperation=`source-in`,c.fillStyle=`#101916`,c.fillRect(0,0,s.width,s.height);let l=e=>{let t=Math.ceil(e*4),n=a.lengthM*r,o=a.widthM*r,c=document.createElement(`canvas`);c.width=Math.max(1,Math.ceil((n+t*2)*i)),c.height=Math.max(1,Math.ceil((o+t*2)*i));let l=c.getContext(`2d`);return l?(l.filter=`blur(${e*i}px)`,l.drawImage(s,t*i,t*i,n*i,o*i),{canvas:c,padding:t}):null};return{soft:l(6),close:l(1.5),pixelsPerMeter:r,lengthM:a.lengthM,widthM:a.widthM}}var Xc={width:96,height:96},Zc=8,Qc=14;function $c(e,t,n,r=Zc){let{width:i,height:a}=Xc,o=i/2,s=a/2,c=e.x-t.width/2,l=e.y-t.height/2,u=Math.hypot(c,l)||1,d={x:c/u,y:l/u},f=Math.max(0,t.width/2-o-Qc-Zc),p=Math.max(0,t.height/2-s-Qc-(l<0?r:Zc)),m=Math.min(Math.abs(c)?f/Math.abs(c):1/0,Math.abs(l)?p/Math.abs(l):1/0),h={x:t.width/2+c*(Number.isFinite(m)?m:0),y:t.height/2+l*(Number.isFinite(m)?m:0)},g={x:d.x*o,y:d.y*s},_={x:g.x+d.x*Qc,y:g.y+d.y*Qc},v=Math.hypot(Math.max(0,-e.x,e.x-t.width),Math.max(0,-e.y,e.y-t.height))/Math.max(.001,n);return{center:h,direction:d,edge:g,tip:_,distance:v>=1e3?`${(v/1e3).toFixed(1)} km away`:`${Math.max(1,Math.round(v))} m away`,width:i,height:a}}var el=class{camera;constructor(e){this.camera=e}captureState(){return E({previousCarVelocity:this.previousCarVelocity,poseOffset:this.poseOffset,poseVelocity:this.poseVelocity,poseForce:this.poseForce,wheelPhase:this.wheelPhase})}restoreState(e){let t=E(e);this.previousCarVelocity=t.previousCarVelocity,this.poseOffset=t.poseOffset,this.poseVelocity=t.poseVelocity,this.poseForce=t.poseForce,this.wheelPhase=t.wheelPhase,this.clearMaterials()}clearMaterials(){this.carImages.clear(),this.pristineShadows=new WeakMap,this.deformedShadows=new WeakMap}reset(){this.markers=[],this.previousCarVelocity=null,this.poseOffset=D(),this.poseVelocity=D(),this.poseForce=D(),this.wheelPhase=[0,0,0,0]}carImages=new Map;pristineShadows=new WeakMap;deformedShadows=new WeakMap;previousCarVelocity=null;poseOffset=D();poseVelocity=D();poseForce=D();wheelPhase=[0,0,0,0];carVisualOffset(e){return A(N(D(this.poseOffset.x,-this.poseOffset.y),-e.body.angle),this.camera.zoom)}updateCarPose(e,t){if(e.mode!==`car`){this.previousCarVelocity=null,this.poseOffset=D(),this.poseVelocity=D(),this.poseForce=D();return}let n=e.body.velocity,r=this.previousCarVelocity?A(k(n,this.previousCarVelocity),1/Math.max(t,1e-4)):D();this.previousCarVelocity={...n};let i=N(r,-e.body.angle),a=1-Math.exp(-t/.11);this.poseForce=O(this.poseForce,A(k(D(P(i.x,-15,15),P(i.y,-15,15)),this.poseForce),a));let o=D(P(-this.poseForce.x*.006,-.055,.055),0);this.poseVelocity=O(this.poseVelocity,A(k(A(k(o,this.poseOffset),65),A(this.poseVelocity,15)),t)),this.poseOffset=O(this.poseOffset,A(this.poseVelocity,t)),e.car.tires.forEach((n,r)=>{this.wheelPhase[r]=(this.wheelPhase[r]+t*Math.abs(n.wheelSurfaceSpeedMps)/Math.max(.18,e.car.preset.geometry.tireLengthM*.45))%1})}line(e,t,n,r,i=1){let a=this.camera.screen(t),o=this.camera.screen(n);e.strokeStyle=r,e.lineWidth=i,e.beginPath(),e.moveTo(a.x,a.y),e.lineTo(o.x,o.y),e.stroke()}outline(e,t,n){e.beginPath(),t.forEach((t,n)=>{let r=this.camera.screen(t);n?e.lineTo(r.x,r.y):e.moveTo(r.x,r.y)}),e.closePath(),e.fillStyle=`${n}15`,e.fill(),e.strokeStyle=n,e.lineWidth=2,e.stroke()}imageFor(e){let t=e.image?.src;if(!t)return null;let n=this.carImages.get(t);return n||(n=new Image,n.crossOrigin=`anonymous`,n.src=t,this.carImages.set(t,n)),n.complete&&n.naturalWidth?n:null}markers=[];markerAt(e){return[...this.markers].reverse().find(t=>Math.hypot(e.x-t.x,e.y-t.y)<=t.width/2+3)?.vehicle??null}drawVehicleMarkers(e,t,n,r){if(this.markers=[],n)for(let n of t){let{sim:i}=n;if(i.mode!==`car`||i.car.explodedAt!==null)continue;let a=O(this.camera.screen(i.body.position),n===t[0]?this.carVisualOffset(i):D()),o=Math.max(i.car.preset.geometry.lengthM,i.car.preset.geometry.widthM)*this.camera.zoom*.5;if(a.x+o>=0&&a.x-o<=this.camera.width&&a.y+o>=0&&a.y-o<=this.camera.height)continue;let s=$c(a,this.camera,this.camera.zoom,this.camera.overlay?84:8),{width:c,height:l}=s,{x:u,y:d}=s.center;this.markers.push({vehicle:n,x:u,y:d,width:c,height:l});let f=n===r,p=f?`#f05a4f`:`#a9c5d4`;e.save(),e.translate(u,d),e.shadowColor=`#0000004a`,e.shadowBlur=16,e.shadowOffsetY=4,e.fillStyle=`#192126f5`,e.beginPath(),e.arc(0,0,c/2,0,Math.PI*2),e.fill(),e.shadowColor=`transparent`,e.strokeStyle=`#ffffff40`,e.lineWidth=1,e.stroke();let m=this.imageFor(i.car.preset);if(e.save(),e.translate(0,-11),e.rotate(-i.body.angle),m){let t=Kt(i.car.preset,m.naturalWidth,m.naturalHeight),n=52*t.widthM/t.lengthM;e.drawImage(m,t.source.x,t.source.y,t.source.width,t.source.height,-26,-n/2,52,n)}else e.fillStyle=`#edf2f2`,e.beginPath(),e.roundRect(-15,-6,30,12,5),e.fill();e.restore(),e.fillStyle=`#f7f9fa`,e.font=`700 10px ui-sans-serif, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(f?`YOUR CAR`:`AI CAR`,0,25),e.fillStyle=`#b6c4c9`,e.font=`500 9px ui-sans-serif, system-ui, sans-serif`,e.fillText(s.distance,0,38);let{direction:h,edge:g,tip:_}=s;e.strokeStyle=p,e.lineWidth=2.5,e.lineCap=`round`,e.beginPath(),e.moveTo(g.x+h.x*2,g.y+h.y*2),e.lineTo(_.x-h.x*5,_.y-h.y*5),e.stroke(),e.fillStyle=p,e.beginPath(),e.moveTo(_.x,_.y),e.lineTo(_.x-h.x*9-h.y*5,_.y-h.y*9+h.x*5),e.lineTo(_.x-h.x*9+h.y*5,_.y-h.y*9-h.x*5),e.closePath(),e.fill(),e.restore()}}shadowFor(e,t,n){let r=this.imageFor(e);if(!r)return null;let i=Kt(e,r.naturalWidth,r.naturalHeight),a=t?.spriteFor(r,i)??null,o=Math.max(1,Math.round(this.camera.zoom/2)*2),s=`${JSON.stringify(e.image?.crop)}|${e.image?.scale}|${e.geometry.lengthM}:${e.geometry.widthM}|${o}:${n}`;if(t&&a){let i=`${s}|${t.geometryRevision}`,c=this.deformedShadows.get(t);if(c?.image===r&&c.key===i)return c.shadow;let l=Yc(r,e,a,o,n);return this.deformedShadows.set(t,{image:r,key:i,shadow:l}),l}let c=this.pristineShadows.get(r);c||(c=new Map,this.pristineShadows.set(r,c));let l=c.get(s);return l||(l=Yc(r,e,a,o,n),c.set(s,l),c.size>12&&c.delete(c.keys().next().value)),l}vehicleBodyPath(e,t,n,r,i){if(!i?.hasDamage){e.roundRect(-t/2,-n/2,t,n,r);return}let a=Math.min(r,n/2),o=[{x:t/2-a,y:-n/2+a,start:-Math.PI/2},{x:t/2-a,y:n/2-a,start:0},{x:-t/2+a,y:n/2-a,start:Math.PI/2},{x:-t/2+a,y:-n/2+a,start:Math.PI}],s=!0;for(let t of o)for(let n=0;n<=8;n++){let r=t.start+n*Math.PI/16,o=D(t.x+Math.cos(r)*a,t.y+Math.sin(r)*a),c=i.point(A(o,1/this.camera.zoom)),l=c.x*this.camera.zoom,u=c.y*this.camera.zoom;s?(e.moveTo(l,u),s=!1):e.lineTo(l,u)}e.closePath()}carGround(e,t,n,r,i){performance.now();let a=t.body,o=t.car.preset.geometry,s=this.camera.screen(a.position),c=o.lengthM*this.camera.zoom,l=o.widthM*this.camera.zoom,u=P(M(this.poseForce)/13,0,1),d=e.globalAlpha;e.save(),e.translate(s.x,s.y),e.rotate(-a.angle),e.save(),e.translate(-this.poseOffset.x*this.camera.zoom*.2+2,this.poseOffset.y*this.camera.zoom*.2+4);let f=i?this.shadowFor(t.car.preset,n,r):null;if(f){let t=f.lengthM*this.camera.zoom,n=f.widthM*this.camera.zoom,r=this.camera.zoom/f.pixelsPerMeter,i=(i,a)=>{let o=i.padding*r;e.drawImage(i.canvas,-t/2-o,-n/2+a-o,t+o*2,n+o*2)};e.globalAlpha=d*(.43+u*.05),f.soft&&i(f.soft,3),e.globalAlpha=d*.14,f.close&&i(f.close,2)}else if(i){e.fillStyle=`rgba(13, 20, 20, ${.18+u*.045})`,e.shadowColor=`rgba(8, 14, 16, 0.43)`,e.shadowBlur=12+u*5,e.shadowOffsetY=2,e.beginPath();let r=t.car.preset.visual,i=r?l*.86:l*.84,a=r?r.shape===`suv`?9:r.shape===`supercar`?24:19:l*.34;this.vehicleBodyPath(e,r?c:c*.96,i,a,n),e.fill()}e.restore(),t.car.tires.forEach((n,r)=>{let i=Jc(t.car.preset),o=i.length*this.camera.zoom,s=i.width*this.camera.zoom;e.save(),e.translate(n.local.x*this.camera.zoom,-n.local.y*this.camera.zoom),e.rotate(-n.angle),e.fillStyle=`#121719`,e.beginPath(),e.roundRect(-o/2,-s/2,o,s,Math.min(3.5,s*.33)),e.fill(),e.save(),e.beginPath(),e.roundRect(-o/2+1,-s/2+1,o-2,s-2,Math.min(3,s*.3)),e.clip();let c=this.wheelPhase[r]??0,l=n.spinning?1:P(M(a.velocity)/24,0,.65),u=Math.max(4.2,o/4);e.strokeStyle=n.spinning?`rgba(170, 181, 178, 0.38)`:`rgba(125, 139, 137, 0.34)`,e.lineWidth=n.spinning?2:1.25;for(let t=-3;t<=4;t++){let n=t*u+c*u;e.beginPath(),e.moveTo(n-l*2,-s*.31),e.lineTo(n+l*2,s*.31),e.stroke()}l>.2&&(e.fillStyle=`rgba(137, 150, 147, ${.08+l*.1})`,e.fillRect(-o*.4,-s*.09,o*.8,s*.18)),e.restore(),e.strokeStyle=`rgba(6, 10, 11, 0.8)`,e.lineWidth=1.2,e.beginPath(),e.roundRect(-o/2,-s/2,o,s,Math.min(3.5,s*.33)),e.stroke(),e.restore()}),e.restore()}car(e,t,n,r,i){let a=n.car.preset,o=a.geometry,s=this.imageFor(a);if(s){let n=this.camera.screen(t.position),o=Kt(a,s.naturalWidth,s.naturalHeight),c=r?.spriteFor(s,o);e.save(),e.translate(n.x,n.y),e.rotate(-t.angle),qa(e,a,this.camera.zoom,o.lengthM,o.widthM,i),c?e.drawImage(c,-o.lengthM*this.camera.zoom/2,-o.widthM*this.camera.zoom/2,o.lengthM*this.camera.zoom,o.widthM*this.camera.zoom):e.drawImage(s,o.source.x,o.source.y,o.source.width,o.source.height,-o.lengthM*this.camera.zoom/2,-o.widthM*this.camera.zoom/2,o.lengthM*this.camera.zoom,o.widthM*this.camera.zoom),e.restore();return}if(a.visual){this.styledCar(e,t,n,r);return}let c=o.lengthM/2,l=o.widthM/2,u=[D(-c,-l),D(c,-l),D(c,l),D(-c,l)].map(e=>t.world(e));this.outline(e,u,`#8ce6c5`),this.line(e,t.world(D(o.wheelbaseM/4,-o.trackWidthM/2)),t.world(D(o.wheelbaseM/4,o.trackWidthM/2)),`#8ce6c5`,2),this.center(e,t,`#8ce6c5`)}exhaustOutlets(e){let t=e.car.preset,n=this.imageFor(t),r=n?Kt(t,n.naturalWidth,n.naturalHeight).lengthM:t.geometry.lengthM,i=t.exhaust.layout,a=t.geometry.widthM*.3;return(i===`left-right`?[-a,a]:i===`left`?[-a]:i===`right`?[a]:[0]).map(e=>D(-r/2-.025,e))}exhaust(e,t){let n=this.camera.screen(t.body.position);e.save(),e.translate(n.x,n.y),e.rotate(-t.body.angle);let r=this.exhaustOutlets(t);for(let t of r)e.fillStyle=`rgba(25, 31, 33, 0.62)`,e.beginPath(),e.ellipse(t.x*this.camera.zoom,-t.y*this.camera.zoom,Math.max(1.3,this.camera.zoom*.065),Math.max(1.2,this.camera.zoom*.055),0,0,Math.PI*2),e.fill();e.restore()}styledCar(e,t,n,r){let{geometry:i,visual:a}=n.car.preset;if(!a)return;let o=this.camera.screen(t.position),s=i.lengthM*this.camera.zoom,c=i.widthM*this.camera.zoom*.86,l=a.shape===`suv`?9:a.shape===`supercar`?24:19;e.save(),e.translate(o.x,o.y),e.rotate(-t.angle),e.beginPath(),this.vehicleBodyPath(e,s,c,l,r),e.fillStyle=a.color,e.fill(),e.strokeStyle=`rgba(18, 29, 27, 0.72)`,e.lineWidth=2,e.stroke(),e.fillStyle=`rgba(16, 32, 36, 0.8)`;let u=s*(a.shape===`suv`?.52:a.shape===`supercar`?.32:.4),d=c*(a.shape===`suv`?.72:.64),f=a.shape===`supercar`?-s*.08:-s*.015;e.beginPath(),e.roundRect(f-u/2,-d/2,u,d,a.shape===`suv`?7:14),e.fill(),e.strokeStyle=`rgba(235, 245, 241, 0.58)`,e.lineWidth=2,e.beginPath(),e.moveTo(f+u*.16,-d/2+3),e.lineTo(f+u*.16,d/2-3),e.stroke(),e.fillStyle=`rgba(255, 246, 205, 0.9)`;let p=tt(n.car.preset);for(let t of[-1,1])e.beginPath(),e.ellipse(p.headlights.xM*this.camera.zoom,t*p.headlights.yM*this.camera.zoom,4,3,0,0,Math.PI*2),e.fill();e.fillStyle=`rgba(139, 28, 21, 0.88)`;for(let t of[-1,1])e.fillRect(p.taillights.xM*this.camera.zoom-2,t*p.taillights.yM*this.camera.zoom-3,4,6);e.restore()}ship(e,t,n){let r=n.ship,i=r.craft,a=t.world(r.counterweight);this.line(e,t.world(O(r.counterweight,D(r.radius))),t.world(O(i,D(-.6))),`#ff6262`,2);let o=this.camera.screen(a);e.beginPath(),e.arc(o.x,o.y,r.radius*this.camera.zoom,0,Math.PI*2),e.fillStyle=`#ff626215`,e.fill(),e.strokeStyle=`#ff6262`,e.lineWidth=2,e.stroke();let s=[D(1.2),D(-.6,-.8),D(-.6,.8)].map(e=>t.world(O(i,N(e,r.headAngle))));this.outline(e,s,`#ff6262`),this.center(e,t,`#ff6262`)}brick(e,t){this.outline(e,[D(-2,-1),D(2,-1),D(2,1),D(-2,1)].map(e=>t.world(e)),`#f6bd79`),this.center(e,t,`#f6bd79`)}center(e,t,n){let r=this.camera.screen(t.position);e.fillStyle=n,e.beginPath(),e.arc(r.x,r.y,3,0,Math.PI*2),e.fill(),!this.camera.overlay&&M(t.velocity)>.1&&this.line(e,t.position,O(t.position,A(t.velocity,.35)),`#658da0`)}};function tl(e,t,n){return n?D(n.x+n.width/2,n.y+n.height/2):D(e/2,t/2)}function nl(e,t,n){let r=tl(e,t,n);return Math.ceil(2*Math.hypot(Math.max(r.x,e-r.x),Math.max(r.y,t-r.y)))}function rl(e,t,n,r){return O(n,N(k(e,t),r))}function il(e,t,n,r){return O(t,N(k(e,n),-r))}function al(e,t,n){return A(D(e,t),n/2)}function ol(e,t,n,r){return e+Math.atan2(Math.sin(t-e),Math.cos(t-e))*(r<=0?1:1-Math.exp(-Math.max(0,n)/r))}function sl(e,t,n){return{x:e.x<n?e.x-n:e.x>t.width-n?e.x-(t.width-n):0,y:e.y<n?e.y-n:e.y>t.height-n?e.y-(t.height-n):0}}var cl={};function ll(e,t={x:0,y:0},n=1){let r=Go();return{x:e.left/n+r.x+t.x,y:e.top/n+r.y+t.y,width:e.width/n,height:e.height/n}}var ul={scale:1,viewportRectToDocument:ll},dl=`[data-jr-overlay],[data-jr-ui],[data-jr-touch-controls],[data-jr-embed],script,style,link`,fl=class{scale=1;signature=``;originals=new Map;viewportRectToDocument(e,t={x:0,y:0}){return ll(e,t,this.scale)}apply(e,t){let n=Go(),r=`${e}:${t.x}:${t.y}:${n.x}:${n.y}:${document.body.children.length}`;if(r!==this.signature||cl.owner!==this){this.signature=r;for(let r of Array.from(document.body.children))if(r instanceof HTMLElement&&!r.matches(dl)){if(!this.originals.has(r)){this.originals.set(r,{translate:r.style.translate,scale:r.style.scale,origin:r.style.transformOrigin});let e=0,t=0;for(let n=r;n;n=n.offsetParent)e+=n.offsetLeft,t+=n.offsetTop;r.style.transformOrigin=`${-e}px ${-t}px`}r.style.scale=String(e),r.style.translate=`${n.x-t.x*e}px ${n.y-t.y*e}px`}this.scale=e,cl.owner=this}}clear(){for(let[e,t]of this.originals)e.style.translate=t.translate,e.style.scale=t.scale,e.style.transformOrigin=t.origin;this.originals.clear(),this.signature=``,this.scale=1,cl.owner===this&&(cl.owner=void 0)}};function pl(e,t,n){let r=Math.min(Math.max(1,t.width-32)/Math.max(1,e.width+160),Math.max(1,t.height-32)/Math.max(1,e.height+160));return Math.max(.1,Math.min(3,n??r))}function ml(e,t){let n=null;for(let r of e){let e=r.bounds;t.x<e.x||t.y<e.y||t.x>=e.x+e.width||t.y>=e.y+e.height||(!n||n.element.contains(r.element)||!r.element.contains(n.element)&&e.width*e.height<n.bounds.width*n.bounds.height)&&(n=r)}return n}var hl=class{projection;regions=[];measuredAt=-1/0;constructor(e=ul){this.projection=e}at(e,t,n){return n-this.measuredAt>120&&(this.measuredAt=n,this.regions=Array.from(document.querySelectorAll(`[data-jr-camera],[data-jr-camera-zoom]`)).filter(e=>!e.closest(`[data-jr-ui],[data-jr-overlay]`)).flatMap(e=>{let n=e.getAttribute(`data-jr-camera`);if(n!==null&&n!==`fixed`&&n!==`follow`)return[];let r=this.projection.viewportRectToDocument(e.getBoundingClientRect(),t);if(r.width<=0||r.height<=0)return[];let i=e.getAttribute(`data-jr-camera-zoom`),a=i?.trim()?Number(i):NaN;return n===null&&(!Number.isFinite(a)||a<=0)?[]:[{element:e,bounds:r,fixed:n===`fixed`,zoom:Number.isFinite(a)&&a>0?a:void 0}]})),ml(this.regions.filter(e=>e.element.isConnected),e)}reset(){this.regions=[],this.measuredAt=-1/0}},gl={minimumScale:.58,startsAtMps:3,fullAtMps:20,responsePerSecond:4};function _l(e,t,n,r,i){return e===`auto`?t&&!n&&(r.x<0||r.y<0||r.x>i.width||r.y>i.height):e}var vl=class{overlay;canvasWorld;requestResize;constructor(e,t,n){this.overlay=e,this.canvasWorld=t,this.requestResize=n,e&&(this.originScroll=D(window.scrollX,window.scrollY),this.observedScroll={...this.originScroll},this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight})}resize(){this.requestResize()}get pixelSpace(){return this.overlay||this.canvasWorld}get timeSeconds(){return this.lastFrame/1e3}rebaseTime(e){this.lastFrame=e}captureState(){return E({outputWidth:this.outputWidth,outputHeight:this.outputHeight,cameraRotation:this.cameraRotation,cameraLock:this.cameraLock,cameraSmoothing:this.cameraSmoothing,cameraLockInitialized:this.cameraLockInitialized,width:this.width,height:this.height,dpr:this.dpr,smokeMargin:this.smokeMargin,regionScale:this.regionScale,canvasWorldScale:this.canvasWorldScale,cameraFrame:this.cameraFrame,camera:this.camera,zoom:this.zoom,baseZoom:this.baseZoom,speedScale:this.speedScale,slowMoScale:this.slowMoScale,zoomAnchor:this.zoomAnchor,pageSize:this.pageSize,lastFrame:this.lastFrame,speedSamples:this.speedSamples,originScroll:this.originScroll,observedScroll:this.observedScroll,virtualScroll:this.virtualScroll,followInterrupted:this.followInterrupted,deadZone:this.deadZone,speedZoom:this.speedZoom,speedZoomMinimumScale:this.speedZoomMinimumScale})}restoreState(e){let t=E(e);this.vehicleReveal=null,this.outputWidth=t.outputWidth,this.outputHeight=t.outputHeight,this.cameraRotation=t.cameraRotation,this.cameraLock=t.cameraLock,this.cameraSmoothing=t.cameraSmoothing,this.cameraLockInitialized=t.cameraLockInitialized,this.width=t.width,this.height=t.height,this.dpr=t.dpr,this.smokeMargin=t.smokeMargin,this.regionScale=t.regionScale,this.canvasWorldScale=t.canvasWorldScale,this.cameraFrame=t.cameraFrame,this.camera=t.camera,this.zoom=t.zoom,this.baseZoom=t.baseZoom,this.speedScale=t.speedScale,this.slowMoScale=t.slowMoScale,this.zoomAnchor=t.zoomAnchor,this.pageSize=t.pageSize,this.lastFrame=t.lastFrame,this.speedSamples=t.speedSamples,this.originScroll=t.originScroll,this.observedScroll=t.observedScroll,this.virtualScroll=t.virtualScroll,this.followInterrupted=t.followInterrupted,this.deadZone=t.deadZone,this.speedZoom=t.speedZoom,this.speedZoomMinimumScale=t.speedZoomMinimumScale}restorePresentation(){this.setVirtualScroll({...this.virtualScroll}),this.overlay&&(window.scrollTo(this.observedScroll.x,this.observedScroll.y),Ko(),this.resize(),this.cameraRegions.reset(),this.activeCameraRegion||this.regionScale!==1?this.pageScene.apply(this.regionScale,this.sceneScroll()):this.pageScene.clear())}reset(){this.vehicleReveal=null,this.camera=D(),this.cameraLockInitialized=!1,this.speedScale=1,this.slowMoZoom=1,this.zoomAnchor=D(),this.overlay&&(this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight}),this.pageScene.clear(),this.activeCameraRegion=null,this.cameraRegions.reset(),this.regionScale=this.canvasWorld?this.canvasWorldScale:1,this.resize(),this.setVirtualScroll(D()),this.speedSamples=[]}vehicleReveal=null;revealVehicle(e,t=550){this.overlay&&(this.syncScroll(),this.followInterrupted=!0,this.vehicleReveal={sim:e,start:this.sceneScroll(),started:null,duration:t})}advanceVehicleReveal(e,t){let n=this.vehicleReveal;if(!n)return;n.started??=e;let r=n.duration<=0?1:P((e-n.started)/n.duration,0,1),i=r*r*(3-2*r),a=k(this.documentPoint(n.sim.body.position),D(this.width/2,this.height/2));!this.virtualScroll.x&&a.x>=-this.width/2&&a.x<=this.pageSize.width-this.width/2&&(a.x=P(a.x,0,Math.max(0,this.pageSize.width-this.width))),!this.virtualScroll.y&&a.y>=-this.height/2&&a.y<=this.pageSize.height-this.height/2&&(a.y=P(a.y,0,Math.max(0,this.pageSize.height-this.height))),this.moveSceneTo(O(n.start,A(k(a,n.start),i))),r===1&&(this.vehicleReveal=null,n.sim===t&&(this.followInterrupted=!1))}resetFollow(){this.vehicleReveal=null,this.overlay&&(this.originScroll=D(window.scrollX,window.scrollY),this.observedScroll={...this.originScroll},this.followInterrupted=!1)}dispose(){this.vehicleReveal=null,this.pageScene.clear(),this.setVirtualScroll(D()),Ko()}resizeLayout(e,t,n){this.outputWidth=e,this.outputHeight=t;let r=this.canvasWorld&&this.cameraLock,i=r?nl(e,t,this.cameraFrame):0,a=(r?i:e)/this.regionScale,o=(r?i:t)/this.regionScale;this.overlay&&this.width>1&&(a!==this.width||o!==this.height)&&(this.originScroll.x+=(this.width-a)/2,this.originScroll.y+=(this.height-o)/2),this.width=a,this.height=o;let s=Math.min(e,t);this.baseZoom=this.canvasWorld?28:this.overlay?Math.max(14,Math.min(28,s/11)):Math.max(1,Math.min(s<600?32:28,(s-32)/10,s/25)),this.zoom=this.baseZoom*(this.canvasWorld?1:this.speedScale*(this.overlay?1:this.slowMoZoom)),this.overlay&&this.regionScale===1&&!this.virtualScroll.x&&!this.virtualScroll.y&&this.speedScale>.999&&(this.pageSize={width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight}),this.smokeMargin=this.canvasWorld?96/this.regionScale:this.pixelSpace?Math.min(112,Math.max(72,Math.min(this.width,this.height)*.1)):0;let c=this.width*this.height;this.dpr=Math.min(2*(this.canvasWorld?this.regionScale:1),n*this.regionScale,Math.sqrt(24e6/c),16384/Math.max(this.width,this.height))}outputWidth=1;outputHeight=1;cameraRotation=0;cameraLock=!1;cameraSmoothing=.25;cameraLockInitialized=!1;width=1;height=1;dpr=1;smokeMargin=0;pageScene=new fl;cameraRegions=new hl(this.pageScene);get documentProjection(){return this.pageScene}activeCameraRegion=null;regionScale=1;canvasWorldScale=1;cameraFrame=null;camera=D();zoom=28;baseZoom=28;speedScale=1;slowMoScale=1;get slowMoZoom(){return this.slowMoScale??1}set slowMoZoom(e){this.slowMoScale=e}zoomAnchor=D();pageSize={width:1,height:1};lastFrame=0;speedSamples=[];originScroll=D();observedScroll=D();virtualScroll=D();followInterrupted=!1;deadZone=!0;speedZoom=`auto`;speedZoomMinimumScale=gl.minimumScale;screen(e){return D(this.width/2+(e.x-this.camera.x)*this.zoom,this.height/2-(e.y-this.camera.y)*this.zoom)}world(e){return D(this.camera.x+(e.x-this.width/2)/this.zoom,this.camera.y-(e.y-this.height/2)/this.zoom)}vehicleViewportPosition(e){return this.overlay&&this.syncScroll(),this.screen(e)}sceneScroll(){return this.canvasWorld?D(this.camera.x*28-this.width/2,-this.camera.y*28-this.height/2):O(Go(),this.virtualScroll)}virtualOffset(){return{...this.virtualScroll}}documentPoint(e){return this.canvasWorld?an(e):(this.overlay&&this.syncScroll(),O(this.screen(e),this.sceneScroll()))}worldFromDocument(e){return this.canvasWorld?on(e):(this.overlay&&this.syncScroll(),this.world(k(e,this.sceneScroll())))}documentScale(){return this.canvasWorld?28:this.zoom}particlePoint(e){return this.pixelSpace?this.documentPoint(e):{...e}}particleScale(){return this.pixelSpace?this.documentScale():1}viewportSize(){return{width:this.width,height:this.height}}presentationScale(){return this.regionScale}setCanvasWorldScale(e,t=1.5){if(!this.canvasWorld)return;this.canvasWorldScale=Math.max(.2,Math.min(Math.max(.2,Math.min(4,Number.isFinite(t)?t:1.5)),Number.isFinite(e)?e:1));let n=this.canvasWorldScale*this.speedScale*this.slowMoZoom;this.regionScale!==n&&(this.regionScale=n,this.resize())}setCameraFrame(e){this.cameraFrame=e,this.canvasWorld&&this.cameraLock&&this.resize()}setCameraLock(e){this.canvasWorld&&this.cameraLock!==e&&(this.cameraLock=e,this.cameraLockInitialized=!1,e||(this.cameraRotation=0),this.resize())}viewportFromDocument(e){let t=A(k(e,this.sceneScroll()),this.regionScale);return this.canvasWorld&&this.cameraLock?rl(t,al(this.width,this.height,this.regionScale),tl(this.outputWidth,this.outputHeight,this.cameraFrame),this.cameraRotation):t}documentFromViewport(e){return O(A(this.canvasWorld&&this.cameraLock?il(e,al(this.width,this.height,this.regionScale),tl(this.outputWidth,this.outputHeight,this.cameraFrame),this.cameraRotation):e,1/this.regionScale),this.sceneScroll())}bounds(){this.overlay&&this.syncScroll();let e=this.width/(2*this.zoom)-3/this.zoom,t=this.height/(2*this.zoom)-3/this.zoom;return{left:this.camera.x-e,right:this.camera.x+e,bottom:this.camera.y-t,top:this.camera.y+t}}setVirtualScroll(e){if(!this.overlay)return;this.virtualScroll=D(Math.abs(e.x)<.01?0:e.x,Math.abs(e.y)<.01?0:e.y);let t=document.body;this.virtualScroll.x||this.virtualScroll.y?(t.dataset.jrVirtualCamera===void 0&&(t.dataset.jrVirtualCamera=``),t.style.setProperty(`--joy-ride-scene-x`,`${-this.virtualScroll.x}px`),t.style.setProperty(`--joy-ride-scene-y`,`${-this.virtualScroll.y}px`)):(t.dataset.jrVirtualCamera!==void 0&&delete t.dataset.jrVirtualCamera,t.style.removeProperty(`--joy-ride-scene-x`),t.style.removeProperty(`--joy-ride-scene-y`))}syncScroll(e=!1){let t=D(Go().x,Go().y);e||M(k(t,this.observedScroll))>.5&&(this.followInterrupted=!0),this.observedScroll=t,(this.activeCameraRegion||this.regionScale!==1)&&this.pageScene?.apply(this.regionScale,this.sceneScroll());let n=O(t,this.virtualScroll);this.camera=D((n.x-this.originScroll.x-this.zoomAnchor.x*(this.baseZoom-this.zoom))/this.zoom,-(n.y-this.originScroll.y+this.zoomAnchor.y*(this.baseZoom-this.zoom))/this.zoom)}resumeFollow(){this.vehicleReveal=null,this.overlay&&(this.syncScroll(),this.followInterrupted=!1)}interruptFollow(){this.vehicleReveal=null,this.overlay&&(this.followInterrupted=!0)}restorePage(e){if(!this.overlay||!this.virtualScroll.x&&!this.virtualScroll.y&&!this.activeCameraRegion&&this.regionScale===1)return!1;this.syncScroll(!0);let t=A(this.screen(e.body.position),this.regionScale??1);return(this.activeCameraRegion||this.regionScale!==1)&&(this.slowMoZoom=1,this.pageScene.clear(),this.activeCameraRegion=null,this.regionScale=1,this.resize()),this.setVirtualScroll(D()),this.syncScroll(!0),e.body.position=this.world(t),!0}followDocument(e){if(!this.overlay)return!1;if(this.vehicleReveal||this.activeCameraRegion?.fixed)return!0;if(this.zoomAnchor={...e.body.position},this.syncScroll(),this.followInterrupted)return!1;let t=this.screen(e.body.position),n=Math.max(e.car.preset.geometry.lengthM*this.zoom/2+12,Math.min(this.width,this.height)*.25),r=sl(t,{width:this.width,height:this.height},n);if(r.x||r.y){if(e.barrier)window.scrollBy({left:r.x,top:r.y,behavior:`instant`}),Ko();else{let e=D(r.x*this.virtualScroll.x<0?Math.sign(r.x)*Math.min(Math.abs(r.x),Math.abs(this.virtualScroll.x)):0,r.y*this.virtualScroll.y<0?Math.sign(r.y)*Math.min(Math.abs(r.y),Math.abs(this.virtualScroll.y)):0);this.setVirtualScroll(O(this.virtualScroll,e));let t=k(r,e),n=Go();(t.x||t.y)&&(window.scrollBy({left:t.x,top:t.y,behavior:`instant`}),Ko());let i=k(Go(),n);this.setVirtualScroll(O(this.virtualScroll,k(t,i)))}}return this.syncScroll(!0),!0}moveSceneTo(e){window.scrollBy({left:e.x-Go().x,top:e.y-Go().y,behavior:`instant`}),Ko(),this.setVirtualScroll(D(e.x-Go().x,e.y-Go().y)),this.syncScroll(!0)}updateCameraRegion(e,t){let n=this.cameraFrame??{x:0,y:0,width:window.innerWidth,height:window.innerHeight},r=this.activeCameraRegion!==null&&!e,i=e!==null&&this.activeCameraRegion?.element!==e.element,a=(e?e.fixed?pl(e.bounds,n,e.zoom):Math.max(.1,Math.min(3,e.zoom??1)):1)*this.slowMoZoom,o=this.regionScale,s=A(k(t,this.sceneScroll()),o);if(this.activeCameraRegion=e,r&&this.pageScene.clear(),Math.abs(a-this.regionScale)>1e-4&&(this.regionScale=a,this.resize()),e?.fixed){this.speedScale=1,this.zoom=this.baseZoom;let t=e.bounds;this.moveSceneTo(D(t.x+t.width/2-(n.x+n.width/2)/this.regionScale,t.y+t.height/2-(n.y+n.height/2)/this.regionScale))}else(r||i)&&(this.followInterrupted=!1,this.moveSceneTo(D(t.x-this.width/2,t.y-this.height/2)));!e?.fixed&&!r&&!i&&Math.abs(a-o)>1e-4&&this.moveSceneTo(k(t,A(s,1/a))),e||a!==1?this.pageScene.apply(this.regionScale,this.sceneScroll()):this.pageScene.clear()}cameraStep(e,t){let n=this.lastFrame?P((t-this.lastFrame)/1e3,0,.1):1/60;this.lastFrame=t;let r=e.body;if(this.canvasWorld){if(this.cameraLock){let e=r.angle-Math.PI/2,t=!this.cameraLockInitialized||M(k(r.position,this.camera))>40;this.cameraRotation=t?e:ol(this.cameraRotation,e,n,this.cameraSmoothing),t&&(this.camera={...r.position}),this.cameraLockInitialized=!0}else this.cameraRotation=0}let i=M(r.velocity);for(this.speedSamples.push({time:t,speed:i});this.speedSamples.length>2&&this.speedSamples[1].time<t-1e3;)this.speedSamples.shift();let a=0,o=0;for(let e=0;e<this.speedSamples.length-1;e++){let n=Math.max(t-1e3,this.speedSamples[e].time),r=this.speedSamples[e+1].time;a+=this.speedSamples[e].speed*(r-n),o+=r-n}let s=o>0?a/o:i,c=D(this.width/2+r.position.x*this.baseZoom+this.originScroll.x,this.height/2-r.position.y*this.baseZoom+this.originScroll.y),l=this.overlay?this.cameraRegions.at(c,this.virtualScroll,t):null;this.overlay&&this.updateCameraRegion(l,c);let u=!l&&(this.canvasWorld?this.speedZoom===!0:_l(this.speedZoom,this.overlay,e.barrier,c,this.pageSize))?1-(1-(this.speedZoomMinimumScale??gl.minimumScale))*P((s-gl.startsAtMps)/(gl.fullAtMps-gl.startsAtMps),0,1):1;this.speedScale+=(u-this.speedScale)*(1-Math.exp(-gl.responsePerSecond*n));let d=this.zoom;if(this.canvasWorld){let e=this.canvasWorldScale*this.speedScale*this.slowMoZoom;Math.abs(this.regionScale-e)>1e-4&&(this.regionScale=e,this.resize()),this.zoom=this.baseZoom}else this.zoom=this.baseZoom*this.speedScale*(this.overlay?1:this.slowMoZoom);if(this.overlay){this.zoomAnchor={...r.position},this.syncScroll(),this.advanceVehicleReveal(t,e);return}if(e.barrier)return;let f=d/this.zoom;if(this.camera=D(r.position.x-(r.position.x-this.camera.x)*f,r.position.y-(r.position.y-this.camera.y)*f),this.canvasWorld&&this.cameraLock){let e=this.cameraSmoothing<=0?1:1-Math.exp(-n/this.cameraSmoothing);this.camera=O(this.camera,A(k(r.position,this.camera),e));return}if(!this.deadZone){let e=this.canvasWorld&&!this.cameraLock?this.cameraFrame:null;this.camera=e?D(r.position.x-((e.x+e.width/2)/this.regionScale-this.width/2)/this.zoom,r.position.y+((e.y+e.height/2)/this.regionScale-this.height/2)/this.zoom):{...r.position};return}let p=this.width*.18/this.zoom,m=this.height*.18/this.zoom,h=D(r.position.x-P(r.position.x-this.camera.x,-p,p),r.position.y-P(r.position.y-this.camera.y,-m,m));this.camera=O(this.camera,A(k(h,this.camera),1-Math.exp(-16*n)))}},yl=class{canvas;camera;overlay;canvasWorld;sceneCanvas=null;sceneContext;constructor(e,t,n,r){this.canvas=e,this.camera=t,this.overlay=n,this.canvasWorld=r;let i=e.getContext(`2d`);if(!i)throw Error(`Joy Ride requires a 2D canvas context.`);this.sceneContext=i}get context(){return this.sceneContext}resize(){let e=Math.max(1,this.overlay?window.innerWidth:this.canvas.clientWidth),t=Math.max(1,this.overlay?window.innerHeight:this.canvas.clientHeight),n=e/this.camera.regionScale!==this.camera.width||t/this.camera.regionScale!==this.camera.height;this.camera.resizeLayout(e,t,window.devicePixelRatio||1);let r=this.canvasWorld&&this.camera.cameraLock;r?(this.sceneCanvas??=document.createElement(`canvas`),this.sceneContext=this.sceneCanvas.getContext(`2d`)):this.sceneCanvas&&(this.sceneContext=this.canvas.getContext(`2d`)),this.overlay&&(n||this.canvas.style.width!==`${this.camera.width}px`)&&(this.canvas.style.width=`${this.camera.width}px`,this.canvas.style.height=`${this.camera.height}px`,this.canvas.style.transformOrigin=`0 0`,this.canvas.style.scale=String(this.camera.regionScale));let i=Math.round(this.camera.width*this.camera.dpr),a=Math.round(this.camera.height*this.camera.dpr),o=r?this.sceneCanvas:this.canvas;if((o.width!==i||o.height!==a)&&(o.width=i,o.height=a),r){let n=this.camera.dpr/this.camera.regionScale,r=Math.round(e*n),i=Math.round(t*n);this.canvas.width!==r&&(this.canvas.width=r),this.canvas.height!==i&&(this.canvas.height=i)}return this.sceneContext.setTransform(this.camera.dpr,0,0,this.camera.dpr,0,0),this.canvasWorld?this.camera.dpr:void 0}clear(){this.sceneContext.setTransform(this.camera.dpr,0,0,this.camera.dpr,0,0),this.sceneContext.clearRect(0,0,this.camera.width,this.camera.height)}presentLockedCamera(){if(!this.canvasWorld||!this.camera.cameraLock||!this.sceneCanvas)return;let e=this.canvas.getContext(`2d`),t=this.camera.dpr/this.camera.regionScale,n=tl(this.camera.outputWidth,this.camera.outputHeight,this.camera.cameraFrame);e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.save(),e.translate(n.x*t,n.y*t),e.rotate(this.camera.cameraRotation),e.drawImage(this.sceneCanvas,-this.sceneCanvas.width/2,-this.sceneCanvas.height/2),e.restore()}dispose(){this.sceneCanvas&&=(this.sceneCanvas.width=1,this.sceneCanvas.height=1,null),this.canvas.style.scale=``,this.canvas.style.transformOrigin=``}},bl=class{frameRate=new qo;captureState(){return this.frameRate.captureState()}restoreState(e){this.frameRate.restoreState(e)}draw(e,t,n,r,i){let a=e,o=t.body,s=this.frameRate.sample(n);a.save();let c=Jc(t.car.preset);for(let e of t.car.tires){let t=r(o.world(e.local));a.strokeStyle=e.front?`#00dcff`:`#ffae31`,a.lineWidth=2;let n=[D(-c.length/2,-c.width/2),D(c.length/2,-c.width/2),D(c.length/2,c.width/2),D(-c.length/2,c.width/2)].map(t=>r(o.world(O(e.local,N(t,e.angle)))));a.beginPath(),n.forEach((e,t)=>t?a.lineTo(e.x,e.y):a.moveTo(e.x,e.y)),a.closePath(),a.stroke(),a.beginPath(),a.arc(t.x,t.y,4,0,Math.PI*2),a.stroke(),a.beginPath(),a.moveTo(t.x-7,t.y),a.lineTo(t.x+7,t.y),a.moveTo(t.x,t.y-7),a.lineTo(t.x,t.y+7),a.stroke(),a.font=`bold 10px ui-monospace, SFMono-Regular, monospace`,a.fillStyle=e.front?`#007e91`:`#895000`,a.fillText(`${e.front?`F`:`R`}${e.local.y>0?`L`:`R`}${e.skidding?` SKID`:``}`,t.x+8,t.y-8)}let l=r(o.position),u=(e,t,n)=>{let r=O(l,A(e,n));a.strokeStyle=t,a.fillStyle=t,a.lineWidth=2.5,a.beginPath(),a.moveTo(l.x,l.y),a.lineTo(r.x,r.y),a.stroke();let i=Math.atan2(e.y,e.x);a.beginPath(),a.moveTo(r.x,r.y),a.lineTo(r.x-Math.cos(i-.5)*9,r.y-Math.sin(i-.5)*9),a.lineTo(r.x-Math.cos(i+.5)*9,r.y-Math.sin(i+.5)*9),a.closePath(),a.fill()};u(D(Math.cos(o.angle),-Math.sin(o.angle)),`#00c4df`,67);let d=M(o.velocity);d>.2&&u(D(o.velocity.x/d,-o.velocity.y/d),`#f05bd6`,48+Math.min(32,d));let f=Math.atan2(o.velocity.y,o.velocity.x),p=Math.atan2(Math.sin(o.angle-f),Math.cos(o.angle-f)),m=Math.max(...t.car.tires.filter(e=>e.front).map(e=>e.gripUtilization)),h=Math.max(...t.car.tires.filter(e=>!e.front).map(e=>e.gripUtilization)),g=t.car.tires.map(e=>`${e.front?`F`:`R`}${e.local.y>0?`L`:`R`} ${e.slipSpeedMps.toFixed(1)}${e.skidding?`*`:``}`).join(` `),_=[`${t.car.preset.name} · ${(d*3.6).toFixed(0)} km/h · ${Math.round(s)} FPS`,`input T ${t.lastInput.throttle} S ${t.lastInput.steer} brake ${Number(t.lastInput.action)}`,`body ${Math.round(o.angle*180/Math.PI)}° travel ${Math.round(f*180/Math.PI)}° slip ${Math.round(p*180/Math.PI)}°`,`front load ${(t.car.frontLoadFraction*100).toFixed(0)}% burnout ${Number(t.car.burnout)} charge ${t.car.boostCharge.toFixed(2)}`,`grip use F ${m.toFixed(2)} R ${h.toFixed(2)} drift ${Number(t.car.drifting)} donut ${Number(t.car.donuting)}`,`drift ${Number(t.car.fastDrifting)} countersteer ${Number(t.car.countersteering)}`,`roof rocket ${i.rocketState}`,`side guns ${i.gunState} · ${i.bulletCount} bullets`,`tire slip m/s ${g}`,`fluid ${i.fluidEngine} ${i.quality} ${i.fluidCols}×${i.fluidRows}`,`shared fire ${i.fireCols}×${i.fireRows} · ${i.groundedFireCount} grounded sources`,`cyan = nose/shape pink = travel amber = walls`,`wheel cyan = front wheel amber = rear violet = letters`];a.fillStyle=`rgba(10, 21, 24, 0.87)`,a.fillRect(12,88,Math.min(430,i.width-24),_.length*18+18),a.font=`12px ui-monospace, SFMono-Regular, monospace`,a.fillStyle=`#f1f5f3`,_.forEach((e,t)=>a.fillText(e,22,110+t*18)),a.restore()}},xl=[.82,.91,1],Sl=[1,.045,.018],Cl=e=>Math.max(0,Math.min(1,e));function wl(e){let t=/^#([\da-f]{6})$/i.exec(e);if(!t)return[.4,.9,1];let n=parseInt(t[1],16);return[(n>>16)/255,(n>>8&255)/255,(n&255)/255]}function Tl(e,t,n){let r=Math.cos(e.angle),i=Math.sin(e.angle);return{x:e.center.x+r*t-i*n,y:e.center.y+i*t+r*n}}var El=class{sprites=new WeakMap;halos=new WeakMap;beam=null;sprite(e){let t=e.image;if(!t||!t.complete||!t.naturalWidth)return null;let n=e.source??{x:0,y:0,width:t.naturalWidth,height:t.naturalHeight},r=e.mounts.taillights.map(t=>`${Math.round(t.x/e.width*1e4)},${Math.round(t.y/e.height*1e4)}`).join(`;`),i=`${n.x},${n.y},${n.width},${n.height}|${r}`,a=this.sprites.get(t);if(a||(a=new Map,this.sprites.set(t,a)),a.has(i))return a.get(i)??null;let o=document.createElement(`canvas`);o.width=192,o.height=Math.max(24,Math.round(192*n.height/n.width));let s=o.getContext(`2d`,{willReadFrequently:!0});if(!s)return a.set(i,null),null;s.drawImage(t,n.x,n.y,n.width,n.height,0,0,o.width,o.height);let c;try{c=s.getImageData(0,0,o.width,o.height)}catch{return a.set(i,null),null}let l=s.createImageData(o.width,o.height),u=0;for(let t=0;t<o.height;t++)for(let n=0;n<o.width;n++){let r=(t*o.width+n)*4,i=c.data[r],a=c.data[r+1],s=c.data[r+2],d=c.data[r+3];n<o.width*.27&&i>100&&i>a*1.6&&i>s*1.5&&d>100&&e.mounts.taillights.some(r=>{let i=n-(.5+r.x/e.width)*o.width,a=t-(.5+r.y/e.height)*o.height;return i*i+a*a<(o.height*.18)**2})&&(l.data[r]=255,l.data[r+1]=22,l.data[r+2]=5,l.data[r+3]=Math.min(235,d),u++),c.data[r]=255,c.data[r+1]=255,c.data[r+2]=255,c.data[r+3]=d>90?255:0}s.putImageData(c,0,0);let d=null;u>1&&u<o.width*o.height*.055&&(d=document.createElement(`canvas`),d.width=o.width,d.height=o.height,d.getContext(`2d`)?.putImageData(l,0,0));let f={silhouette:o,brakes:d};return a.size>=8&&a.clear(),a.set(i,f),f}halo(e,t){let n=this.halos.get(e);n||(n=new Map,this.halos.set(e,n));let r=n.get(t);if(r)return r;let i=document.createElement(`canvas`);i.width=e.width+64,i.height=e.height+64;let a=i.getContext(`2d`);a.drawImage(e,32,32),a.globalCompositeOperation=`source-in`,a.fillStyle=t,a.fillRect(0,0,i.width,i.height),a.globalCompositeOperation=`source-over`;let o=document.createElement(`canvas`);o.width=i.width,o.height=i.height,o.getContext(`2d`).drawImage(i,0,0),a.clearRect(0,0,i.width,i.height),a.filter=`blur(14px)`,a.globalAlpha=.92,a.drawImage(o,-2,-5,o.width+4,o.height+10),a.filter=`blur(7px)`,a.globalAlpha=.9,a.drawImage(o,0,0),a.filter=`blur(3px)`,a.globalAlpha=.8,a.strokeStyle=t,a.lineWidth=3,a.lineCap=`round`;for(let t of[-1,1])a.beginPath(),a.moveTo(32+e.width*.18,32+e.height*(.5+t*.34)),a.lineTo(32+e.width*.82,32+e.height*(.5+t*.34)),a.stroke();return a.filter=`none`,a.globalAlpha=1,n.size>8&&n.clear(),n.set(t,i),i}beamImage(){if(this.beam)return this.beam;let e=document.createElement(`canvas`);e.width=256,e.height=128;let t=e.getContext(`2d`),n=t.createImageData(e.width,e.height);for(let t=0;t<e.height;t++)for(let r=0;r<e.width;r++){let i=r/e.width,a=(t/e.height-.5)*2,o=.035+i*.94,s=Cl((1-i)/.4),c=Math.exp(-a*a/(o*o))*s*s*(3-2*s),l=(t*e.width+r)*4;n.data[l]=210,n.data[l+1]=230,n.data[l+2]=255,n.data[l+3]=Math.round(c*255)}return t.putImageData(n,0,0),this.beam=e,e}ground(e,t){let n=t.opacity??1,r=t.options.brakeLights?Cl(t.braking):0;if(!(n<=0||t.width<=0)){if(e.save(),e.translate(t.center.x,t.center.y),e.rotate(t.angle),e.globalCompositeOperation=`screen`,t.dark&&t.options.underglow&&t.options.underglowOpacity>0){let r=this.sprite(t);if(e.globalAlpha=Cl(t.options.underglowOpacity)*n,r){let n=this.halo(r.silhouette,t.options.underglowColor),i=32/r.silhouette.width*t.width,a=32/r.silhouette.height*t.height;e.drawImage(n,-t.width/2-i,-t.height/2-a,t.width+i*2,t.height+a*2)}else e.shadowColor=t.options.underglowColor,e.shadowBlur=t.height*.5,e.fillStyle=t.options.underglowColor,e.beginPath(),e.roundRect(-t.width*.43,-t.height*.38,t.width*.86,t.height*.76,t.height*.22),e.fill(),e.shadowBlur=0}if(t.dark&&t.options.headlights)for(let r of t.mounts.headlights)e.globalAlpha=.085*n,e.drawImage(this.beamImage(),r.x,r.y-t.width*.68,t.width*5.7,t.width*1.36);if(t.dark&&t.options.taillights||r>0){let i=r;for(let{x:r,y:a}of t.mounts.taillights){let o=t.height*(.48+i*.38),s=e.createRadialGradient(r,a,0,r,a,o),c=(t.dark?.12+i*.19:i*.13)*n;s.addColorStop(0,`rgba(255,30,8,${c})`),s.addColorStop(1,`rgba(255,20,4,0)`),e.fillStyle=s,e.fillRect(r-o,a-o,o*2,o*2)}}e.restore()}}glints(e,t){e.save(),e.translate(t.center.x,t.center.y),e.rotate(t.angle),e.globalCompositeOperation=`screen`;let n=t.opacity??1,r=t.options.brakeLights?Cl(t.braking):0;if(r>0){let i=this.sprite(t)?.brakes;i&&(e.globalAlpha=r*n*(t.dark?.9:.52),e.shadowColor=`#ff250d`,e.shadowBlur=t.height*(t.dark?.16:.055),e.drawImage(i,-t.width/2,-t.height/2,t.width,t.height))}for(let i of[!0,!1])if(!(i?!(t.dark&&t.options.headlights):!(t.dark&&t.options.taillights||r>0)))for(let a of t.mounts[i?`headlights`:`taillights`]){e.globalAlpha=n*(i?.75:t.dark?.34+r*.6:r*.45);let o=t.height*(i?.15:.12),s=e.createRadialGradient(a.x,a.y,0,a.x,a.y,o);s.addColorStop(0,i?`#e6f1ffd9`:`#ff3518c0`),s.addColorStop(.28,i?`#c1dcff70`:`#ff230760`),s.addColorStop(1,i?`#c1dcff00`:`#ff230700`),e.fillStyle=s,e.beginPath(),e.arc(a.x,a.y,o,0,Math.PI*2),e.fill()}e.restore()}smokeLights(e){let t=[],n={x:Math.cos(e.angle),y:Math.sin(e.angle)},r=e.opacity??1,i=e.options.brakeLights?Cl(e.braking):0;if(e.dark&&e.options.headlights)for(let i of e.mounts.headlights)t.push({point:Tl(e,i.x,i.y),direction:n,color:xl,range:e.width*6.2,radius:e.height*.075,spread:.14,intensity:1.7*r});if(e.dark&&e.options.taillights||i>0)for(let a of e.mounts.taillights)t.push({point:Tl(e,a.x,a.y),direction:{x:-n.x,y:-n.y},color:Sl,range:e.width*(i>0?1.6:.9),radius:e.height*.15,spread:.46,intensity:r*(e.dark?.24+i*.85:i*.42)});if(e.dark&&e.options.underglow&&e.options.underglowOpacity>0)for(let n of[-.27,0,.27])t.push({point:Tl(e,e.width*n,0),direction:{x:0,y:0},color:wl(e.options.underglowColor),range:e.height,radius:e.height*.8,spread:0,intensity:r*e.options.underglowOpacity*.8});return t}},Dl=Object.freeze({underglow:!1,underglowColor:`#66e6ff`,underglowOpacity:.6,headlights:!0,taillights:!0,brakeLights:!0});function Ol(e={}){return{underglow:typeof e.underglow==`boolean`?e.underglow:Dl.underglow,underglowColor:/^#[\da-f]{6}$/i.test(e.underglowColor??``)?e.underglowColor:Dl.underglowColor,underglowOpacity:Number.isFinite(e.underglowOpacity)?Math.max(0,Math.min(1,e.underglowOpacity)):Dl.underglowOpacity,headlights:typeof e.headlights==`boolean`?e.headlights:Dl.headlights,brakeLights:typeof e.brakeLights==`boolean`?e.brakeLights:Dl.brakeLights,taillights:typeof e.taillights==`boolean`?e.taillights:Dl.taillights}}var kl={light:{ink:`#161c17`,alphaScale:1},dark:{ink:`#a9adb0`,alphaScale:1.7}};function Al(e){let t=e.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);if(!t)return!1;let[,n,r,i]=t.map(Number);return n*.2126+r*.7152+i*.0722<112}var jl=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},Ml={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Nl=e=>jl(Ml[e.toLowerCase()],6),Pl=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,Fl=e=>{let t;return(t=e.match(Pl))?jl(parseInt(t[1],16),t[1].length):void 0},Il=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`,Ll=`${Il}%`,Rl=`(?:${Il}%|${Il})`,zl=`(?:${Il}%|${Il}|none)`,Bl=`(?:${Il}(deg|grad|rad|turn)|${Il})`,Vl=`\\s*,\\s*`;RegExp(`^`+zl+`$`);var Hl=RegExp(`^rgba?\\(\\s*${Il}${Vl}${Il}${Vl}${Il}\\s*(?:,\\s*${Rl}\\s*)?\\)$`),Ul=RegExp(`^rgba?\\(\\s*${Ll}${Vl}${Ll}${Vl}${Ll}\\s*(?:,\\s*${Rl}\\s*)?\\)$`),Wl=e=>{let t={mode:`rgb`},n;if(n=e.match(Hl))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(Ul))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},Gl=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:mu(e),Kl=(e=`rgb`)=>t=>(t=Gl(t,e))===void 0?void 0:t.mode===e?t:ql[t.mode][e]?ql[t.mode][e](t):e===`rgb`?ql[t.mode].rgb(t):ql.rgb[e](ql[t.mode].rgb(t)),ql={},Jl={},Yl=[],Xl={},Zl=e=>e,Ql=e=>(ql[e.mode]={...ql[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{ql[t]||(ql[t]={}),ql[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=Zl)}),Jl[e.mode]=e,(e.parse||[]).forEach(t=>{eu(t,e.mode)}),Kl(e.mode)),$l=e=>Jl[e],eu=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);Xl[e]=t}else typeof e==`function`&&Yl.indexOf(e)<0&&Yl.push(e)},tu=/[^\x00-\x7F]|[a-zA-Z_]/,nu=/[^\x00-\x7F]|[-\w]/,I={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},L=0;function ru(e){let t=e[L],n=e[L+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[L+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function iu(e){if(L>=e.length)return!1;let t=e[L];if(tu.test(t))return!0;if(t===`-`){if(e.length-L<2)return!1;let t=e[L+1];return!!(t===`-`||tu.test(t))}return!1}var au={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function ou(e){let t=``;if((e[L]===`-`||e[L]===`+`)&&(t+=e[L++]),t+=su(e),e[L]===`.`&&/\d/.test(e[L+1])&&(t+=e[L++]+su(e)),(e[L]===`e`||e[L]===`E`)&&((e[L+1]===`-`||e[L+1]===`+`)&&/\d/.test(e[L+2])?t+=e[L++]+e[L++]+su(e):/\d/.test(e[L+1])&&(t+=e[L++]+su(e))),iu(e)){let n=cu(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:I.Hue,value:t*au[n]}:void 0}return e[L]===`%`?(L++,{type:I.Percentage,value:+t}):{type:I.Number,value:+t}}function su(e){let t=``;for(;/\d/.test(e[L]);)t+=e[L++];return t}function cu(e){let t=``;for(;L<e.length&&nu.test(e[L]);)t+=e[L++];return t}function lu(e){let t=cu(e);return e[L]===`(`?(L++,{type:I.Function,value:t}):t===`none`?{type:I.None,value:void 0}:{type:I.Ident,value:t}}function uu(e=``){let t=e.trim(),n=[],r;for(L=0;L<t.length;)if(r=t[L++],r===`
49
49
  `||r===` `||r===` `)for(;L<t.length&&(t[L]===`
50
50
  `||t[L]===` `||t[L]===` `);)L++;else{if(r===`,`)return;if(r===`)`)n.push({type:I.ParenClose});else{if(r===`+`){if(L--,ru(t)){n.push(ou(t));continue}return}if(r===`-`){if(L--,ru(t)){n.push(ou(t));continue}if(iu(t)){n.push({type:I.Ident,value:cu(t)});continue}return}if(r===`.`){if(L--,ru(t)){n.push(ou(t));continue}return}if(r===`/`){for(;L<t.length&&(t[L]===`
51
51
  `||t[L]===` `||t[L]===` `);)L++;let e;if(ru(t)&&(e=ou(t),e.type!==I.Hue)){n.push({type:I.Alpha,value:e});continue}if(iu(t)&&cu(t)===`none`){n.push({type:I.Alpha,value:{type:I.None,value:void 0}});continue}return}if(/\d/.test(r))L--,n.push(ou(t));else if(tu.test(r))L--,n.push(lu(t));else return}}return n}function du(e){e._i=0;let t=e[e._i++];if(!t||t.type!==I.Function||t.value!==`color`||(t=e[e._i++],t.type!==I.Ident))return;let n=Xl[t.value];if(!n)return;let r={mode:n},i=fu(e,!1);if(!i)return;let a=$l(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==I.None&&(r[n]=t.type===I.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function fu(e,t){let n=[],r;for(;e._i<e.length;)if(r=e[e._i++],r.type===I.None||r.type===I.Number||r.type===I.Alpha||r.type===I.Percentage||t&&r.type===I.Hue)n.push(r);else if(r.type===I.ParenClose){if(e._i<e.length)return}else return;if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==I.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:I.None,value:void 0}),n.every(e=>e.type!==I.Alpha)?n:void 0}}function pu(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==I.Function)return;let r=fu(e,t);if(r)return r.unshift(n.value),r}var mu=e=>{if(typeof e!=`string`)return;let t=uu(e),n=t?pu(t,!0):void 0,r,i=0,a=Yl.length;for(;i<a;)if((r=Yl[i++](e,n))!==void 0)return r;return t?du(t):void 0};function hu(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(r.type!==I.Hue&&i.type!==I.Hue&&a.type!==I.Hue)return r.type!==I.None&&(n.r=r.type===I.Number?r.value/255:r.value/100),i.type!==I.None&&(n.g=i.type===I.Number?i.value/255:i.value/100),a.type!==I.None&&(n.b=a.type===I.Number?a.value/255:a.value/100),o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var gu=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,_u=(e,t,n)=>e+n*(t-e),vu=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},R=(e=>t=>{let n=vu(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(_u),yu=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},bu={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[hu,Fl,Wl,Nl,gu,`srgb`],serialize:`srgb`,interpolate:{r:R,g:R,b:R,alpha:{use:R,fixup:yu}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},xu=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),Su=e=>{let t=xu(e.r),n=xu(e.g),r=xu(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},Cu=e=>Math.abs(e)**(256/563)*Math.sign(e),wu=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:Cu(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Cu(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Cu(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Tu=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Eu=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Tu(e),g:Tu(t),b:Tu(n)};return r!==void 0&&(i.alpha=r),i},Du=e=>{let{r:t,g:n,b:r,alpha:i}=Eu(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},Ou=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},ku=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Ou(e),g:Ou(t),b:Ou(n)};return r!==void 0&&(a.alpha=r),a},Au=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=ku({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},ju={...bu,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>wu(Du(e)),xyz65:wu},toMode:{rgb:e=>Au(Su(e)),xyz65:Su}},Mu=e=>(e%=360)<0?e+360:e,Nu=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=Mu(n);return r===0||e[r-1]===void 0?a:t(a-Mu(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),Pu=e=>Nu(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Fu=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=Mu(e.h),r=Mu(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Iu=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=Mu(e.h),r=Mu(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},Lu=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=Mu(e.h),r=Mu(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},Ru=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},zu=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=Mu(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},Bu=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},Vu={X:.3457/.3585,Y:1,Z:.2958/.3585};function Hu({h:e,s:t,l:n,alpha:r}){e=Mu(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function Uu({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}var Wu=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},Gu=RegExp(`^hsla?\\(\\s*${Bl}${Vl}${Ll}${Vl}${Ll}\\s*(?:,\\s*${Rl}\\s*)?\\)$`),Ku=e=>{let t=e.match(Gu);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=Wu(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function qu(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==I.None){if(r.type===I.Percentage)return;n.h=r.value}if(i.type!==I.None){if(i.type===I.Hue)return;n.s=i.value/100}if(a.type!==I.None){if(a.type===I.Hue)return;n.l=a.value/100}return o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var Ju={mode:`hsl`,toMode:{rgb:Hu},fromMode:{rgb:Uu},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[qu,Ku],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:Pu},s:R,l:R,alpha:{use:R,fixup:yu}},difference:{h:Fu},average:{h:Ru}};function Yu({h:e,s:t,v:n,alpha:r}){e=Mu(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function Xu({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}function Zu({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return Yu({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function Qu(e){let t=Xu(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function $u(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==I.None){if(r.type===I.Percentage)return;n.h=r.value}if(i.type!==I.None){if(i.type===I.Hue)return;n.w=i.value/100}if(a.type!==I.None){if(a.type===I.Hue)return;n.b=a.value/100}return o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var ed={mode:`hwb`,toMode:{rgb:Zu},fromMode:{rgb:Qu},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[$u],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:Pu},w:R,b:R,alpha:{use:R,fixup:yu}},difference:{h:Iu},average:{h:Ru}},td=29**3/27,nd=216/29**3,rd=e=>e**3>nd?e**3:(116*e-16)/td,id=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:rd(a)*Vu.X,y:rd(i)*Vu.Y,z:rd(o)*Vu.Z};return r!==void 0&&(s.alpha=r),s},ad=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=ku({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},od=e=>ad(id(e)),sd=e=>{let{r:t,g:n,b:r,alpha:i}=Eu(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},cd=e=>e>nd?Math.cbrt(e):(td*e+16)/116,ld=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=cd(e/Vu.X),a=cd(t/Vu.Y),o=cd(n/Vu.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},ud=e=>{let t=ld(sd(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function dd(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(r.type!==I.Hue&&i.type!==I.Hue&&a.type!==I.Hue)return r.type!==I.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==I.None&&(n.a=i.type===I.Number?i.value:i.value*125/100),a.type!==I.None&&(n.b=a.type===I.Number?a.value:a.value*125/100),o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var fd={mode:`lab`,toMode:{xyz50:id,rgb:od},fromMode:{xyz50:ld,rgb:ud},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[dd],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:R,a:R,b:R,alpha:{use:R,fixup:yu}}};function pd(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==I.None){if(r.type===I.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==I.None&&(n.c=Math.max(0,i.type===I.Number?i.value:i.value*150/100)),a.type!==I.None){if(a.type===I.Percentage)return;n.h=a.value}return o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var md={mode:`lch`,toMode:{lab:Bu,rgb:e=>od(Bu(e))},fromMode:{rgb:e=>zu(ud(e)),lab:zu},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[pd],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:R,fixup:Pu},c:R,l:R,alpha:{use:R,fixup:yu}},difference:{h:Lu},average:{h:Ru}},hd={...bu,mode:`lrgb`,toMode:{rgb:ku},fromMode:{rgb:Eu},parse:[`srgb-linear`],serialize:`srgb-linear`},gd=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},_d=e=>{let t=gd(Eu(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},vd=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},yd=e=>ku(vd(e));function bd(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(r.type!==I.Hue&&i.type!==I.Hue&&a.type!==I.Hue)return r.type!==I.None&&(n.l=Math.min(Math.max(0,r.type===I.Number?r.value:r.value/100),1)),i.type!==I.None&&(n.a=i.type===I.Number?i.value:i.value*.4/100),a.type!==I.None&&(n.b=a.type===I.Number?a.value:a.value*.4/100),o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var xd={...fd,mode:`oklab`,toMode:{lrgb:vd,rgb:yd},fromMode:{lrgb:gd,rgb:_d},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[bd],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function Sd(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==I.None){if(r.type===I.Hue)return;n.l=Math.min(Math.max(0,r.type===I.Number?r.value:r.value/100),1)}if(i.type!==I.None&&(n.c=Math.max(0,i.type===I.Number?i.value:i.value*.4/100)),a.type!==I.None){if(a.type===I.Percentage)return;n.h=a.value}return o.type!==I.None&&(n.alpha=Math.min(1,Math.max(0,o.type===I.Number?o.value:o.value/100))),n}var Cd={...md,mode:`oklch`,toMode:{oklab:e=>Bu(e,`oklab`),rgb:e=>yd(Bu(e,`oklab`))},fromMode:{rgb:e=>zu(_d(e),`oklch`),oklab:e=>zu(e,`oklch`)},parse:[Sd],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},wd=e=>{let{r:t,g:n,b:r,alpha:i}=Eu(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},Td=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=ku({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},Ed={...bu,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>Td(Du(e)),xyz65:Td},toMode:{rgb:e=>Au(wd(e)),xyz65:wd}},Dd=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},Od=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:Dd(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:Dd(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:Dd(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},kd=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},Ad=e=>{let t=kd(e.r),n=kd(e.g),r=kd(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},jd={...bu,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:Od,rgb:e=>Od(sd(e))},toMode:{xyz50:Ad,rgb:e=>ad(Ad(e))}},Md=1.09929682680944,Nd=.018053968510807,Pd=e=>{let t=Math.abs(e);return t>Nd?(Math.sign(e)||1)*(Md*t**.45-.09929682680944008):4.5*e},Fd=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:Pd(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:Pd(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:Pd(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},Id=1.09929682680944,Ld=.018053968510807,Rd=(e=0)=>{let t=Math.abs(e);return t<Ld*4.5?e/4.5:(Math.sign(e)||1)*((t+Id-1)/Id)**(1/.45)},zd=e=>{let t=Rd(e.r),n=Rd(e.g),r=Rd(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},Bd={...bu,mode:`rec2020`,fromMode:{xyz65:Fd,rgb:e=>Fd(Du(e))},toMode:{xyz65:zd,rgb:e=>Au(zd(e))},parse:[`rec2020`],serialize:`rec2020`},Vd={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:ad,lab:ld},fromMode:{rgb:sd,lab:id},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:R,y:R,z:R,alpha:{use:R,fixup:yu}}},Hd={mode:`xyz65`,toMode:{rgb:Au,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:Du,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:R,y:R,z:R,alpha:{use:R,fixup:yu}}},Ud=Ql(bu);Ql(hd),Ql(Ju),Ql(ed),Ql(fd),Ql(md),Ql(xd);var Wd=Ql(Cd);Ql(Ed),Ql(ju),Ql(jd),Ql(Bd),Ql(Vd),Ql(Hd);var Gd=new Map,Kd=e=>Math.max(0,Math.min(1,e));function qd(e){let t=e.trim().toLowerCase();if(!t||t===`transparent`)return null;if(Gd.has(t))return Gd.get(t);let n=Ud(t),r=null;if(n){let e=[n.r??0,n.g??0,n.b??0],t=n.alpha??1;if([...e,t].every(Number.isFinite)){let[n,i,a]=e.map(Kd),o=Kd(t),s=Wd({mode:`rgb`,r:n,g:i,b:a});r=Object.freeze({paint:Object.freeze({color:`rgb(${[n,i,a].map(e=>Math.round(e*255)).join(` `)})`,alpha:o}),appearance:Object.freeze({lightness:s.l,chroma:s.c,alpha:o})})}}return Gd.size>=256&&Gd.delete(Gd.keys().next().value),Gd.set(t,r),r}function Jd(e){return qd(e)?.paint??null}function Yd(e){return qd(e)?.appearance??null}function Xd(e){let t=0,n=0,r=0,i=0;for(let a of e.layers){let e=`layers`in a?Xd(a):[a.color[0]*a.alpha,a.color[1]*a.alpha,a.color[2]*a.alpha,a.alpha];if(t+=(1-i)*e[0],n+=(1-i)*e[1],r+=(1-i)*e[2],i+=(1-i)*e[3],i>=.9999)break}return[t*e.opacity,n*e.opacity,r*e.opacity,i*e.opacity]}function Zd(e,t=!1){let n={opacity:1,layers:[]},r=new Map,i=new Map,a=e=>{let t=r.get(e);return t||(t=getComputedStyle(e),r.set(e,t)),t},o=e=>{let t=i.get(e);if(t)return t;let r=e.parentElement?o(e.parentElement):n,s=Number.parseFloat(a(e).opacity),c=Number.isFinite(s)?Math.max(0,Math.min(1,s)):1,l=r;return c<1&&(l={opacity:c,layers:[]},r.layers.push(l)),i.set(e,l),l};for(let t of document.elementsFromPoint(e.x,e.y)){if(!(t instanceof HTMLElement)||t.closest(`[data-jr-overlay],[data-jr-embed],[data-jr-touch-controls]`))continue;let e=Jd(a(t).backgroundColor);if(!e||e.alpha<=0)continue;let n=e.color.match(/[\d.]+/g).slice(0,3).map(Number);o(t).layers.push({color:n,alpha:e.alpha})}let[s,c,l,u]=Xd(n);if(u<=0)return null;let d=t?0:255;return Al(`rgb(${s+d*(1-u)} ${c+d*(1-u)} ${l+d*(1-u)})`)}var Qd=class{resolve;samples=new WeakMap;constructor(e=Zd){this.resolve=e}at(e,t,n,r=performance.now()){let i=this.samples.get(e);if(i&&i.fallback===n&&r-i.at<80&&Math.hypot(t.x-i.x,t.y-i.y)<48)return i.dark;let a=this.resolve(t,n)??n;return this.samples.set(e,{x:t.x,y:t.y,at:r,dark:a,fallback:n}),a}},z={lightColor:[.012,.015,.021],darkColor:[.98,.985,1],vorticity:23,maxMotionSpeedPxPerSecond:260,emissionFactor:1.2,wakeSpeedPxPerSecond:260,wakeEmissionFactor:1.6,wakeFlowFactor:.18,wallSmokeFactor:1.45,emergenceSmokeFactor:1.7,emergenceFadeSeconds:.8,spriteBlurPx:1.15,insideWallSpriteOpacity:.1,styles:{specter:{emissionPerSecond:1.05,driftPixelsPerSecond:33,radiusFactor:.24,bodyInfluence:.28,spriteAlpha:{light:.69,dark:.58},shadowBlurDark:3},phantom:{emissionPerSecond:.82,driftPixelsPerSecond:27,radiusFactor:.17,bodyInfluence:.24,spriteAlpha:{light:.18,dark:.17},contourAlpha:.48,shadowBlurDark:3},wraith:{emissionPerSecond:.72,driftPixelsPerSecond:40,radiusFactor:.25,bodyInfluence:.3,spriteAlpha:{light:.35,dark:.32},shadowBlurDark:4}}};function $d(e,t,n,r,i){if(!i.length)return 0;let a=D(-t.y,t.x),o=Math.abs(t.x)*n+Math.abs(a.x)*r,s=Math.abs(t.y)*n+Math.abs(a.y)*r,c=i.filter(t=>t.x<=e.x+o&&t.x+t.width>=e.x-o&&t.y<=e.y+s&&t.y+t.height>=e.y-s);if(!c.length)return 0;let l=0;for(let i=0;i<5;i++)for(let o=0;o<7;o++){let s=((o+.5)/7*2-1)*n,u=((i+.5)/5*2-1)*r,d=e.x+t.x*s+a.x*u,f=e.y+t.y*s+a.y*u;c.some(e=>d>=e.x&&d<=e.x+e.width&&f>=e.y&&f<=e.y+e.height)&&l++}return l/35}var ef=new WeakMap;function tf(e,t=`high`){let n=ef.get(e),r=n?.get(t);if(r)return r;let i=[],a=t===`high`?4:t===`medium`?2:1,o=4*a,s=9*a,c=(t,n)=>{if(t<0||t>=o||n<0||n>=s)return!1;let r=Math.min(e.columns-1,Math.floor((n+.5)/s*e.columns)),i=Math.min(e.rows-1,Math.floor((t+.5)/o*e.rows));return!!e.solid[i*e.columns+r]};for(let e=0;e<o;e++)for(let t=0;t<s;t++)c(e,t)&&(c(e-1,t)&&c(e+1,t)&&c(e,t-1)&&c(e,t+1)||i.push(D((t+.5)/s*2-1,(e+.5)/o*2-1)));return i.length||i.push(D()),n||ef.set(e,n=new Map),n.set(t,i),i}var nf=e=>Math.max(0,Math.min(1,e)),rf=class{cache=new WeakMap;get(e,t){let n=this.cache.get(e);if(n)return n;let r=Math.max(1,Math.min(512,Math.round(t.width))),i=Math.max(1,Math.round(t.height/t.width*r)),a=document.createElement(`canvas`);a.width=r,a.height=i;let o=a.getContext(`2d`,{willReadFrequently:!0});if(!o)throw Error(`Ghost material requires a 2D canvas`);o.drawImage(e,t.x,t.y,t.width,t.height,0,0,r,i);let s=o.getImageData(0,0,r,i).data,c=document.createElement(`canvas`),l=document.createElement(`canvas`),u=document.createElement(`canvas`),d=document.createElement(`canvas`);for(let e of[c,l,u,d])e.width=r,e.height=i;let f=c.getContext(`2d`),p=l.getContext(`2d`),m=u.getContext(`2d`),h=d.getContext(`2d`);if(!f||!p||!m||!h)throw Error(`Ghost material requires a 2D canvas`);let g=f.createImageData(r,i),_=p.createImageData(r,i),v=m.createImageData(r,i),y=h.createImageData(r,i),b=(e,t)=>(Math.max(0,Math.min(i-1,t))*r+Math.max(0,Math.min(r-1,e)))*4,x=e=>(s[e]*.2126+s[e+1]*.7152+s[e+2]*.0722)/255;for(let e=0;e<i;e++)for(let t=0;t<r;t++){let n=b(t,e),r=s[n+3];if(!r)continue;let i=x(n),a=b(t-2,e),o=b(t+2,e),c=b(t,e-2),l=b(t,e+2),u=nf(Math.max(Math.abs(i-x(a)),Math.abs(i-x(o)),Math.abs(i-x(c)),Math.abs(i-x(l)))*2.8),d=nf((r-s[a+3]+(r-s[c+3]))/360),f=nf(u*.65+d*.8),p=Math.round(7+f*220),m=Math.round(242-(1-i)*105+d*13),h=Math.round(247-(1-i)*114+d*8);g.data[n]=p,g.data[n+1]=Math.min(255,p+2),g.data[n+2]=Math.min(255,p+6),g.data[n+3]=r,_.data[n]=Math.min(255,m),_.data[n+1]=Math.min(255,h),_.data[n+2]=Math.min(255,h+5),_.data[n+3]=r;let S=Math.round(r*nf(u*.6+d*.9));v.data[n]=Math.round(13+d*214),v.data[n+1]=Math.round(17+d*214),v.data[n+2]=Math.round(22+d*214),v.data[n+3]=S,y.data[n]=Math.round(185+d*70),y.data[n+1]=Math.round(192+d*63),y.data[n+2]=Math.round(204+d*51),y.data[n+3]=S}f.putImageData(g,0,0),p.putImageData(_,0,0),m.putImageData(v,0,0),h.putImageData(y,0,0);let S={light:c,dark:l,contourLight:u,contourDark:d};return this.cache.set(e,S),S}},af=class{materials=new rf;clearMaterials(){this.materials=new rf}draw(e,t,n){let{imageFor:r,screen:i,visualOffset:a,zoom:o,width:s,height:c,pixelSpace:l,walls:u,scroll:d,dark:f,styleName:p}=n,{sim:m}=e,h=r(m.car.preset),g=t,_=z.styles[p],v=f?z.darkColor:z.lightColor,y=O(i(m.body.position),a(m)),b=m.car.preset.geometry.lengthM*o,x=m.car.preset.geometry.widthM*o,S=null;if(h){let t=Kt(m.car.preset,h.naturalWidth,h.naturalHeight),n=e.damage.spriteFor(h,t);b=t.lengthM*o,x=t.widthM*o,S=this.materials.get(n??h,n?{x:0,y:0,width:n.width,height:n.height}:t.source)}let C=e=>{g.save(),g.translate(y.x,y.y),g.rotate(-m.body.angle),g.filter=`blur(${z.spriteBlurPx}px)`,g.globalAlpha=_.spriteAlpha[f?`dark`:`light`]*e,g.shadowColor=`rgb(${v.map(e=>Math.round(e*255)).join(` `)})`,g.shadowBlur=f?_.shadowBlurDark:0,S?(g.drawImage(S[f?`dark`:`light`],-b/2,-x/2,b,x),p===`phantom`&&(g.globalAlpha=z.styles.phantom.contourAlpha*e,g.drawImage(S[f?`contourDark`:`contourLight`],-b/2,-x/2,b,x))):(g.fillStyle=f?`#f0f5ff`:`#0b0d0f`,g.beginPath(),g.roundRect(-b/2,-x/2,b,x,12),g.fill()),g.restore()},w=[];if(l&&u.length){let e=Math.abs(Math.cos(m.body.angle)),t=Math.abs(Math.sin(m.body.angle)),n=(e*b+t*x)/2+z.spriteBlurPx*2,r=(t*b+e*x)/2+z.spriteBlurPx*2;for(let e of u){let t=e.x-d.x,i=e.y-d.y;t>=y.x+n||t+e.width<=y.x-n||i>=y.y+r||i+e.height<=y.y-r||w.push({x:t,y:i,width:e.width,height:e.height})}}if(!w.length)C(1);else{g.save();for(let e of w)g.beginPath(),g.rect(0,0,s,c),g.rect(e.x,e.y,e.width,e.height),g.clip(`evenodd`);C(1),g.restore(),g.save(),g.beginPath();for(let e of w)g.rect(e.x,e.y,e.width,e.height);g.clip(),C(z.insideWallSpriteOpacity),g.restore()}}},of=64,sf=e=>e.width>0&&e.height>0&&e.width<=64&&e.height<=64&&e.pixelWidth<=128&&e.pixelHeight<=128&&e.fixedRadius===void 0&&e.blastAge===void 0&&!e.smokeOnly,cf=class{groups=new Map;combine(e,t,n){let r=e.filter(sf);if(r.length<of)return[...e];let i=Math.ceil(t/2),a=Math.ceil(n/2),o=e.filter(e=>!sf(e)),s=new Map;for(let e of r){let t=Math.max(0,Math.min(.999,e.age/Math.max(.01,e.burnSeconds))),n=Math.floor(t*4),r=s.get(n)??[];r.push(e),s.set(n,r)}for(let[e,r]of s){let s=this.groups.get(e);s&&s.alpha.length===i*a||(s={key:{},alpha:new Uint8Array(i*a),revision:0},this.groups.set(e,s)),s.alpha.fill(0);let c=!1;for(let e of r)c=this.rasterize(s.alpha,i,a,e,t,n)||c;if(!c)continue;s.revision++;let l=r.reduce((e,t)=>e+t.age/Math.max(.01,t.burnSeconds),0)/r.length;o.push({key:s.key,alpha:s.alpha,pixelWidth:i,pixelHeight:a,x:0,y:0,width:t,height:n,origin:{x:t/2,y:n/2},age:l,farthest:Math.max(t,n),spreadSeconds:0,burnSeconds:1,smokeRate:r.reduce((e,t)=>e+(t.smokeRate??13),0)/r.length,revision:s.revision})}return o}rasterize(e,t,n,r,i,a){let o=t/i,s=n/a,c=r.x+r.width/2,l=r.y+r.height/2,u=Math.cos(r.angle??0),d=Math.sin(r.angle??0),f=Math.hypot(r.width,r.height)/2,p=Math.max(0,Math.floor((c-f)*o)),m=Math.min(t-1,Math.ceil((c+f)*o)),h=Math.max(0,Math.floor((l-f)*s)),g=Math.min(n-1,Math.ceil((l+f)*s)),_=!1;for(let n=h;n<=g;n++){let i=(n+.5)/s-l;for(let a=p;a<=m;a++){let s=(a+.5)/o-c,l=s*u+i*d+r.width/2,f=-s*d+i*u+r.height/2;if(l<0||l>=r.width||f<0||f>=r.height)continue;let p=Math.floor(l/r.width*r.pixelWidth),m=Math.floor(f/r.height*r.pixelHeight),h=Math.round((r.alpha[m*r.pixelWidth+p]??0)*(r.intensity??1)),g=n*t+a;h>e[g]&&(e[g]=h),_||=h>0}}return _}},lf=class{points=[];get count(){return this.points.length}get managedBytes(){return this.points.length*40}captureState(){return{points:this.points.map(({point:e,...t})=>({point:{...e},...t})),dispose:()=>void 0}}restoreState(e){this.points=e?.points.map(({point:e,...t})=>({point:{...e},...t}))??[]}reset(){this.points=[]}dispose(){this.reset()}ignite(e,t,n,r,i){let a=k(t,e),o=Math.max(1,Math.ceil(M(a)/Math.max(1,i)));for(let t=1;t<=o;t++)this.points.push({point:O(e,A(a,t/o)),width:n,age:0,lifetime:r});this.points.length>1200&&this.points.splice(0,this.points.length-1200)}step(e){let t=0;for(let n of this.points)n.age+=e,n.age<n.lifetime&&(this.points[t++]=n);this.points.length=t}stamps(){return this.points.map(({point:e,width:t,age:n,lifetime:r})=>({point:e,radius:Math.max(5,t*.8),progress:.42,flow:D(0,-25),strength:Math.max(0,1-(n/r)**2)*1.85,stir:!1}))}emberSource(){if(!this.points.length)return null;let e=this.points[Math.floor(Math.random()*this.points.length)];return{point:e.point,radius:e.width*.42,heat:Math.max(0,1-(e.age/e.lifetime)**2)}}},uf=5120,df=5121,ff=5122,pf=5123,mf=5124,hf=5125,gf=5126,_f=32819,vf=32820,yf=33635,bf=5131,xf=33640,Sf=35899,Cf=35902,wf=36269,Tf=34042,Ef={};{let e=Ef;e[uf]=Int8Array,e[df]=Uint8Array,e[ff]=Int16Array,e[pf]=Uint16Array,e[mf]=Int32Array,e[hf]=Uint32Array,e[gf]=Float32Array,e[_f]=Uint16Array,e[vf]=Uint16Array,e[yf]=Uint16Array,e[bf]=Uint16Array,e[xf]=Uint32Array,e[Sf]=Uint32Array,e[Cf]=Uint32Array,e[wf]=Uint32Array,e[Tf]=Uint32Array}function Df(...e){console.error(...e)}var Of=new Map;function kf(e,t){if(!e||typeof e!=`object`)return!1;let n=Of.get(t);n||(n=new WeakMap,Of.set(t,n));let r=n.get(e);if(r===void 0){let i=Object.prototype.toString.call(e);r=i.substring(8,i.length-1)===t,n.set(e,r)}return r}function Af(e,t){return typeof WebGLBuffer<`u`&&kf(t,`WebGLBuffer`)}function jf(e,t){return typeof WebGLTexture<`u`&&kf(t,`WebGLTexture`)}function Mf(e,t){return typeof WebGLSampler<`u`&&kf(t,`WebGLSampler`)}var Nf=35044,Pf=34962;function Ff(e,t,n,r,i){e.bindBuffer(t,n),e.bufferData(t,r,i||Nf)}function If(e,t,n,r){if(Af(e,t))return t;n||=Pf;let i=e.createBuffer();return Ff(e,n,i,t,r),i}function Lf(e){return!!e.texStorage2D}var Rf=function(){let e={},t={};function n(n){let r=n.constructor.name;if(!e[r]){for(let e in n)if(typeof n[e]==`number`){let r=t[n[e]];t[n[e]]=r?`${r} | ${e}`:e}e[r]=!0}}return function(e,r){return n(e),t[r]||(typeof r==`number`?`0x${r.toString(16)}`:r)}}();new Uint8Array([128,192,255,255]);var zf=6406,Bf=6407,Vf=6408,Hf=6409,Uf=6410,Wf=6402,Gf=34041,Kf=3553,qf=34067,Jf=32879,Yf=35866,Xf=34069,Zf=10241,Qf=10240,$f=10242,ep=10243,tp=32882,np=33082,rp=33083,ip=33084,ap=33085,op=34892,sp=34893,cp=37443,lp=37441,up=37440,dp=33321,fp=36756,pp=33325,mp=33326,hp=33330,gp=33329,_p=33338,vp=33337,yp=33340,bp=33339,xp=33323,Sp=36757,Cp=33327,wp=33328,Tp=33336,Ep=33335,Dp=33332,Op=33331,kp=33334,Ap=33333,jp=32849,Mp=35905,Np=36194,Pp=36758,Fp=35898,Ip=35901,Lp=34843,Rp=34837,zp=36221,Bp=36239,Vp=36215,Hp=36233,Up=36209,Wp=36227,Gp=32856,Kp=35907,qp=36759,Jp=32855,Yp=32854,Xp=32857,Zp=34842,Qp=34836,$p=36220,em=36238,tm=36975,nm=36214,rm=36232,im=36226,am=36208,om=33189,sm=33190,cm=36012,lm=36013,um=35056,dm=5120,fm=5121,pm=5122,mm=5123,hm=5124,gm=5125,_m=5126,vm=32819,ym=32820,bm=33635,xm=5131,Sm=36193,Cm=33640,wm=35899,Tm=35902,Em=36269,Dm=34042,Om=33319,km=33320,Am=6403,jm=36244,Mm=36248,Nm=36249,Pm=33776,Fm=33777,Im=33778,Lm=33779,Rm=35916,zm=35917,Bm=35918,Vm=35919,Hm=36196,Um=37488,Wm=37489,Gm=37490,Km=37491,qm=37492,Jm=37493,Ym=37494,Xm=37495,Zm=37496,Qm=37497,$m=35840,eh=35841,th=35842,nh=35843,rh=37808,ih=37809,ah=37810,oh=37811,sh=37812,ch=37813,lh=37814,uh=37815,dh=37816,fh=37817,ph=37818,mh=37819,hh=37820,gh=37821,_h=37840,vh=37841,yh=37842,bh=37843,xh=37844,Sh=37845,Ch=37846,wh=37847,Th=37848,Eh=37849,Dh=37850,Oh=37851,kh=37852,Ah=37853,jh=36492,Mh=36493,Nh=36494,Ph=36495,Fh=36283,Ih=36284,Lh=36285,Rh=36286,zh={};{let e=zh;e[zf]={numColorComponents:1},e[Hf]={numColorComponents:1},e[Uf]={numColorComponents:2},e[Bf]={numColorComponents:3},e[Vf]={numColorComponents:4},e[Am]={numColorComponents:1},e[jm]={numColorComponents:1},e[Om]={numColorComponents:2},e[km]={numColorComponents:2},e[Bf]={numColorComponents:3},e[Mm]={numColorComponents:3},e[Vf]={numColorComponents:4},e[Nm]={numColorComponents:4},e[Wf]={numColorComponents:1},e[Gf]={numColorComponents:2}}var Bh;function Vh(e){if(!Bh){let e={};e[zf]={textureFormat:zf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[fm,xm,Sm,_m]},e[Hf]={textureFormat:Hf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[fm,xm,Sm,_m]},e[Uf]={textureFormat:Uf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[fm,xm,Sm,_m]},e[Bf]={textureFormat:Bf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[fm,xm,Sm,_m,bm]},e[Vf]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[fm,xm,Sm,_m,vm,ym]},e[Wf]={textureFormat:Wf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[gm,mm]},e[dp]={textureFormat:Am,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[fm]},e[fp]={textureFormat:Am,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[dm]},e[pp]={textureFormat:Am,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[_m,xm]},e[mp]={textureFormat:Am,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[_m]},e[hp]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[fm]},e[gp]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[dm]},e[Dp]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[mm]},e[Op]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[pm]},e[kp]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[gm]},e[Ap]={textureFormat:jm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[hm]},e[xp]={textureFormat:Om,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[fm]},e[Sp]={textureFormat:Om,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[dm]},e[Cp]={textureFormat:Om,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[_m,xm]},e[wp]={textureFormat:Om,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[_m]},e[Tp]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[fm]},e[Ep]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[dm]},e[_p]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[mm]},e[vp]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[pm]},e[yp]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[gm]},e[bp]={textureFormat:km,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[hm]},e[jp]={textureFormat:Bf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[fm]},e[Mp]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[fm]},e[Np]={textureFormat:Bf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[fm,bm]},e[Pp]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[dm]},e[Fp]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[_m,xm,wm]},e[Ip]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[_m,xm,Tm]},e[Lp]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[_m,xm]},e[Rp]={textureFormat:Bf,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[_m]},e[zp]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[fm]},e[Bp]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[dm]},e[Vp]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[mm]},e[Hp]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[pm]},e[Up]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[gm]},e[Wp]={textureFormat:Mm,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[hm]},e[Gp]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[fm]},e[Kp]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[fm]},e[qp]={textureFormat:Vf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[dm]},e[Jp]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[fm,ym,Cm]},e[Yp]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[fm,vm]},e[Xp]={textureFormat:Vf,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[Cm]},e[Zp]={textureFormat:Vf,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[_m,xm]},e[Qp]={textureFormat:Vf,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[_m]},e[$p]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[fm]},e[em]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[dm]},e[tm]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Cm]},e[nm]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[mm]},e[rm]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[pm]},e[im]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[hm]},e[am]={textureFormat:Nm,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[gm]},e[om]={textureFormat:Wf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[mm,gm]},e[sm]={textureFormat:Wf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[gm]},e[cm]={textureFormat:Wf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[_m]},e[um]={textureFormat:Gf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Dm]},e[lm]={textureFormat:Gf,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Em]},Object.keys(e).forEach(function(t){let n=e[t];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(e,t){let r=n.type[t];n.bytesPerElementMap[r]=e})});let t={bytes:8,width:4,height:4},n={bytes:16,width:4,height:4};e[Pm]={textureFormat:Pm,colorRenderable:!1,textureFilterable:!0,block:t},e[Fm]={textureFormat:Fm,colorRenderable:!1,textureFilterable:!0,block:t},e[Im]={textureFormat:Im,colorRenderable:!1,textureFilterable:!0,block:n},e[Lm]={textureFormat:Lm,colorRenderable:!1,textureFilterable:!0,block:n},e[Rm]={textureFormat:Rm,colorRenderable:!1,textureFilterable:!0,block:t},e[zm]={textureFormat:zm,colorRenderable:!1,textureFilterable:!0,block:t},e[Bm]={textureFormat:Bm,colorRenderable:!1,textureFilterable:!0,block:n},e[Vm]={textureFormat:Vm,colorRenderable:!1,textureFilterable:!0,block:n},e[Hm]={textureFormat:Hm,colorRenderable:!1,textureFilterable:!0,block:t},e[Um]={textureFormat:Um,colorRenderable:!1,textureFilterable:!0,block:t},e[Wm]={textureFormat:Wm,colorRenderable:!1,textureFilterable:!0,block:t},e[Gm]={textureFormat:Gm,colorRenderable:!1,textureFilterable:!0,block:n},e[Km]={textureFormat:Km,colorRenderable:!1,textureFilterable:!0,block:n},e[qm]={textureFormat:qm,colorRenderable:!1,textureFilterable:!0,block:t},e[Jm]={textureFormat:Jm,colorRenderable:!1,textureFilterable:!0,block:t},e[Ym]={textureFormat:Ym,colorRenderable:!1,textureFilterable:!0,block:t},e[Xm]={textureFormat:Xm,colorRenderable:!1,textureFilterable:!0,block:t},e[Zm]={textureFormat:Zm,colorRenderable:!1,textureFilterable:!0,block:n},e[Qm]={textureFormat:Qm,colorRenderable:!1,textureFilterable:!0,block:n},e[$m]={textureFormat:$m,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[eh]={textureFormat:eh,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[th]={textureFormat:th,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:8,height:8}},e[nh]={textureFormat:nh,colorRenderable:!1,textureFilterable:!0,block:{bytes:32,width:16,height:8}},e[rh]={textureFormat:rh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[ih]={textureFormat:ih,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[ah]={textureFormat:ah,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[oh]={textureFormat:oh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[sh]={textureFormat:sh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[ch]={textureFormat:ch,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[lh]={textureFormat:lh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[uh]={textureFormat:uh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[dh]={textureFormat:dh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[fh]={textureFormat:fh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[ph]={textureFormat:ph,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[mh]={textureFormat:mh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[hh]={textureFormat:hh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[gh]={textureFormat:gh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[_h]={textureFormat:_h,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:4,height:4}},e[vh]={textureFormat:vh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:4}},e[yh]={textureFormat:yh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:5,height:5}},e[bh]={textureFormat:bh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:5}},e[xh]={textureFormat:xh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:6,height:6}},e[Sh]={textureFormat:Sh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:5}},e[Ch]={textureFormat:Ch,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:6}},e[wh]={textureFormat:wh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:8,height:8}},e[Th]={textureFormat:Th,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:5}},e[Eh]={textureFormat:Eh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:6}},e[Dh]={textureFormat:Dh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:8}},e[Oh]={textureFormat:Oh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:10,height:10}},e[kh]={textureFormat:kh,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:10}},e[Ah]={textureFormat:Ah,colorRenderable:!1,textureFilterable:!0,block:{bytes:16,width:12,height:12}},e[jh]={textureFormat:jh,colorRenderable:!1,textureFilterable:!0,block:n},e[Mh]={textureFormat:Mh,colorRenderable:!1,textureFilterable:!0,block:n},e[Nh]={textureFormat:Nh,colorRenderable:!1,textureFilterable:!0,block:n},e[Ph]={textureFormat:Ph,colorRenderable:!1,textureFilterable:!0,block:n},e[Fh]={textureFormat:Fh,colorRenderable:!1,textureFilterable:!0,block:t},e[Ih]={textureFormat:Ih,colorRenderable:!1,textureFilterable:!0,block:t},e[Lh]={textureFormat:Lh,colorRenderable:!1,textureFilterable:!0,block:t},e[Rh]={textureFormat:Rh,colorRenderable:!1,textureFilterable:!0,block:t},Bh=e}let t=Bh[e];if(!t)throw Error(`unknown internal format`);return t}function Hh(e){let t=Vh(e);if(!t)throw Error(`unknown internal format`);return{format:t.textureFormat,type:t.type?.[0]??fm}}function Uh(e,t,n){let r,i,a;t.colorspaceConversion!==void 0&&(r=e.getParameter(cp),e.pixelStorei(cp,t.colorspaceConversion)),t.premultiplyAlpha!==void 0&&(i=e.getParameter(lp),e.pixelStorei(lp,t.premultiplyAlpha)),t.flipY!==void 0&&(a=e.getParameter(up),e.pixelStorei(up,t.flipY)),n(),r!==void 0&&e.pixelStorei(cp,r),i!==void 0&&e.pixelStorei(lp,i),a!==void 0&&e.pixelStorei(up,a)}function Wh(e,t,n,r){r.minMag&&(n.call(e,t,Zf,r.minMag),n.call(e,t,Qf,r.minMag)),r.min&&n.call(e,t,Zf,r.min),r.mag&&n.call(e,t,Qf,r.mag),r.wrap&&(n.call(e,t,$f,r.wrap),n.call(e,t,ep,r.wrap),(t===Jf||Mf(e,t))&&n.call(e,t,tp,r.wrap)),r.wrapR&&n.call(e,t,tp,r.wrapR),r.wrapS&&n.call(e,t,$f,r.wrapS),r.wrapT&&n.call(e,t,ep,r.wrapT),r.minLod!==void 0&&n.call(e,t,np,r.minLod),r.maxLod!==void 0&&n.call(e,t,rp,r.maxLod),r.baseLevel!==void 0&&n.call(e,t,ip,r.baseLevel),r.maxLevel!==void 0&&n.call(e,t,ap,r.maxLevel),r.compareFunc!==void 0&&n.call(e,t,sp,r.compareFunc),r.compareMode!==void 0&&n.call(e,t,op,r.compareMode)}function Gh(e,t,n){let r=n.target||Kf;e.bindTexture(r,t),Wh(e,r,e.texParameteri,n)}function Kh(e,t,n){let r=n.target||Kf;e.bindTexture(r,t);let i=n.level||0,a=n.internalFormat||n.format||Vf,o=Hh(a),s=n.format||o.format,c=n.type||o.type;Uh(e,n,()=>{if(r===qf)for(let t=0;t<6;++t)e.texImage2D(Xf+t,i,a,n.width,n.height,0,s,c,null);else r===Jf||r===Yf?e.texImage3D(r,i,a,n.width,n.height,n.depth,0,s,c,null):e.texImage2D(r,i,a,n.width,n.height,0,s,c,null)})}var qh=Df;function Jh(e){return typeof document<`u`&&document.getElementById?document.getElementById(e):null}var Yh=33984,Xh=34962,Zh=34963,Qh=35713,$h=35714,eg=35632,tg=35633,ng=35981,rg=35718,ig=35721,ag=35971,og=35382,sg=35396,cg=35398,lg=35392,ug=35395,dg=5126,fg=35664,pg=35665,mg=35666,hg=5124,gg=35667,_g=35668,vg=35669,yg=35670,bg=35671,xg=35672,Sg=35673,Cg=35674,wg=35675,Tg=35676,Eg=35678,Dg=35680,Og=35679,kg=35682,Ag=35685,jg=35686,Mg=35687,Ng=35688,Pg=35689,Fg=35690,Ig=36289,Lg=36292,Rg=36293,zg=5125,Bg=36294,Vg=36295,Hg=36296,Ug=36298,Wg=36299,Gg=36300,Kg=36303,qg=36306,Jg=36307,Yg=36308,Xg=36311,Zg=3553,Qg=34067,$g=32879,e_=35866,B={};function t_(e,t){return B[t].bindPoint}function n_(e,t){return function(n){e.uniform1f(t,n)}}function r_(e,t){return function(n){e.uniform1fv(t,n)}}function i_(e,t){return function(n){e.uniform2fv(t,n)}}function a_(e,t){return function(n){e.uniform3fv(t,n)}}function o_(e,t){return function(n){e.uniform4fv(t,n)}}function s_(e,t){return function(n){e.uniform1i(t,n)}}function c_(e,t){return function(n){e.uniform1iv(t,n)}}function l_(e,t){return function(n){e.uniform2iv(t,n)}}function u_(e,t){return function(n){e.uniform3iv(t,n)}}function d_(e,t){return function(n){e.uniform4iv(t,n)}}function f_(e,t){return function(n){e.uniform1ui(t,n)}}function p_(e,t){return function(n){e.uniform1uiv(t,n)}}function m_(e,t){return function(n){e.uniform2uiv(t,n)}}function h_(e,t){return function(n){e.uniform3uiv(t,n)}}function g_(e,t){return function(n){e.uniform4uiv(t,n)}}function __(e,t){return function(n){e.uniformMatrix2fv(t,!1,n)}}function v_(e,t){return function(n){e.uniformMatrix3fv(t,!1,n)}}function y_(e,t){return function(n){e.uniformMatrix4fv(t,!1,n)}}function b_(e,t){return function(n){e.uniformMatrix2x3fv(t,!1,n)}}function x_(e,t){return function(n){e.uniformMatrix3x2fv(t,!1,n)}}function S_(e,t){return function(n){e.uniformMatrix2x4fv(t,!1,n)}}function C_(e,t){return function(n){e.uniformMatrix4x2fv(t,!1,n)}}function w_(e,t){return function(n){e.uniformMatrix3x4fv(t,!1,n)}}function T_(e,t){return function(n){e.uniformMatrix4x3fv(t,!1,n)}}function E_(e,t,n,r){let i=t_(e,t);return Lf(e)?function(t){let a,o;!t||jf(e,t)?(a=t,o=null):(a=t.texture,o=t.sampler),e.uniform1i(r,n),e.activeTexture(Yh+n),e.bindTexture(i,a),e.bindSampler(n,o)}:function(t){e.uniform1i(r,n),e.activeTexture(Yh+n),e.bindTexture(i,t)}}function D_(e,t,n,r,i){let a=t_(e,t),o=new Int32Array(i);for(let e=0;e<i;++e)o[e]=n+e;return Lf(e)?function(t){e.uniform1iv(r,o),t.forEach(function(t,r){e.activeTexture(Yh+o[r]);let i,s;!t||jf(e,t)?(i=t,s=null):(i=t.texture,s=t.sampler),e.bindSampler(n,s),e.bindTexture(a,i)})}:function(t){e.uniform1iv(r,o),t.forEach(function(t,n){e.activeTexture(Yh+o[n]),e.bindTexture(a,t)})}}B[dg]={Type:Float32Array,size:4,setter:n_,arraySetter:r_},B[fg]={Type:Float32Array,size:8,setter:i_,cols:2},B[pg]={Type:Float32Array,size:12,setter:a_,cols:3},B[mg]={Type:Float32Array,size:16,setter:o_,cols:4},B[hg]={Type:Int32Array,size:4,setter:s_,arraySetter:c_},B[gg]={Type:Int32Array,size:8,setter:l_,cols:2},B[_g]={Type:Int32Array,size:12,setter:u_,cols:3},B[vg]={Type:Int32Array,size:16,setter:d_,cols:4},B[zg]={Type:Uint32Array,size:4,setter:f_,arraySetter:p_},B[Bg]={Type:Uint32Array,size:8,setter:m_,cols:2},B[Vg]={Type:Uint32Array,size:12,setter:h_,cols:3},B[Hg]={Type:Uint32Array,size:16,setter:g_,cols:4},B[yg]={Type:Uint32Array,size:4,setter:s_,arraySetter:c_},B[bg]={Type:Uint32Array,size:8,setter:l_,cols:2},B[xg]={Type:Uint32Array,size:12,setter:u_,cols:3},B[Sg]={Type:Uint32Array,size:16,setter:d_,cols:4},B[Cg]={Type:Float32Array,size:32,setter:__,rows:2,cols:2},B[wg]={Type:Float32Array,size:48,setter:v_,rows:3,cols:3},B[Tg]={Type:Float32Array,size:64,setter:y_,rows:4,cols:4},B[Ag]={Type:Float32Array,size:32,setter:b_,rows:2,cols:3},B[jg]={Type:Float32Array,size:32,setter:S_,rows:2,cols:4},B[Mg]={Type:Float32Array,size:48,setter:x_,rows:3,cols:2},B[Ng]={Type:Float32Array,size:48,setter:w_,rows:3,cols:4},B[Pg]={Type:Float32Array,size:64,setter:C_,rows:4,cols:2},B[Fg]={Type:Float32Array,size:64,setter:T_,rows:4,cols:3},B[Eg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Zg},B[Dg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Qg},B[Og]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:$g},B[kg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Zg},B[Ig]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:e_},B[Lg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:e_},B[Rg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Qg},B[Ug]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Zg},B[Wg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:$g},B[Gg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Qg},B[Kg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:e_},B[qg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Zg},B[Jg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:$g},B[Yg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:Qg},B[Xg]={Type:null,size:0,setter:E_,arraySetter:D_,bindPoint:e_};function O_(e,t){return function(n){if(n.value)switch(e.disableVertexAttribArray(t),n.value.length){case 4:e.vertexAttrib4fv(t,n.value);break;case 3:e.vertexAttrib3fv(t,n.value);break;case 2:e.vertexAttrib2fv(t,n.value);break;case 1:e.vertexAttrib1fv(t,n.value);break;default:throw Error(`the length of a float constant value must be between 1 and 4!`)}else e.bindBuffer(Xh,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,n.numComponents||n.size,n.type||dg,n.normalize||!1,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function k_(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4iv(t,n.value);else throw Error(`The length of an integer constant value must be 4!`)}else e.bindBuffer(Xh,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||hg,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function A_(e,t){return function(n){if(n.value){if(e.disableVertexAttribArray(t),n.value.length===4)e.vertexAttrib4uiv(t,n.value);else throw Error(`The length of an unsigned integer constant value must be 4!`)}else e.bindBuffer(Xh,n.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,n.numComponents||n.size,n.type||zg,n.stride||0,n.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,n.divisor||0)}}function j_(e,t,n){let r=n.size,i=n.count;return function(n){e.bindBuffer(Xh,n.buffer);let a=n.size||n.numComponents||r,o=a/i,s=n.type||dg,c=B[s].size*a,l=n.normalize||!1,u=n.offset||0,d=c/i;for(let r=0;r<i;++r)e.enableVertexAttribArray(t+r),e.vertexAttribPointer(t+r,o,s,l,c,u+d*r),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+r,n.divisor||0)}}var M_={};M_[dg]={size:4,setter:O_},M_[fg]={size:8,setter:O_},M_[pg]={size:12,setter:O_},M_[mg]={size:16,setter:O_},M_[hg]={size:4,setter:k_},M_[gg]={size:8,setter:k_},M_[_g]={size:12,setter:k_},M_[vg]={size:16,setter:k_},M_[zg]={size:4,setter:A_},M_[Bg]={size:8,setter:A_},M_[Vg]={size:12,setter:A_},M_[Hg]={size:16,setter:A_},M_[yg]={size:4,setter:k_},M_[bg]={size:8,setter:k_},M_[xg]={size:12,setter:k_},M_[Sg]={size:16,setter:k_},M_[Cg]={size:4,setter:j_,count:2},M_[wg]={size:9,setter:j_,count:3},M_[Tg]={size:16,setter:j_,count:4};var N_=/ERROR:\s*\d+:(\d+)/gi;function P_(e,t=``,n=0){let r=[...t.matchAll(N_)],i=new Map(r.map((e,n)=>{let i=parseInt(e[1]),a=r[n+1],o=a?a.index:t.length,s=t.substring(e.index,o);return[i-1,s]}));return e.split(`