UNPKG

p5

Version:

[![npm version](https://badge.fury.io/js/p5.svg)](https://www.npmjs.com/package/p5)

1,899 lines • 1.19 MB
/*! p5.js v2.4.0 November 11, 2026 */
var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(t,n)=>()=>(n||(t((n={exports:{}}).exports,n,n.exports),t=null),n.exports),c=(t,r)=>{let i={};for(var a in t)n(i,a,{get:t[a],enumerable:!0});return r||n(i,Symbol.toStringTag,{value:`Module`}),i},l=(t,a,s,c)=>{if(a&&typeof a==`object`||typeof a==`function`)for(var l=i(a),u=0,d=l.length,f;u<d;u++)f=l[u],!o.call(t,f)&&f!==s&&n(t,f,{get:(t=>a[t]).bind(null,f),enumerable:!(c=r(a,f))||c.enumerable});return t},u=(r,i,s)=>(s=r==null?{}:t(a(r)),l(i||!r||!r.__esModule||!o.call(r,`default`)?n(s,`default`,{value:r,enumerable:!0}):s,r)),d=/* @__PURE__ */ c({ADD:()=>Ae,ALT:()=>`Alt`,ARROW:()=>v,AUTO:()=>_e,AXES:()=>At,BACKSPACE:()=>ve,BASELINE:()=>ae,BEVEL:()=>he,BEZIER:()=>lt,BLEND:()=>F,BLUR:()=>Ze,BOLD:()=>et,BOLDITALIC:()=>tt,BOTTOM:()=>P,BURN:()=>Ue,CENTER:()=>ie,CHAR:()=>nt,CHORD:()=>de,CLAMP:()=>yt,CLOSE:()=>le,CONTAIN:()=>Nt,CONTROL:()=>ye,CORNER:()=>ee,CORNERS:()=>te,COVER:()=>Pt,CROSS:()=>x,CURVE:()=>ut,DARKEST:()=>je,DEG_TO_RAD:()=>j,DELETE:()=>be,DIFFERENCE:()=>Ne,DILATE:()=>Ye,DODGE:()=>He,DOWN_ARROW:()=>xe,EMPTY_PATH:()=>7,ENTER:()=>Se,ERODE:()=>Xe,ESCAPE:()=>Ce,EXCLUDE:()=>Bt,EXCLUSION:()=>Fe,FALLBACK:()=>Mt,FILL:()=>ft,FLAT:()=>St,FLOAT:()=>Lt,FULL:()=>b,GRAY:()=>Ge,GRID:()=>kt,HALF_FLOAT:()=>Rt,HALF_PI:()=>E,HAND:()=>S,HARD_LIGHT:()=>Be,IMAGE:()=>ht,IMMEDIATE:()=>mt,INCLUDE:()=>zt,INVERT:()=>qe,ITALIC:()=>$e,JOIN:()=>Vt,KEEP_CONNECTIONS:()=>xt,LABEL:()=>jt,LANDSCAPE:()=>Tt,LEFT:()=>re,LEFT_ARROW:()=>we,LIGHTEST:()=>Me,LINEAR:()=>st,LINEAR_MIPMAP:()=>gt,LINES:()=>1,LINE_LOOP:()=>2,LINE_STRIP:()=>3,MIRROR:()=>bt,MITER:()=>ge,MOVE:()=>C,MULTIPLY:()=>Ie,NEAREST:()=>_t,NORMAL:()=>Qe,OPAQUE:()=>Ke,OPEN:()=>ue,OPTION:()=>`Alt`,OVERLAY:()=>ze,P2D:()=>`p2d`,P2DP3:()=>m,PATH:()=>8,PI:()=>D,PIE:()=>`pie`,POINTS:()=>0,PORTRAIT:()=>Et,POSTERIZE:()=>Je,PROJECT:()=>fe,QUADRATIC:()=>ct,QUADS:()=>oe,QUAD_STRIP:()=>se,QUARTER_PI:()=>O,RADIUS:()=>N,RAD_TO_DEG:()=>M,REMOVE:()=>ke,REPEAT:()=>vt,REPLACE:()=>Re,RETURN:()=>Te,RIGHT:()=>ne,RIGHT_ARROW:()=>Ee,ROUND:()=>me,SCREEN:()=>Le,SEGMENTED:()=>wt,SHIFT:()=>De,SIMPLE:()=>y,SMOOTH:()=>Ct,SOFT_LIGHT:()=>Ve,SQUARE:()=>pe,STROKE:()=>dt,SUBTRACT:()=>Pe,TAB:()=>`Tab`,TAU:()=>k,TESS:()=>ce,TEXT:()=>w,TEXTURE:()=>pt,THRESHOLD:()=>We,TOP:()=>`top`,TRIANGLES:()=>4,TRIANGLE_FAN:()=>6,TRIANGLE_STRIP:()=>5,TWO_PI:()=>A,UNSIGNED_BYTE:()=>Ft,UNSIGNED_INT:()=>It,UP_ARROW:()=>Oe,VERSION:()=>p,WAIT:()=>T,WEBGL:()=>h,WEBGL2:()=>g,WEBGPU:()=>_,WORD:()=>rt,_CTX_MIDDLE:()=>ot,_DEFAULT_FILL:()=>Ot,_DEFAULT_LEADMULT:()=>at,_DEFAULT_STROKE:()=>Dt,_DEFAULT_TEXT_FILL:()=>it});const f=Math.PI,p=`2.4.0`,m=`p2d-p3`,h=`webgl`,g=`webgl2`,_=`webgpu`,v=`default`,y=`simple`,b=`full`,x=`crosshair`,S=`pointer`,C=`move`,w=`text`,T=`wait`,E=f/2,D=f,O=f/4,k=f*2,A=f*2,j=f/180,M=180/f,ee=`corner`,te=`corners`,N=`radius`,ne=`right`,re=`left`,ie=`center`,P=`bottom`,ae=`alphabetic`,oe=`quads`,se=`quad_strip`,ce=`tess`,le=`close`,ue=`open`,de=`chord`,fe=`square`,pe=`butt`,me=`round`,he=`bevel`,ge=`miter`,_e=`auto`,ve=`Backspace`,ye=`Control`,be=`Delete`,xe=`ArrowDown`,Se=`Enter`,Ce=`Escape`,we=`ArrowLeft`,Te=`Enter`,Ee=`ArrowRight`,De=`Shift`,Oe=`ArrowUp`,F=`source-over`,ke=`destination-out`,Ae=`lighter`,je=`darken`,Me=`lighten`,Ne=`difference`,Pe=`subtract`,Fe=`exclusion`,Ie=`multiply`,Le=`screen`,Re=`copy`,ze=`overlay`,Be=`hard-light`,Ve=`soft-light`,He=`color-dodge`,Ue=`color-burn`,We=`threshold`,Ge=`gray`,Ke=`opaque`,qe=`invert`,Je=`posterize`,Ye=`dilate`,Xe=`erode`,Ze=`blur`,Qe=`normal`,$e=`italic`,et=`bold`,tt=`bold italic`,nt=`CHAR`,rt=`WORD`,it=`#000000`,at=1.25,ot=`middle`,st=`linear`,ct=`quadratic`,lt=`bezier`,ut=`curve`,dt=`stroke`,ft=`fill`,pt=`texture`,mt=`immediate`,ht=`image`,gt=`linear_mipmap`,_t=`nearest`,vt=`repeat`,yt=`clamp`,bt=`mirror`,xt=`keep_connections`,St=xt,Ct=`smooth`,wt=`segmented`,Tt=`landscape`,Et=`portrait`,Dt=`#000000`,Ot=`#FFFFFF`,kt=`grid`,At=`axes`,jt=`label`,Mt=`fallback`,Nt=`contain`,Pt=`cover`,Ft=`unsigned-byte`,It=`unsigned-int`,Lt=`float`,Rt=`half-float`,zt=Symbol(`include`),Bt=Symbol(`exclude`),Vt=Symbol(`join`);function Ht(t,n){n.applyMatrix=function(...t){let n=t[0]instanceof Object.getPrototypeOf(Uint8Array);return Array.isArray(t[0])||n?this._renderer.applyMatrix(...t[0]):this._renderer.applyMatrix(...t),this},n.resetMatrix=function(){return this._renderer.resetMatrix(),this},n.rotate=function(t,n){return this._renderer.rotate(this._toRadians(t),n)},n.rotateX=function(t){return this._assert3d(`rotateX`),this._renderer.rotateX(this._toRadians(t))},n.rotateY=function(t){return this._assert3d(`rotateY`),this._renderer.rotateY(this._toRadians(t))},n.rotateZ=function(t){return this._assert3d(`rotateZ`),this._renderer.rotateZ(this._toRadians(t))},n.scale=function(n,r,i){if(n instanceof t.Vector){let t=n;n=t.x,r=t.y,i=t.z}else if(Array.isArray(n)){let t=n;n=t[0],r=t[1],i=t[2]||1}return isNaN(r)?r=i=n:isNaN(i)&&(i=1),this._renderer.scale(n,r,i)},n.shearX=function(t){let n=this._toRadians(t);return this._renderer.applyMatrix(1,0,Math.tan(n),1,0,0),this},n.shearY=function(t){let n=this._toRadians(t);return this._renderer.applyMatrix(1,Math.tan(n),0,1,0,0),this},n.translate=function(t,n,r){return this._renderer.isP3D?this._renderer.translate(t,n,r):this._renderer.translate(t,n)},n.push=function(){this._renderer.push()},n.pop=function(){this._renderer.pop()}}typeof p5<`u`&&Ht(p5,p5.prototype);function Ut(t,n){n.noLoop=function(){this._loop=!1},n.loop=function(){this._loop||(this._loop=!0,this._setupDone&&this._draw())},n.isLooping=function(){return this._loop},n.redraw=async function(t){if(this._inUserDraw||!this._setupDone)return;let n=parseInt(t);(isNaN(n)||n<1)&&(n=1);let r=this._isGlobal?window:this;if(typeof r.draw==`function`){r.setup===void 0&&r.scale(r._pixelDensity,r._pixelDensity);for(let t=0;t<n;t++){r.resetMatrix(),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._updateAccsOutput(),this._renderer.isP3D&&this._renderer._update(),this.frameCount=r.frameCount+1,await this._runLifecycleHook(`predraw`),this._inUserDraw=!0;try{await r.draw()}finally{this._inUserDraw=!1}await this._runLifecycleHook(`postdraw`)}await this._renderer.finishDraw?.()}}}typeof p5<`u`&&Ut(p5,p5.prototype);function Wt(t,n,r){let i=[v,x,S,C,w,T],a=typeof window<`u`&&typeof document<`u`;n._frameRate=0,n._lastFrameTime=globalThis.performance.now(),n._targetFrameRate=60;let o=a?window.print:null,s=!1;r.presetup=function(){let t=[`resize`];if(a)for(let n of t)window.addEventListener(n,this[`_on${n}`].bind(this),{passive:!1,signal:this._removeSignal})},n.print=function(...t){!t.length&&o!==null?s||(o(),window.confirm(`You just tried to print the webpage. Do you want to prevent this from running again?`)&&(s=!0)):console.log(...t)},n.frameCount=0,n.deltaTime=0,n.focused=!a||document.hasFocus(),n.cursor=function(t,n,r){let a=`auto`,o=this._curElement.elt;if(t===void 0){let t=o.style.cursor;return t.length?t:`default`}if(i.includes(t))a=t;else if(typeof t==`string`){let i=``;typeof n==`number`&&(r=typeof r==`number`?r:0,i=`${Math.max(n,0)} ${Math.max(r,0)}`),a=t.substring(0,7)===`http://`||t.substring(0,8)===`https://`||/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(t)?`url(${t}) ${i}, auto`:t}o.style.cursor=a},n.frameRate=function(t){return typeof t!=`number`||t<0?this._frameRate:(this._targetFrameRate=t,t===0&&(this._frameRate=t),this)},n.getFrameRate=function(){return this.frameRate()},n.setFrameRate=function(t){return this.frameRate(t)},n.getTargetFrameRate=function(){return this._targetFrameRate},n.noCursor=function(){this._curElement.elt.style.cursor=`none`},n.webglVersion=`p2d`,n.rendererType=`p2d`,n.displayWidth=a?window.screen.width:0,n.displayHeight=a?window.screen.height:0,n.windowWidth=0,n.windowHeight=0,n._onresize=function(t){this.windowWidth=c(),this.windowHeight=l();let n;typeof this._customActions.windowResized==`function`&&(n=this._customActions.windowResized(t),n!==void 0&&!n&&t.preventDefault())};function c(){return a?document.documentElement.clientWidth:0}function l(){return a?document.documentElement.clientHeight:0}n._updateWindowSize=function(){this.windowWidth=c(),this.windowHeight=l()},Object.defineProperty(n,"width",{configurable:!0,enumerable:!0,get(){return this._renderer?.width}}),Object.defineProperty(n,"height",{configurable:!0,enumerable:!0,get(){return this._renderer?.height}}),n.fullscreen=function(t){if(t===void 0)return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;t?u(document.documentElement):d()},n.pixelDensity=function(t){let n;return typeof t==`number`?(t!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=t),n=this,this.resizeCanvas(this.width,this.height,!0)):n=this._renderer._pixelDensity,n},n.displayDensity=()=>window.devicePixelRatio;function u(t){if(!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled))throw Error(`Fullscreen not enabled in this browser.`);t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}function d(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()}n.getURL=()=>location.href,n.getURLPath=()=>location.pathname.split(`/`).filter(t=>t!==``),n.getURLParams=function(){let t=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim,n,r={};for(;(n=t.exec(location.search))!=null;)n.index===t.lastIndex&&t.lastIndex++,r[n[1]]=n[2];return r},n.worldToScreen=function(t){return typeof t==`number`&&(t=this.createVector(...arguments)),this._renderer.getWorldToScreenMatrix().multiplyAndNormalizePoint(t)},n.screenToWorld=function(t){typeof t==`number`&&(t=this.createVector(...arguments));let n=this._renderer.getWorldToScreenMatrix();if(t.dimensions===2){let r=n.mat4[14]/n.mat4[15];t=this.createVector(t.x,t.y,r)}return n.invert(n).multiplyAndNormalizePoint(t)}}typeof p5<`u`&&Wt(p5,p5.prototype);function Gt(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Kt(t,n,r=[0,0,0]){let i=Gt(t,n[0]),a=Gt(t,n[1]),o=Gt(t,n[2]);return r[0]=i,r[1]=a,r[2]=o,r}function qt(t){return Jt(t)===`string`}function Jt(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||``).toLowerCase()}function Yt(t,{precision:n=16,unit:r}){return Xt(t)?`none`:(t=+Zt(t,n),t+(r??``))}function Xt(t){return t===null}function Zt(t,n){if(t===0)return 0;let r=~~t,i=0;r&&n&&(i=~~Math.log10(Math.abs(r))+1);let a=10**(n-i);return Math.floor(t*a+.5)/a}function Qt(t,n,r){return isNaN(t)?n:isNaN(n)?t:t+(n-t)*r}function $t(t,n,r){return(r-t)/(n-t)}function en(t,n,r){return!t||!n||t===n||t[0]===n[0]&&t[1]===n[1]||isNaN(r)||r===null?r:Qt(n[0],n[1],$t(t[0],t[1],r))}function tn(t,n,r){return Math.max(Math.min(r,n),t)}function nn(t,n){return Math.sign(t)===Math.sign(n)?t:-t}function rn(t,n){return nn(Math.abs(t)**n,t)}function an(t,n){return n===0?0:t/n}function on(t,n,r=0,i=t.length){for(;r<i;){let a=r+i>>1;t[a]<n?r=a+1:i=a}return r}function sn(t,n){if(t instanceof n)return!0;let r=n.name;for(;t;){let n=Object.getPrototypeOf(t),i=n?.constructor?.name;if(i===r)return!0;if(!i||i===`Object`)return!1;t=n}return!1}var cn=class{type;coordMeta;coordRange;range;constructor(t,n){if(typeof t==`object`&&(this.coordMeta=t),n&&(this.coordMeta=n,this.coordRange=n.range??n.refRange),typeof t==`string`){let n=t.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);if(!n)throw TypeError(`Cannot parse ${t} as a type definition.`);this.type=n.groups.type;let{min:r,max:i}=n.groups;(r||i)&&(this.range=[+r,+i])}}get computedRange(){return this.range?this.range:this.type===`<percentage>`?this.percentageRange():this.type===`<angle>`?[0,360]:null}get unit(){return this.type===`<percentage>`?`%`:this.type===`<angle>`?`deg`:``}resolve(t){if(this.type===`<angle>`)return t;let n=this.computedRange,r=this.coordRange;return this.type===`<percentage>`&&(r??=this.percentageRange()),en(n,r,t)}serialize(t,n){let r=this.type===`<percentage>`?this.percentageRange(100):this.computedRange,i=this.unit;return t=en(this.coordRange,r,t),Yt(t,{unit:i,precision:n})}toString(){let t=this.type;if(this.range){let[n=``,r=``]=this.range;t+=`[${n},${r}]`}return t}percentageRange(t=1){let n;return n=this.coordMeta&&this.coordMeta.range||this.coordRange&&this.coordRange[0]>=0?[0,1]:[-1,1],[n[0]*t,n[1]*t]}static get(t,n){return sn(t,this)?t:new this(t,n)}};const ln=Symbol(`instance`);var un=class t{type;name;spaceCoords;coords;id;alpha;constructor(t,n=t.space){t[ln]=this,this.type=`function`,this.name=`color`,Object.assign(this,t),this.space=n,this.type!==`custom`&&(this.spaceCoords=Object.values(n.coords),this.coords||=this.spaceCoords.map(t=>{let n=[`<number>`,`<percentage>`];return t.type===`angle`&&n.push(`<angle>`),n}),this.coords=this.coords.map((t,n)=>{let r=this.spaceCoords[n];return typeof t==`string`&&(t=t.trim().split(/\s*\|\s*/)),t.map(t=>cn.get(t,r))}))}serializeCoords(t,n,r){return r=t.map((t,n)=>cn.get(r?.[n]??this.coords[n][0],this.spaceCoords[n])),t.map((t,i)=>r[i].serialize(t,n))}coerceCoords(t,n){return Object.entries(this.space.coords).map(([r,i],a)=>{let o=t[a];if(Xt(o)||isNaN(o))return o;let s=n[a],c=this.coords[a].find(t=>t.type==s);if(!c){let t=i.name||r;throw TypeError(`${s??o?.raw??o} not allowed for ${t} in ${this.name}()`)}return o=c.resolve(o),c.range&&(n[a]=c.toString()),o})}canSerialize(){return this.type===`function`||this.serialize}parse(t){return null}static get(n,...r){return!n||sn(n,this)?n:n[ln]?n[ln]:new t(n,...r)}};const dn=new class{add(t,n,r){if(typeof arguments[0]!=`string`)for(var t in arguments[0])this.add(t,arguments[0][t],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(t){this[t]=this[t]||[],n&&this[t][r?`unshift`:`push`](n)},this)}run(t,n){this[t]=this[t]||[],this[t].forEach(function(t){t.call(n&&n.context?n.context:n,n)})}},pn={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function mn(t){return Array.isArray(t)?t:pn[t]}function hn(t,n,r,i={}){if(t=mn(t),n=mn(n),!t||!n)throw TypeError(`Missing white point to convert ${t?``:`from`}${!t&&!n?`/`:``}${n?``:`to`}`);if(t===n)return r;let a={W1:t,W2:n,XYZ:r,options:i};if(dn.run(`chromatic-adaptation-start`,a),a.M||(a.W1===pn.D65&&a.W2===pn.D50?a.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:a.W1===pn.D50&&a.W2===pn.D65&&(a.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),dn.run(`chromatic-adaptation-end`,a),a.M)return Kt(a.XYZ,a.M);throw TypeError(`Only Bradford CAT with white points D50 and D65 supported for now.`)}var gn={gamut_mapping:`css`,precision:5,deltaE:`76`,verbose:globalThis?.process?.env?.NODE_ENV?.toLowerCase()!==`test`,warn:function(t){this.verbose&&globalThis?.console?.warn?.(t)}};function _n(t,n){let r={str:String(t)?.trim(),options:n};if(dn.run(`parse-start`,r),r.color)return r.color;r.parsed=xn(r.str);let i,a=r.options?r.options.parseMeta??r.options.meta:null;if(r.parsed){let n=r.parsed.name,o,s,c=r.parsed.args,l=c.map((t,n)=>r.parsed.argMeta[n]?.type);if(n===`color`){let i=c.shift();l.shift();let a=i.startsWith(`--`)?i.substring(2):`--${i}`,u=[i,a];if(o=Cn.findFormat({name:n,id:u,type:`function`}),!o){let n,o=i in Cn.registry?i:a;if(o in Cn.registry){let r=Cn.registry[o].formats?.color?.id;r&&(n=`Did you mean ${t.replace(`color(`+i,`color(`+r)}?`)}throw TypeError(`Cannot parse ${r.str}. `+(n??`Missing a plugin?`))}s=o.space,o.id.startsWith(`--`)&&!i.startsWith(`--`)&&gn.warn(`${s.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${o.id}) instead of color(${i}).`),i.startsWith(`--`)&&!o.id.startsWith(`--`)&&gn.warn(`${s.name} is a standard space and supported in the CSS spec. Use color(${o.id}) instead of prefixed color(${i}).`)}else o=Cn.findFormat({name:n,type:`function`}),s=o.space;a&&Object.assign(a,{format:o,formatId:o.name,types:l,commas:r.parsed.commas});let u=1;r.parsed.lastAlpha&&(u=r.parsed.args.pop(),a&&(a.alphaType=l.pop()));let d=o.coords.length;if(c.length!==d)throw TypeError(`Expected ${d} coordinates for ${s.id} in ${r.str}), got ${c.length}`);c=o.coerceCoords(c,l),i={spaceId:s.id,coords:c,alpha:u}}else spaceloop:for(let t of Cn.all)for(let n in t.formats){let o=t.formats[n];if(o.type!==`custom`||o.test&&!o.test(r.str))continue;let s=t.getFormat(o),c=s.parse(r.str);if(c){a&&Object.assign(a,{format:s,formatId:n}),i=c;break spaceloop}}if(!i)throw TypeError(`Could not parse ${t} as a color. Missing a plugin?`);return i.alpha=Xt(i.alpha)?i.alpha:i.alpha===void 0?1:tn(0,i.alpha,1),i}const vn={"%":.01,deg:1,grad:.9,rad:180/Math.PI,turn:360},yn={function:/^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,number:/^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,unitValue:RegExp(`(${Object.keys(vn).join(`|`)})$`),singleArgument:/\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g};function bn(t){let n={},r=t.match(yn.unitValue)?.[0],i=n.raw=t;return r?(n.type=r===`%`?`<percentage>`:`<angle>`,n.unit=r,n.unitless=Number(i.slice(0,-r.length)),i=n.unitless*vn[r]):yn.number.test(i)?(i=Number(i),n.type=`<number>`):i===`none`?i=null:i===`NaN`||i===`calc(NaN)`?(i=NaN,n.type=`<number>`):n.type=`<ident>`,{value:i,meta:n}}function xn(t){if(!t)return;t=t.trim();let n=t.match(yn.function);if(n){let t=[],r=[],i=!1,a=n[1].toLowerCase(),o=n[2].replace(yn.singleArgument,(n,o)=>{let{value:s,meta:c}=bn(o);return(n.startsWith(`/`)||a!==`color`&&t.length===3)&&(i=!0),t.push(s),r.push(c),``});return{name:a,args:t,argMeta:r,lastAlpha:i,commas:o.includes(`,`),rawName:n[1],rawArgs:n[2]}}}function Sn(t,n){if(Array.isArray(t))return t.map(t=>Sn(t,n));if(!t)throw TypeError(`Empty color reference`);qt(t)&&(t=_n(t,n));let r=t.space||t.spaceId;return typeof r==`string`&&(t.space=Cn.get(r)),t.alpha===void 0&&(t.alpha=1),t}var Cn=class t{constructor(n){this.id=n.id,this.name=n.name,this.base=n.base?t.get(n.base):null,this.aliases=n.aliases,this.base&&(this.fromBase=n.fromBase,this.toBase=n.toBase);let r=n.coords??this.base.coords;for(let t in r)`name`in r[t]||(r[t].name=t);this.coords=r;let i=n.white??this.base.white??`D65`;this.white=mn(i),this.formats=n.formats??{};for(let t in this.formats){let n=this.formats[t];n.type||=`function`,n.name||=t}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:n.cssId||this.id}),this.gamutSpace=n.gamutSpace?n.gamutSpace===`self`?this:t.get(n.gamutSpace):this.isPolar?this.base:this,this.gamutSpace.isUnbounded&&(this.inGamut=(t,n)=>!0),this.referred=n.referred,Object.defineProperty(this,"path",{value:wn(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),dn.run(`colorspace-init-end`,this)}inGamut(t,{epsilon:n=75e-6}={}){if(!this.equals(this.gamutSpace))return t=this.to(this.gamutSpace,t),this.gamutSpace.inGamut(t,{epsilon:n});let r=Object.values(this.coords);return t.every((t,i)=>{let a=r[i];if(a.type!==`angle`&&a.range){if(Xt(t))return!0;let[r,i]=a.range;return(r===void 0||t>=r-n)&&(i===void 0||t<=i+n)}return!0})}get isUnbounded(){return Object.values(this.coords).every(t=>!(`range`in t))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let t in this.coords)if(this.coords[t].type===`angle`)return!0;return!1}getFormat(t){if(!t)return null;t==="default"?t=Object.values(this.formats)[0]:typeof t==`string`&&(t=this.formats[t]);let n=un.get(t,this);return n!==t&&t.name in this.formats&&(this.formats[t.name]=n),n}equals(t){return t?this===t||this.id===t||this.id===t.id:!1}to(n,r){if(arguments.length===1){let t=Sn(n);[n,r]=[t.space,t.coords]}if(n=t.get(n),this.equals(n))return r;r=r.map(t=>Xt(t)?0:t);let i=this.path,a=n.path,o,s;for(let t=0;t<i.length&&i[t].equals(a[t]);t++)o=i[t],s=t;if(!o)throw Error(`Cannot convert between color spaces ${this} and ${n}: no connection space was found`);for(let t=i.length-1;t>s;t--)r=i[t].toBase(r);for(let t=s+1;t<a.length;t++)r=a[t].fromBase(r);return r}from(n,r){if(arguments.length===1){let t=Sn(n);[n,r]=[t.space,t.coords]}return n=t.get(n),n.to(this,r)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let t=[];for(let n in this.coords){let r=this.coords[n],i=r.range||r.refRange;t.push(i?.min??0)}return t}static registry={};static get all(){return[...new Set(Object.values(t.registry))]}static register(t,n){if(arguments.length===1&&(n=arguments[0],t=n.id),n=this.get(n),this.registry[t]&&this.registry[t]!==n)throw Error(`Duplicate color space registration: '${t}'`);if(this.registry[t]=n,arguments.length===1&&n.aliases)for(let t of n.aliases)this.register(t,n);return n}static get(n,...r){if(!n||sn(n,this))return n;if(Jt(n)===`string`){let r=t.registry[n.toLowerCase()];if(!r)throw TypeError(`No color space found with id = "${n}"`);return r}if(r.length)return t.get(...r);throw TypeError(`${n} is not a valid color space`)}static findFormat(n,r=t.all){if(!n)return null;typeof n==`string`&&(n={name:n});for(let t of r)for(let[r,i]of Object.entries(t.formats)){i.name??=r,i.type??=`function`;let a=(!n.name||i.name===n.name)&&(!n.type||i.type===n.type);if(n.id){let t=i.ids||[i.id],r=Array.isArray(n.id)?n.id:[n.id];a&&=r.some(n=>t.includes(n))}if(a){let n=un.get(i,t);return n!==i&&(t.formats[i.name]=n),n}}return null}static resolveCoord(n,r){let i=Jt(n),a,o;if(i===`string`?n.includes(`.`)?[a,o]=n.split(`.`):[a,o]=[,n]:Array.isArray(n)?[a,o]=n:(a=n.space,o=n.coordId),a=t.get(a),a||=r,!a)throw TypeError(`Cannot resolve coordinate reference ${n}: No color space specified and relative references are not allowed here`);if(i=Jt(o),i===`number`||i===`string`&&o>=0){let t=Object.entries(a.coords)[o];if(t)return{space:a,id:t[0],index:o,...t[1]}}a=t.get(a);let s=o.toLowerCase(),c=0;for(let t in a.coords){let n=a.coords[t];if(t.toLowerCase()===s||n.name?.toLowerCase()===s)return{space:a,id:t,index:c,...n};c++}throw TypeError(`No "${o}" coordinate found in ${a.name}. Its coordinates are: ${Object.keys(a.coords).join(`, `)}`)}static DEFAULT_FORMAT={type:`functions`,name:`color`}};function wn(t){let n=[t];for(let r=t;r=r.base;)n.push(r);return n}var Tn=new Cn({id:`xyz-d65`,name:`XYZ D65`,coords:{x:{refRange:[0,1],name:`X`},y:{refRange:[0,1],name:`Y`},z:{refRange:[0,1],name:`Z`}},white:`D65`,formats:{color:{ids:[`xyz-d65`,`xyz`]}},aliases:[`xyz`]}),En=class extends Cn{constructor(t){t.coords||={r:{range:[0,1],name:`Red`},g:{range:[0,1],name:`Green`},b:{range:[0,1],name:`Blue`}},t.base||=Tn,t.toXYZ_M&&t.fromXYZ_M&&(t.toBase??=n=>{let r=Kt(n,t.toXYZ_M);return this.white!==this.base.white&&(r=hn(this.white,this.base.white,r)),r},t.fromBase??=n=>(n=hn(this.base.white,this.white,n),Kt(n,t.fromXYZ_M))),t.referred??=`display`,super(t)}};function Dn(t,n){t=Sn(t);let r=Cn.get(n,n?.space),i=n?.precision,a;return a=!r||t.space.equals(r)?t.coords.slice():r.from(t),i===void 0?a:a.map(t=>Zt(t,i))}function On(t,n){if(t=Sn(t),n===`alpha`)return t.alpha??1;let{space:r,index:i}=Cn.resolveCoord(n,t.space);return Dn(t,r)[i]}function kn(t,n,r,i){return t=Sn(t),Array.isArray(n)&&([n,r,i]=[t.space,n,r]),n=Cn.get(n),t.coords=n===t.space?r.slice():n.to(t.space,r),i!==void 0&&(t.alpha=i),t}kn.returns=`color`;function An(t,n,r){if(t=Sn(t),arguments.length===2&&Jt(arguments[1])===`object`){let n=arguments[1];for(let r in n)An(t,r,n[r])}else if(typeof r==`function`&&(r=r(On(t,n))),n===`alpha`)t.alpha=r;else{let{space:i,index:a}=Cn.resolveCoord(n,t.space),o=Dn(t,i);o[a]=r,kn(t,i,o)}return t}An.returns=`color`;var jn=new Cn({id:`xyz-d50`,name:`XYZ D50`,white:`D50`,base:Tn,fromBase:t=>hn(Tn.white,`D50`,t),toBase:t=>hn(`D50`,Tn.white,t)});const Mn=24/116,Nn=24389/27;let Pn=pn.D50;var Fn=new Cn({id:`lab`,name:`Lab`,coords:{l:{refRange:[0,100],name:`Lightness`},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Pn,base:jn,fromBase(t){let n=t.map((t,n)=>t/Pn[n]).map(t=>t>.008856451679035631?Math.cbrt(t):(Nn*t+16)/116);return[116*n[1]-16,500*(n[0]-n[1]),200*(n[1]-n[2])]},toBase(t){let[n,r,i]=t,a=[];return a[1]=(n+16)/116,a[0]=r/500+a[1],a[2]=a[1]-i/200,[a[0]>Mn?a[0]**3:(116*a[0]-16)/Nn,t[0]>8?((t[0]+16)/116)**3:t[0]/Nn,a[2]>Mn?a[2]**3:(116*a[2]-16)/Nn].map((t,n)=>t*Pn[n])},formats:{lab:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <percentage>`]}}});function In(t){return typeof t==`number`?(t%360+360)%360:t}function Ln(t,n){let[r,i]=n,a=Xt(r),o=Xt(i);if(a&&o)return[r,i];if(a?r=i:o&&(i=r),t===`raw`)return n;r=In(r),i=In(i);let s=i-r;return t===`increasing`?s<0&&(i+=360):t===`decreasing`?s>0&&(r+=360):t===`longer`?-180<s&&s<180&&(s>0?r+=360:i+=360):t===`shorter`&&(s>180?r+=360:s<-180&&(i+=360)),[r,i]}var Rn=new Cn({id:`lch`,name:`LCH`,coords:{l:{refRange:[0,100],name:`Lightness`},c:{refRange:[0,150],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:Fn,fromBase(t){if(this.ε===void 0){let t=Object.values(this.base.coords)[1].refRange,n=t[1]-t[0];this.ε=n/1e5}let[n,r,i]=t,a=Math.abs(r)<this.ε&&Math.abs(i)<this.ε,o=a?null:In(Math.atan2(i,r)*180/Math.PI);return[n,a?0:Math.sqrt(r**2+i**2),o]},toBase(t){let[n,r,i]=t,a=null,o=null;return Xt(i)||(r=r<0?0:r,a=r*Math.cos(i*Math.PI/180),o=r*Math.sin(i*Math.PI/180)),[n,a,o]},formats:{lch:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <angle>`]}}});const zn=25**7,Bn=Math.PI,Vn=180/Bn,Hn=Bn/180;function Un(t){let n=t*t;return n*n*n*t}function Wn(t,n,{kL:r=1,kC:i=1,kH:a=1}={}){[t,n]=Sn([t,n]);let[o,s,c]=Fn.from(t),l=Rn.from(Fn,[o,s,c])[1],[u,d,f]=Fn.from(n),p=Rn.from(Fn,[u,d,f])[1];l<0&&(l=0),p<0&&(p=0);let m=Un((l+p)/2),h=.5*(1-Math.sqrt(m/(m+zn))),g=(1+h)*s,_=(1+h)*d,v=Math.sqrt(g**2+c**2),y=Math.sqrt(_**2+f**2),b=g===0&&c===0?0:Math.atan2(c,g),x=_===0&&f===0?0:Math.atan2(f,_);b<0&&(b+=2*Bn),x<0&&(x+=2*Bn),b*=Vn,x*=Vn;let S=u-o,C=y-v,w=x-b,T=b+x,E=Math.abs(w),D;v*y===0?D=0:E<=180?D=w:w>180?D=w-360:w<-180?D=w+360:gn.warn(`the unthinkable has happened`);let O=2*Math.sqrt(y*v)*Math.sin(D*Hn/2),k=(o+u)/2,A=(v+y)/2,j=Un(A),M;M=v*y===0?T:E<=180?T/2:T<360?(T+360)/2:(T-360)/2;let ee=(k-50)**2,te=1+.015*ee/Math.sqrt(20+ee),N=1+.045*A,ne=1;ne-=.17*Math.cos((M-30)*Hn),ne+=.24*Math.cos(2*M*Hn),ne+=.32*Math.cos((3*M+6)*Hn),ne-=.2*Math.cos((4*M-63)*Hn);let re=1+.015*A*ne,ie=30*Math.exp(-1*((M-275)/25)**2),P=2*Math.sqrt(j/(j+zn)),ae=-1*Math.sin(2*ie*Hn)*P,oe=(S/(r*te))**2;return oe+=(C/(i*N))**2,oe+=(O/(a*re))**2,oe+=ae*(C/(i*N))*(O/(a*re)),Math.sqrt(oe)}const Gn=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],Kn=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],qn=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],Jn=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var Yn=new Cn({id:`oklab`,name:`Oklab`,coords:{l:{refRange:[0,1],name:`Lightness`},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:`D65`,base:Tn,fromBase(t){let n=Kt(t,Gn);return n[0]=Math.cbrt(n[0]),n[1]=Math.cbrt(n[1]),n[2]=Math.cbrt(n[2]),Kt(n,qn,n)},toBase(t){let n=Kt(t,Jn);return n[0]**=3,n[1]**=3,n[2]**=3,Kt(n,Kn,n)},formats:{oklab:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <percentage>`]}}});function Xn(t,n){[t,n]=Sn([t,n]);let[r,i,a]=Yn.from(t),[o,s,c]=Yn.from(n),l=r-o,u=i-s,d=a-c;return Math.sqrt(l**2+u**2+d**2)}function Zn(t,n,{epsilon:r=75e-6}={}){t=Sn(t),n||=t.space,n=Cn.get(n);let i=t.coords;return n!==t.space&&(i=n.from(t)),n.inGamut(i,{epsilon:r})}function Qn(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}function $n(t,n,r=`lab`){r=Cn.get(r);let i=r.from(t),a=r.from(n);return Math.sqrt(i.reduce((t,n,r)=>{let i=a[r];return Xt(n)||Xt(i)?t:t+(i-n)**2},0))}function er(t,n){return $n(t,n,`lab`)}const tr=Math.PI/180;function nr(t,n,{l:r=2,c:i=1}={}){[t,n]=Sn([t,n]);let[a,o,s]=Fn.from(t),[,c,l]=Rn.from(Fn,[a,o,s]),[u,d,f]=Fn.from(n),p=Rn.from(Fn,[u,d,f])[1];c<0&&(c=0),p<0&&(p=0);let m=a-u,h=c-p,g=o-d,_=s-f,v=g**2+_**2-h**2,y=.511;a>=16&&(y=.040975*a/(1+.01765*a));let b=.0638*c/(1+.0131*c)+.638,x;Xt(l)&&(l=0),x=l>=164&&l<=345?.56+Math.abs(.2*Math.cos((l+168)*tr)):.36+Math.abs(.4*Math.cos((l+35)*tr));let S=c**4,C=Math.sqrt(S/(S+1900)),w=b*(C*x+1-C),T=(m/(r*y))**2;return T+=(h/(i*b))**2,T+=v/w**2,Math.sqrt(T)}var rr=new Cn({id:`xyz-abs-d65`,cssId:`--xyz-abs-d65`,name:`Absolute XYZ D65`,coords:{x:{refRange:[0,9504.7],name:`Xa`},y:{refRange:[0,1e4],name:`Ya`},z:{refRange:[0,10888.3],name:`Za`}},base:Tn,fromBase(t){return t.map(t=>t*203)},toBase(t){return t.map(t=>t/203)}});const ir=1.15,ar=.66,or=2610/2**14,sr=2**14/2610,cr=3424/4096,lr=2413/128,ur=2392/128,dr=32/(1.7*2523),fr=-.56,pr=16295499532821565e-27,mr=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],hr=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],gr=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],_r=[[1,.13860504327153927,.05804731615611883],[1,-.1386050432715393,-.058047316156118904],[1,-.09601924202631895,-.811891896056039]];var vr=new Cn({id:`jzczhz`,name:`JzCzHz`,coords:{jz:{refRange:[0,1],name:`Jz`},cz:{refRange:[0,.26],name:`Chroma`},hz:{refRange:[0,360],type:`angle`,name:`Hue`}},base:new Cn({id:`jzazbz`,name:`Jzazbz`,coords:{jz:{refRange:[0,1],name:`Jz`},az:{refRange:[-.21,.21]},bz:{refRange:[-.21,.21]}},base:rr,fromBase(t){let[n,r,i]=t,[a,o,s]=Kt(Kt([ir*n-.1499999999999999*i,ar*r- -.33999999999999997*n,i],mr).map(function(t){return rn((cr+lr*rn(t/1e4,or))/(1+ur*rn(t/1e4,or)),134.03437499999998)}),gr);return[.43999999999999995*a/(1+fr*a)-pr,o,s]},toBase(t){let[n,r,i]=t,[a,o,s]=Kt(Kt([(n+pr)/(.43999999999999995-fr*(n+pr)),r,i],_r).map(function(t){return 1e4*rn((cr-rn(t,dr))/(ur*rn(t,dr)-lr),sr)}),hr),c=(a+.1499999999999999*s)/ir;return[c,(o+-.33999999999999997*c)/ar,s]},formats:{jzazbz:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <percentage>`]}}}),fromBase:Rn.fromBase,toBase:Rn.toBase,formats:{jzczhz:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <angle>`]}}});function yr(t,n){[t,n]=Sn([t,n]);let[r,i,a]=vr.from(t),[o,s,c]=vr.from(n),l=r-o,u=i-s;Xt(a)&&Xt(c)?(a=0,c=0):Xt(a)?a=c:Xt(c)&&(c=a);let d=a-c,f=2*Math.sqrt(i*s)*Math.sin(d/2*(Math.PI/180));return Math.sqrt(l**2+u**2+f**2)}const br=3424/4096,xr=2413/128,Sr=2392/128,Cr=2610/16384,wr=32/2523,Tr=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],Er=[[2048/4096,2048/4096,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],Dr=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],Or=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var kr=new Cn({id:`ictcp`,name:`ICTCP`,coords:{i:{refRange:[0,1],name:`I`},ct:{refRange:[-.5,.5],name:`CT`},cp:{refRange:[-.5,.5],name:`CP`}},base:rr,fromBase(t){return Ar(Kt(t,Tr))},toBase(t){return Kt(jr(t),Or)},formats:{ictcp:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <percentage>`]}}});function Ar(t){return Kt(t.map(function(t){return((br+xr*(t/1e4)**Cr)/(1+Sr*(t/1e4)**Cr))**78.84375}),Er)}function jr(t){return Kt(t,Dr).map(function(t){return 1e4*(Math.max(t**wr-br,0)/(xr-Sr*t**wr))**6.277394636015326})}function Mr(t,n){[t,n]=Sn([t,n]);let[r,i,a]=kr.from(t),[o,s,c]=kr.from(n);return 720*Math.sqrt((r-o)**2+.25*(i-s)**2+(a-c)**2)}function Nr(t,n){[t,n]=Sn([t,n]);let[r,i,a]=Yn.from(t),[o,s,c]=Yn.from(n),l=r-o,u=2*(i-s),d=2*(a-c);return Math.sqrt(l**2+u**2+d**2)}const Pr=pn.D65,Fr=.42,Ir=1/Fr,Lr=2*Math.PI,Rr=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],zr=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Br=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Vr={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},Hr={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Ur=180/Math.PI,Wr=Math.PI/180;function Gr(t,n){return t.map(t=>{let r=rn(n*Math.abs(t)*.01,Fr);return 400*nn(r,t)/(r+27.13)})}function Kr(t,n){let r=100/n*27.13**Ir;return t.map(t=>{let n=Math.abs(t);return nn(r*rn(n/(400-n),Ir),t)})}function qr(t){let n=In(t);n<=Hr.h[0]&&(n+=360);let r=on(Hr.h,n)-1,[i,a]=Hr.h.slice(r,r+2),[o,s]=Hr.e.slice(r,r+2),c=Hr.H[r],l=(n-i)/o;return c+100*l/(l+(a-n)/s)}function Jr(t){let n=(t%400+400)%400,r=Math.floor(.01*n);n%=100;let[i,a]=Hr.h.slice(r,r+2),[o,s]=Hr.e.slice(r,r+2);return In((n*(s*i-o*a)-100*i*s)/(n*(s-o)-100*s))}function Yr(t,n,r,i,a){let o={};o.discounting=a,o.refWhite=t,o.surround=i;let s=t.map(t=>t*100);o.la=n,o.yb=r;let c=s[1],l=Kt(s,Rr),u=Vr[o.surround],d=u[0];o.c=u[1],o.nc=u[2];let f=(1/(5*o.la+1))**4;o.fl=f*o.la+.1*(1-f)*(1-f)*Math.cbrt(5*o.la),o.flRoot=o.fl**.25,o.n=o.yb/c,o.z=1.48+Math.sqrt(o.n),o.nbb=.725*o.n**-.2,o.ncb=o.nbb;let p=a?1:Math.max(Math.min(d*(1-1/3.6*Math.exp((-o.la-42)/92)),1),0);o.dRgb=l.map(t=>Qt(1,c/t,p)),o.dRgbInv=o.dRgb.map(t=>1/t);let m=Gr(l.map((t,n)=>t*o.dRgb[n]),o.fl);return o.aW=o.nbb*(2*m[0]+m[1]+.05*m[2]),o}const Xr=Yr(Pr,64/Math.PI*.2,20,`average`,!1);function Zr(t,n){if(!(t.J!==void 0^t.Q!==void 0))throw Error(`Conversion requires one and only one: 'J' or 'Q'`);if(!(t.C!==void 0^t.M!==void 0^t.s!==void 0))throw Error(`Conversion requires one and only one: 'C', 'M' or 's'`);if(!(t.h!==void 0^t.H!==void 0))throw Error(`Conversion requires one and only one: 'h' or 'H'`);if(t.J===0||t.Q===0)return[0,0,0];let r=0;r=t.h===void 0?Jr(t.H)*Wr:In(t.h)*Wr;let i=Math.cos(r),a=Math.sin(r),o=0;t.J===void 0?t.Q!==void 0&&(o=.25*n.c*t.Q/((n.aW+4)*n.flRoot)):o=rn(t.J,1/2)*.1;let s=0;t.C===void 0?t.M===void 0?t.s!==void 0&&(s=4e-4*t.s**2*(n.aW+4)/n.c):s=t.M/n.flRoot/o:s=t.C/o;let c=rn(s*(1.64-.29**n.n)**-.73,10/9),l=.25*(Math.cos(r+2)+3.8),u=n.aW*rn(o,2/n.c/n.z),d=5e4/13*n.nc*n.ncb*l,f=u/n.nbb,p=23*(f+.305)*an(c,23*d+c*(11*i+108*a));return Kt(Kr(Kt([f,p*i,p*a],Br).map(t=>t*1/1403),n.fl).map((t,r)=>t*n.dRgbInv[r]),zr).map(t=>t/100)}function Qr(t,n){let r=Gr(Kt(t.map(t=>t*100),Rr).map((t,r)=>t*n.dRgb[r]),n.fl),i=r[0]+(-12*r[1]+r[2])/11,a=(r[0]+r[1]-2*r[2])/9,o=(Math.atan2(a,i)%Lr+Lr)%Lr,s=.25*(Math.cos(o+2)+3.8),c=rn(5e4/13*n.nc*n.ncb*an(s*Math.sqrt(i**2+a**2),r[0]+r[1]+1.05*r[2]+.305),.9)*(1.64-.29**n.n)**.73,l=rn(n.nbb*(2*r[0]+r[1]+.05*r[2])/n.aW,.5*n.c*n.z),u=100*rn(l,2),d=4/n.c*l*(n.aW+4)*n.flRoot,f=c*l,p=f*n.flRoot,m=In(o*Ur),h=qr(m);return{J:u,C:f,h:m,s:50*rn(n.c*c/(n.aW+4),1/2),Q:d,M:p,H:h}}new Cn({id:`cam16-jmh`,cssId:`--cam16-jmh`,name:`CAM16-JMh`,coords:{j:{refRange:[0,100],name:`J`},m:{refRange:[0,105],name:`Colorfulness`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},base:Tn,fromBase(t){this.ε===void 0&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);let n=Qr(t,Xr),r=Math.abs(n.M)<this.ε;return[n.J,r?0:n.M,r?null:n.h]},toBase(t){return Zr({J:t[0],M:t[1],h:t[2]},Xr)}});const $r=pn.D65,ei=24389/27;function ti(t){return 116*(t>.008856451679035631?Math.cbrt(t):(ei*t+16)/116)-16}function ni(t){return t>8?((t+16)/116)**3:t/ei}function ri(t,n){let[r,i,a]=t,o=[],s=0;if(a===0)return[0,0,0];let c=ni(a);s=a>0?.00379058511492914*a**2+.608983189401032*a+.9155088574762233:9514440756550361e-21*a**2+.08693057439788597*a-21.928975842194614;let l=0,u=1/0;for(;l<=15;){o=Zr({J:s,C:i,h:r},n);let t=Math.abs(o[1]-c);if(t<u){if(t<=2e-12)return o;u=t}s-=(o[1]-c)*s/(2*o[1]),l+=1}return Zr({J:s,C:i,h:r},n)}function ii(t,n){let r=ti(t[1]);if(r===0)return[0,0,0];let i=Qr(t,ai);return[In(i.h),i.C,r]}const ai=Yr($r,200/Math.PI*ni(50),ni(50)*100,`average`,!1);var oi=new Cn({id:`hct`,name:`HCT`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},c:{refRange:[0,145],name:`Colorfulness`},t:{refRange:[0,100],name:`Tone`}},base:Tn,fromBase(t){this.ε===void 0&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);let n=ii(t,ai);return n[1]<this.ε&&(n[1]=0,n[0]=null),n},toBase(t){return ri(t,ai)},formats:{color:{id:`--hct`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}});const si=Math.PI/180,ci=[1,.007,.0228];function li(t){t[1]<0&&(t=oi.fromBase(oi.toBase(t)));let n=Math.log(Math.max(1+ci[2]*t[1]*ai.flRoot,1))/ci[2],r=t[0]*si,i=n*Math.cos(r),a=n*Math.sin(r);return[t[2],i,a]}function ui(t,n){[t,n]=Sn([t,n]);let[r,i,a]=li(oi.from(t)),[o,s,c]=li(oi.from(n));return Math.sqrt((r-o)**2+(i-s)**2+(a-c)**2)}var di={deltaE76:er,deltaECMC:nr,deltaE2000:Wn,deltaEJz:yr,deltaEITP:Mr,deltaEOK:Xn,deltaEOK2:Nr,deltaEHCT:ui};function fi(t){return Math.max(parseFloat(`1e${(t?Math.floor(Math.log10(Math.abs(t))):0)-2}`),1e-6)}const pi={hct:{method:`hct.c`,jnd:2,deltaEMethod:`hct`,blackWhiteClamp:{}},"hct-tonal":{method:`hct.c`,jnd:0,deltaEMethod:`hct`,blackWhiteClamp:{channel:`hct.t`,min:0,max:100}}};function mi(t,{method:n=gn.gamut_mapping,space:r=void 0,deltaEMethod:i=``,jnd:a=2,blackWhiteClamp:o=void 0}={}){if(t=Sn(t),qt(arguments[1])?r=arguments[1]:r||=t.space,r=Cn.get(r),Zn(t,r,{epsilon:0}))return t;let s;if(n===`css`)s=gi(t,{space:r});else{if(n!==`clip`&&!Zn(t,r)){Object.prototype.hasOwnProperty.call(pi,n)&&({method:n,jnd:a,deltaEMethod:i,blackWhiteClamp:o}=pi[n]);let c=Wn;if(i!==``){for(let t in di)if(`deltae`+i.toLowerCase()===t.toLowerCase()){c=di[t];break}}a===0&&(a=1e-16);let l=mi(_i(t,r),{method:`clip`,space:r});if(c(t,l)>a){if(o&&Object.keys(o).length===3){let n=Cn.resolveCoord(o.channel),r=On(_i(t,n.space),n.id);if(Xt(r)&&(r=0),r>=o.max)return _i({space:`xyz-d65`,coords:pn.D65},t.space);if(r<=o.min)return _i({space:`xyz-d65`,coords:[0,0,0]},t.space)}let i=Cn.resolveCoord(n),l=i.space,u=i.id,d=_i(t,l);d.coords.forEach((t,n)=>{Xt(t)&&(d.coords[n]=0)});let f=(i.range||i.refRange)[0],p=fi(a),m=f,h=On(d,u);for(;h-m>p;){let t=Qn(d);t=mi(t,{space:r,method:`clip`}),c(d,t)-a<p?m=On(d,u):h=On(d,u),An(d,u,(m+h)/2)}s=_i(d,r)}else s=l}else s=_i(t,r);if(n===`clip`||!Zn(s,r,{epsilon:0})){let t=Object.values(r.coords).map(t=>t.range||[]);s.coords=s.coords.map((n,r)=>{let[i,a]=t[r];return i!==void 0&&(n=Math.max(i,n)),a!==void 0&&(n=Math.min(n,a)),n})}}return r!==t.space&&(s=_i(s,t.space)),t.coords=s.coords,t}mi.returns=`color`;const hi={WHITE:{space:Yn,coords:[1,0,0],alpha:1},BLACK:{space:Yn,coords:[0,0,0],alpha:1}};function gi(t,{space:n}={}){let r=.02,i=1e-4;t=Sn(t),n||=t.space,n=Cn.get(n);let a=Cn.get(`oklch`);if(n.isUnbounded)return _i(t,n);let o=_i(t,a),s=o.coords[0];if(s>=1){let r=_i(hi.WHITE,n);return r.alpha=t.alpha,_i(r,n)}if(s<=0){let r=_i(hi.BLACK,n);return r.alpha=t.alpha,_i(r,n)}if(Zn(o,n,{epsilon:0}))return _i(o,n);function c(t){let r=_i(t,n),i=Object.values(n.coords);return r.coords=r.coords.map((t,n)=>{if(`range`in i[n]){let[r,a]=i[n].range;return tn(r,t,a)}return t}),r}let l=0,u=o.coords[1],d=!0,f=Qn(o),p=c(f),m=Xn(p,f);if(m<r)return p;for(;u-l>i;){let t=(l+u)/2;if(f.coords[1]=t,d&&Zn(f,n,{epsilon:0}))l=t;else if(p=c(f),m=Xn(p,f),m<r){if(r-m<i)break;d=!1,l=t}else u=t}return p}function _i(t,n,{inGamut:r}={}){t=Sn(t),n=Cn.get(n);let i=n.from(t),a={space:n,coords:i,alpha:t.alpha};return r&&(a=mi(a,r===!0?void 0:r)),a}_i.returns=`color`;function vi(t,n={}){let{precision:r=gn.precision,format:i,inGamut:a=!0,coords:o,alpha:s,commas:c}=n,l,u=Sn(t),d=i,f=u.parseMeta;f&&!i&&(f.format.canSerialize()&&(i=f.format,d=f.formatId),o??=f.types,s??=f.alphaType,c??=f.commas),d&&(i=u.space.getFormat(i)??Cn.findFormat(d)),i||(i=u.space.getFormat(`default`)??Cn.DEFAULT_FORMAT,d=i.name),i&&i.space&&i.space!==u.space&&(u=_i(u,i.space));let p=u.coords.slice();if(a||=i.toGamut,a&&!Zn(u)&&(p=mi(Qn(u),a===!0?void 0:a).coords),i.type===`custom`){if(i.serialize)l=i.serialize(p,u.alpha,n);else throw TypeError(`format ${d} can only be used to parse colors, not for serialization`)}else{let t=i.name||`color`,n=i.serializeCoords(p,r,o);if(t===`color`){let t=i.id||i.ids?.[0]||u.space.cssId||u.space.id;n.unshift(t)}let a=u.alpha;s!==void 0&&typeof s!=`object`&&(s=typeof s==`string`?{type:s}:{include:s});let d=s?.type??`<number>`,f=s?.include===!0||i.alpha===!0||s?.include!==!1&&i.alpha!==!1&&a<1,m=``;if(c??=i.commas,f){if(r!==null){let t;d===`<percentage>`&&(t=`%`,a*=100),a=Yt(a,{precision:r,unit:t})}m=`${c?`,`:` /`} ${a}`}l=`${t}(${n.join(c?`, `:` `)}${m})`}return l}var yi=new En({id:`p3-linear`,cssId:`display-p3-linear`,name:`Linear P3`,white:`D65`,toXYZ_M:[[.4865709486482162,.26566769316909306,.1982172852343625],[.2289745640697488,.6917385218365064,.079286914093745],[0,.04511338185890264,1.043944368900976]],fromXYZ_M:[[2.493496911941425,-.9313836179191239,-.40271078445071684],[-.8294889695615747,1.7626640603183463,.023624685841943577],[.03584583024378447,-.07617238926804182,.9568845240076872]]}),bi=new En({id:`srgb-linear`,name:`Linear sRGB`,white:`D65`,toXYZ_M:[[.41239079926595934,.357584339383878,.1804807884018343],[.21263900587151027,.715168678767756,.07219231536073371],[.01933081871559182,.11919477979462598,.9505321522496607]],fromXYZ_M:[[3.2409699419045226,-1.537383177570094,-.4986107602930034],[-.9692436362808796,1.8759675015077202,.04155505740717559],[.05563007969699366,-.20397695888897652,1.0569715142428786]]}),xi={aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aqua:[0,1,1],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],black:[0,0,0],blanchedalmond:[1,235/255,205/255],blue:[0,0,1],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[153/255,50/255,204/255],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],fuchsia:[1,0,1],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],gray:[128/255,128/255,128/255],green:[0,128/255,0],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,153/255],lightslategrey:[119/255,136/255,153/255],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],lime:[0,1,0],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],maroon:[128/255,0,0],mediumaquamarine:[102/255,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,204/255],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],navy:[0,0,128/255],oldlace:[253/255,245/255,230/255],olive:[128/255,128/255,0],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],purple:[128/255,0,128/255],rebeccapurple:[102/255,51/255,153/255],red:[1,0,0],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],silver:[192/255,192/255,192/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],teal:[0,128/255,128/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],white:[1,1,1],whitesmoke:[245/255,245/255,245/255],yellow:[1,1,0],yellowgreen:[154/255,205/255,50/255]};let Si=[,,,].fill(`<percentage> | <number>[0, 255]`),Ci=[,,,].fill(`<number>[0, 255]`);var wi=new En({id:`srgb`,name:`sRGB`,base:bi,fromBase:t=>t.map(t=>{let n=t<0?-1:1,r=t*n;return r>.0031308?n*(1.055*r**(1/2.4)-.055):12.92*t}),toBase:t=>t.map(t=>{let n=t<0?-1:1,r=t*n;return r<=.04045?t/12.92:n*((r+.055)/1.055)**2.4}),formats:{rgb:{coords:Si},rgb_number:{name:`rgb`,commas:!0,coords:Ci,alpha:!1},color:{},rgba:{coords:Si,commas:!0,alpha:!0},rgba_number:{name:`rgba`,commas:!0,coords:Ci},hex:{type:`custom`,toGamut:!0,test:t=>/^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(t),parse(t){t.length<=5&&(t=t.replace(/[a-f0-9]/gi,`$&$&`));let n=[];return t.replace(/[a-f0-9]{2}/gi,t=>{n.push(parseInt(t,16)/255)}),{spaceId:`srgb`,coords:n.slice(0,3),alpha:n.slice(3)[0]}},serialize:(t,n,{collapse:r=!0,alpha:i}={})=>{(i!==!1&&n<1||i===!0)&&t.push(n),t=t.map(t=>Math.round(t*255));let a=r&&t.every(t=>t%17==0);return`#`+t.map(t=>a?(t/17).toString(16):t.toString(16).padStart(2,`0`)).join(``)}},keyword:{type:`custom`,test:t=>/^[a-z]+$/i.test(t),parse(t){t=t.toLowerCase();let n={spaceId:`srgb`,coords:null,alpha:1};if(t===`transparent`?(n.coords=xi.black,n.alpha=0):n.coords=xi[t],n.coords)return n}}}}),Ti=new En({id:`p3`,cssId:`display-p3`,name:`P3`,base:yi,fromBase:wi.fromBase,toBase:wi.toBase});function Ei(t){return On(t,[Tn,`y`])}function Di(t,n){t=Sn(t),n=Sn(n);let r=Math.max(Ei(t),0),i=Math.max(Ei(n),0);return i>r&&([r,i]=[i,r]),(r+.05)/(i+.05)}const Oi=.022,ki=.027;function Ai(t){return t>=Oi?t:t+(Oi-t)**1.414}function ji(t){return(t<0?-1:1)*Math.abs(t)**2.4}function Mi(t,n){n=Sn(n),t=Sn(t);let r,i,a,o,s,c;n=_i(n,`srgb`),[o,s,c]=n.coords.map(t=>Xt(t)?0:t);let l=ji(o)*.2126729+ji(s)*.7151522+ji(c)*.072175;t=_i(t,`srgb`),[o,s,c]=t.coords.map(t=>Xt(t)?0:t);let u=ji(o)*.2126729+ji(s)*.7151522+ji(c)*.072175,d=Ai(l),f=Ai(u),p=f>d;return Math.abs(f-d)<5e-4?i=0:p?(r=f**.56-d**.57,i=r*1.14):(r=f**.65-d**.62,i=r*1.14),a=Math.abs(i)<.1?0:i>0?i-ki:i+ki,a*100}function Ni(t,n,r={}){if(Pi(t)){let[r,i]=[t,n];return Ni(...r.rangeArgs.colors,{...r.rangeArgs.options,...i})}let{space:i,outputSpace:a,progression:o,premultiplied:s}=r;t=Sn(t),n=Sn(n),t=Qn(t),n=Qn(n);let c={colors:[t,n],options:r};if(i=i?Cn.get(i):Cn.registry[gn.interpolationSpace]||t.space,a=a?Cn.get(a):i,t=_i(t,i),n=_i(n,i),t=mi(t),n=mi(n),i.coords.h&&i.coords.h.type===`angle`){let a=r.hue=r.hue||`shorter`,o=[i,`h`],[s,c]=[On(t,o),On(n,o)];Xt(s)&&!Xt(c)?s=c:Xt(c)&&!Xt(s)&&(c=s),[s,c]=Ln(a,[s,c]),An(t,o,s),An(n,o,c)}return s&&(t.coords=t.coords.map(n=>n*t.alpha),n.coords=n.coords.map(t=>t*n.alpha)),Object.assign(r=>{r=o?o(r):r;let c=t.coords.map((t,i)=>{let a=n.coords[i];return Qt(t,a,r)}),l=Qt(t.alpha,n.alpha,r),u={space:i,coords:c,alpha:l};return s&&(u.coords=u.coords.map(t=>t/l)),a!==i&&(u=_i(u,a)),u},{rangeArgs:c})}function Pi(t){return Jt(t)===`function`&&!!t.rangeArgs}gn.interpolationSpace=`lab`;var Fi=new Cn({id:`hsl`,name:`HSL`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},l:{range:[0,100],name:`Lightness`}},base:wi,fromBase:t=>{let n=Math.max(...t),r=Math.min(...t),[i,a,o]=t,[s,c,l]=[null,0,(r+n)/2],u=n-r;if(u!==0){switch(c=l===0||l===1?0:(n-l)/Math.min(l,1-l),n){case i:s=(a-o)/u+(a<o?6:0);break;case a:s=(o-i)/u+2;break;case o:s=(i-a)/u+4}s*=60}return c<0&&(s+=180,c=Math.abs(c)),s>=360&&(s-=360),[s,c*100,l*100]},toBase:t=>{let[n,r,i]=t;n%=360,n<0&&(n+=360),r/=100,i/=100;function a(t){let a=(t+n/30)%12,o=r*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(a-3,9-a,1))}return[a(0),a(8),a(4)]},formats:{hsl:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]},hsla:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`],commas:!0,alpha:!0}}}),Ii=new Cn({id:`hwb`,name:`HWB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},w:{range:[0,100],name:`Whiteness`},b:{range:[0,100],name:`Blackness`}},base:new Cn({id:`hsv`,name:`HSV`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},v:{range:[0,100],name:`Value`}},base:wi,fromBase(t){let n=Math.max(...t),r=Math.min(...t),[i,a,o]=t,[s,c,l]=[null,0,n],u=n-r;if(u!==0){switch(n){case i:s=(a-o)/u+(a<o?6:0);break;case a:s=(o-i)/u+2;break;case o:s=(i-a)/u+4}s*=60}return l&&(c=u/l),s>=360&&(s-=360),[s,c*100,l*100]},toBase(t){let[n,r,i]=t;n%=360,n<0&&(n+=360),r/=100,i/=100;function a(t){let a=(t+n/60)%6;return i-i*r*Math.max(0,Math.min(a,4-a,1))}return[a(5),a(3),a(1)]},formats:{color:{id:`--hsv`,coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),fromBase(t){let[n,r,i]=t;return[n,i*(100-r)/100,100-i]},toBase(t){let[n,r,i]=t;r/=100,i/=100;let a=r+i;if(a>=1)return[n,0,r/a*100];let o=1-i;return[n,(o===0?0:1-r/o)*100,o*100]},formats:{hwb:{coords:[`<number> | <angle>`,`<percentage> | <number>`,`<percentage> | <number>`]}}}),Li=new Cn({id:`oklch`,name:`OkLCh`,coords:{l:{refRange:[0,1],name:`Lightness`},c:{refRange:[0,.4],name:`Chroma`},h:{refRange:[0,360],type:`angle`,name:`Hue`}},white:`D65`,base:Yn,fromBase:Rn.fromBase,toBase:Rn.toBase,formats:{oklch:{coords:[`<percentage> | <number>`,`<number> | <percentage>`,`<number> | <angle>`]}}}),Ri=new Cn({id:`hsb`,name:`HSB`,coords:{h:{refRange:[0,360],type:`angle`,name:`Hue`},s:{range:[0,100],name:`Saturation`},b:{range:[0,100],name:`Brightness`}},base:wi,fromBase:t=>{let n=Math.max(...t),r=n-Math.min(...t),[i,a,o]=t,s,c;return r===0?(s=0,c=0):(c=r/n,i===n?s=(a-o)/r:a===n?s=2+(o-i)/r:o===n&&(s=4+(i-a)/r),s<0?s+=6:s>=6&&(s-=6)),[s/6*360,c*100,n*100]},toBase:zi,formats:{default:{type:`custom`,serialize:(t,n)=>{let r=zi(t),i=`rgb(${Math.round(r[0]*100*100)/100}% ${Math.round(r[1]*100*100)/100}% ${Math.round(r[2]*100*100)/100}%`;return n<1&&(i+=` / ${n}`),i+=`)`,i}},hsb:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`]},hsba:{coords:[`<number> | <angle>`,`<percentage>`,`<percentage>`],commans:!0,lastAlpha:!0}}});function zi(t){let n=t[0]/360*6,r=t[1]/100,i=t[2]/100,a=[];if(r===0)a=[i,i,i];else{let t=Math.floor(n),o=i*(1-r),s=i*(1-r*(n-t)),c=i*(1-r*(1+t-n)),l,u,d;t===1?(l=s,u=i,d=o):t===2?(l=o,u=i,d=c):t===3?(l=o,u=s,d=i):t===4?(l=c,u=o,d=i):t===5?(l=i,u=o,d=s):(l=i,u=c,d=o),a=[l,u,d]}return a}const Bi=(t,n,r,i,a,o)=>{let s=(t-n)/(r-n)*(a-i)+i;return o&&(s=Math.max(s,Math.min(i,a)),s=Math.min(s,Math.max(i,a))),s},Vi=t=>{let n=(~~(t*255)).toString(16);return n.length<2?`0`+n:n},Hi=/* @__PURE__ */ new Map;var Ui=class t{static colorMap={};static#e={};static#t={};isColor=!0;static addColorMode(n,r){Cn.register(r),t.colorMap[n]=r.id,t.#e[n]=Object.values(r.coords).reduce((t,n)=>(t.push(n.refRange||n.range),t),[]),t.#e[n].push([0,1]),t.#t[n]=r.fromGray}constructor(n,r,i,{clamp:a=!1}={}){if(this._cachedMode=r||`rgb`,n instanceof t){let i=r?t.colorMap[r]:t.colorMap[n.mode];this._initialize=()=>{this._cachedColor=_i(n._color,i),this._cachedMode=i}}else if(typeof n==`object`&&!Array.isArray(n)&&n!==null){let i=r?t.colorMap[r]:n.spaceId;this._initialize=()=>{this._cachedColor=_i(n,i),this._cachedMode=r||Object.entries(t.colorMap).find(([t,n])=>n===this._cachedColor.spaceId)}}else if(typeof n[0]==`string`)this._defaultStringValue=n[0],this._initialize=()=>{try{this._cachedColor=_n(n[0]);let[r]=Object.entries(t.colorMap).find(([t,n])=>n===this._cachedColor.spaceId);this._cachedMode=r,this._cachedColor=_i(this._cachedColor,this._cachedColor.spaceId)}catch{throw Error(`Invalid color string`)}};else{let r;if(i){if(n.length===4)r=t.mapColorRange(n,this._cachedMode,i,a);else if(n.length===3)r=t.mapColorRange([n[0],n[1],n[2]],this._cachedMode,i,a),r.push(1);else if(n.length===2){r=t.#t[this._cachedMode]?t.#t[this._cachedMode](n[0],i,a):t.mapColorRange([n[0],n[0],n[0]],this._cachedMode,i,a);let o=Array.isArray(i[i.length-1])?i[i.length-1]:[0,i[i.length-1]];r.push(Bi(n[1],o[0],o[1],0,1,a))}else if(n.length===1)r=t.#t[this._cachedMode]?t.#t[this._cachedMode](n[0],i,a):t.mapColorRange([n[0],n[0],n[0]],this._cachedMode,i,a),r.push(1);else throw Error(`Invalid color`)}else r=n;this._cachedMode===`rgb`&&(this._defaultStringValue=r[3]===1?`#`+Vi(r[0])+Vi(r[1])+Vi(r[2]):`#`+Vi(r[0])+Vi(r[1])+Vi(r[2])+Vi(r[3])),this._initialize=()=>{let n=t.colorMap[this._cachedMode]||console.error(`Invalid color mode`),i={space:n,coords:r.slice(0,3),alpha:r[3]};this._cachedColor=_i(i,n)}}}get mode(){return this._initialize&&=(this._initialize(),void 0),this._cachedMode}get _color(){return this._initialize&&=(this._initialize(),void 0),this._cachedColor}set _color(t){this._initialize&&=(this._initialize(),void 0),this._cachedColor=t}static mapColorRange(n,r,i,a){let o=i.map(t=>Array.isArray(t)?t:[0,t]),s=t.#e[r];return n.map((t,n)=>Bi(t,o[n][0],o[n][1],s[n][0],s[n][1],a))}static unmapColorRange(n,r,i){let a=i.map(t=>Array.isArray(t)?t:[0,t]),o=t.#e[r];return n.map((t,n)=>Bi(t,o[n][0],o[n][1],a[n][0],a[n][1]))}get _array(){return this._getRGBA()}array(){return this._array}lerp(n,r,i){let a=i;typeof r==`object`&&(i=r.outputMode,a=r.lerpMode,r=r.amount);let o=Ni(this._color,n._color,{space:t.colorMap[a]})(r);return new t(o,i||this.mode)}toString(t){if(t===void 0&&this._defaultStringValue!==void 0)return this._defaultStringValue;let n=t;t===`#rrggbb`&&(n=`hex`);let r=`${this._color.space.id}-${this._color.coords.join(`,`)}-${this._color.alpha}-${t}`,i=Hi.get(r);if(!i){if(i=vi(this._color,{format:n}),t===`#rrggbb`){if(i=String(i),i.length===4){let t=i[1],n=i[2],r=i[3];i=`#${t}${t}${n}${n}${r}${r}`}i.length>7&&(i=i.slice(0,7)),i=i.toLowerCase()}Hi.size>1e3&&Hi.delete(Hi.keys().next().value),Hi.set(r,i)}return i}contrast(t,n=`WCAG21`){if(n!==`all`){let r,i;switch(n){case`WCAG21`:r=Di(this._color,t._color),i=4.5;break;case`APCA`:r=Math.abs(Mi(this._color,t._color)),i=75;break;default:return null}return r>=i}{let n=Di(this._color,t._color),r=Mi(this._color,t._color);return{WCAG21:{value:n,passedMinimum:n>=4.5,passedAAA:n>=7},APCA:{value:r,passedMinimum:Math.abs(r)>=75}}}}setRed(n,r=[0,1]){this._defaultStringValue=void 0,Array.isArray(r)||(r=[0,r]);let i=t.#e.rgb[0],a=Bi(n,r[0],r[1],i[0],i[1]);if(this.mode===`rgb`||this.mode===`rgbp3`)this._color.coords[0]=a;else{let t=this._color.space.id,n=_i(this._color,`srgb`);n.coords[0]=a,this._color=_i(n,t)}}setGreen(n,r=[0,1]){this._defaultStringValue=void 0,Array.isArray(r)||(r=[0,r]);let i=t.#e.rgb[1],a=Bi(n,r[0],r[1],i[0],i[1]);if(this.mode===`rgb`||this.mode===`rgbp3`)this._color.coords[1]=a;else{let t=this._color.space.id,n=_i(this._color,`srgb`);n.coords[1]=a,this._color=_i(n,t)}}setBlue(n,r=[0,1]){this._defaultStringValue=void 0,Array.isArray(r)||(r=[0,r]);let i=t.#e.rgb[2],a=Bi(n,r[0],r[1],i[0],i[1]);if(this.mode===`rgb`||this.mode===`rgbp3`)this._color.coords[2]=a;else{let t=this._color.space.id,n=_i(this._color,`srgb`);n.coords[2]=a,this._color=_i(n,t)}}setAlpha(n,r=[0,1]){this._defaultStringValue=void 0,Array.isArray(r)||(r=[0,r]);let i=t.#e[this.mode][3],a=Bi(n,r[0],r[1],i[0],i[1]);this._color.alpha=a}_getRGBA(n=[1,1,1,1]){let r=t.#e.rgb,i=n.map(t=>Array.isArray(t)?t:[0,t]),a;return this.mode===`rgb`?a=[...this._color.coords,this._color.alpha]:(a=structuredClone(_i(this._color,`srgb`).coords),a.push(this._color.alpha)),a.map((t,n)=>Bi(t,r[n][0],r[n][1],i[n][0],i[n][1]))}_getMode(){return this.mode}_getRed(n=[0,1]){if(Array.isArray(n)||(n=[0,n]),this.mode===`rgb`||this.mode===`rgbp3`){let r=t.#e[this.mode][0];return Bi(this._color.coords[0],r[0],r[1],n[0],n[1])}{let r=t.#e.rgb[0];return Bi(_i(this._color,`srgb`).coords[0],r[0],r[1],n[0],n[1])}}_getGreen(n=[0,1]){if(Array.isArray(n)||(n=[0,n]),this.mode===`rgb`||this.mode===`rgbp3`){let r=t.#e[this.mode][1];return Bi(this._color.coords[1],r[0],r[1],n[0],n[1])}{let r=t.#e.rgb[1];return Bi(_i(this._color,`srgb`).coords[1],r[0],r[1],n[0],n[1])}}_getBlue(n=[0,1]){if(Array.isArray(n)||(n=[0,n]),this.mode===`rgb`||this.mode===`rgbp3`){let r=t.#e[this.mode][2];return Bi(this._color.coords[2],r[0],r[1],n[0],n[1])}{let r=t.#e.rgb[2];return Bi(_i(this._color,`srgb`).coords[2],r[0],r[1],n[0],n[1])}}_getAlpha(n=[0,1]){Array.isArray(n)||(n=[0,n]);let r=t.#e[this.mode][3];return Bi(this._color.alpha,r[0],r[1],n[0],n[1])}_getHue(n=[0,360]){if(Array.isArray(n)||(n=[0,n]),this.mode===`hsb`||this.mode===`hsl`){let r=t.#e[this.mode][0];return Bi(this._color.coords[0],r[0],r[1],n[0],n[1])}{let r=t.#e.hsl[0];return Bi(_i(this._color,`hsl`).coords[0],r[0],r[1],n[0],n[1])}}_getSaturation(n=[0,100]){if(Array.isArray(n)||(n=[0,n]),this.mode===`hsb`||this.mode===`hsl`){let r=t.#e[this.mode][1];return Bi(this._color.coords[1],r[0],r[1],n[0],n[1])}{let r=t.#e.hsl[1];return Bi(_i(this._color,`hsl`).coords[1],r[0],r[1],n[0],n[1])}}_getBrightness(n=[0,100]){if(Array.isArray(n)||(n=[0,n]),this.mode===`hsb`){let r=t.#e[this.mode][2];return Bi(this._color.coords[2],r[0],r[1],n[0],n[1])}{let r=t.#e.hsb[2];return Bi(_i(this._color,`hsb`).coords[2],r[0],r[1],n[0],n[1])}}_getLightness(n=[0,100]){if(Array.isArray(n)||(n=[0,n]),this.mode===`hsl`){let r=t.#e[this.mode][2];return Bi(this._color.coords[2],r[0],r[1],n[0],n[1])}{let r=t.#e.hsl[2];return Bi(_i(this._color,`hsl`).coords[2],r[0],r[1],n[0],n[1])}}};function Wi(t,n,r){t.Color=Ui,wi.fromGray=Ti.fromGray=function(t,n,r){let i=n.map(t=>Array.isArray(t)?t:[0,t]),a=Bi(t,i[2][0],i[2][1],0,1,r);return[a,a,a]},Ri.fromGray=Fi.fromGray=function(t,n,r){let i=n.map(t=>Array.isArray(t)?t:[0,t]);return[0,0,Bi(t,i[2][0],i[2][1],0,100,r)]},Ii.fromGray=function(t,n,r){let i=n.map(t=>Array.isArray(t)?t:[0,t]),a=Math.abs(i[1][0]-i[1][1])/2+Math.abs(i[2][0]-i[2][1])/2,o=Bi(t,0,a,0,100),s,c;return o<50?(c=o,s=100-o):o>=50&&(s=o,c=100-o),[0,s,c]},Fn.fromGray=Rn.fromGray=Yn.fromGray=Li.fromGray=function(t,n,r){let i=n.map(t=>Array.isArray(t)?t:[0,t]);return[Bi(t,i[0][0],i[0][1],0,100,r),0,0]},t.Color.addColorMode(`rgb`,wi),t.Color.addColorMode(Gi,Ti),t.Color.addColorMode(`hsb`,Ri),t.Color.addColorMode(`hsl`,Fi),t.Color.addColorMode(`hwb`,Ii),t.Color.addColorMode(`lab`,Fn),t.Color.addColorMode(`lch`,Rn),t.Color.addColorMode(Ki,Yn),t.Color.addColorMode(qi,Li),r.presetup=function(){let n=this,r=[`Red`,`Green`,`Blue`,`Alpha`];for(let i in r){let a=r[i],o=t.Color.prototype[`set`+a];t.Color.prototype[`set`+a]=function(t,r){return r||=n?._renderer?.states?.colorMaxes?.rgb[i],o.call(this,t,r)}}function i(r,i){let a=t.Color.prototype[`_get`+r];t.Color.prototype[`_get`+r]=function(t){if(Object.keys(i).includes(this.mode))t||=n?._renderer?.states?.colorMaxes?.[this.mode][i[this.mode]];else{let r=Object.keys(i)[0];t||=n?._renderer?.states?.colorMaxes?.[r][i[r]]}return a.call(this,t)}}i(`Red`,{rgb:0,[Gi]:0}),i(`Green`,{rgb:1,[Gi]:1}),i(`Blue`,{rgb:2,[Gi]:2}),i(`Alpha`,{rgb:3,[Gi]:3,hsb:3,hsl:3,hwb:3,lab:3,lch:3,[Ki]:3,[qi]:3}),i(`Hue`,{hsl:0,hsb:0,hwb:0,lch:2,[qi]:2}),i(`Saturation`,{hsl:1,hsb:1}),i(`Brightness`,{hsb:2}),i(`Lightness`,{hsl:2})}}typeof p5<`u`&&Wi(p5,p5.prototype);const Gi=`rgbp3`,Ki=`oklab`,qi=`oklch`,Ji=`rgba`;function Yi(t,n){n.RGB=`rgb`,n.RGBP3=Gi,n.HSB=`hsb`,n.HSL=`hsl`,n.HWB=`hwb`,n.LAB=`lab`,n.LCH=`lch`,n.OKLAB=Ki,n.OKLCH=qi,n.RGBA=Ji,t.Renderer.states.colorMode=`rgb`,t.Renderer.states.colorMaxes={rgb:[255,255,255,255],[Gi]:[255,255,255,255],hsb:[360,100,100,1],hsl:[360,100,100,1],hwb:[360,100,100,1],lab:[100,[-125,125],[-125,125],1],lch:[100,150,360,1],[Ki]:[100,[-125,125],[-125,125],1],[qi]:[100,150,360,1],clone:function(){let t={...this};for(let n in t)t[n]instanceof Array&&(t[n]=[...t[n]]);return t}},n.color=function(...t){return t[0]instanceof Ui?t[0]:new Ui(Array.isArray(t[0])?t[0]:t,this._renderer.states.colorMode,this._renderer.states.colorMaxes[this._renderer.states.colorMode],{clamp:!0})},n.red=function(t){return this.color(t)._getRed()},n.green=function(t){return this.color(t)._getGreen()},n.blue=function(t){return this.color(t)._getBlue()},n.alpha=function(t){return this.color(t)._getAlpha()},n.hue=function(t){let n=`hsl`,r=0;return this._renderer.states.colorMode===`hsb`||this._renderer.states.colorMode===`hsl`?n=this._renderer.states.colorMode:(this._renderer.states.colorMode===`lch`||this._renderer.states.colorMode===`oklch`)&&(n=this._renderer.states.colorMode,r=2),this.color(t)._getHue(this._renderer.states.colorMaxes[n][r])},n.saturation=function(t){let n=this._renderer.states.colorMode===`hsb`?`hsb`:`hsl`;return this.color(t)._getSaturation(this._renderer.states.colorMaxes[n][1])},n.brightness=function(t){return this.color(t)._getBrightness(this._renderer.states.colorMaxes.hsb[2])},n.lightness=function(t){return this.color(t)._getLightness(this._renderer.states.colorMaxes.hsl[2])},n.lerpColor=function(t,n,r){let i=this._renderer.states.colorMode,a=i,o=i;return typeof r==`object`&&(a=r.outputMode??a,o=r.lerpMode??o,r=r.amount),t.lerp(n,{amount:r,lerpMode:o,outputMode:a})},n.paletteLerp=function(t,n){let r=t[0];if(n<r[1])return this.color(r[0]);for(let r=1;r<t.length;r++){let i=t[r];if(n<i[1]){let a=t[r-1];return this.lerpColor(this.color(a[0]),this.color(i[0]),(n-a[1])/(i[1]-a[1]))}}return this.color(t[t.length-1][0])}}typeof p5<`u`&&Yi(p5,p5.prototype);var Xi=class t{constructor(t){if(t)this.DOM=t;else{let t=document.implementation.createDocument(null,`doc`);this.DOM=t.createElement(`root`)}}getParent(){return new t(this.DOM.parentElement)}getName(){return this.DOM.tagName}setName(t){let n=this.DOM.innerHTML,r=this.DOM.attributes,i=document.implementation.createDocument(null,`default`).createElement(t);i.innerHTML=n;for(let t=0;t<r.length;t++)i.setAttribute(r[t].nodeName,r[t].nodeValue);this.DOM=i}hasChildren(){return this.DOM.children.length>0}listChildren(){let t=[];for(let n=0;n<this.DOM.childNodes.length;n++)t.push(this.DOM.childNodes[n].nodeName);return t}getChildren(t){return Zi(t?this.DOM.getElementsByTagName(t):this.DOM.children)}getChild(n){if(typeof n==`string`){for(let r of this.DOM.children)if(r.tagName===n)return new t(r)}else return new t(this.DOM.children[n])}addChild(n){n instanceof t&&this.DOM.appendChild(n.DOM)}removeChild(t){let n=-1;if(typeof t==`string`){for(let r=0;r<this.DOM.children.length;r++)if(this.DOM.children[r].tagName===t){n=r;break}}else n=t;n!==-1&&this.DOM.removeChild(this.DOM.children[n])}getAttributeCount(){return this.DOM.attributes.length}listAttributes(){let t=[];for(let n of this.DOM.attributes)t.push(n.nodeName);return t}hasAttribute(t){let n={};for(let t of this.DOM.attributes)n[t.nodeName]=t.nodeValue;return!!n[t]}getNum(t,n){let r={};for(let t of this.DOM.attributes)r[t.nodeName]=t.nodeValue;return Number(r[t])||n||0}getString(t,n){let r={};for(let t of this.DOM.attributes)r[t.nodeName]=t.nodeValue;return r[t]?String(r[t]):n||null}setAttribute(t,n){this.DOM.setAttribute(t,n)}getContent(t){let n;return n=this.DOM.textContent,n=n.replace(/\s\s+/g,`,`),n||t||null}setContent(t){this.DOM.children.length||(this.DOM.textContent=t)}serialize(){return new XMLSerializer().serializeToString(this.DOM)}};function Zi(t){let n=[];for(let r=0;r<t.length;r++)n.push(new Xi(t[r]));return n}function Qi(t,n){t.XML=Xi}typeof p5<`u`&&Qi(p5,p5.prototype);var $i=class t{constructor(t){this.file=t;let n=t.type.split(`/`);this.type=n[0],this.subtype=n[1],this.name=t.name,this.size=t.size,this.data=void 0,this._isBlobUrl=!1}revoke(){this._isBlobUrl&&this.data&&(URL.revokeObjectURL(this.data),this._isBlobUrl=!1)}static _createLoader(n,r){let i=new FileReader;return i.onload=function(i){let a=new t(n);a.data=a.file.type===`application/json`?JSON.parse(i.target.result):a.file.type===`text/xml`?new Xi(new DOMParser().parseFromString(i.target.result,`text/xml`).documentElement):i.target.result,r(a)},i}static _load(n,r){if(/^text\//.test(n.type)||n.type===`application/json`)t._createLoader(n,r).readAsText(n);else if(!/^(video|audio)\//.test(n.type))t._createLoader(n,r).readAsDataURL(n);else{let i=new t(n);i.data=URL.createObjectURL(n),i._isBlobUrl=!0,r(i)}}};function ea(t,n,r){r.remove=function(){if(this._blobFiles){for(let t of this._blobFiles)t.revoke();this._blobFiles.clear()}},t.File=$i}typeof p5<`u`&&p5.registerAddon(ea);var ta=class t{width;height;elt;constructor(t,n){this.elt=t,this._pInst=this._pixelsState=n,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight}remove(){if(this.stop){this.stop();let t=this.elt.srcObject;t!==null&&t.getTracks().forEach(t=>{t.stop()})}let t=this._pInst;if(t&&!t._elements&&t._pInst&&(t=t._pInst),t&&t._elements){let n=t._elements.indexOf(this);n!==-1&&t._elements.splice(n,1)}for(let t in this._events)this.elt.removeEventListener(t,this._events[t]);this.elt&&this.elt.parentNode&&this.elt.parentNode.removeChild(this.elt)}parent(n){return n===void 0?this.elt.parentNode:(typeof n==`string`?(n[0]===`#`&&(n=n.substring(1)),n=document.getElementById(n)):n instanceof t&&(n=n.elt),n.appendChild(this.elt),this)}child(n){return n===void 0?this.elt.childNodes:(typeof n==`string`?(n[0]===`#`&&(n=n.substring(1)),n=document.getElementById(n)):n instanceof t&&(n=n.elt),n instanceof HTMLElement&&this.elt.appendChild(n),this)}html(...t){return t.length===0?this.elt.innerHTML:t[1]?(this.elt.insertAdjacentHTML(`beforeend`,t[0]),this):(this.elt.innerHTML=t[0],this)}id(t){return t===void 0?this.elt.id:(this.elt.id=t,this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight,this)}class(t){return t===void 0?this.elt.className:(this.elt.className=t,this)}addClass(t){return this.elt.className?this.hasClass(t)||(this.elt.className=this.elt.className+` `+t):this.elt.className=t,this}removeClass(t){return this.elt.classList.remove(t),this}hasClass(t){return this.elt.classList.contains(t)}toggleClass(t){return this.elt.classList.contains(t)?this.elt.classList.remove(t):this.elt.classList.add(t),this}center(t){let n=this.elt.style.display,r=this.elt.style.display===`none`,i=this.parent().style.display===`none`,a={x:this.elt.offsetLeft,y:this.elt.offsetTop};r&&this.show(),i&&this.parent().show(),this.elt.style.display=`block`,this.position(0,0);let o=Math.abs(this.parent().offsetWidth-this.elt.offsetWidth),s=Math.abs(this.parent().offsetHeight-this.elt.offsetHeight);return t===`both`||t===void 0?this.position(o/2+this.parent().offsetLeft,s/2+this.parent().offsetTop):t===`horizontal`?this.position(o/2+this.parent().offsetLeft,a.y):t===`vertical`&&this.position(a.x,s/2+this.parent().offsetTop),this.style(`display`,n),r&&this.hide(),i&&this.parent().hide(),this}position(...t){if(t.length===0)return{x:this.elt.offsetLeft,y:this.elt.offsetTop};{let n=`absolute`;return(t[2]===`static`||t[2]===`fixed`||t[2]===`relative`||t[2]===`sticky`||t[2]===`initial`||t[2]===`inherit`)&&(n=t[2]),this.elt.style.position=n,this.elt.style.left=t[0]+`px`,this.elt.style.top=t[1]+`px`,this.x=t[0],this.y=t[1],this}}show(){return this.elt.style.display=`block`,this}hide(){return this.elt.style.display=`none`,this}size(t,n){if(arguments.length===0)return{width:this.elt.offsetWidth,height:this.elt.offsetHeight};{let r=t,i=n,a=_e;if(r!==a||i!==a){if(r===a?r=n*this.width/this.height:i===a&&(i=t*this.height/this.width),this.elt instanceof HTMLCanvasElement){let t={},n=this.elt.getContext(`2d`),a;for(a in n)t[a]=n[a];for(a in this.elt.setAttribute(`width`,r*this._pInst._pixelDensity),this.elt.setAttribute(`height`,i*this._pInst._pixelDensity),this.elt.style.width=r+`px`,this.elt.style.height=i+`px`,this._pInst.scale(this._pInst._pixelDensity,this._pInst._pixelDensity),t)this.elt.getContext(`2d`)[a]=t[a]}else this.elt.style.width=r+`px`,this.elt.style.height=i+`px`,this.elt.width=r,this.elt.height=i;this.width=r,this.height=i,this._pInst&&this._pInst._curElement&&this._pInst._curElement.elt===this.elt&&(this._pInst.width=r,this._pInst.height=i)}return this}}style(t,n){let r=this;if(n instanceof Ui&&(n=n.toString()),n===void 0){if(t.indexOf(`:`)===-1)return window.getComputedStyle(r.elt).getPropertyValue(t);{let n=t.split(`;`);for(let t=0;t<n.length;t++){let r=n[t].split(`:`);r[0]&&r[1]&&(this.elt.style[r[0].trim()]=r[1].trim())}}}else if(this.elt.style[t]=n,t===`width`||t===`height`||t===`left`||t===`top`){let n=window.getComputedStyle(r.elt).getPropertyValue(t).replace(/[^\d.]/g,``);this[t]=Math.round(parseFloat(n,10))}return this}_translate(...t){this.elt.style.position=`absolute`;let n=``;return this.elt.style.transform&&(n=this.elt.style.transform.replace(/translate3d\(.*\)/g,``),n=n.replace(/translate[X-Z]?\(.*\)/g,``)),t.length===2?this.elt.style.transform=`translate(`+t[0]+`px, `+t[1]+`px)`:t.length>2&&(this.elt.style.transform=`translate3d(`+t[0]+`px,`+t[1]+`px,`+t[2]+`px)`,t.length===3?this.elt.parentElement.style.perspective=`1000px`:this.elt.parentElement.style.perspective=t[3]+`px`),this.elt.style.transform+=n,this}_rotate(...t){let n=``;return this.elt.style.transform&&(n=this.elt.style.transform.replace(/rotate3d\(.*\)/g,``),n=n.replace(/rotate[X-Z]?\(.*\)/g,``)),t.length===1?this.elt.style.transform=`rotate(`+t[0]+`deg)`:t.length===2?this.elt.style.transform=`rotate(`+t[0]+`deg, `+t[1]+`deg)`:t.length===3&&(this.elt.style.transform=`rotateX(`+t[0]+`deg)`,this.elt.style.transform+=`rotateY(`+t[1]+`deg)`,this.elt.style.transform+=`rotateZ(`+t[2]+`deg)`),this.elt.style.transform+=n,this}attribute(t,n){if(this.elt.firstChild!=null&&(this.elt.firstChild.type===`checkbox`||this.elt.firstChild.type===`radio`)){if(n===void 0)return this.elt.firstChild.getAttribute(t);for(let r=0;r<this.elt.childNodes.length;r++)this.elt.childNodes[r].setAttribute(t,n)}else if(n===void 0)return this.elt.getAttribute(t);else return this.elt.setAttribute(t,n),this}removeAttribute(t){if(this.elt.firstChild!=null&&(this.elt.firstChild.type===`checkbox`||this.elt.firstChild.type===`radio`))for(let n=0;n<this.elt.childNodes.length;n++)this.elt.childNodes[n].removeAttribute(t);return this.elt.removeAttribute(t),this}value(...t){return t.length>0?(this.elt.value=t[0],this):this.elt.type===`range`?parseFloat(this.elt.value):this.elt.value}mousePressed(n){return t._adjustListener(`pointerdown`,function(t){return this._pInst.mouseIsPressed=!0,this._pInst._activePointers.set(t.pointerId,t),this._pInst._setMouseButton(t),this._pInst._updatePointerCoords(t),n.call(this,t)},this),this}doubleClicked(n){return t._adjustListener(`dblclick`,n,this),this}mouseWheel(n){return t._adjustListener(`wheel`,n,this),this}mouseReleased(n){return t._adjustListener(`pointerup`,n,this),this}mouseClicked(n){return t._adjustListener(`click`,n,this),this}mouseMoved(n){return t._adjustListener(`pointermove`,n,this),this}mouseOver(n){return t._adjustListener(`pointerover`,n,this),this}mouseOut(n){return t._adjustListener(`pointerout`,n,this),this}dragOver(n){return t._adjustListener(`dragover`,n,this),this}dragLeave(n){return t._adjustListener(`dragleave`,n,this),this}changed(n){return t._adjustListener(`change`,n,this),this}input(n){return t._adjustListener(`input`,n,this),this}drop(n,r){if(window.File&&window.FileReader&&window.FileList&&window.Blob){if(!this._dragDisabled){this._dragDisabled=!0;let t=function(t){t.preventDefault()};this.elt.addEventListener(`dragover`,t),this.elt.addEventListener(`dragleave`,t)}let i=t=>n=>{n._isBlobUrl&&(this._pInst._blobFiles||(this._pInst._blobFiles=/* @__PURE__ */ new Set),this._pInst._blobFiles.add(n)),t(n)};t._attachListener(`drop`,function(t){t.preventDefault(),typeof r==`function`&&r.call(this,t);let a=t.dataTransfer.files;for(let t of a)$i._load(t,i(n))},this)}else console.log(`The File APIs are not fully supported in this browser.`);return this}draggable(t){let n=`ontouchstart`in window,r=0,i=0,a=0,o=0,s,c=n?`touchstart`:`mousedown`,l=n?`touchend`:`mouseup`,u=n?`touchmove`:`mousemove`;t===void 0?(t=this.elt,s=t):t!==this.elt&&t.elt!==this.elt&&(t=t.elt,s=this.elt),s.addEventListener(c,d,!1),s.style.cursor=`move`;function d(t){if(t||=window.event,n){let n=t.changedTouches;a=parseInt(n[0].clientX),o=parseInt(n[0].clientY)}else a=parseInt(t.clientX),o=parseInt(t.clientY);return document.addEventListener(l,p,!1),document.addEventListener(u,f,!1),!1}function f(s){if(s||=window.event,n){let t=s.changedTouches;r=a-parseInt(t[0].clientX),i=o-parseInt(t[0].clientY),a=parseInt(t[0].clientX),o=parseInt(t[0].clientY)}else r=a-parseInt(s.clientX),i=o-parseInt(s.clientY),a=parseInt(s.clientX),o=parseInt(s.clientY);t.style.left=t.offsetLeft-r+`px`,t.style.top=t.offsetTop-i+`px`}function p(){document.removeEventListener(l,p,!1),document.removeEventListener(u,f,!1)}return this}static _adjustListener(n,r,i){return r===!1?t._detachListener(n,i):t._attachListener(n,r,i),this}static _attachListener(n,r,i){i._events[n]&&t._detachListener(n,i);let a=r.bind(i);i.elt.addEventListener(n,a,{capture:!1,signal:i._pInst._removeSignal}),i._events[n]=a}static _detachListener(t,n){let r=n._events[t];n.elt.removeEventListener(t,r,!1),n._events[t]=null}};function na(t,n){t.Element=ta}typeof p5<`u`&&na(p5,p5.prototype);const ra={_toPixels(t){if(t instanceof ImageData)return t.data;if(t.getContext(`2d`))return t.getContext(`2d`).getImageData(0,0,t.width,t.height).data;if(t.getContext(`webgl`)){let n=t.getContext(`webgl`),r=n.drawingBufferWidth*n.drawingBufferHeight*4,i=new Uint8Array(r);return n.readPixels(0,0,t.width,t.height,n.RGBA,n.UNSIGNED_BYTE,i),i}},_getARGB(t,n){let r=n*4;return t[r+3]<<24&4278190080|t[r]<<16&16711680|t[r+1]<<8&65280|t[r+2]&255},_setPixels(t,n){let r=0;for(let i=0,a=t.length;i<a;i++)r=i*4,t[r+0]=(n[i]&16711680)>>>16,t[r+1]=(n[i]&65280)>>>8,t[r+2]=n[i]&255,t[r+3]=(n[i]&4278190080)>>>24},_toImageData(t){return t instanceof ImageData?t:t.getContext(`2d`).getImageData(0,0,t.width,t.height)},_createImageData(t,n){return ra._tmpCanvas=document.createElement(`canvas`),ra._tmpCtx=ra._tmpCanvas.getContext(`2d`),this._tmpCtx.createImageData(t,n)},apply(t,n,r){let i=t.getContext(`2d`),a=i.getImageData(0,0,t.width,t.height),o=n(a,r);o instanceof ImageData?i.putImageData(o,0,0,0,0,t.width,t.height):i.putImageData(a,0,0,0,0,t.width,t.height)},threshold(t,n=.5){let r=ra._toPixels(t),i=Math.floor(n*255);for(let t=0;t<r.length;t+=4){let n=r[t],a=r[t+1],o=r[t+2],s=.2126*n+.7152*a+.0722*o,c;c=s>=i?255:0,r[t]=r[t+1]=r[t+2]=c}},gray(t){let n=ra._toPixels(t);for(let t=0;t<n.length;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=.2126*r+.7152*i+.0722*a;n[t]=n[t+1]=n[t+2]=o}},opaque(t){let n=ra._toPixels(t);for(let t=0;t<n.length;t+=4)n[t+3]=255;return n},invert(t){let n=ra._toPixels(t);for(let t=0;t<n.length;t+=4)n[t]=255-n[t],n[t+1]=255-n[t+1],n[t+2]=255-n[t+2]},posterize(t,n=4){let r=ra._toPixels(t);if(n<2||n>255)throw Error(`Level must be greater than 2 and less than 255 for posterize`);let i=n-1;for(let t=0;t<r.length;t+=4){let a=r[t],o=r[t+1],s=r[t+2];r[t]=(a*n>>8)*255/i,r[t+1]=(o*n>>8)*255/i,r[t+2]=(s*n>>8)*255/i}},dilate(t){let n=ra._toPixels(t),r=0,i=n.length?n.length/4:0,a=new Int32Array(i),o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S;for(;r<i;)for(o=r,s=r+t.width;r<s;)c=l=ra._getARGB(n,r),f=r-1,d=r+1,p=r-t.width,m=r+t.width,f<o&&(f=r),d>=s&&(d=r),p<0&&(p=0),m>=i&&(m=r),_=ra._getARGB(n,p),g=ra._getARGB(n,f),v=ra._getARGB(n,m),h=ra._getARGB(n,d),u=77*(c>>16&255)+151*(c>>8&255)+28*(c&255),b=77*(g>>16&255)+151*(g>>8&255)+28*(g&255),y=77*(h>>16&255)+151*(h>>8&255)+28*(h&255),x=77*(_>>16&255)+151*(_>>8&255)+28*(_&255),S=77*(v>>16&255)+151*(v>>8&255)+28*(v&255),b>u&&(l=g,u=b),y>u&&(l=h,u=y),x>u&&(l=_,u=x),S>u&&(l=v,u=S),a[r++]=l;ra._setPixels(n,a)},erode(t){let n=ra._toPixels(t),r=0,i=n.length?n.length/4:0,a=new Int32Array(i),o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S;for(;r<i;)for(o=r,s=r+t.width;r<s;)c=l=ra._getARGB(n,r),f=r-1,d=r+1,p=r-t.width,m=r+t.width,f<o&&(f=r),d>=s&&(d=r),p<0&&(p=0),m>=i&&(m=r),_=ra._getARGB(n,p),g=ra._getARGB(n,f),v=ra._getARGB(n,m),h=ra._getARGB(n,d),u=77*(c>>16&255)+151*(c>>8&255)+28*(c&255),b=77*(g>>16&255)+151*(g>>8&255)+28*(g&255),y=77*(h>>16&255)+151*(h>>8&255)+28*(h&255),x=77*(_>>16&255)+151*(_>>8&255)+28*(_&255),S=77*(v>>16&255)+151*(v>>8&255)+28*(v&255),b<u&&(l=g,u=b),y<u&&(l=h,u=y),x<u&&(l=_,u=x),S<u&&(l=v,u=S),a[r++]=l;ra._setPixels(n,a)},blur(t,n){la(t,n)}};let ia,aa,oa,sa;function ca(t){let n=t*3.5|0;if(n=n<1?1:n<248?n:248,ia!==n){ia=n,aa=1+ia<<1,oa=new Int32Array(aa),sa=Array(aa);for(let t=0;t<aa;t++)sa[t]=/* @__PURE__ */ new Int32Array(256);let t,r,i,a;for(let t=1,o=n-1;t<n;t++){oa[n+t]=oa[o]=r=o*o,i=sa[n+t],a=sa[o--];for(let t=0;t<256;t++)i[t]=a[t]=r*t}t=oa[n]=n*n,i=sa[n];for(let n=0;n<256;n++)i[n]=t*n}}function la(t,n){let r=ra._toPixels(t),i=t.width,a=t.height,o=i*a,s=new Int32Array(o);for(let t=0;t<o;t++)s[t]=ra._getARGB(r,t);let c,l,u,d,f,p,m,h,g,_,v=new Int32Array(o),y=new Int32Array(o),b=new Int32Array(o),x=new Int32Array(o),S=0;ca(n);let C,w,T,E;for(w=0;w<a;w++){for(C=0;C<i;C++){if(d=u=l=f=c=0,p=C-ia,p<0)_=-p,p=0;else{if(p>=i)break;_=0}for(T=_;T<aa&&!(p>=i);T++){let t=s[p+S];E=sa[T],f+=E[(t&-16777216)>>>24],l+=E[(t&16711680)>>16],u+=E[(t&65280)>>8],d+=E[t&255],c+=oa[T],p++}m=S+C,v[m]=f/c,y[m]=l/c,b[m]=u/c,x[m]=d/c}S+=i}for(S=0,h=-ia,g=h*i,w=0;w<a;w++){for(C=0;C<i;C++){if(d=u=l=f=c=0,h<0)_=m=-h,p=C;else{if(h>=a)break;_=0,m=h,p=C+g}for(T=_;T<aa&&!(m>=a);T++)E=sa[T],f+=E[v[p]],l+=E[y[p]],u+=E[b[p]],d+=E[x[p]],c+=oa[T],m++,p+=i;s[C+S]=f/c<<24|l/c<<16|u/c<<8|d/c}S+=i,g+=i,h++}ra._setPixels(r,s)}function ua(t,n,r){let i=da(n,r)[0],a=t;if(a instanceof Blob||(a=new Blob([t])),document){let t=URL.createObjectURL(a),n=document.createElement(`a`);n.href=t,n.download=i,n.click(),URL.revokeObjectURL(t)}}function da(t,n){(!n||n===!0||n===`true`)&&(n=``),t||=`untitled`;let r=``;return t&&t.includes(`.`)&&(r=t.split(`.`).pop()),n&&r!==n&&(r=n,t=`${t}.${r}`),[t,r]}var fa=class t{constructor(t,n){this.width=t,this.height=n,this.canvas=document.createElement(`canvas`),this.canvas.width=this.width,this.canvas.height=this.height,this.drawingContext=this.canvas.getContext(`2d`),this._pixelsState=this,this._pixelDensity=1,this.gifProperties=null,this._modified=!1,this.pixels=[]}_friendlyError(t){}pixelDensity(t){return t===void 0?this._pixelDensity:(t<=0&&(t=1),this._pixelDensity=t,this.width=this.canvas.width/t,this.height=this.canvas.height/t,this)}_animateGif(t){let n=this.gifProperties,r=t._lastRealFrameTime||window.performance.now();if(n.lastChangeTime===0&&(n.lastChangeTime=r),n.playing){n.timeDisplayed=r-n.lastChangeTime;let t=n.frames[n.displayIndex].delay;if(n.timeDisplayed>=t){let i=Math.floor(n.timeDisplayed/t);if(n.timeDisplayed=0,n.lastChangeTime=r,n.displayIndex+=i,n.loopCount=Math.floor(n.displayIndex/n.numFrames),n.loopLimit!==null&&n.loopCount>=n.loopLimit)n.playing=!1;else{let t=n.displayIndex%n.numFrames;this.drawingContext.putImageData(n.frames[t].image,0,0),n.displayIndex=t,this.setModified(!0)}}}}loadPixels(){let t=this._pixelsState,n=this._pixelDensity,r=this.width*n,i=this.height*n,a=this.drawingContext.getImageData(0,0,r,i);t.imageData=a,this.pixels=t.pixels=a.data,this.setModified(!0)}updatePixels(t,n,r,i){let a=this._pixelsState,o=this._pixelDensity;t===void 0&&n===void 0&&r===void 0&&i===void 0&&(t=0,n=0,r=this.width,i=this.height),t*=o,n*=o,r*=o,i*=o,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=a.imageData),this.drawingContext.putImageData(a.imageData,t,n,0,0,r,i),this.setModified(!0)}get(n,r,i,a){let o=this._pixelsState,s=this._pixelDensity,c=this.canvas;if(n===void 0&&r===void 0)n=r=0,i=o.width,a=o.height;else if(n*=s,r*=s,i===void 0&&a===void 0)return n<0||r<0||n>=c.width||r>=c.height?[0,0,0,0]:this._getPixel(n,r);let l=new t(i*s,a*s);return l.pixelDensity(s),l.canvas.getContext(`2d`).drawImage(c,n,r,i*s,a*s,0,0,i*s,a*s),l}_getPixel(t,n){let r,i;return r=this.drawingContext.getImageData(t,n,1,1).data,i=0,[r[i+0],r[i+1],r[i+2],r[i+3]]}set(n,r,i){n=Math.floor(n),r=Math.floor(r);let a=this._pixelsState;if(i instanceof t)this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this.drawingContext.clearRect(n,r,i.width,i.height),this.drawingContext.drawImage(i.canvas,n,r),this.drawingContext.restore();else{let t=0,o=0,s=0,c=0,l=4*(r*this._pixelDensity*(this.width*this._pixelDensity)+n*this._pixelDensity);if(a.imageData||a.loadPixels(),typeof i==`number`)l<a.pixels.length&&(t=i,o=i,s=i,c=255);else if(Array.isArray(i)){if(i.length<4)throw Error(`pixel array must be of the form [R, G, B, A]`);l<a.pixels.length&&(t=i[0],o=i[1],s=i[2],c=i[3])}else i?.isColor&&l<a.pixels.length&&([t,o,s,c]=i._getRGBA([255,255,255,255]));for(let i=0;i<this._pixelDensity;i++)for(let u=0;u<this._pixelDensity;u++)l=4*((r*this._pixelDensity+u)*this.width*this._pixelDensity+(n*this._pixelDensity+i)),a.pixels[l]=t,a.pixels[l+1]=o,a.pixels[l+2]=s,a.pixels[l+3]=c}this.setModified(!0)}resize(t,n){t===0&&n===0?(t=this.width,n=this.height):t===0?t=this.width*n/this.height:n===0&&(n=this.height*t/this.width),t=Math.floor(t),n=Math.floor(n);let r=this._pixelDensity,i=Math.floor(t*r),a=Math.floor(n*r),o=document.createElement(`canvas`);if(o.width=i,o.height=a,this.gifProperties){let t=this.gifProperties,n=(t,n)=>{let r=0;for(let i=0;i<n.height;i++)for(let a=0;a<n.width;a++){let o=Math.floor(a*t.width/n.width),s=(Math.floor(i*t.height/n.height)*t.width+o)*4;n.data[r++]=t.data[s++],n.data[r++]=t.data[s++],n.data[r++]=t.data[s++],n.data[r++]=t.data[s++]}};for(let r=0;r<t.numFrames;r++){let o=this.drawingContext.createImageData(i,a);n(t.frames[r].image,o),t.frames[r].image=o}}o.getContext(`2d`).drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,i,a),this.width=t,this.height=n,this.canvas.width=i,this.canvas.height=a,this.drawingContext.drawImage(o,0,0,i,a,0,0,i,a),this.pixels.length>0&&this.loadPixels(),this.setModified(!0)}copy(...t){let n,r,i,a,o,s,c,l,u;if(t.length===9)n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8];else if(t.length===8)n=this,r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7];else throw Error(`Signature not supported`);this._copyHelper(this,n,r,i,a,o,s,c,l,u)}_copyHelper(t,n,r,i,a,o,s,c,l,u){let d=n.canvas.width/n.width,f=0,p=0;n._renderer&&n._renderer.isP3D&&(f=n.width/2,p=n.height/2),t._renderer&&t._renderer.isP3D?(t.push(),t.resetMatrix(),t.noLights(),t.blendMode(t.BLEND),t.imageMode(t.CORNER),t._renderer.image(n,r+f,i+p,a,o,s,c,l,u),t.pop()):t.drawingContext.drawImage(n.canvas,d*(r+f),d*(i+p),d*a,d*o,s,c,l,u)}mask(t){t===void 0&&(t=this);let n=this.drawingContext.globalCompositeOperation,r=this._pixelDensity,i=1;t instanceof L&&(i=t._pInst._renderer._pixelDensity);let a=[t,0,0,i*t.width,i*t.height,0,0,r*this.width,r*this.height];if(this.drawingContext.globalCompositeOperation=`destination-in`,this.gifProperties){for(let t=0;t<this.gifProperties.frames.length;t++)this.drawingContext.putImageData(this.gifProperties.frames[t].image,0,0),this.copy(...a),this.gifProperties.frames[t].image=this.drawingContext.getImageData(0,0,r*this.width,r*this.height);this.drawingContext.putImageData(this.gifProperties.frames[this.gifProperties.displayIndex].image,0,0)}else this.copy(...a);this.drawingContext.globalCompositeOperation=n,this.setModified(!0)}filter(t,n){ra.apply(this.canvas,ra[t],n),this.setModified(!0)}blend(...t){let n=this.drawingContext.globalCompositeOperation,r=t[t.length-1],i=Array.prototype.slice.call(t,0,t.length-1);this.drawingContext.globalCompositeOperation=r,this.copy(...i),this.drawingContext.globalCompositeOperation=n,this.setModified(!0)}setModified(t){this._modified=t}isModified(){return this._modified}save(t,n){if(this.gifProperties)pa(this,t);else{let r=this.canvas;n=n||da(t,n)[1]||`png`;let i;switch(n){default:i=`image/png`;break;case`webp`:i=`image/webp`;break;case`jpeg`:case`jpg`:i=`image/jpeg`}r.toBlob(r=>{ua(r,t,n)},i)}}async toBlob(){return new Promise(t=>{this.canvas.toBlob(t)})}reset(){if(this.gifProperties){let t=this.gifProperties;t.playing=!0,t.timeSinceStart=0,t.timeDisplayed=0,t.lastChangeTime=0,t.loopCount=0,t.displayIndex=0,this.drawingContext.putImageData(t.frames[0].image,0,0)}}getCurrentFrame(){if(this.gifProperties){let t=this.gifProperties;return t.displayIndex%t.numFrames}}setFrame(t){if(this.gifProperties){let n=this.gifProperties;t<n.numFrames&&t>=0?(n.timeDisplayed=0,n.lastChangeTime=0,n.displayIndex=t,this.drawingContext.putImageData(n.frames[t].image,0,0)):this._friendlyError(`Cannot set GIF to a frame number that is higher than total number of frames or below zero.`,`setFrame`)}}numFrames(){if(this.gifProperties)return this.gifProperties.numFrames}play(){this.gifProperties&&(this.gifProperties.playing=!0)}pause(){this.gifProperties&&(this.gifProperties.playing=!1)}delay(t,n){if(this.gifProperties){let r=this.gifProperties;if(n<r.numFrames&&n>=0)r.frames[n].delay=t;else for(let n of r.frames)n.delay=t}}};function pa(t,n){let r=t.gifProperties,i=r.loopLimit;i===1?i=null:i===null&&(i=0);let a=new Uint8Array(t.width*t.height*r.numFrames),o=[],s={};for(let n=0;n<r.numFrames;n++){let i=/* @__PURE__ */ new Set,a=r.frames[n].image.data,c=a.length,l=new Uint32Array(t.width*t.height);for(let t=0,n=0;t<c;t+=4,n++){let r=a[t+0],o=a[t+1],s=a[t+2],c=r<<16|o<<8|s;i.add(c),l[n]=c}let u=[...i].sort().toString();s[u]===void 0?s[u]={freq:1,frames:[n]}:(s[u].freq+=1,s[u].frames.push(n)),o.push(l)}let c=[],l=Object.keys(s).sort(function(t,n){return s[n].freq-s[t].freq}),u=l[0].split(`,`).map(t=>parseInt(t));c=c.concat(s[u].frames);let d=new Set(u);for(let t=1;t<l.length;t++){let n=l[t].split(`,`).map(t=>parseInt(t)).filter(t=>!d.has(t));if(u.length+n.length<=256){for(let t=0;t<n.length;t++)u.push(n[t]),d.add(n[t]);c=c.concat(s[l[t]].frames)}}c=new Set(c);let f={};for(let t=0;t<u.length;t++)f[u[t]]||(f[u[t]]=t);let p=1;for(;p<u.length;)p<<=1;u.length=p;let m={loop:i,palette:new Uint32Array(u)},h=new omggif.GifWriter(a,t.width,t.height,m),g={};for(let n=0;n<r.numFrames;n++){let i=!c.has(n),a=i?[]:u,s=new Uint8Array(t.width*t.height),l={},d=/* @__PURE__ */ new Set;o[n].forEach((t,r)=>{i?(l[t]===void 0&&(l[t]=a.length,a.push(t)),s[r]=l[t]):s[r]=f[t],n>0&&o[n-1][r]!==t&&d.add(t)});let p={},m=a.filter(t=>!d.has(t));if(m.length>0){let t=m[0],r=i?l[t]:f[t];if(n>0){for(let t=0;t<o[n].length;t++)o[n-1][t]===o[n][t]&&(s[t]=r);p.transparent=r,g.frameOpts.disposal=1}}if(p.delay=r.frames[n].delay/10,i){let t=1;for(;t<a.length;)t<<=1;a.length=t,p.palette=new Uint32Array(a)}n>0&&h.addFrame(0,0,t.width,t.height,g.pixelPaletteIndex,g.frameOpts),g={pixelPaletteIndex:s,frameOpts:p}}g.frameOpts.disposal=1,h.addFrame(0,0,t.width,t.height,g.pixelPaletteIndex,g.frameOpts),ua(new Blob([a.slice(0,h.end())],{type:`image/gif`}),n,`gif`)}function ma(t,n){t.Image=fa,fa.prototype._friendlyError=t._friendlyError}typeof p5<`u`&&ma(p5,p5.prototype);const ha=function(t,n){let r=Math.min(t,n.length);return Array.isArray(n)&&t!==n.length&&console.warn(`When working with two vectors of different sizes, the smaller dimension is used. In this operation, both vectors will be treated as `+r+`D vectors, and any additional values of the longer vector will be ignored.`),r},ga=function(t,n){for(;t.length>n;)t.pop()};var I=class t{values=[];static friendlyErrorsDisabled(){return!0}constructor(...n){if(n.length===0&&this._friendlyError(`Requires valid arguments.`,`p5.Vector`),typeof n[0]==`function`&&(this.isPInst=!0,this._fromRadians=n.shift(),this._toRadians=n.shift()),this.values=n,Array.isArray(n))for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=`number`||!Number.isFinite(i)){t.friendlyErrorsDisabled()||this._friendlyError(`Arguments contain non-finite numbers`,`p5.Vector`),this.values=[];break}}else this.values=[];this.isVector=!0}_friendlyError(t){}get dimensions(){return this.values.length}get x(){return this.values[0]||0}getValue(t){if(t<this.values.length)return this.values[t];this._friendlyError(`The index parameter is trying to set a value outside the bounds of the vector`,`p5.Vector.setValue`)}setValue(t,n){t<this.values.length?this.values[t]=n:this._friendlyError(`The index parameter is trying to set a value outside the bounds of the vector`,`p5.Vector.setValue`)}get y(){return this.values[1]||0}get z(){return this.values[2]||0}get w(){return this.values[3]||0}set x(t){this.values.length>0&&(this.values[0]=t)}set y(t){this.values.length>1&&(this.values[1]=t)}set z(t){this.values.length>2&&(this.values[2]=t)}set w(t){this.values.length>3&&(this.values[3]=t)}toString(){return`vector[${this.values.join(`, `)}]`}set(...n){return this.values=n[0]instanceof t?n[0].values.slice():Array.isArray(n[0])?n[0].map(t=>t||0):n.map(t=>t||0),this}copy(){return this.isPInst?new t(this._fromRadians,this._toRadians,...this.values):new t(...this.values)}add(t){let n=ha(this.dimensions,t);ga(this.values,n);for(let n=0;n<this.values.length;n++)this.values[n]+=t[n];return this}rem(t){let n=ha(this.dimensions,t);if(ga(this.values,n),Array.isArray(t))for(let n=0;n<this.values.length;n++)Math.abs(t[n])>0&&(this.values[n]=this.values[n]%t[n]);else if(Math.abs(t)>0)for(let n=0;n<this.values.length;n++)this.values[n]=this.values[n]%t;return this}sub(t){let n=ha(this.dimensions,t);ga(this.values,n);for(let n=0;n<this.values.length;n++)this.values[n]-=t[n];return this}mult(t){let n=ha(this.dimensions,t);if(ga(this.values,n),Array.isArray(t))for(let n=0;n<this.values.length;n++)this.values[n]*=t[n];else for(let n=0;n<this.values.length;n++)this.values[n]*=t;return this}div(t){let n=ha(this.dimensions,t);if(Array.isArray(t)){for(let r=0;r<n;r++)if(typeof t[r]!=`number`||t[r]===0)return this.friendlyErrorsDisabled()||console.warn(`p5.Vector.prototype.div`,`Arguments contain components that are 0`),this}else if(typeof t!=`number`||t===0)return this.friendlyErrorsDisabled()||console.warn(`p5.Vector.prototype.div`,`Arguments contain components that are 0`),this;if(ga(this.values,n),Array.isArray(t))for(let n=0;n<this.values.length;n++)this.values[n]/=t[n];else for(let n=0;n<this.values.length;n++)this.values[n]/=t;return this}mag(){let t=0;for(let n=0;n<this.values.length;n++){let r=this.values[n];t+=r*r}return Math.sqrt(t)}magSq(){let t=0;for(let n=0;n<this.values.length;n++){let r=this.values[n];t+=r*r}return t}dot(...n){let r=n;n[0]instanceof t&&(r=n[0].values);let i=ha(this.dimensions,r),a=0;for(let t=0;t<i;t++)a+=this.values[t]*r[t];return a}cross(n){let r=this.y*n.z-this.z*n.y,i=this.z*n.x-this.x*n.z,a=this.x*n.y-this.y*n.x;return this.isPInst?new t(this._fromRadians,this._toRadians,r,i,a):new t(r,i,a)}dist(t){let n=ha(this.dimensions,t.values),r=0;for(let i=0;i<n;i++){let n=this.values[i]-t.values[i];r+=n*n}return Math.sqrt(r)}normalize(){let t=this.mag();return t!==0&&this.mult(1/t),this}limit(t){let n=this.magSq();return n>t*t&&this.div(Math.sqrt(n)).mult(t),this}setMag(t){return this.normalize().mult(t)}heading(){let t=Math.atan2(this.y,this.x);return this.isPInst?this._fromRadians(t):t}setHeading(t){if(this.dimensions<2||this.values instanceof Array&&this.values.slice(2).some(t=>t!==0))return this._friendlyError(`p5.Vector.setHeading() only supports 2D vectors (z === 0). For 3D or higher-dimensional vectors, use rotate() or another appropriate method instead.`,`p5.Vector.setHeading`),this;let n=this.mag();return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this}rotate(t){let n=this.heading()+t;this.isPInst&&(n=this._toRadians(n));let r=this.mag();return this.x=Math.cos(n)*r,this.y=Math.sin(n)*r,this}angleBetween(t){if(this.magSq()*t.magSq()===0)return NaN;let n=this.cross(t),r=Math.atan2(n.mag(),this.dot(t))*Math.sign(n.z||1);return this.isPInst&&(r=this._fromRadians(r)),r}lerp(t,n){let r=ha(this.dimensions,t);ga(this.values,r);for(let r=0;r<this.values.length;r++)this.values[r]+=(t[r]-this.values[r])*n;return this}slerp(t,n){if(n===0)return this;if(n===1)return this.set(t);let r=this.mag(),i=t.mag();if(r*i===0)return this.mult(1-n).add(t.x*n,t.y*n,t.z*n),this;let a=this.cross(t),o=a.mag(),s=Math.atan2(o,this.dot(t));if(o>0)a.x/=o,a.y/=o,a.z/=o;else if(s<Math.PI*.5)return this.mult(1-n).add(t.x*n,t.y*n,t.z*n),this;else this.z===0&&t.z===0?a.set(0,0,1):this.x===0?a.set(1,0,0):a.set(this.y,-this.x,0).normalize();let c=a.cross(this),l=1-n+n*i/r,u=l*Math.cos(n*s),d=l*Math.sin(n*s);return this.x=this.x*u+c.x*d,this.y=this.y*u+c.y*d,this.z=this.z*u+c.z*d,this}reflect(n){let r=t.normalize(n);return this.sub(r.mult(2*this.dot(r)))}array(){return[this.x||0,this.y||0,this.z||0]}equals(...n){let r;r=n[0]instanceof t?n[0].values:Array.isArray(n[0])?n[0]:n;let i=ha(this.values.length,r);for(let t=0;t<i;t++)if(this.values[t]!==r[t])return!1;return!0}clampToZero(){for(let t=0;t<this.values.length;t++)this.values[t]=this._clampToZero(this.values[t]);return this}_clampToZero(t){return Math.abs((t||0)-0)<=2**-52?0:t}static fromAngle(n,r){return r===void 0&&(r=1),new t(r*Math.cos(n),r*Math.sin(n))}static fromAngles(n,r,i){i===void 0&&(i=1);let a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),c=Math.sin(n);return new t(i*c*o,-i*s,i*c*a)}static random2D(){return this.fromAngle(Math.random()*A)}static random3D(){let n=Math.random()*A,r=Math.random()*2-1,i=Math.sqrt(1-r*r),a=i*Math.cos(n),o=i*Math.sin(n);return new t(a,o,r)}static copy(t){return t.copy(t)}static add(t,n,r){return r?r.set(t):(r=t.copy(),arguments.length===3&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.add`)),r.add(n),r}static rem(n,r){if(n instanceof t&&r instanceof t){let t=n.copy();return t.rem(r),t}}static sub(t,n,r){return r?r.set(t):(r=t.copy(),arguments.length===3&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.sub`)),r.sub(n),r}static mult(t,n,r){return r?r.set(t):(r=t.copy(),arguments.length===3&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.mult`)),r.mult(n),r}static rotate(n,r,i){return arguments.length===2?i=n.copy():(i instanceof t||this._friendlyError(`The target parameter should be of type p5.Vector`,`p5.Vector.rotate`),i.set(n)),i.rotate(r),i}static div(t,n,r){return r?r.set(t):(r=t.copy(),arguments.length===3&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.div`)),r.div(n),r}static dot(t,n){return t.dot(n)}static cross(t,n){return t.cross(n)}static dist(t,n){return t.dist(n)}static lerp(t,n,r,i){return i?i.set(t):(i=t.copy(),arguments.length===4&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.lerp`)),i.lerp(n,r),i}static slerp(t,n,r,i){return i?i.set(t):(i=t.copy(),arguments.length===4&&this._friendlyError(`The target parameter is undefined, it should be of type p5.Vector`,`p5.Vector.slerp`)),i.slerp(n,r),i}static mag(t){return t.mag()}static magSq(t){return t.magSq()}static normalize(n,r){return arguments.length<2?r=n.copy():(r instanceof t||this._friendlyError(`The target parameter should be of type p5.Vector`,`p5.Vector.normalize`),r.set(n)),r.normalize()}static limit(n,r,i){return arguments.length<3?i=n.copy():(i instanceof t||this._friendlyError(`The target parameter should be of type p5.Vector`,`p5.Vector.limit`),i.set(n)),i.limit(r)}static setMag(n,r,i){return arguments.length<3?i=n.copy():(i instanceof t||this._friendlyError(`The target parameter should be of type p5.Vector`,`p5.Vector.setMag`),i.set(n)),i.setMag(r)}static heading(t){return t.heading()}static angleBetween(t,n){return t.angleBetween(n)}static reflect(n,r,i){return arguments.length<3?i=n.copy():(i instanceof t||this._friendlyError(`The target parameter should be of type p5.Vector`,`p5.Vector.reflect`),i.set(n)),i.reflect(r)}static array(t){return t.array()}static equals(n,r){let i;if(n instanceof t)i=n;else if(n instanceof Array)i=new t().set(n);else return this._friendlyError(`The v1 parameter should be of type Array or p5.Vector`,`p5.Vector.equals`),!1;return i.equals(r)}};function _a(t,n){t.Vector=I,I.prototype._friendlyError=t._friendlyError,I.prototype.friendlyErrorsDisabled=function(){return t.disableFriendlyErrors},I._friendlyError=t._friendlyError,I.friendlyErrorsDisabled=function(){return t.disableFriendlyErrors}}typeof p5<`u`&&_a(p5,p5.prototype);function va(t){let n=0;for(let r=1;r<t.length;r++)n+=t[r-1].position.dist(t[r].position);return n}var ya=class{constructor(t){Object.assign(this,t)}},ba=class t{vertices;_shape=null;_primitivesIndex=null;_contoursIndex=null;isClosing=!1;constructor(...n){if(new.target===t)throw Error(`ShapePrimitive is an abstract class: it cannot be instantiated.`);if(n.length>0)this.vertices=n;else throw Error(`At least one vertex must be passed to the constructor.`)}get vertexCount(){return this.vertices.length}get vertexCapacity(){throw Error(`Getter vertexCapacity must be implemented.`)}get _firstInterpolatedVertex(){return this.startVertex()}get canOverrideAnchor(){return!1}accept(t){throw Error(`Method accept() must be implemented.`)}addToShape(t){let n=t.at(-1);if(n.primitives.length===0)n.primitives.push(this);else{let r=t.at(-1,-1),i=r instanceof this.constructor,a=r.vertexCapacity-r.vertexCount,o,s;i&&a>0?(o=this.vertices.splice(0,a),s=this.vertices,r.vertices.push(...o),s.length>0&&n.primitives.push(this)):n.primitives.push(this)}if(this.vertices.length>0){let n=t.at(-1);this._primitivesIndex=n.primitives.length-1,this._contoursIndex=t.contours.length-1,this._shape=t}return t.at(-1,-1)}get _nextPrimitive(){return this._belongsToShape?this._shape.at(this._contoursIndex,this._primitivesIndex+1):null}get _belongsToShape(){return this._shape!==null}handlesClose(){return!1}close(t){throw Error(`Unimplemented!`)}},xa=class{#e;primitives;constructor(t=8){this.#e=t,this.primitives=[]}get kind(){let t=this.primitives.length===0,n=this.#e===8;return t&&n?7:this.#e}accept(t){for(let n of this.primitives)n.accept(t)}},Sa=class extends ba{get vertexCapacity(){return 1}accept(t){t.visitAnchor(this)}getEndVertex(){return this.vertices[0]}},Ca=class t extends ba{constructor(...n){if(super(...n),new.target===t)throw Error(`Segment is an abstract class: it cannot be instantiated.`)}get _previousPrimitive(){return this._belongsToShape?this._shape.at(this._contoursIndex,this._primitivesIndex-1):null}getStartVertex(){return this._previousPrimitive.getEndVertex()}getEndVertex(){return this.vertices[this.vertices.length-1]}},wa=class extends Ca{get vertexCapacity(){return 1}accept(t){t.visitLineSegment(this)}},Ta=class extends Ca{#e;#t;constructor(t,...n){super(...n);let r=Array.isArray(t)?t[0]:t;this.#e=r,this.#t=r}get order(){return this.#e}get vertexCapacity(){return this.#t}#n;hullLength(){return this.#n===void 0&&(this.#n=va([this.getStartVertex(),...this.vertices])),this.#n}accept(t){t.visitBezierSegment(this)}},Ea=class extends Ca{#e=1/0;_splineProperties={ends:zt,tightness:0};get vertexCapacity(){return this.#e}accept(t){t.visitSplineSegment(this)}get _comesAfterSegment(){return this._previousPrimitive instanceof Ca}get canOverrideAnchor(){return this._splineProperties.ends===Bt}get _firstInterpolatedVertex(){return this._splineProperties.ends===Bt?this._comesAfterSegment?this.vertices[1]:this.vertices[0]:this.getStartVertex()}get _chainedToSegment(){if(this._belongsToShape&&this._comesAfterSegment){let t=this._firstInterpolatedVertex.position;return this.getStartVertex().position.equals(t)}return!1}addToShape(t){let n=super.addToShape(t);if(this._splineProperties.ends=t._splineProperties.ends,this._splineProperties.tightness=t._splineProperties.tightness,this._splineProperties.ends!==Bt)return n;let r=!this._belongsToShape,i=t.at(-1,-1),a=(t,n)=>`Spline does not start where previous path segment ends:
      second spline vertex at (${t})
      expected to be at (${n}).`;if(r&&i.vertices.length===2&&i._comesAfterSegment&&!i._chainedToSegment){let t=i._firstInterpolatedVertex.position,n=i.getStartVertex().position;console.warn(a(t.array(),n.array()))}return n}getEndVertex(){return this._splineProperties.ends===zt?super.getEndVertex():this._splineProperties.ends===Bt?this.vertices.at(-2):this.getStartVertex()}getControlPoints(){let t=[];this._comesAfterSegment&&t.push(this.getStartVertex()),t.push(this.getStartVertex());for(let n of this.vertices)t.push(n);let n=this.getStartVertex();return this._splineProperties.ends===zt?(t.unshift(n),t.push(this.vertices.at(-1))):this._splineProperties.ends===Vt&&(t.unshift(this.vertices.at(-1)),t.push(n,this.vertices.at(0))),t}handlesClose(){return this._belongsToShape?this._shape.at(this._contoursIndex).primitives.length===2&&this._primitivesIndex===1:!1}close(){this._splineProperties.ends=Vt}},Da=class extends ba{get vertexCapacity(){return 1}accept(t){t.visitPoint(this)}},Oa=class extends ba{get vertexCapacity(){return 2}accept(t){t.visitLine(this)}},ka=class extends ba{get vertexCapacity(){return 3}accept(t){t.visitTriangle(this)}},Aa=class extends ba{get vertexCapacity(){return 4}accept(t){t.visitQuad(this)}},ja=class extends ba{#e;#t;#n;#r;#i;#a;#o;#s=2;constructor(t,n,r,i,a,o,s,c,l){super(t,n),this.#e=r,this.#t=i,this.#n=a,this.#r=o,this.#i=s,this.#a=c,this.#o=l}get x(){return this.#e}get y(){return this.#t}get w(){return this.#n}get h(){return this.#r}get start(){return this.#i}get stop(){return this.#a}get mode(){return this.#o}get startVertex(){return this.vertices[0]}get endVertex(){return this.vertices[1]}get vertexCapacity(){return this.#s}accept(t){t.visitArcPrimitive(this)}},Ma=class extends ba{#e;#t;#n;#r;#i=1;constructor(t,n,r,i,a){super(t),this.#e=n,this.#t=r,this.#n=i,this.#r=a}get x(){return this.#e}get y(){return this.#t}get w(){return this.#n}get h(){return this.#r}get vertexCapacity(){return this.#i}accept(t){t.visitEllipsePrimitive(this)}},Na=class extends ba{#e;#t;#n;#r;#i;#a;#o;#s;#c=1;constructor(t,n,r,i,a,o,s,c,l){super(t),this.#e=n,this.#t=r,this.#n=i,this.#r=a,this.#i=o,this.#a=s,this.#o=c,this.#s=l}get x(){return this.#e}get y(){return this.#t}get w(){return this.#n}get h(){return this.#r}get tl(){return this.#i}get tr(){return this.#a}get br(){return this.#o}get bl(){return this.#s}get vertexCapacity(){return this.#c}accept(t){t.visitRectPrimitive(this)}},Pa=class extends ba{get vertexCapacity(){return 1/0}accept(t){t.visitTriangleFan(this)}},Fa=class extends ba{get vertexCapacity(){return 1/0}accept(t){t.visitTriangleStrip(this)}},Ia=class extends ba{get vertexCapacity(){return 1/0}accept(t){t.visitQuadStrip(this)}};const La={vertex:{7:(...t)=>new Sa(...t),8:(...t)=>new wa(...t),0:(...t)=>new Da(...t),1:(...t)=>new Oa(...t),4:(...t)=>new ka(...t),[oe]:(...t)=>new Aa(...t),6:(...t)=>new Pa(...t),5:(...t)=>new Fa(...t),[se]:(...t)=>new Ia(...t)},bezierVertex:{7:(t,...n)=>new Sa(...n),8:(t,...n)=>new Ta(t,...n)},splineVertex:{7:(...t)=>new Sa(...t),8:(...t)=>new Ea(...t)}};var Ra=class{#e;#t;#n;#r=3;kind=null;contours=[];_splineProperties={tightness:0,ends:zt};userVertexProperties=null;constructor(t,n=La){this.#t=t,this.#e=t,this.#n=n;for(let t in this.#e)t!==`position`&&t!==`textureCoordinates`&&(this[t]=function(n){this.#e[t]=n})}serializeToArray(t){if(t==null)return[];if(t instanceof Number)return[t];if(t instanceof Array)return t;if(t.array instanceof Function)return t.array();throw Error(`Can't convert ${t} to array!`)}vertexToArray(t){let n=[];for(let r in this.#e){if(this.userVertexProperties&&r in this.userVertexProperties)continue;let i=t[r];n.push(...this.serializeToArray(i))}for(let r in this.userVertexProperties)r in t?n.push(...this.serializeToArray(t[r])):n.push(...Array(this.userVertexProperties[r]).fill(0));return n}hydrateValue(t,n){if(n===null)return null;if(n instanceof Number)return t.shift();if(n instanceof Array){let r=[];for(let i=0;i<n.length;i++)r.push(t.shift());return r}if(n instanceof I)return new I(t.shift(),t.shift(),t.shift());if(n instanceof Ui)return new Ui([t.shift(),t.shift(),t.shift(),t.shift()])}arrayToVertex(t){let n={},r=[...t];for(let t in this.#e){if(this.userVertexProperties&&t in this.userVertexProperties)continue;let i=this.#e[t];n[t]=this.hydrateValue(r,i)}for(let t in this.userVertexProperties){let i=this.#e[t];n[t]=this.hydrateValue(r,i)}return n}arrayScale(t,n){return t.map(t=>t*n)}arraySum(t,...n){return t.map((t,r)=>{let i=t;for(let t=0;t<n.length;t++)i+=n[t][r];return i})}arrayMinus(t,n){return t.map((t,r)=>t-n[r])}evaluateCubicBezier([t,n,r,i],a){return this.arraySum(this.arrayScale(t,(1-a)**3),this.arrayScale(n,3*(1-a)**2*a),this.arrayScale(r,3*(1-a)*a**2),this.arrayScale(i,a**3))}evaluateQuadraticBezier([t,n,r],i){return this.arraySum(this.arrayScale(t,(1-i)**2),this.arrayScale(n,2*(1-i)*i),this.arrayScale(r,i*i))}catmullRomToBezier(t,n){let r=1-n,i=[];for(let n=0;n+3<t.length;n++){let[a,o,s,c]=t.slice(n,n+4),l=this.arraySum(o,this.arrayScale(this.arrayMinus(s,a),r/6)),u=this.arraySum(s,this.arrayScale(this.arrayMinus(o,c),r/6)),d=s;i.push([l,u,d])}return i}at(t,n,r){let i,a;switch(i=this.contours.at(t),arguments.length){case 1:return i;case 2:return i.primitives.at(n);case 3:return a=i.primitives.at(n),a.vertices.at(r)}}reset(){this.#e={...this.#t},this.kind=null,this.contours=[],this.userVertexProperties=null}vertexProperty(t,n){this.userVertexProperties=this.userVertexProperties||{};let r=this.vertexPropertyKey(t),i=Array.isArray(n)?n:[n];this.userVertexProperties[r]||(this.userVertexProperties[r]=i.length),this.#e[r]=i}vertexPropertyName(t){return t.replace(/Src$/,``)}vertexPropertyKey(t){return t+`Src`}bezierOrder(...t){this.#r=t}splineProperty(t,n){this._splineProperties[t]=n}splineProperties(t){if(t)for(let n in t)this.splineProperty(n,t[n]);else return this._splineProperties}#i(t,n){return this.#e.position=t,n!==void 0&&(this.#e.textureCoordinates=n),new ya(this.#e)}#a(t,n,...r){let i=this.#n[t][n];return t===`bezierVertex`?i(this.#r,...r):i(...r)}#o(t,n,r){let i=t,a=this.at(-1).kind,o=this.#i(n,r);return this.#a(i,a,o).addToShape(this)}vertex(t,n,{isClosing:r=!1}={}){let i=this.contours,a=i[i.length-1];if(a!==void 0&&a.primitives.length>0&&a.kind===8){let o=this.#i(t,n),s=a.primitives,c=s[s.length-1];if(!r&&c instanceof wa&&!c.isClosing){c.vertices.push(o);return}let l=new wa(o);l.isClosing=r,l._primitivesIndex=s.length,l._contoursIndex=i.length-1,l._shape=this,s.push(l);return}let o=this.#o(`vertex`,t,n);o.isClosing=r}bezierVertex(t,n){this.#o(`bezierVertex`,t,n)}splineVertex(t,n){this.#o(`splineVertex`,t,n)}arcVertex(t,n){this.#o(`arcVertex`,t,n)}arcPrimitive(t,n,r,i,a,o,s){this.beginShape();let c=t+r/2,l=n+i/2,u=r/2,d=i/2;return new ja(this.#i(new I(c+u*Math.cos(a),l+d*Math.sin(a))),this.#i(new I(c+u*Math.cos(o),l+d*Math.sin(o))),t,n,r,i,a,o,s).addToShape(this),this.endShape(),this}ellipsePrimitive(t,n,r,i){return new Ma(this.#i(new I(t+r/2,n+i/2)),t,n,r,i).addToShape(this)}rectPrimitive(t,n,r,i,a,o,s,c){return new Na(this.#i(new I(t,n)),t,n,r,i,a,o,s,c).addToShape(this)}point(t,n){return new Da(this.#i(new I(t,n))).addToShape(this)}line(t,n,r,i){return new Oa(this.#i(new I(t,n)),this.#i(new I(r,i))).addToShape(this)}triangle(t,n,r,i,a,o){return new ka(this.#i(new I(t,n)),this.#i(new I(r,i)),this.#i(new I(a,o))).addToShape(this)}quad(t,n,r,i,a,o,s,c){return new Aa(this.#i(new I(t,n)),this.#i(new I(r,i)),this.#i(new I(a,o)),this.#i(new I(s,c))).addToShape(this)}beginContour(t=8){this.at(-1)?.kind===7&&this.contours.pop(),this.contours.push(new xa(t))}endContour(t=ue,n=this.contours.length-1){let r=this.at(n);if(t===`close`){let t=r.kind===8,i=this.at(n,0,0),a=Object.hasOwn(i,`position`),o=this.at(n,-1);if(t&&a){if(o.handlesClose())o.close(i);else{let t=this.contours.splice(n+1,this.contours.length-n-1),r=this.#e;this.#e={...r};for(let t in i)t!==`position`&&t!==`textureCoordinates`&&(this.#e[t]=i[t]);this.vertex(i.position,i.textureCoordinates,{isClosing:!0}),this.#e=r,this.contours.push(...t)}}}}beginShape(t=8){this.kind=t,this.beginContour(t)}endShape(t=ue){t===`close`&&this.endContour(t,0)}accept(t){for(let n of this.contours)n.accept(t)}},za=class t{constructor(){if(new.target===t)throw Error(`PrimitiveVisitor is an abstract class: it cannot be instantiated.`)}visitAnchor(t){throw Error(`Method visitAnchor() has not been implemented.`)}visitLineSegment(t){throw Error(`Method visitLineSegment() has not been implemented.`)}visitBezierSegment(t){throw Error(`Method visitBezierSegment() has not been implemented.`)}visitSplineSegment(t){throw Error(`Method visitSplineSegment() has not been implemented.`)}visitArcSegment(t){throw Error(`Method visitArcSegment() has not been implemented.`)}visitArcPrimitive(t){throw Error(`Method visitArcPrimitive() has not been implemented.`)}visitEllipsePrimitive(t){throw Error(`Method visitEllipsePrimitive() has not been implemented.`)}visitRectPrimitive(t){throw Error(`Method visitRectPrimitive() has not been implemented.`)}visitPoint(t){throw Error(`Method visitPoint() has not been implemented.`)}visitLine(t){throw Error(`Method visitLine() has not been implemented.`)}visitTriangle(t){throw Error(`Method visitTriangle() has not been implemented.`)}visitQuad(t){throw Error(`Method visitQuad() has not been implemented.`)}visitTriangleFan(t){throw Error(`Method visitTriangleFan() has not been implemented.`)}visitTriangleStrip(t){throw Error(`Method visitTriangleStrip() has not been implemented.`)}visitQuadStrip(t){throw Error(`Method visitQuadStrip() has not been implemented.`)}},Ba=class extends za{path=new Path2D;strokePath=null;fillPath=null;strokeWeight;hasFill;hasStroke;constructor({strokeWeight:t,hasFill:n=!0,hasStroke:r=!0}){super(),this.strokeWeight=t,this.hasFill=n,this.hasStroke=r}visitAnchor(t){let n=t.getEndVertex();this.path.moveTo(n.position.x,n.position.y)}visitLineSegment(t){if(t.isClosing)this.path.closePath();else{let n=t.vertices;for(let t=0;t<n.length;t++){let r=n[t].position;this.path.lineTo(r.x,r.y)}}}visitBezierSegment(t){let[n,r,i]=t.vertices;switch(t.order){case 2:this.path.quadraticCurveTo(n.position.x,n.position.y,r.position.x,r.position.y);break;case 3:this.path.bezierCurveTo(n.position.x,n.position.y,r.position.x,r.position.y,i.position.x,i.position.y)}}visitSplineSegment(t){let n=t._shape;if(t._splineProperties.ends===Bt&&!t._comesAfterSegment){let n=t._firstInterpolatedVertex;this.path.moveTo(n.position.x,n.position.y)}let r=t.getControlPoints().map(t=>n.vertexToArray(t)),i=n.catmullRomToBezier(r,t._splineProperties.tightness).map(t=>t.map(t=>n.arrayToVertex(t)));for(let t of i){let n=t.flatMap(t=>[t.position.x,t.position.y]);this.path.bezierCurveTo(...n)}}visitPoint(t){let{x:n,y:r}=t.vertices[0].position;this.path.moveTo(n,r),this.path.lineTo(n+Math.max(1e-5,Math.abs(n)*1e-6),r)}visitLine(t){let{x:n,y:r}=t.vertices[0].position,{x:i,y:a}=t.vertices[1].position;this.path.moveTo(n,r),this.path.lineTo(i,a)}visitTriangle(t){let[n,r,i]=t.vertices;this.path.moveTo(n.position.x,n.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}visitQuad(t){let[n,r,i,a]=t.vertices;this.path.moveTo(n.position.x,n.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(a.position.x,a.position.y),this.path.closePath()}visitTriangleFan(t){let[n,...r]=t.vertices;for(let t=0;t<r.length-1;t++){let i=r[t],a=r[t+1];this.path.moveTo(n.position.x,n.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(a.position.x,a.position.y),this.path.closePath()}}visitTriangleStrip(t){for(let n=0;n<t.vertices.length-2;n++){let r=t.vertices[n],i=t.vertices[n+1],a=t.vertices[n+2];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(a.position.x,a.position.y),this.path.closePath()}}visitArcPrimitive(t){let n=t.x+t.w/2,r=t.y+t.h/2,i=t.w/2,a=t.h/2,o=n+i*Math.cos(t.start),s=r+a*Math.sin(t.start),c=t.stop-t.start,l=Math.abs(c%(2*Math.PI))<1e-5&&Math.abs(c)>1e-5,u=!(t.mode===`chord`||t.mode===`open`||l);this.hasFill&&(this.fillPath||=new Path2D(this.path),this.fillPath.moveTo(o,s),this.fillPath.ellipse(n,r,i,a,0,t.start,t.stop),u&&this.fillPath.lineTo(n,r),this.fillPath.closePath()),this.hasStroke&&(this.strokePath||=new Path2D(this.path),this.strokePath.moveTo(o,s),this.strokePath.ellipse(n,r,i,a,0,t.start,t.stop),t.mode===`pie`&&u&&this.strokePath.lineTo(n,r),(t.mode===`pie`||t.mode===`chord`)&&this.strokePath.closePath()),this.path.moveTo(o,s),this.path.ellipse(n,r,i,a,0,t.start,t.stop)}visitEllipsePrimitive(t){let n=t.x+t.w/2,r=t.y+t.h/2,i=t.w/2,a=t.h/2;this.path.moveTo(n+i,r),this.path.ellipse(n,r,i,a,0,0,2*Math.PI)}visitRectPrimitive(t){let n=t.x,r=t.y,i=t.w,a=t.h,o=t.tl,s=t.tr,c=t.br,l=t.bl;if(o===void 0)this.path.rect(n,r,i,a);else{s===void 0&&(s=o),c===void 0&&(c=s),l===void 0&&(l=c);let t=Math.abs(i),u=Math.abs(a),d=t/2,f=u/2;t<2*o&&(o=d),u<2*o&&(o=f),t<2*s&&(s=d),u<2*s&&(s=f),t<2*c&&(c=d),u<2*c&&(c=f),t<2*l&&(l=d),u<2*l&&(l=f),this.path.roundRect(n,r,i,a,[o,s,c,l])}}visitQuadStrip(t){for(let n=0;n<t.vertices.length-3;n+=2){let r=t.vertices[n],i=t.vertices[n+1],a=t.vertices[n+2],o=t.vertices[n+3];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.lineTo(o.position.x,o.position.y),this.path.lineTo(a.position.x,a.position.y),this.path.closePath()}}},Va=class extends za{contours=[];curveDetail;pointsToLines;constructor({curveDetail:t=1,pointsToLines:n=!0}={}){super(),this.curveDetail=t,this.pointsToLines=n}lastContour(){return this.contours[this.contours.length-1]}visitAnchor(t){this.contours.push([]);let n=t._nextPrimitive;n?.canOverrideAnchor?this.lastContour().push(n._firstInterpolatedVertex):this.lastContour().push(t.getEndVertex())}visitLineSegment(t){let n=this.lastContour(),r=t.vertices;for(let t=0;t<r.length;t++)n.push(r[t])}visitBezierSegment(t){let n=this.lastContour(),r=Math.max(1,Math.ceil(t.hullLength()*this.curveDetail)),i=[t.getStartVertex(),...t.vertices].map(n=>t._shape.vertexToArray(n));for(let a=0;a<r;a++){let o=(a+1)/r;n.push(t._shape.arrayToVertex(t.order===3?t._shape.evaluateCubicBezier(i,o):t._shape.evaluateQuadraticBezier(i,o)))}}visitSplineSegment(t){let n=t._shape,r=this.lastContour(),i=t.getControlPoints().map(t=>n.vertexToArray(t)),a=n.catmullRomToBezier(i,t._splineProperties.tightness),o=n.vertexToArray(t._firstInterpolatedVertex);for(let t of a){let i=[o,...t],a=Math.max(1,Math.ceil(va(i.map(t=>n.arrayToVertex(t)))*this.curveDetail));for(let t=0;t<a;t++){let o=(t+1)/a;r.push(n.arrayToVertex(n.evaluateCubicBezier(i,o)))}o=t[2]}}visitPoint(t){this.pointsToLines?this.contours.push(...t.vertices.map(t=>[t,t])):this.contours.push(t.vertices.slice())}visitLine(t){this.contours.push(t.vertices.slice())}visitTriangle(t){this.contours.push(t.vertices.slice())}visitQuad(t){this.contours.push(t.vertices.slice())}visitTriangleFan(t){this.contours.push(t.vertices.slice())}visitTriangleStrip(t){this.contours.push(t.vertices.slice())}visitQuadStrip(t){this.contours.push(t.vertices.slice())}visitArcPrimitive(t){let n=t.startVertex,r=t.endVertex,i=t.x+t.w/2,a=t.y+t.h/2,o=t.w/2,s=t.h/2,c=(o+s)/2*Math.abs(t.stop-t.start),l=Math.max(3,Math.ceil(this.curveDetail*c)),u=[],d=(t,n,r)=>{let i={};for(let[a,o]of Object.entries(t))a!==`position`&&(i[a]=typeof o==`number`&&typeof n[a]==`number`?o*(1-r)+n[a]*r:o);return i};if(t.mode===`pie`){let t=d(n,r,.5);t.position=new I(i,a),u.push(new ya(t))}for(let c=0;c<=l;c++){let f=c/l,p=t.start+(t.stop-t.start)*f,m=d(n,r,f);m.position=new I(i+o*Math.cos(p),a+s*Math.sin(p)),u.push(new ya(m))}this.contours.push(u)}visitEllipsePrimitive(t){let n=t.x+t.w/2,r=t.y+t.h/2,i=t.w/2,a=t.h/2,o=(i+a)/2,s=2*Math.PI*o,c=Math.max(3,Math.ceil(this.curveDetail*s)),l=[],u=t.vertices[0];for(let t=0;t<=c;t++){let o=2*Math.PI*t/c,s={};for(let[t,n]of Object.entries(u))t!==`position`&&(s[t]=n);s.position=new I(n+i*Math.cos(o),r+a*Math.sin(o)),l.push(new ya(s))}this.contours.push(l)}visitRectPrimitive(t){let n=t.x,r=t.y,i=t.w,a=t.h,o=t.tl,s=t.tr,c=t.br,l=t.bl,u=t.vertices[0],d=(t,n)=>{let r={};for(let[t,n]of Object.entries(u))t!==`position`&&(r[t]=n);return r.position=new I(t,n),new ya(r)},f=[];if(o===void 0)f.push(d(n,r)),f.push(d(n+i,r)),f.push(d(n+i,r+a)),f.push(d(n,r+a)),f.push(d(n,r));else{s===void 0&&(s=o),c===void 0&&(c=s),l===void 0&&(l=c);let t=Math.abs(i),u=Math.abs(a),p=t/2,m=u/2;t<2*o&&(o=p),u<2*o&&(o=m),t<2*s&&(s=p),u<2*s&&(s=m),t<2*c&&(c=p),u<2*c&&(c=m),t<2*l&&(l=p),u<2*l&&(l=m);let h=(t,n,r,i,a,o)=>{let s=Math.PI/2*(r+i)/2,c=Math.max(1,Math.ceil(this.curveDetail*s));for(let s=0;s<=c;s++){let l=a+(o-a)*(s/c);f.push(d(t+r*Math.cos(l),n+i*Math.sin(l)))}};h(n+o,r+o,o,o,Math.PI,1.5*Math.PI),h(n+i-s,r+s,s,s,1.5*Math.PI,2*Math.PI),h(n+i-c,r+a-c,c,c,0,.5*Math.PI),h(n+l,r+a-l,l,l,.5*Math.PI,Math.PI),f.push(f[0])}this.contours.push(f)}},Ha=class extends za{constructor(){super()}};function Ua(t,n){t.Shape=Ra,t.Contour=xa,t.ShapePrimitive=ba,t.Vertex=ya,t.Anchor=Sa,t.Segment=Ca,t.LineSegment=wa,t.BezierSegment=Ta,t.SplineSegment=Ea,t.Point=Da,t.Line=Oa,t.Triangle=ka,t.Quad=Aa,t.TriangleFan=Pa,t.TriangleStrip=Fa,t.QuadStrip=Ia,t.PrimitiveVisitor=za,t.PrimitiveToPath2DConverter=Ba,t.PrimitiveToVerticesConverter=Va,t.PointAtLengthGetter=Ha,n.bezierOrder=function(n){return!t.disableFriendlyErrors&&n!==void 0&&n!==2&&n!==3&&t._friendlyError(`bezierOrder() expects an order of 2 or 3, but received ${n}.`,`bezierOrder`),this._renderer.bezierOrder(n)},n.splineVertex=function(...t){let n=0,r=0,i=0,a=0,o=0;t.length===2?[n,r]=t:t.length===4?[n,r,a,o]=t:t.length===3?[n,r,i]=t:t.length===5&&([n,r,i,a,o]=t),this._renderer.splineVertex(n,r,i,a,o)},n.splineProperty=function(t,n){return this._renderer.splineProperty(t,n)},n.splineProperties=function(t){return this._renderer.splineProperties(t)},n.vertex=function(t,n){let r,i,a;r=i=a=0,arguments.length===3?r=arguments[2]:arguments.length===4?(i=arguments[2],a=arguments[3]):arguments.length===5&&(r=arguments[2],i=arguments[3],a=arguments[4]),this._renderer.vertex(t,n,r,i,a)},n.beginContour=function(t){this._renderer.beginContour(t)},n.endContour=function(t=ue){this._renderer.endContour(t)}}typeof p5<`u`&&Ua(p5,p5.prototype);var Wa=class{#e={};constructor(t){for(let n in t)this[n]=t[n]}setValue(t,n){t in this.#e||(this.#e[t]=this[t]),this[t]=n}takeDiff(){let t=this.#e;return this.#e={},t}getModified(){return this.#e}applyDiff(t){for(let t in this.#e)this[t]=this.#e[t];this.#e=t}},Ga=class t{constructor(t={}){for(let n in t)this[n]=t[n]}clone(){return new t(this)}},L=class t{static states={strokeColor:null,strokeSet:!1,fillColor:null,fillSet:!1,tint:null,imageMode:ee,rectMode:ee,ellipseMode:ie,strokeWeight:1,bezierOrder:3,splineProperties:new Ga({ends:zt,tightness:0}),textFont:{family:`sans-serif`},textLeading:15,leadingSet:!1,textSize:12,textAlign:re,textBaseline:ae,textWrap:rt,fontStyle:Qe,fontStretch:Qe,fontWeight:Qe,lineHeight:Qe,fontVariant:Qe,direction:`inherit`};constructor(n,r,i,a){this._pInst=n,this._isMainCanvas=a,this.pixels=[];let o=typeof window<`u`?Math.ceil(window.devicePixelRatio):1;if(a)this._pixelDensity=o;else{let t=n._pInst?._renderer?._pixelDensity;this._pixelDensity=t||o}this.width=r,this.height=i,this._events={},a&&(this._isMainCanvas=!0),this.states=new Wa(t.states),this.states.strokeColor=new Ui([0,0,0]),this.states.fillColor=new Ui([1,1,1]),this._pushPopStack=[],this._pushPopDepth=0,this._clipping=!1,this._clipInvert=!1,this._currentShape=void 0,this._supportsIndividualTextureCoordinates=void 0,this.rendererType=`p2d`,this._pInst.rendererType=this.rendererType}get currentShape(){return this._currentShape||=new Ra(this.getCommonVertexProperties()),this._currentShape}remove(){}pixelDensity(t){let n;return typeof t==`number`?(t!==this._pixelDensity&&(this._pixelDensity=t),n=this,this.resize(this.width,this.height)):n=this._pixelDensity,n}push(){this._pushPopDepth++,this._pushPopStack.push(this.states.takeDiff())}pop(){this._pushPopDepth--;let t=this._pushPopStack.pop()||{},n=this.states.getModified();this.states.applyDiff(t),this.updateShapeVertexProperties(n),this.updateShapeProperties(n)}bezierOrder(t){if(t===void 0)return this.states.bezierOrder;this.states.setValue(`bezierOrder`,t),this.updateShapeProperties()}_individualTextureCoordinates(t,n){return this._supportsIndividualTextureCoordinates===void 0&&(this._supportsIndividualTextureCoordinates=this.getSupportedIndividualVertexProperties().textureCoordinates),this._supportsIndividualTextureCoordinates?new I(t,n):void 0}bezierVertex(t,n,r=0,i=0,a=0){let o=new I(t,n,r),s=this._individualTextureCoordinates(i,a);this.currentShape.bezierVertex(o,s)}splineProperty(t,n){if(n===void 0)return this.states.splineProperties[t];this.states.setValue(`splineProperties`,this.states.splineProperties.clone()),this.states.splineProperties[t]=n,this.updateShapeProperties()}splineProperties(t){if(t)for(let n in t)this.splineProperty(n,t[n]);else return{...this.states.splineProperties}}splineVertex(t,n,r=0,i=0,a=0){let o=new I(t,n,r),s=this._individualTextureCoordinates(i,a);this.currentShape.splineVertex(o,s)}curveDetail(t){if(t===void 0)return this.states.curveDetail;this.states.setValue(`curveDetail`,t)}beginShape(...t){this.currentShape.reset(),this.updateShapeVertexProperties(),this.currentShape.beginShape(...t)}endShape(...t){this.currentShape.endShape(...t),this.drawShape(this.currentShape)}beginContour(t){this.currentShape.beginContour(t)}endContour(t){this.currentShape.endContour(t)}drawShape(t,n){throw Error(`Unimplemented`)}vertex(t,n,r=0,i=0,a=0){let o=new I(t,n,r),s=this._individualTextureCoordinates(i,a);this.currentShape.vertex(o,s)}bezier(t,n,r,i,a,o,s,c){let l=this._pInst.bezierOrder();return this._pInst.bezierOrder(l),this._pInst.beginShape(),this._pInst.bezierVertex(t,n),this._pInst.bezierVertex(r,i),this._pInst.bezierVertex(a,o),this._pInst.bezierVertex(s,c),this._pInst.endShape(),this}spline(...t){if(t.length===8){let[n,r,i,a,o,s,c,l]=t;this._pInst.beginShape(),this._pInst.splineVertex(n,r),this._pInst.splineVertex(i,a),this._pInst.splineVertex(o,s),this._pInst.splineVertex(c,l),this._pInst.endShape()}else if(t.length===12){let[n,r,i,a,o,s,c,l,u,d,f,p]=t;this._pInst.beginShape(),this._pInst.splineVertex(n,r,i),this._pInst.splineVertex(a,o,s),this._pInst.splineVertex(c,l,u),this._pInst.splineVertex(d,f,p),this._pInst.endShape()}return this}beginClip(t={}){if(this._clipping)throw Error(`It looks like you're trying to clip while already in the middle of clipping. Did you forget to endClip()?`);this._clipping=!0,this._clipInvert=t.invert}endClip(){if(!this._clipping)throw Error(`It looks like you've called endClip() without beginClip(). Did you forget to call beginClip() first?`);this._clipping=!1}resize(t,n){this.width=t,this.height=n}get(t,n,r,i){let a=this._pixelDensity,o=this.canvas;if(t===void 0&&n===void 0)t=n=0,r=this.width,i=this.height;else if(t*=a,n*=a,r===void 0&&i===void 0)return t<0||n<0||t>=o.width||n>=o.height?[0,0,0,0]:this._getPixel(t,n);let s=new fa(r*a,i*a);return s.pixelDensity(a),s.canvas.getContext(`2d`).drawImage(o,t,n,r*a,i*a,0,0,r*a,i*a),s}scale(t,n){}fill(...t){return t.length>0&&(this.states.setValue(`fillSet`,!0),this.states.setValue(`fillColor`,this._pInst.color(...t)),this.updateShapeVertexProperties()),this.states.fillColor}noFill(){this.states.setValue(`fillColor`,null)}strokeWeight(t){if(t===void 0)return this.states.strokeWeight;this.states.setValue(`strokeWeight`,t)}stroke(...t){if(t.length===0)return this.states.strokeColor;this.states.setValue(`strokeSet`,!0),this.states.setValue(`strokeColor`,this._pInst.color(...t)),this.updateShapeVertexProperties()}noStroke(){this.states.setValue(`strokeColor`,null)}getCommonVertexProperties(){return{}}getSupportedIndividualVertexProperties(){return{textureCoordinates:!1}}updateShapeProperties(t){if(!t||t.bezierOrder||t.splineProperties){let t=this.currentShape;t.bezierOrder(this.states.bezierOrder),t.splineProperty(`ends`,this.states.splineProperties.ends),t.splineProperty(`tightness`,this.states.splineProperties.tightness)}}updateShapeVertexProperties(t){let n=this.getCommonVertexProperties();if(!t||Object.keys(t).some(t=>t in n)){let t=this.currentShape;for(let r in n)t[r](n[r])}}_applyDefaults(){return this}finishDraw(){}_middleAlignOffset=function(){let{textFont:t,textSize:n}=this.states,r=t?.font,i=this.textDrawingContext().measureText(`X`),a=(r?.data||{})[`OS/2`]?.sCapHeight;if(a){let t=r.data.head.unitsPerEm;a*=n/t}else a=i.fontBoundingBoxAscent;return i.alphabeticBaseline+a/2}};function Ka(t,n){t.Renderer=L}var qa=class t{static bucket=[];static patterns=/* @__PURE__ */ new Map([[`zero`,t=>parseFloat(t)===0],[`one`,t=>parseFloat(t)===1],[`*`,()=>!0]]);static addTranslations(n,r){let i=/\$\{(.+?)\}/gm;for(let[a,o]of Object.entries(r)){let r=/* @__PURE__ */ new Map;if(typeof o==`string`){let n=o.split(i),a=[],s=[];for(let t=0;t<n.length;t++)t%2==0?a.push(n[t]):s.push(n[t]);r.set(t.patterns.get(`*`),{strings:a,placeholders:s})}else for(let[n,a]of Object.entries(o)){let o=n.split(`_`)[1],s=/\[(.+?)\]/.exec(o)?.[1],c=/\((.+?)\)/.exec(o)?.[1],l=a.split(i),u=[],d=[];for(let t=0;t<l.length;t++)t%2==0?u.push(l[t]):d.push(l[t]);r.set(t.patterns.get(s)||(c?t=>t.toString()===c:()=>!0),{strings:u,placeholders:d})}t.bucket.push({lang:Intl.getCanonicalLocales(Array.isArray(n)?n:[n]),label:a,pattern:new Ja(r)})}}static tl(n,...r){return new t(Array.from(n),r)}strings;values;constructor(t,n){this.strings=t,this.values=n}toString(n){n&&=Intl.getCanonicalLocales(Array.isArray(n)?n:[n]);let r=t.bucket.find(t=>t.pattern.isMatch(this.strings));if(!r){let r=``;for(let i=0;i<this.strings.length;i++)r+=this.strings[i],this.values[i]&&(r+=this.values[i]instanceof t?this.values[i].toString(n):this.values[i]);return r}let i;i=n?n.reduce((n,i)=>(n||=t.bucket.find(t=>t.label===r.label&&t.lang.includes(i)),n),null):t.bucket.find(t=>t.label===r.label&&t.lang.filter(t=>r.lang.includes(t)).length>0),i||=r;let{strings:a,placeholders:o}=i.pattern.match(this.values[0]),{placeholders:s}=r.pattern.match(this.values[0]),c=this.values.reduce((t,n,r)=>(s[r]&&(t[s[r]]=n),t),{}),l=``;for(let n=0;n<a.length;n++){l+=a[n];let r=c[o[n]];r!==void 0&&(l+=r instanceof t?r.toString(i.lang):r)}return l}setValues(){}},Ja=class{patterns;constructor(t){this.patterns=t}match(t){for(let[n,r]of this.patterns.entries())if(n(t))return r}isMatch(t){for(let{strings:n}of this.patterns.values())if(t.join(`---`)===n.join(`---`))return!0;return!1}};qa.addTranslations([`en`,`en-US`,`en-GB`],{tkkbbojj0n:`Sorry, Could not set the attributes, you need to call setAttributes() before calling the other drawing methods in setup()`,wji0jlntb6:"Error during parsing: ${error.message}","6eru983h1s":`Sorry, the file type is invalid. Only OBJ and STL files are supported.`,wuo7dk4fkf:"It looks like you've called ${functionName} outside of a shader's modify() function.",ecbfo4yfrl:`It looks like you've called getTexture outside of a shader's modify() function.`,btvs56mkpo:"It looks like you've called noise() with ${args.length} arguments. It only supports 1D to 3D input.",pzoz7wj542:"It looks like you've called random() with ${args.length} arguments. In strands, random() supports 0, 1, or 2 numeric arguments.",lgfuy6eb2r:"It looks like you've called ${typeInfo.fnName} outside of a shader's modify() function.","4lplbdw1xp":`file`,dl8q3ezp00:`JSON file`,"99dup7cw27":`text file`,vzls8t7bw4:"It looks like there was a problem loading your ${errorFileType}. Try checking if the file path (${path}) is correct, hosting the file online, or running a local server.\n\n+ More info: ${infoURL}","5cz1brq3ke":`There was some trouble loading your GIF. Make sure that your GIF is using 87a or 89a encoding.`,"1kv37lrbjy":`🌸 p5.js says: `,ordinal1:`first`,ordinal2:`second`,ordinal3:`third`,ordinal4:`fourth`,ordinal5:`fifth`,ordinal6:`sixth`,ordinal7:`seventh`,ordinal8:`eighth`,ordinal9:`ninth`,ordinal10:`tenth`,typeString:`string`,typeBoolean:`boolean`,typeNumber:`number`,typeFunction:`function`,"54cbftewi2":"${message} (https://p5js.org/reference/${referenceSection}.${funcName})",rnwntgqpx8:"${message} (https://p5js.org/reference/${referenceSection}/${funcName})",jya7nlorb5:`The preload() function has been removed in p5.js 2.0. Please load assets in setup() using async / await keywords or callbacks instead. See https://github.com/processing/p5.js-compatibility for more information about 2.0 and compatibility, or https://dev.to/limzykenneth/asynchronous-p5js-20-458f for more information about promises and async/await.`,qj9oojqr1i:"It seems that you may have accidentally written ${prop} instead of ${fxns[lowercase]}. Please correct it if it's not intentional.","0t1z3tmmr8":'${locationObj\n	? FES.log`[${locationObj.file}, line ${locationObj.line}]`\n	: \'\'} It seems that you may have accidentally written "${errSym}" instead of "${matchedSymbols[0].name}". Please correct it to ${matchedSymbols[0].name} if you wish to use the ${matchedSymbols[0].type} from p5.js.',ita6bv1dd3:"[${locationObj.file}, line ${locationObj.line}]","2xeoxf2b68":"${locationObj\n	? FES.log`[${locationObj.file}, line ${locationObj.line}]`\n	: ''} It seems that you may have accidentally written \"${errSym}\".\\nYou may have meant one of the following: \\n${suggestions}",mfljpzrw6p:"Did you just try to use p5.js's ${symbolName} ${symbol.type}? If so, you may want to move it into your sketch's setup() function.\\n\\nFor more details, see: ${FAQ_URL}",aorhrzsojk:"Syntax Error - Found a symbol that JavaScript doesn't recognize or didn't expect at its place.\\n\\n+ More info: ${url}",xrwjb1a7yc:"Syntax Error - Symbol present at a place that wasn't expected.\\nUsually this is due to a typo. Check the line number in the error for anything missing/extra.\\n\\n+ More info: ${url}",redeclare:'Syntax Error - "${errSym}" is being redeclared. JavaScript doesn\'t allow declaring a variable more than once. Check the line number in error for redeclaration of the variable.\\n\\n+ More info: ${url}',"6tfheg3s15":"Syntax Error - A const variable is declared but not initialized. In JavaScript, an initializer for a const is required. A value must be specified in the same statement in which the variable is declared. Check the line number in the error and assign the const variable a value.\\n\\n+ More info: ${url}",ywpv6fodj4:"Syntax Error - return lies outside of a function. Make sure you’re not missing any brackets, so that return lies inside a function.\\n\\n+ More info: ${url}",a694k1m6nn:"at the ${ordinals[position]} parameter","00gwqo2yxt":", but received ${actualType}",jfjwdczlfk:"Expected ${expectedTypeStr} ${positionStr}${actualTypeStr}","1roh3zggwt":"Did you mean to put \\`await\\` before a loading function? An unexpected Promise was found. ",ltzhpuu4r8:"${message}${buildTypeMismatchMessage(actualType, expectedTypesStr, position)} in ${func + '()'}.",referenceLink:"For more information, see ${documentationLink}.",paramTooFew:{"${minArgs}_[one]":"Expected at least ${minArgs} argument, but received fewer in ${func}(). ${referenceLink}","${minArgs}_[*]":"Expected at least ${minArgs} arguments, but received fewer in ${func}(). ${referenceLink}"},paramTooMany:{"${minArgs}_[one]":"Expected at most ${maxArgs} argument, but received more in ${func}(). ${referenceLink}","${minArgs}_[*]":"Expected at most ${maxArgs} arguments, but received more in ${func}(). ${referenceLink}"},paramType:"Expected ${typeName} at the ${position} parameter in ${funcName}.",hr7vkbw7rp:"┌[${location}] \\n\\t Error at line ${frame.lineNumber} in ${frame.functionName}()\\n",zcob0p6ap3:"└[${location}] \\n\\t Called from line ${frame.lineNumber} in ${frame.functionName}()\\n",e1bltb2f3i:"The media that tried to play (with '${this.src}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy.\\n\\n+ More info: https://developer.mozilla.org/docs/Web/Media/Autoplay_guide",fxcmxx850s:"${experimentalMessages[subjectArea]} For more info, see https://p5js.org/contribute/${subjectArea}/",ukmn4qp8ql:`To create a WEBGPU canvas, remember to add the WebGPU add-on to your project.`,gp2s5qktp8:"We weren't able to find a renderer called ${selectedRenderer}.",rf4evsxua3:`The GIF is over the maximum allowed dimension. Try to shrink the image or set p5.MAX_GIF_PIXELS to a higher value.`,"5szmoepgx4":`To create a WEBGPU canvas, add the WebGPU add-on to your project.`,xswmwyt2ek:`Falling back to WebGL renderer.`,fxy3ssriqw:"${e.message} Falling back to WebGL renderer."});const Ya=navigator.language,Xa=to(`localStorage`),Za=Xa?window.localStorage.getItem(`${Ya}-${p}`):null;let Qa=new Promise(async t=>{if(Za)qa.addTranslations(Ya,JSON.parse(Za)),t();else try{let t=await fetch(`./${Ya}.json`);if(!t.ok)throw Error(`Cannot reach local file`);let n=await t.json();qa.addTranslations(Ya,n),Xa&&window.localStorage.setItem(`${Ya}-${p}`,JSON.stringify(n))}catch{try{let t=await fetch(`https://cdn.jsdelivr.net/npm/p5@${p}/translations/${Ya}/extracted.json`);if(!t.ok)throw Error(`Cannot reach CDN file`);let n=await t.json();qa.addTranslations(Ya,n),Xa&&window.localStorage.setItem(`${Ya}-${p}`,JSON.stringify(n))}catch{}}finally{t()}});var R=class t{static languageCode=navigator.languages;static translationPromise=Qa;static disableFriendlyErrors=!1;static#e(n,r,...i){if(t.disableFriendlyErrors)return;let a=[],o=qa.tl(r,...i.map(n=>{if(n instanceof $a){let r=`%c${n.message.toString(t.languageCode)}%c`;return a.push(n.styleString,``),r}return n?.message&&n?.styleStrings?(a.push(...n.styleStrings),n.message):n})),s=o.toString(t.languageCode),c=r=>{let{prefix:i}=Object.assign({prefix:qa.tl`🌸 p5.js says: `},r),o=``;r?.reference&&(o+=eo(s,r.reference)),i instanceof qa?console[n](i.toString(t.languageCode)+s+o,...a):i===!1?console[n](s+o,...a):console[n](i+s+o,...a)};return c.message=s,c.styleStrings=a,c.toString=function(t){return o.toString(t)},c}static log(n,...r){return t.#e(`log`,n,...r)}static debug(n,...r){return t.#e(`debug`,n,...r)}static error(n,...r){return t.#e(`error`,n,...r)}static info(n,...r){return t.#e(`info`,n,...r)}static warn(n,...r){return t.#e(`warn`,n,...r)}static TL=qa;static premade={ordinals:[qa.tl`first`,qa.tl`second`,qa.tl`third`,qa.tl`fourth`,qa.tl`fifth`,qa.tl`sixth`,qa.tl`seventh`,qa.tl`eighth`,qa.tl`ninth`,qa.tl`tenth`],types:{string:qa.tl`string`,boolean:qa.tl`boolean`,number:qa.tl`number`,function:qa.tl`function`}}},$a=class{message;styleString;constructor(t,n){this.message=t,this.styleString=n}toString(t){return this.message.toString(t)}};function eo(t,n){let r=``;if(n==null||n.substring(0,4)===`load`)r=t;else{let t=n.split(`.`),i=t.length>1?`${t[0]}.${t[1]}`:`p5`,a=t.length===1?n:t.slice(2).join(`/`);r=a.startsWith(`p5.`)?` (https://p5js.org/reference/${i}.${a})`:` (https://p5js.org/reference/${i}/${a})`}return r}function to(t){let n;try{n=window[t];let r=`__storage_test__`;return n.setItem(r,r),n.removeItem(r),!0}catch(t){return t instanceof DOMException&&t.name===`QuotaExceededError`&&n&&n.length!==0}}function no(t,n,r){t.FES=R,Object.defineProperty(t.FES,"disableFriendlyErrors",{get:()=>t.disableFriendlyErrors})}const ro=`video`,io=`audio`;var ao=class{constructor(t,n,r,i){this.callback=t,this.time=n,this.id=r,this.val=i}},oo=class extends ta{constructor(t,n){super(t,n);let r=this;this.elt.crossOrigin=`anonymous`,this._prevTime=0,this._cueIDCounter=0,this._cues=[],this.pixels=[],this._pixelsState=this,this._pixelDensity=1,this._modified=!1,this._frameOnCanvas=-1,Object.defineProperty(r,"src",{get(){let t=r.elt.children[0].src,n=r.elt.src===window.location.href?``:r.elt.src;return t===window.location.href?n:t},set(n){for(let t=0;t<r.elt.children.length;t++)r.elt.removeChild(r.elt.children[t]);let i=document.createElement(`source`);i.src=n,t.appendChild(i),r.elt.src=n,r._modified=!0}}),r._onended=function(){},r.elt.onended=function(){r._onended(r)}}play(){this.elt.currentTime===this.elt.duration&&(this.elt.currentTime=0);let t;return this.elt.readyState>1||this.elt.load(),t=this.elt.play(),t&&t.catch&&t.catch(t=>{t.name===`NotAllowedError`?typeof IS_MINIFIED>`u`?R.log`The media that tried to play (with '${this.src}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy.\n\n+ More info: https://developer.mozilla.org/docs/Web/Media/Autoplay_guide`():console.error(t):console.error(`Media play method encountered an unexpected error`,t)}),this}stop(){return this.elt.pause(),this.elt.currentTime=0,this}pause(){return this.elt.pause(),this}loop(){return this.elt.setAttribute(`loop`,!0),this.play(),this}noLoop(){return this.elt.removeAttribute(`loop`),this}_setupAutoplayFailDetection(){let t=setTimeout(()=>{typeof IS_MINIFIED>`u`?R.log`The media that tried to play (with '${this.src}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy.\n\n+ More info: https://developer.mozilla.org/docs/Web/Media/Autoplay_guide`():console.error(e)},500);this.elt.addEventListener(`play`,()=>clearTimeout(t),{passive:!0,once:!0})}autoplay(t){let n=this.elt.getAttribute(`autoplay`);if(this.elt.setAttribute(`autoplay`,t),t&&!n){let t=()=>this._setupAutoplayFailDetection();this.elt.readyState===4?t():this.elt.addEventListener(`canplay`,t,{passive:!0,once:!0})}return this}volume(t){if(t===void 0)return this.elt.volume;this.elt.volume=t}speed(t){if(t===void 0)return this.presetPlaybackRate||this.elt.playbackRate;this.loadedmetadata?this.elt.playbackRate=t:this.presetPlaybackRate=t}time(t){return t!==void 0&&(this.elt.currentTime=t),this.elt.currentTime}duration(){return this.elt.duration}_checkIfTextureNeedsUpdate(){this._frameOnTexture!==this._pInst.frameCount&&(this.setModified(!0),this._frameOnTexture=this._pInst.frameCount)}_ensureCanvas(){this.canvas||(this.canvas=document.createElement(`canvas`),this.drawingContext=this.canvas.getContext(`2d`),this.setModified(!0));let t=this._frameOnCanvas!==this._pInst.frameCount;this.loadedmetadata&&t&&(this.canvas.width!==this.elt.width&&(this.canvas.width=this.elt.width,this.canvas.height=this.elt.height,this.width=this.canvas.width,this.height=this.canvas.height),this.drawingContext.clearRect(0,0,this.canvas.width,this.canvas.height),this.flipped===!0&&(this.drawingContext.save(),this.drawingContext.scale(-1,1),this.drawingContext.translate(-this.canvas.width,0)),this.drawingContext.drawImage(this.elt,0,0,this.canvas.width,this.canvas.height),this.flipped===!0&&this.drawingContext.restore(),this.setModified(!0),this._frameOnCanvas=this._pInst.frameCount)}loadPixels(...t){return this._ensureCanvas(),p5.Renderer2D.prototype.loadPixels.apply(this,t)}updatePixels(t,n,r,i){return this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.updatePixels.call(this,t,n,r,i)),this.setModified(!0),this}get(...t){return this._ensureCanvas(),p5.Renderer2D.prototype.get.apply(this,t)}_getPixel(...t){return this.loadPixels(),p5.Renderer2D.prototype._getPixel.apply(this,t)}set(t,n,r){this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.set.call(this,t,n,r),this.setModified(!0))}copy(...t){this._ensureCanvas(),p5.prototype.copy.apply(this,t)}mask(...t){this.loadPixels(),this.setModified(!0),p5.Image.prototype.mask.apply(this,t)}isModified(){return this._modified}setModified(t){this._modified=t}onended(t){return this._onended=t,this}_getAudioContext(){}_getSoundOut(){}connect(t){let n,r;if(this._getAudioContext()&&this._getSoundOut())n=this._getAudioContext(),r=this._getSoundOut().input;else try{n=t.context,r=n.destination}catch{throw`connect() is meant to be used with Web Audio API or p5.sound.js`}this.audioSourceNode||(this.audioSourceNode=n.createMediaElementSource(this.elt),this.audioSourceNode.connect(r)),t?t.input?this.audioSourceNode.connect(t.input):this.audioSourceNode.connect(t):this.audioSourceNode.connect(r)}disconnect(){if(this.audioSourceNode)this.audioSourceNode.disconnect();else throw`nothing to disconnect`}showControls(){this.elt.style[`text-align`]=`inherit`,this.elt.controls=!0}hideControls(){this.elt.controls=!1}addCue(t,n,r){let i=this._cueIDCounter++,a=new ao(n,t,i,r);return this._cues.push(a),this.elt.ontimeupdate||(this.elt.ontimeupdate=this._onTimeUpdate.bind(this)),i}removeCue(t){for(let n=0;n<this._cues.length;n++)this._cues[n].id===t&&this._cues.splice(n,1);this._cues.length===0&&(this.elt.ontimeupdate=null)}clearCues(){this._cues=[],this.elt.ontimeupdate=null}_onTimeUpdate(){let t=this.time();for(let n=0;n<this._cues.length;n++){let r=this._cues[n].time,i=this._cues[n].val;this._prevTime<r&&r<=t&&this._cues[n].callback(i)}this._prevTime=t}};function so(t,n){function r(t,n,r){(n._userNode?n._userNode:document.body).appendChild(t);let i=r?new oo(t,n):new ta(t,n);return n._elements.push(i),i}function i(t,n,i,a){let o=document.createElement(n);i||=``,typeof i==`string`&&(i=[i]);for(let t of i){let n=document.createElement(`source`);n.setAttribute(`src`,t),o.appendChild(n)}let s=r(o,t,!0);if(s.loadedmetadata=!1,o.addEventListener(`loadedmetadata`,()=>{s.width=o.videoWidth,s.height=o.videoHeight,s.elt.width===0&&(s.elt.width=o.videoWidth),s.elt.height===0&&(s.elt.height=o.videoHeight),s.presetPlaybackRate&&(s.elt.playbackRate=s.presetPlaybackRate,delete s.presetPlaybackRate),s.loadedmetadata=!0}),typeof a==`function`){let t=()=>{a(s),o.removeEventListener(`canplaythrough`,t)};o.addEventListener(`canplaythrough`,t)}return s}n.createVideo=function(t,n){return i(this,ro,t,n)},n.createAudio=function(t,n){return i(this,io,t,n)},n.VIDEO=ro,n.AUDIO=io,navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(t){let n=navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return n?new Promise(function(r,i){n.call(navigator,t,r,i)}):Promise.reject(/* @__PURE__ */ Error(`getUserMedia is not implemented in this browser`))}),n.createCapture=function(...i){if(!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia))throw new DOMException(`getUserMedia not supported in this browser`);let a=!0,o=!0,s,c,l=!1;for(let t of i)t===n.VIDEO?o=!1:t===n.AUDIO?a=!1:typeof t==`object`?(t.flipped!==void 0&&(l=t.flipped,delete t.flipped),s=Object.assign({},s,t)):typeof t==`function`&&(c=t);s=Object.assign({},{video:a,audio:o},s);let u=document.createElement(ro);u.setAttribute(`playsinline`,``);let d=this._removeSignal;navigator.mediaDevices.getUserMedia(s).then(function(t){if(d.aborted)t.getTracks().forEach(t=>t.stop());else try{`srcObject`in u?u.srcObject=t:u.src=window.URL.createObjectURL(t)}catch{u.src=t}}).catch(n=>{n.name===`NotFoundError`&&t._friendlyError(`No webcam found on this device`,`createCapture`),n.name===`NotAllowedError`&&t._friendlyError(`Access to the camera was denied`,`createCapture`),console.error(n)});let f=r(u,this,!0);return f.loadedmetadata=!1,u.addEventListener(`loadedmetadata`,function(){u.play(),u.width?(f.width=u.width,f.height=u.height):(f.width=f.elt.width=u.videoWidth,f.height=f.elt.height=u.videoHeight),l&&(f.elt.style.transform=`scaleX(-1)`),f.loadedmetadata=!0,c&&c(u.srcObject)}),f.flipped=l,f},t.MediaElement=oo,oo.prototype._getSoundOut=function(){return t.soundOut},oo.prototype._getAudioContext=function(){if(typeof n.getAudioContext==`function`)return n.getAudioContext()}}typeof p5<`u`&&so(p5,p5.prototype);function co(t,n,r,i,a){let o;return a===`corner`?o={x:t,y:n,w:Math.abs(r),h:Math.abs(i)}:a===`corners`?o={x:Math.min(t,r),y:Math.min(n,i),w:Math.abs(r-t),h:Math.abs(i-n)}:a===`radius`?(r=Math.abs(r),i=Math.abs(i),o={x:t-r,y:n-i,w:2*r,h:2*i}):a===`center`&&(r=Math.abs(r),i=Math.abs(i),o={x:t-r*.5,y:n-i*.5,w:r,h:i}),o}var lo={modeAdjust:co};function uo(t,n){n._normalizeArcAngles=(t,n,r,i,a)=>{let o;return t-=A*Math.floor(t/A),n-=A*Math.floor(n/A),o=Math.min(Math.abs(t-n),A-Math.abs(t-n)),a&&(t=t<=E?Math.atan(r/i*Math.tan(t)):t>E&&t<=3*E?Math.atan(r/i*Math.tan(t))+D:Math.atan(r/i*Math.tan(t))+A,n=n<=E?Math.atan(r/i*Math.tan(n)):n>E&&n<=3*E?Math.atan(r/i*Math.tan(n))+D:Math.atan(r/i*Math.tan(n))+A),t>n&&(n+=A),{start:t,stop:n,correspondToSamePoint:o<1e-5}},n.arc=function(t,n,r,i,a,o,s,c){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor||a===o)return this;a=this._toRadians(a),o=this._toRadians(o);let l=lo.modeAdjust(t,n,r,i,this._renderer.states.ellipseMode),u=this._normalizeArcAngles(a,o,l.w,l.h,!0);return u.correspondToSamePoint?this._renderer.ellipse([l.x,l.y,l.w,l.h,c]):(this._renderer.arc(l.x,l.y,l.w,l.h,u.start,u.stop,s,c),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`arc`,[l.x,l.y,l.w,l.h,u.start,u.stop,s])),this},n.ellipse=function(t,n,r,i,a){return this._renderEllipse(...arguments)},n.circle=function(...t){let n=t.slice(0,2);return n.push(t[2],t[2]),this._renderEllipse(...n)},n._renderEllipse=function(t,n,r,i,a){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor)return this;i===void 0&&(i=r);let o=lo.modeAdjust(t,n,r,i,this._renderer.states.ellipseMode);return this._renderer.ellipse([o.x,o.y,o.w,o.h,a]),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`ellipse`,[o.x,o.y,o.w,o.h]),this},n.line=function(...t){return this._renderer.states.strokeColor&&this._renderer.line(...t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`line`,t),this},n.point=function(...n){return this._renderer.states.strokeColor&&(n.length===1&&n[0]instanceof t.Vector?this._renderer.point.call(this._renderer,n[0].x,n[0].y,n[0].z):(this._renderer.point(...n),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`point`,n))),this},n.quad=function(...t){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&(this._renderer.isP3D&&t.length<12?this._renderer.quad.call(this._renderer,t[0],t[1],0,t[2],t[3],0,t[4],t[5],0,t[6],t[7],0,t[8],t[9]):(this._renderer.quad(...t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`quadrilateral`,t))),this},n.rect=function(...t){return this._renderRect(...t)},n.square=function(t,n,r,i,a,o,s){return this._renderRect.call(this,t,n,r,r,i,a,o,s)},n._renderRect=function(){if(this._renderer.states.strokeColor||this._renderer.states.fillColor){arguments.length===3&&(arguments[3]=arguments[2]);let t=lo.modeAdjust(arguments[0],arguments[1],arguments[2],arguments[3],this._renderer.states.rectMode);this._renderer.states.rectMode===`corner`&&(t.w=arguments[2],t.h=arguments[3]);let n=[t.x,t.y,t.w,t.h];for(let t=4;t<arguments.length;t++)n[t]=arguments[t];this._renderer.rect(n),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`rectangle`,[t.x,t.y,t.w,t.h])}return this},n.triangle=function(...t){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&this._renderer.triangle(t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput(`triangle`,t),this}}typeof p5<`u`&&uo(p5,p5.prototype);function fo(t,n){n.ellipseMode=function(t){return t===void 0?this._renderer?.states.ellipseMode:((t===`corner`||t===`corners`||t===`radius`||t===`center`)&&this._renderer.states.setValue(`ellipseMode`,t),this)},n.noSmooth=function(){return this._renderer.isP3D?this.setAttributes(`antialias`,!1):(`imageSmoothingEnabled`in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!1),this)},n.rectMode=function(t){return t===void 0?this._renderer?.states.rectMode:((t===`corner`||t===`corners`||t===`radius`||t===`center`)&&this._renderer.states.setValue(`rectMode`,t),this)},n.smooth=function(){return this._renderer.isP3D?this.setAttributes(`antialias`,!0):`imageSmoothingEnabled`in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!0),this},n.strokeCap=function(t){return t===void 0?this._renderer.strokeCap():((t===`round`||t===`butt`||t===`square`)&&this._renderer.strokeCap(t),this)},n.strokeJoin=function(t){return t===void 0?this._renderer.strokeJoin():((t===`round`||t===`bevel`||t===`miter`)&&this._renderer.strokeJoin(t),this)},n.strokeWeight=function(t){return this._renderer.strokeWeight(t)}}typeof p5<`u`&&fo(p5,p5.prototype);function po(t,n){n.bezier=function(...t){return!this._renderer.states.strokeColor&&!this._renderer.states.fillColor||this._renderer.bezier(...t),this},n.bezierPoint=function(t,n,r,i,a){let o=1-a;return o**3*t+3*o**2*a*n+3*o*a**2*r+a**3*i},n.bezierTangent=function(t,n,r,i,a){let o=1-a;return 3*i*a**2-3*r*a**2+6*r*o*a-6*n*o*a+3*n*o**2-3*t*o**2},n.spline=function(...t){return!this._renderer.states.strokeColor&&!this._renderer.states.fillColor||this._renderer.spline(...t),this},n.splinePoint=function(t,n,r,i,a){let o=this._renderer.states.splineProperties.tightness,s=a*a*a,c=a*a,l=(o-1)/2*s+(1-o)*c+(o-1)/2*a,u=(o+3)/2*s+(-5-o)/2*c+1,d=(-3-o)/2*s+(o+2)*c+(1-o)/2*a,f=(1-o)/2*s+(o-1)/2*c;return t*l+n*u+r*d+i*f},n.splineTangent=function(t,n,r,i,a){let o=this._renderer.states.splineProperties.tightness,s=a*a*3,c=a*2,l=(o-1)/2*s+(1-o)*c+(o-1)/2,u=(o+3)/2*s+(-5-o)/2*c,d=(-3-o)/2*s+(o+2)*c+(1-o)/2,f=(1-o)/2*s+(o-1)/2*c;return t*l+n*u+r*d+i*f}}typeof p5<`u`&&po(p5,p5.prototype);function mo(t,n){n.beginShape=function(t){this._renderer.beginShape(...arguments)},n.bezierVertex=function(...t){this._renderer.bezierVertex(...t)},n.endShape=function(t,n){typeof t==`number`&&(n=t,t=void 0),n!==void 0&&(n<1?(console.log(`🌸 p5.js says: You can not have less than one instance`),n=1):n=Math.round(n)),this._renderer.endShape(t,n)},n.normal=function(t,n,r){return this._assert3d(`normal`),this._renderer.normal(...arguments),this},n.vertexProperty=function(t,n){this._renderer.vertexProperty(t,n)}}typeof p5<`u`&&mo(p5,p5.prototype);function ho(t,n){n.beginClip=function(t={}){this._renderer.beginClip(t)},n.endClip=function(){this._renderer.endClip()},n.clip=function(t,n){this._renderer.beginClip(n),t(),this._renderer.endClip(n)},n.background=function(...t){return this._renderer.background(...t)},n.clear=function(...t){let n=t[0]||0,r=t[1]||0,i=t[2]||0,a=t[3]||0;return this._renderer.clear(n,r,i,a),this},n.colorMode=function(t,n,r,i,a){if([`rgb`,`rgbp3`,`hsb`,`hsl`,`hwb`,`lab`,`lch`,`oklab`,`oklch`].includes(t)){this._renderer.states.setValue(`colorMode`,t),this._renderer.states.setValue(`colorMaxes`,this._renderer.states.colorMaxes.clone());let o=this._renderer.states.colorMaxes[t];arguments.length===2?(o[0]=n,o[1]=n,o[2]=n,o[3]=n):arguments.length===4?(o[0]=n,o[1]=r,o[2]=i):arguments.length===5&&(o[0]=n,o[1]=r,o[2]=i,o[3]=a)}return this._renderer.states.colorMode},n.fill=function(...t){return this._renderer.fill(...t)},n.noFill=function(){return this._renderer.noFill(),this},n.noStroke=function(){return this._renderer.states.setValue(`strokeColor`,null),this},n.stroke=function(...t){return this._renderer.stroke(...t)},n.erase=function(t=255,n=255){return this._renderer.erase(t,n),this},n.noErase=function(){return this._renderer.noErase(),this},n.blendMode=function(t){return t===`normal`&&(console.warn(`NORMAL has been deprecated for use in blendMode. defaulting to BLEND instead.`),t=F),this._renderer.blendMode(t)}}typeof p5<`u`&&ho(p5,p5.prototype);var go=/* @__PURE__ */ u((/* @__PURE__ */ s((t=>{function n(t,n,i,a){var o=0,a=a===void 0?{}:a,s=a.loop===void 0?null:a.loop,c=a.palette===void 0?null:a.palette;if(n<=0||i<=0||n>65535||i>65535)throw Error(`Width/Height invalid.`);function l(t){var n=t.length;if(n<2||n>256||n&n-1)throw Error(`Invalid code/color length, must be power of 2 and 2 .. 256.`);return n}t[o++]=71,t[o++]=73,t[o++]=70,t[o++]=56,t[o++]=57,t[o++]=97;var u=0,d=0;if(c!==null){for(var f=l(c);f>>=1;)++u;if(f=1<<u,--u,a.background!==void 0){if(d=a.background,d>=f)throw Error(`Background index out of range.`);if(d===0)throw Error(`Background index explicitly passed as 0.`)}}if(t[o++]=n&255,t[o++]=n>>8&255,t[o++]=i&255,t[o++]=i>>8&255,t[o++]=(c===null?0:128)|u,t[o++]=d,t[o++]=0,c!==null)for(var p=0,m=c.length;p<m;++p){var h=c[p];t[o++]=h>>16&255,t[o++]=h>>8&255,t[o++]=h&255}if(s!==null){if(s<0||s>65535)throw Error(`Loop count invalid.`);t[o++]=33,t[o++]=255,t[o++]=11,t[o++]=78,t[o++]=69,t[o++]=84,t[o++]=83,t[o++]=67,t[o++]=65,t[o++]=80,t[o++]=69,t[o++]=50,t[o++]=46,t[o++]=48,t[o++]=3,t[o++]=1,t[o++]=s&255,t[o++]=s>>8&255,t[o++]=0}var g=!1;this.addFrame=function(n,i,a,s,u,d){if(g===!0&&(--o,g=!1),d=d===void 0?{}:d,n<0||i<0||n>65535||i>65535)throw Error(`x/y invalid.`);if(a<=0||s<=0||a>65535||s>65535)throw Error(`Width/Height invalid.`);if(u.length<a*s)throw Error(`Not enough pixels for the frame size.`);var f=!0,p=d.palette;if(p??=(f=!1,c),p==null)throw Error(`Must supply either a local or global palette.`);for(var m=l(p),h=0;m>>=1;)++h;m=1<<h;var _=d.delay===void 0?0:d.delay,v=d.disposal===void 0?0:d.disposal;if(v<0||v>3)throw Error(`Disposal out of range.`);var y=!1,b=0;if(d.transparent!==void 0&&d.transparent!==null&&(y=!0,b=d.transparent,b<0||b>=m))throw Error(`Transparent color index.`);if((v!==0||y||_!==0)&&(t[o++]=33,t[o++]=249,t[o++]=4,t[o++]=v<<2|y===!0,t[o++]=_&255,t[o++]=_>>8&255,t[o++]=b,t[o++]=0),t[o++]=44,t[o++]=n&255,t[o++]=n>>8&255,t[o++]=i&255,t[o++]=i>>8&255,t[o++]=a&255,t[o++]=a>>8&255,t[o++]=s&255,t[o++]=s>>8&255,t[o++]=f===!0?128|h-1:0,f===!0)for(var x=0,S=p.length;x<S;++x){var C=p[x];t[o++]=C>>16&255,t[o++]=C>>8&255,t[o++]=C&255}return o=r(t,o,h<2?2:h,u),o},this.end=function(){return g===!1&&(t[o++]=59,g=!0),o},this.getOutputBuffer=function(){return t},this.setOutputBuffer=function(n){t=n},this.getOutputBufferPosition=function(){return o},this.setOutputBufferPosition=function(t){o=t}}function r(t,n,r,i){t[n++]=r;var a=n++,o=1<<r,s=o-1,c=o+1,l=c+1,u=r+1,d=0,f=0;function p(r){for(;d>=r;)t[n++]=f&255,f>>=8,d-=8,n===a+256&&(t[a]=255,a=n++)}function m(t){f|=t<<d,d+=u,p(8)}var h=i[0]&s,g={};m(o);for(var _=1,v=i.length;_<v;++_){var y=i[_]&s,b=h<<8|y,x=g[b];if(x===void 0){for(f|=h<<d,d+=u;d>=8;)t[n++]=f&255,f>>=8,d-=8,n===a+256&&(t[a]=255,a=n++);l===4096?(m(o),l=c+1,u=r+1,g={}):(l>=1<<u&&++u,g[b]=l++),h=y}else h=x}return m(h),m(c),p(1),a+1===n?t[a]=0:(t[a]=n-a-1,t[n++]=0),n}function i(t){var n=0;if(t[n++]!==71||t[n++]!==73||t[n++]!==70||t[n++]!==56||(t[n++]+1&253)!=56||t[n++]!==97)throw Error(`Invalid GIF 87a/89a header.`);var r=t[n++]|t[n++]<<8,i=t[n++]|t[n++]<<8,o=t[n++],s=o>>7,c=1<<(o&7)+1;t[n++],t[n++];var l=null,u=null;s&&(l=n,u=c,n+=c*3);var d=!0,f=[],p=0,m=null,h=0,g=null;for(this.width=r,this.height=i;d&&n<t.length;)switch(t[n++]){case 33:switch(t[n++]){case 255:if(t[n]!==11||t[n+1]==78&&t[n+2]==69&&t[n+3]==84&&t[n+4]==83&&t[n+5]==67&&t[n+6]==65&&t[n+7]==80&&t[n+8]==69&&t[n+9]==50&&t[n+10]==46&&t[n+11]==48&&t[n+12]==3&&t[n+13]==1&&t[n+16]==0)n+=14,g=t[n++]|t[n++]<<8,n++;else for(n+=12;;){var _=t[n++];if(!(_>=0))throw Error(`Invalid block size`);if(_===0)break;n+=_}break;case 249:if(t[n++]!==4||t[n+4]!==0)throw Error(`Invalid graphics extension block.`);var v=t[n++];p=t[n++]|t[n++]<<8,m=t[n++],v&1||(m=null),h=v>>2&7,n++;break;case 254:for(;;){var _=t[n++];if(!(_>=0))throw Error(`Invalid block size`);if(_===0)break;n+=_}break;default:throw Error(`Unknown graphic control label: 0x`+t[n-1].toString(16))}break;case 44:var y=t[n++]|t[n++]<<8,b=t[n++]|t[n++]<<8,x=t[n++]|t[n++]<<8,S=t[n++]|t[n++]<<8,C=t[n++],w=C>>7,T=C>>6&1,E=1<<(C&7)+1,D=l,O=u,k=!1;if(w){var k=!0;D=n,O=E,n+=E*3}var A=n;for(n++;;){var _=t[n++];if(!(_>=0))throw Error(`Invalid block size`);if(_===0)break;n+=_}f.push({x:y,y:b,width:x,height:S,has_local_palette:k,palette_offset:D,palette_size:O,data_offset:A,data_length:n-A,transparent_index:m,interlaced:!!T,delay:p,disposal:h});break;case 59:d=!1;break;default:throw Error(`Unknown gif block: 0x`+t[n-1].toString(16))}this.numFrames=function(){return f.length},this.loopCount=function(){return g},this.frameInfo=function(t){if(t<0||t>=f.length)throw Error(`Frame index out of range.`);return f[t]},this.decodeAndBlitFrameBGRA=function(n,i){var o=this.frameInfo(n),s=o.width*o.height,c=new Uint8Array(s);a(t,o.data_offset,c,s);var l=o.palette_offset,u=o.transparent_index;u===null&&(u=256);var d=o.width,f=r-d,p=d,m=(o.y*r+o.x)*4,h=((o.y+o.height)*r+o.x)*4,g=m,_=f*4;o.interlaced===!0&&(_+=r*4*7);for(var v=8,y=0,b=c.length;y<b;++y){var x=c[y];if(p===0&&(g+=_,p=d,g>=h&&(_=f*4+r*4*(v-1),g=m+(d+f)*(v<<1),v>>=1)),x===u)g+=4;else{var S=t[l+x*3],C=t[l+x*3+1],w=t[l+x*3+2];i[g++]=w,i[g++]=C,i[g++]=S,i[g++]=255}--p}},this.decodeAndBlitFrameRGBA=function(n,i){var o=this.frameInfo(n),s=o.width*o.height,c=new Uint8Array(s);a(t,o.data_offset,c,s);var l=o.palette_offset,u=o.transparent_index;u===null&&(u=256);var d=o.width,f=r-d,p=d,m=(o.y*r+o.x)*4,h=((o.y+o.height)*r+o.x)*4,g=m,_=f*4;o.interlaced===!0&&(_+=r*4*7);for(var v=8,y=0,b=c.length;y<b;++y){var x=c[y];if(p===0&&(g+=_,p=d,g>=h&&(_=f*4+r*4*(v-1),g=m+(d+f)*(v<<1),v>>=1)),x===u)g+=4;else{var S=t[l+x*3],C=t[l+x*3+1],w=t[l+x*3+2];i[g++]=S,i[g++]=C,i[g++]=w,i[g++]=255}--p}}}function a(t,n,r,i){for(var a=t[n++],o=1<<a,s=o+1,c=s+1,l=a+1,u=(1<<l)-1,d=0,f=0,p=0,m=t[n++],h=/* @__PURE__ */ new Int32Array(4096),g=null;;){for(;d<16&&m!==0;)f|=t[n++]<<d,d+=8,m===1?m=t[n++]:--m;if(d<l)break;var _=f&u;if(f>>=l,d-=l,_===o)c=s+1,l=a+1,u=(1<<l)-1,g=null;else{if(_===s)break;for(var v=_<c?_:g,y=0,b=v;b>o;)b=h[b]>>8,++y;var x=b;if(p+y+(v===_?0:1)>i){console.log(`Warning, gif stream longer than expected.`);return}r[p++]=x,p+=y;var S=p;for(v!==_&&(r[p++]=x),b=v;y--;)b=h[b],r[--S]=b&255,b>>=8;g!==null&&c<4096&&(h[c++]=g<<8|x,c>=u+1&&l<12&&(++l,u=u<<1|1)),g=_}}return p!==i&&console.log(`Warning, gif stream shorter than expected.`),r}try{t.GifWriter=n,t.GifReader=i}catch{}})))(),1);function _o(t,n){n.createImage=function(n,r){return new t.Image(n,r)},n.saveCanvas=function(...t){let r,i,a,o;if(t[0]instanceof HTMLCanvasElement)r=t[0],t.shift();else if(t[0]instanceof ta)r=t[0].elt,t.shift();else if(t[0]instanceof Vs){let n=t[0];o=this.createGraphics(n.width,n.height),o.pixelDensity(n.pixelDensity()),n.loadPixels(),o.loadPixels(),o.pixels.set(n.pixels),o.updatePixels(),r=o._renderer.canvas,t.shift()}else r=this._curElement&&this._curElement.elt;t.length>=1&&(i=t[0]),t.length>=2&&(a=t[1]),a=a||n._checkFileExtension(i,a)[1]||`png`;let s;switch(a){default:s=`image/png`;break;case`webp`:s=`image/webp`;break;case`jpeg`:case`jpg`:s=`image/jpeg`}r.toBlob(t=>{n.downloadFile(t,i,a),o&&o.remove()},s)},n.encodeAndDownloadGif=function(t,r){let i=t.gifProperties,a=i.loopLimit;a===1?a=null:a===null&&(a=0);let o=new Uint8Array(t.width*t.height*i.numFrames),s=[],c={};for(let n=0;n<i.numFrames;n++){let r=/* @__PURE__ */ new Set,a=i.frames[n].image.data,o=a.length,l=new Uint32Array(t.width*t.height);for(let t=0,n=0;t<o;t+=4,n++){let i=a[t+0],o=a[t+1],s=a[t+2],c=i<<16|o<<8|s;r.add(c),l[n]=c}let u=[...r].sort().toString();c[u]===void 0?c[u]={freq:1,frames:[n]}:(c[u].freq+=1,c[u].frames.push(n)),s.push(l)}let l=[],u=Object.keys(c).sort(function(t,n){return c[n].freq-c[t].freq}),d=u[0].split(`,`).map(t=>parseInt(t));l=l.concat(c[d].frames);let f=new Set(d);for(let t=1;t<u.length;t++){let n=u[t].split(`,`).map(t=>parseInt(t)).filter(t=>!f.has(t));if(d.length+n.length<=256){for(let t=0;t<n.length;t++)d.push(n[t]),f.add(n[t]);l=l.concat(c[u[t]].frames)}}l=new Set(l);let p={};for(let t=0;t<d.length;t++)p[d[t]]||(p[d[t]]=t);let m=1;for(;m<d.length;)m<<=1;d.length=m;let h={loop:a,palette:new Uint32Array(d)},g=new go.GifWriter(o,t.width,t.height,h),_={};for(let n=0;n<i.numFrames;n++){let r=!l.has(n),a=r?[]:d,o=new Uint8Array(t.width*t.height),c={},u=/* @__PURE__ */ new Set;s[n].forEach((t,i)=>{r?(c[t]===void 0&&(c[t]=a.length,a.push(t)),o[i]=c[t]):o[i]=p[t],n>0&&s[n-1][i]!==t&&u.add(t)});let f={},m=a.filter(t=>!u.has(t));if(m.length>0){let t=m[0],i=r?c[t]:p[t];if(n>0){for(let t=0;t<s[n].length;t++)s[n-1][t]===s[n][t]&&(o[t]=i);f.transparent=i,_.frameOpts.disposal=1}}if(f.delay=i.frames[n].delay/10,r){let t=1;for(;t<a.length;)t<<=1;a.length=t,f.palette=new Uint32Array(a)}n>0&&g.addFrame(0,0,t.width,t.height,_.pixelPaletteIndex,_.frameOpts),_={pixelPaletteIndex:o,frameOpts:f}}_.frameOpts.disposal=1,g.addFrame(0,0,t.width,t.height,_.pixelPaletteIndex,_.frameOpts);let v=new Blob([o.slice(0,g.end())],{type:`image/gif`});n.downloadFile(v,r,`gif`)},n.saveFrames=function(t,r,i,a,o){let s=i||3;s=Math.max(Math.min(s,15),0),s*=1e3;let c=a||15;c=Math.max(Math.min(c,22),0);let l=0,u=n._makeFrame,d=this._curElement.elt,f=[],p=s*c/1e3,m=setInterval(()=>{if(f.push(u(t+l,r,d)),l++,l>=p){if(clearInterval(m),o)o(f);else for(let t of f)n.downloadFile(t.imageData,t.filename,t.ext);f=[]}},1e3/c)},n._makeFrame=function(t,n,r){let i;i=this?this._curElement.elt:r;let a;if(!n)n=`png`,a=`image/png`;else switch(n.toLowerCase()){case`png`:a=`image/png`;break;case`jpeg`:a=`image/jpeg`;break;case`jpg`:a=`image/jpeg`;break;default:a=`image/png`}let o=i.toDataURL(a);o=o.replace(a,`image/octet-stream`);let s={};return s.imageData=o,s.filename=t,s.ext=n,s}}typeof p5<`u`&&_o(p5,p5.prototype);function vo(t,n,r=t=>t){let i=Object.create(null);if(i.options=n||{},i.reviver=r,i.value=``,i.entry=[],i.output=[],i.col=1,i.row=1,i.options.delimiter=i.options.delimiter===void 0?`"`:n.delimiter,i.options.delimiter.length>1||i.options.delimiter.length===0)throw Error(`CSVError: delimiter must be one character [${i.options.separator}]`);if(i.options.separator=i.options.separator===void 0?`,`:n.separator,i.options.separator.length>1||i.options.separator.length===0)throw Error(`CSVError: separator must be one character [${i.options.separator}]`);let a=RegExp(`${Co(i.options.delimiter)}|${Co(i.options.separator)}|\r\n|\n|\r|[^${Co(i.options.delimiter)}${Co(i.options.separator)}\r\n]+`,`y`),o=/^(\r\n|\n|\r)$/,s=[],c=``,l=0;for(;(s=a.exec(t))!==null;)switch(c=s[0],l){case 0:switch(!0){case c===i.options.delimiter:l=3;break;case c===i.options.separator:l=0,bo(i);break;case o.test(c):l=0,bo(i),xo(i);break;default:i.value+=c,l=2}break;case 2:switch(!0){case c===i.options.separator:l=0,bo(i);break;case o.test(c):l=0,bo(i),xo(i);break;default:throw l=4,Error(`CSVError: Illegal state [row:${i.row}, col:${i.col}]`)}break;case 3:switch(!0){case c===i.options.delimiter:l=4;break;default:l=3,i.value+=c}break;case 4:switch(!0){case c===i.options.delimiter:l=3,i.value+=c;break;case c===i.options.separator:l=0,bo(i);break;case o.test(c):l=0,bo(i),xo(i);break;default:throw Error(`CSVError: Illegal state [row:${i.row}, col:${i.col}]`)}}return i.entry.length!==0&&(bo(i),xo(i)),i.output}function yo(t,n={},r=t=>t){let i=Object.create(null);if(i.options=n,i.options.eof=i.options.eof===void 0||i.options.eof,i.row=1,i.col=1,i.output=``,i.options.delimiter=i.options.delimiter===void 0?`"`:n.delimiter,i.options.delimiter.length>1||i.options.delimiter.length===0)throw Error(`CSVError: delimiter must be one character [${i.options.separator}]`);if(i.options.separator=i.options.separator===void 0?`,`:n.separator,i.options.separator.length>1||i.options.separator.length===0)throw Error(`CSVError: separator must be one character [${i.options.separator}]`);let a=RegExp(`${Co(i.options.delimiter)}|${Co(i.options.separator)}|\r\n|\n|\r`);return t.forEach((n,o)=>{let s=``;switch(i.col=1,n.forEach((t,o)=>{typeof t==`string`&&(t=t.replace(new RegExp(i.options.delimiter,`g`),`${i.options.delimiter}${i.options.delimiter}`),t=a.test(t)?`${i.options.delimiter}${t}${i.options.delimiter}`:t),s+=r(t,i.row,i.col),o!==n.length-1&&(s+=i.options.separator),i.col++}),!0){case i.options.eof:case!i.options.eof&&o!==t.length-1:i.output+=`${s}\n`;break;default:i.output+=`${s}`}i.row++}),i.output}function bo(t){let n=t.options.typed?So(t.value):t.value;t.entry.push(t.reviver(n,t.row,t.col)),t.value=``,t.col++}function xo(t){t.output.push(t.entry),t.entry=[],t.row++,t.col=1}function So(t){let n=/.\./;switch(!0){case t===`true`:case t===`false`:return t===`true`;case n.test(t):return parseFloat(t);case isFinite(t):return parseInt(t);default:return t}}function Co(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,`\\$&`)}var wo=class extends Error{status;response;ok};async function To(t,n){let r=qa.tl`file`;try{let i=await fetch(t);if(i.ok){let t;switch(n){case`json`:r=qa.tl`JSON file`,t=await i.json();break;case`text`:r=qa.tl`text file`,t=await i.text();break;case`arrayBuffer`:t=await i.arrayBuffer();break;case`blob`:t=await i.blob();break;case`bytes`:t=await i.bytes();break;default:throw Error(`Unsupported response type`)}return{data:t,headers:i.headers}}{let t=new wo(i.statusText);throw t.status=i.status,t.response=i,t.ok=!1,t}}catch(n){throw n instanceof TypeError?console.log(`You may have encountered a CORS error`):n instanceof wo?R.log`It looks like there was a problem loading your ${r}. Try checking if the file path (${t}) is correct, hosting the file online, or running a local server.

+ More info: ${`https://github.com/processing/p5.js/wiki/Local-server`}`():n instanceof SyntaxError&&console.log(`There is an error parsing the response to requested data structure`),n}}function Eo(t,n){n.loadJSON=async function(t,n,r){try{let{data:r}=await To(t,`json`),i=()=>n?n(r):r;return this._internal?this._internal(i):i()}catch(t){if(r)return r(t);throw t}},n.loadStrings=async function(t,n,r){try{let{data:r}=await To(t,`text`),i=()=>(r=r.split(/\r?\n/),n?n(r):r);return this._internal?this._internal(i):i()}catch(t){if(r)return r(t);throw t}},n.loadTable=async function(n,r,i,a,o){typeof arguments[arguments.length-1]==`function`&&(typeof arguments[arguments.length-2]==`function`?(a=arguments[arguments.length-2],o=arguments[arguments.length-1]):a=arguments[arguments.length-1]),typeof r!=`string`&&(r=`,`),typeof i==`function`&&(i=!1);try{let{data:o}=await To(n,`text`),s=()=>{let n=new t.Table;return o=vo(o,{separator:r}),n.columns=i?o.shift():Array(o[0].length).fill(null),o.forEach(r=>{let i=new t.TableRow(r);n.addRow(i)}),a?a(n):n};return this._internal?this._internal(s):s()}catch(t){if(o)return o(t);throw t}},n.loadXML=async function(n,r,i){try{let i=new DOMParser,{data:a}=await To(n,`text`),o=()=>{let n=i.parseFromString(a,`application/xml`);return a=new t.XML(n),r?r(a):a};return this._internal?this._internal(o):o()}catch(t){if(i)return i(t);throw t}},n.loadBytes=async function(t,n,r){try{let{data:r}=await To(t,`arrayBuffer`),i=()=>(r=new Uint8Array(r),n?n(r):r);return this._internal?this._internal(i):i()}catch(t){if(r)return r(t);throw t}},n.loadBlob=async function(t,n,r){try{let{data:r}=await To(t,`blob`),i=()=>n?n(r):r;return this._internal?this._internal(i):i()}catch(t){if(r)return r(t);throw t}},n.httpGet=async function(t,n=`text`,r,i){return typeof n==`function`&&(i=r,r=n,n=`text`),this.httpDo(t,`GET`,n,r,i)},n.httpPost=async function(n,r,i=`text`,a,o){typeof r==`function`?(a=r,o=i,r=void 0,i=`text`):typeof i==`function`&&(o=a,a=i,i=`text`);let s=r,c=`text/plain`;r instanceof t.XML?(s=r.serialize(),c=`application/xml`):r instanceof t.Image?(s=await r.toBlob(),c=`image/png`):typeof r==`object`&&(s=JSON.stringify(r),c=`application/json`);let l={method:`POST`,body:s,headers:{"Content-Type":c}};s&&(l.body=s);let u=new Request(n,l);return this.httpDo(u,`POST`,i,a,o)},n.httpDo=async function(t,n,r,i,a){if(typeof r==`function`&&(a=i,i=r,r=void 0),!r)switch(typeof t==`string`?t.split(`.`).pop():t.url.split(`.`).pop()){case`json`:r=`json`;break;case`jpg`:case`jpeg`:case`png`:case`webp`:case`gif`:r=`blob`;break;default:r=`text`}let o=new Request(t,{method:n});try{let{data:t}=await To(o,r);return i?i(t):t}catch(t){if(a)return a(t);throw t}},n._pWriters=[],n.createWriter=function(r,i){let a;for(let o in n._pWriters)if(n._pWriters[o].name===r)return a=new t.PrintWriter(r+this.millis(),i),n._pWriters.push(a),a;return a=new t.PrintWriter(r,i),n._pWriters.push(a),a},t.PrintWriter=function(t,r){let i=this;this.name=t,this.content=``,this.write=function(t){this.content+=t},this.print=function(t){this.content+=`${t}\n`},this.clear=function(){this.content=``},this.close=function(){let a=[];a.push(this.content),n.writeFile(a,t,r);for(let t in n._pWriters)n._pWriters[t].name===this.name&&n._pWriters.splice(t,1);i.clear(),i={}}},n.save=function(r,i,a){let o=arguments,s=this._curElement?this._curElement.elt:this.elt;if(o.length===0)n.saveCanvas(s);else if(o[0]instanceof L||o[0]instanceof Ts)n.saveCanvas(o[0].canvas,o[1],o[2]);else if(o.length===1&&typeof o[0]==`string`)n.saveCanvas(s,o[0]);else switch(da(o[1],o[2])[1]){case`json`:n.saveJSON(o[0],o[1],o[2]);return;case`txt`:n.saveStrings(o[0],o[1],`txt`,o[2]);return;default:o[0]instanceof Array?n.saveStrings(o[0],o[1],void 0,o[2]):o[0]instanceof t.Table?n.saveTable(o[0],o[1],o[2]):o[0]instanceof t.Image?n.saveCanvas(o[0].canvas,o[1]):o[0]instanceof t.SoundFile&&n.saveSound(o[0],o[1],o[2],o[3])}},n.saveJSON=function(t,n,r){let i;i=r?JSON.stringify(t):JSON.stringify(t,void 0,2),this.saveStrings(i.split(`
`),n,`json`)},n.saveStrings=function(n,r,i,a){let o=i||`txt`,s=new t.PrintWriter(r,o);for(let t of n)a?s.write(t+`\r
`):s.write(t+`
`);s.close(),s.clear()};function r(t){return t.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#039;`)}n.saveTable=function(t,n,i){let a;i===void 0?(a=n.substring(n.lastIndexOf(`.`)+1,n.length),a===n&&(a=`csv`)):a=i;let o=this.createWriter(n,a),s=t.columns,c=`,`;if(a===`tsv`&&(c=`	`),a!==`html`){let n=t.toString(c);o.write(n)}else{o.print(`<html>`),o.print(`<head>`);let n=`  <meta http-equiv="content-type" content`;if(n+=`="text/html;charset=utf-8" />`,o.print(n),o.print(`</head>`),o.print(`<body>`),o.print(`  <table>`),s[0]!==`0`){o.print(`    <tr>`);for(let t=0;t<s.length;t++){let n=r(s[t]);o.print(`      <td>${n}`),o.print(`      </td>`)}o.print(`    </tr>`)}for(let n=0;n<t.rows.length;n++){o.print(`    <tr>`);for(let i=0;i<t.columns.length;i++){let a=r(t.rows[n].getString(i));o.print(`      <td>${a}`),o.print(`      </td>`)}o.print(`    </tr>`)}o.print(`  </table>`),o.print(`</body>`),o.print(`</html>`)}o.close(),o.clear()},n.writeFile=function(t,r,i){let a=`application/octet-stream`;n._isSafari()&&(a=`text/plain`);let o=new Blob(t,{type:a});n.downloadFile(o,r,i)},n.downloadFile=ua,n._checkFileExtension=da,n._isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}typeof p5<`u`&&Eo(p5,p5.prototype);var Do=(/* @__PURE__ */ s((t=>{var n=Object.defineProperty;(t=>n(t,`__esModule`,{value:!0}))(t),((t,r)=>{for(var i in r)n(t,i,{get:r[i],enumerable:!0})})(t,{GIFEncoder:()=>j,applyPalette:()=>C,default:()=>oe,nearestColor:()=>A,nearestColorIndex:()=>O,nearestColorIndexWithDistance:()=>k,prequantize:()=>S,quantize:()=>v,snapColorsToPalette:()=>E});var r={signature:`GIF`,version:`89a`,trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};function i(t=256){let n=0,r=new Uint8Array(t);return{get buffer(){return r.buffer},reset(){n=0},bytesView(){return r.subarray(0,n)},bytes(){return r.slice(0,n)},writeByte(t){i(n+1),r[n]=t,n++},writeBytes(t,a=0,o=t.length){i(n+o);for(let i=0;i<o;i++)r[n++]=t[i+a]},writeBytesView(t,a=0,o=t.byteLength){i(n+o),r.set(t.subarray(a,a+o),n),n+=o}};function i(t){var i=r.length;if(i>=t)return;t=Math.max(t,i*(i<1048576?2:1.125)>>>0),i!=0&&(t=Math.max(t,256));let a=r;r=new Uint8Array(t),n>0&&r.set(a.subarray(0,n),0)}}var a=12,o=5003,s=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function c(t,n,r,c,l=i(512),u=/* @__PURE__ */ new Uint8Array(256),d=new Int32Array(o),f=new Int32Array(o)){let p=d.length,m=Math.max(2,c);u.fill(0),f.fill(0),d.fill(-1);let h=0,g=0,_=m+1,v=_,y=!1,b=v,x=(1<<b)-1,S=1<<_-1,C=S+1,w=S+2,T=0,E=r[0],D=0;for(let t=p;t<65536;t*=2)++D;D=8-D,l.writeByte(m),k(S);let O=r.length;for(let t=1;t<O;t++)next_block:{let n=r[t],i=(n<<a)+E,o=n<<D^E;if(d[o]===i){E=f[o];break next_block}let s=o===0?1:p-o;for(;d[o]>=0;)if(o-=s,o<0&&(o+=p),d[o]===i){E=f[o];break next_block}k(E),E=n,w<1<<a?(f[o]=w++,d[o]=i):(d.fill(-1),w=S+2,y=!0,k(S))}return k(E),k(C),l.writeByte(0),l.bytesView();function k(t){for(h&=s[g],g>0?h|=t<<g:h=t,g+=b;g>=8;)u[T++]=h&255,T>=254&&(l.writeByte(T),l.writeBytesView(u,0,T),T=0),h>>=8,g-=8;if((w>x||y)&&(y?(b=v,x=(1<<b)-1,y=!1):(++b,x=b===a?1<<b:(1<<b)-1)),t==C){for(;g>0;)u[T++]=h&255,T>=254&&(l.writeByte(T),l.writeBytesView(u,0,T),T=0),h>>=8,g-=8;T>0&&(l.writeByte(T),l.writeBytesView(u,0,T),T=0)}}}var l=c;function u(t,n,r){return t<<8&63488|n<<2&992|r>>3}function d(t,n,r,i){return t>>4|n&240|(r&240)<<4|(i&240)<<8}function f(t,n,r){return t>>4<<8|n&240|r>>4}function p(t,n,r){return t<n?n:t>r?r:t}function m(t){return t*t}function h(t,n,r){var i=0,a=1e100;let o=t[n],s=o.cnt,c=o.ac,l=o.rc,u=o.gc,d=o.bc;for(var f=o.fw;f!=0;f=t[f].fw){let n=t[f],o=n.cnt,h=s*o/(s+o);if(!(h>=a)){var p=0;r&&(p+=h*m(n.ac-c),p>=a)||(p+=h*m(n.rc-l),!(p>=a)&&(p+=h*m(n.gc-u),!(p>=a)&&(p+=h*m(n.bc-d),!(p>=a)&&(a=p,i=f))))}}o.err=a,o.nn=i}function g(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}function _(t,n){let r=Array(n===`rgb444`?4096:65536),i=t.length;if(n===`rgba4444`)for(let n=0;n<i;++n){let i=t[n],a=i>>24&255,o=i>>16&255,s=i>>8&255,c=i&255,l=d(c,s,o,a),u=l in r?r[l]:r[l]=g();u.rc+=c,u.gc+=s,u.bc+=o,u.ac+=a,u.cnt++}else if(n===`rgb444`)for(let n=0;n<i;++n){let i=t[n],a=i>>16&255,o=i>>8&255,s=i&255,c=f(s,o,a),l=c in r?r[c]:r[c]=g();l.rc+=s,l.gc+=o,l.bc+=a,l.cnt++}else for(let n=0;n<i;++n){let i=t[n],a=i>>16&255,o=i>>8&255,s=i&255,c=u(s,o,a),l=c in r?r[c]:r[c]=g();l.rc+=s,l.gc+=o,l.bc+=a,l.cnt++}return r}function v(t,n,r={}){let{format:i=`rgb565`,clearAlpha:a=!0,clearAlphaColor:o=0,clearAlphaThreshold:s=0,oneBitAlpha:c=!1}=r;if(!t||!t.buffer||!(t instanceof Uint8Array)&&!(t instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);let l=new Uint32Array(t.buffer),u=r.useSqrt!==!1,d=i===`rgba4444`,f=_(l,i),g=f.length,v=g-1,b=new Uint32Array(g+1);for(var x=0,S=0;S<g;++S){let t=f[S];if(t!=null){var C=1/t.cnt;d&&(t.ac*=C),t.rc*=C,t.gc*=C,t.bc*=C,f[x++]=t}}m(n)/x<.022&&(u=!1);for(var S=0;S<x-1;++S)f[S].fw=S+1,f[S+1].bk=S,u&&(f[S].cnt=Math.sqrt(f[S].cnt));u&&(f[S].cnt=Math.sqrt(f[S].cnt));var w,T,E;for(S=0;S<x;++S){h(f,S,!1);var D=f[S].err;for(T=++b[0];T>1&&(E=T>>1,!(f[w=b[E]].err<=D));T=E)b[T]=w;b[T]=S}var O=x-n;for(S=0;S<O;){for(var k;;){var A=b[1];if(k=f[A],k.tm>=k.mtm&&f[k.nn].mtm<=k.tm)break;k.mtm==v?A=b[1]=b[b[0]--]:(h(f,A,!1),k.tm=S);var D=f[A].err;for(T=1;(E=T+T)<=b[0]&&(E<b[0]&&f[b[E]].err>f[b[E+1]].err&&E++,!(D<=f[w=b[E]].err));T=E)b[T]=w;b[T]=A}var j=f[k.nn],M=k.cnt,ee=j.cnt,C=1/(M+ee);d&&(k.ac=C*(M*k.ac+ee*j.ac)),k.rc=C*(M*k.rc+ee*j.rc),k.gc=C*(M*k.gc+ee*j.gc),k.bc=C*(M*k.bc+ee*j.bc),k.cnt+=j.cnt,k.mtm=++S,f[j.bk].fw=j.fw,f[j.fw].bk=j.bk,j.mtm=v}let te=[];var N=0;for(S=0;;++N){let t=p(Math.round(f[S].rc),0,255),n=p(Math.round(f[S].gc),0,255),r=p(Math.round(f[S].bc),0,255),i=255;d&&(i=p(Math.round(f[S].ac),0,255),c&&(i=i<=(typeof c==`number`?c:127)?0:255),a&&i<=s&&(t=n=r=o,i=0));let l=d?[t,n,r,i]:[t,n,r];if(y(te,l)||te.push(l),(S=f[S].fw)==0)break}return te}function y(t,n){for(let r=0;r<t.length;r++){let i=t[r],a=i[0]===n[0]&&i[1]===n[1]&&i[2]===n[2],o=i.length>=4&&n.length>=4?i[3]===n[3]:!0;if(a&&o)return!0}return!1}function b(t,n){for(var r=0,i=0;i<t.length;i++){let a=t[i]-n[i];r+=a*a}return r}function x(t,n){return n>1?Math.round(t/n)*n:t}function S(t,{roundRGB:n=5,roundAlpha:r=10,oneBitAlpha:i=null}={}){let a=new Uint32Array(t.buffer);for(let t=0;t<a.length;t++){let o=a[t],s=o>>24&255,c=o>>16&255,l=o>>8&255,u=o&255;s=x(s,r),i&&(s=s<=(typeof i==`number`?i:127)?0:255),u=x(u,n),l=x(l,n),c=x(c,n),a[t]=s<<24|c<<16|l<<8|u}}function C(t,n,r=`rgb565`){if(!t||!t.buffer||!(t instanceof Uint8Array)&&!(t instanceof Uint8ClampedArray))throw Error(`quantize() expected RGBA Uint8Array data`);if(n.length>256)throw Error(`applyPalette() only works with 256 colors or less`);let i=new Uint32Array(t.buffer),a=i.length,o=r===`rgb444`?4096:65536,s=new Uint8Array(a),c=Array(o);if(r===`rgba4444`)for(let t=0;t<a;t++){let r=i[t],a=r>>24&255,o=r>>16&255,l=r>>8&255,u=r&255,f=d(u,l,o,a),p=f in c?c[f]:c[f]=w(u,l,o,a,n);s[t]=p}else{let t=r===`rgb444`?f:u;for(let r=0;r<a;r++){let a=i[r],o=a>>16&255,l=a>>8&255,u=a&255,d=t(u,l,o),f=d in c?c[d]:c[d]=T(u,l,o,n);s[r]=f}}return s}function w(t,n,r,i,a){let o=0,s=1e100;for(let c=0;c<a.length;c++){let l=a[c],u=l[3],d=D(u-i);if(d>s)continue;let f=l[0];if(d+=D(f-t),d>s)continue;let p=l[1];if(d+=D(p-n),d>s)continue;let m=l[2];d+=D(m-r),!(d>s)&&(s=d,o=c)}return o}function T(t,n,r,i){let a=0,o=1e100;for(let s=0;s<i.length;s++){let c=i[s],l=c[0],u=D(l-t);if(u>o)continue;let d=c[1];if(u+=D(d-n),u>o)continue;let f=c[2];u+=D(f-r),!(u>o)&&(o=u,a=s)}return a}function E(t,n,r=5){if(!t.length||!n.length)return;let i=t.map(t=>t.slice(0,3)),a=r*r,o=t[0].length;for(let r=0;r<n.length;r++){let s=n[r];s=s.length<o?[s[0],s[1],s[2],255]:s.length>o?s.slice(0,3):s.slice();let c=k(i,s.slice(0,3),b),l=c[0],u=c[1];u>0&&u<=a&&(t[l]=s)}}function D(t){return t*t}function O(t,n,r=b){let i=1/0,a=-1;for(let o=0;o<t.length;o++){let s=t[o],c=r(n,s);c<i&&(i=c,a=o)}return a}function k(t,n,r=b){let i=1/0,a=-1;for(let o=0;o<t.length;o++){let s=t[o],c=r(n,s);c<i&&(i=c,a=o)}return[a,i]}function A(t,n,r=b){return t[O(t,n,r)]}function j(t={}){let{initialCapacity:n=4096,auto:a=!0}=t,o=i(n),s=5003,c=/* @__PURE__ */ new Uint8Array(256),l=new Int32Array(s),u=new Int32Array(s),d=!1;return{reset(){o.reset(),d=!1},finish(){o.writeByte(r.trailer)},bytes(){return o.bytes()},bytesView(){return o.bytesView()},get buffer(){return o.buffer},get stream(){return o},writeHeader:f,writeFrame(t,n,r,i={}){let{transparent:s=!1,transparentIndex:p=0,delay:m=0,palette:h=null,repeat:g=0,colorDepth:_=8,dispose:v=-1}=i,y=!1;if(a?d||=(y=!0,f(),!0):y=!!i.first,n=Math.max(0,Math.floor(n)),r=Math.max(0,Math.floor(r)),y){if(!h)throw Error(`First frame must include a { palette } option`);ee(o,n,r,h,_),N(o,h),g>=0&&te(o,g)}let b=Math.round(m/10);M(o,v,b,s,p);let x=!!h&&!y;ne(o,n,r,x?h:null),x&&N(o,h),re(o,t,n,r,_,c,l,u)}};function f(){P(o,`GIF89a`)}}function M(t,n,r,i,a){t.writeByte(33),t.writeByte(249),t.writeByte(4),a<0&&(a=0,i=!1);var o,s;i?(o=1,s=2):(o=0,s=0),n>=0&&(s=n&7),s<<=2,t.writeByte(s|0|o),ie(t,r),t.writeByte(a||0),t.writeByte(0)}function ee(t,n,r,i,a=8){let o=ae(i.length)-1,s=a-1<<4|128|o;ie(t,n),ie(t,r),t.writeBytes([s,0,0])}function te(t,n){t.writeByte(33),t.writeByte(255),t.writeByte(11),P(t,`NETSCAPE2.0`),t.writeByte(3),t.writeByte(1),ie(t,n),t.writeByte(0)}function N(t,n){let r=1<<ae(n.length);for(let i=0;i<r;i++){let r=[0,0,0];i<n.length&&(r=n[i]),t.writeByte(r[0]),t.writeByte(r[1]),t.writeByte(r[2])}}function ne(t,n,r,i){if(t.writeByte(44),ie(t,0),ie(t,0),ie(t,n),ie(t,r),i){let n=ae(i.length)-1;t.writeByte(128|n)}else t.writeByte(0)}function re(t,n,r,i,a=8,o,s,c){l(r,i,n,a,t,o,s,c)}function ie(t,n){t.writeByte(n&255),t.writeByte(n>>8&255)}function P(t,n){for(var r=0;r<n.length;r++)t.writeByte(n.charCodeAt(r))}function ae(t){return Math.max(Math.ceil(Math.log2(t)),1)}var oe=j})))();function Oo(t,n){t.MAX_GIF_PIXELS=16e6,n.loadImage=async function(n,r,i){try{let i=new t.Image(1,1,this),{data:o,headers:s}=await To(new Request(n,{method:`GET`,mode:`cors`}),`bytes`),c=s.get(`content-type`);if(c===null&&console.warn(`The image you loaded does not have a Content-Type header. If you are using the online editor consider reuploading the asset.`),c&&c.includes(`image/gif`))await a(o,i);else{let t=await new Promise((t,n)=>{let r=new Image,i=new Blob([o],{type:c}),a=URL.createObjectURL(i);r.onerror=t=>{URL.revokeObjectURL(a),n(t)},r.onload=()=>{URL.revokeObjectURL(a),t(r)},r.src=a});i.width=i.canvas.width=t.width,i.height=i.canvas.height=t.height,i.drawingContext.drawImage(t,0,0)}let l=()=>(i.modified=!0,r?r(i):i);return this._internal?this._internal(l):l()}catch(t){if(typeof i==`function`)return i(t);throw t}},n.saveGif=async function(a,o,s={delay:0,units:`seconds`,silent:!1,notificationDuration:0,notificationID:`progressBar`,reset:!0}){if(typeof a!=`string`)throw TypeError(`fileName parameter must be a string`);if(typeof o!=`number`)throw TypeError(`Duration parameter must be a number`);let c=s&&s.delay||0,l=s&&s.units||`seconds`,u=s&&s.silent||!1,d=s&&s.notificationDuration||0,f=s&&s.notificationID||`progressBar`,p=s&&s.reset!==void 0?s.reset:!0;if(typeof c!=`number`)throw TypeError(`Delay parameter must be a number`);if(l!==`seconds`&&l!==`frames`)throw TypeError(`Units parameter must be either "frames" or "seconds"`);if(typeof u!=`boolean`)throw TypeError(`Silent parameter must be a boolean`);if(typeof d!=`number`)throw TypeError(`Notification duration parameter must be a number`);if(typeof f!=`string`)throw TypeError(`Notification ID parameter must be a string`);this._recording=!0;let m=this._targetFrameRate;(m===1/0||m===void 0||m===0)&&(m=60);let h=1/m*1e3;h=h<20?20:h;let g=l===`seconds`?o*m:o,_=l===`seconds`?c*m:c,v,y;p?(v=_,this.frameCount=v,y=g+_):(v=this.frameCount+_,y=v+g);let b=this._renderer._pixelDensity;this.pixelDensity(1);let x=[];document.getElementById(f)!==null&&document.getElementById(f).remove();let S;u||(S=this.createP(``),S.id(f),S.style(`font-size`,`16px`),S.style(`font-family`,`Montserrat`),S.style(`background-color`,`#ffffffa0`),S.style(`padding`,`8px`),S.style(`border-radius`,`10px`),S.position(0,0));let C,w;for(this._renderer instanceof t.RendererGL&&(w=this.drawingContext,C=new Uint8Array(w.drawingBufferWidth*w.drawingBufferHeight*4)),this.noLoop(),await new Promise(requestAnimationFrame);v<y;){this.redraw(),await new Promise(requestAnimationFrame);let n;this._renderer instanceof t.RendererGL?(C=new Uint8Array(w.drawingBufferWidth*w.drawingBufferHeight*4),w.readPixels(0,0,w.drawingBufferWidth,w.drawingBufferHeight,w.RGBA,w.UNSIGNED_BYTE,C),n=r(C,this.width,this.height)):n=this.drawingContext.getImageData(0,0,this.width,this.height).data,x.push(n),v++,u||S.html(`Saved frame <b>`+x.length.toString()+`</b> out of `+g.toString()),await new Promise(t=>setTimeout(t,0))}u||S.html(`Frames processed, generating color palette...`),this.loop(),this.pixelDensity(b);let T=(0,Do.GIFEncoder)(),E=i(x),D={},O=t=>{let n=t.length/4,r=new Uint8Array(n);for(let i=0;i<n;i++){let n=t[i*4]<<24|t[i*4+1]<<16|t[i*4+2]<<8|t[i*4+3];D[n]===void 0&&(D[n]=(0,Do.nearestColorIndex)(E,t.slice(i*4,(i+1)*4))),r[i]=D[n]}return r},k=E.length-1,A=[];for(let t=0;t<x.length;t++){let n=O(x[t]),r=n.slice();if(t===0)T.writeFrame(n,this.width,this.height,{palette:E,delay:h,dispose:1});else{for(let t=0;t<n.length;t++)n[t]===A[t]&&(n[t]=k);T.writeFrame(n,this.width,this.height,{delay:h,transparent:!0,transparentIndex:k,dispose:1})}A=r,u||S.html(`Rendered frame <b>`+t.toString()+`</b> out of `+g.toString()),await new Promise(t=>setTimeout(t,0))}T.finish();let j=T.bytesView(),M=new Blob([j],{type:`image/gif`});x=[],this._recording=!1,this.loop(),u||(S.html(`Done. Downloading your gif!🌸`),d>0&&setTimeout(()=>S.remove(),d*1e3)),n.downloadFile(M,a,`gif`)};function r(t,n,r){let i=parseInt(r/2),a=n*4,o=new Uint8Array(n*4);for(let n=0;n<i;++n){let i=n*a,s=(r-n-1)*a;o.set(t.subarray(i,i+a)),t.copyWithin(i,s,s+a),t.set(o,s)}return t}function i(t){let n=new Uint8Array(t.length*t[0].length);for(let r=0;r<t.length;r++)n.set(t[r],r*t[0].length);let r=(0,Do.quantize)(n,256,{format:`rgba4444`,oneBitAlpha:!0});return r.length===256?r[r.length-1]=[Math.random()*255,Math.random()*255,Math.random()*255,0]:r.push([Math.random()*255,Math.random()*255,Math.random()*255,0]),r}async function a(n,r){let i=new go.GifReader(n);r.width=r.canvas.width=i.width,r.height=r.canvas.height=i.height;let a=[],o=i.numFrames();if(r.width*r.height>t.MAX_GIF_PIXELS)throw t.FES.log`The GIF is over the maximum allowed dimension. Try to shrink the image or set p5.MAX_GIF_PIXELS to a higher value.`(),Error(`The GIF is over the maximum allowed dimension.`);let s=new Uint8ClampedArray(r.width*r.height*4),c=(n,r)=>{try{r.decodeAndBlitFrameRGBA(n,s)}catch(n){throw t.FES.log`There was some trouble loading your GIF. Make sure that your GIF is using 87a or 89a encoding.`(),n}};for(let t=0;t<o;t++){let n=i.frameInfo(t),o=r.drawingContext.getImageData(0,0,r.width,r.height);s=o.data.slice(),c(t,i);let l=new ImageData(s,r.width,r.height);r.drawingContext.putImageData(l,0,0);let u=n.delay;u===0&&(u=10),a.push({image:r.drawingContext.getImageData(0,0,r.width,r.height),delay:u*10}),n.disposal===2?r.drawingContext.clearRect(n.x,n.y,n.width,n.height):n.disposal===3&&r.drawingContext.putImageData(o,0,0,n.x,n.y,n.width,n.height)}let l=i.loopCount();return l===null?l=1:l===0&&(l=null),r.drawingContext.putImageData(a[0].image,0,0),a.length>1&&(r.gifProperties={displayIndex:0,loopLimit:l,loopCount:0,frames:a,numFrames:o,playing:!0,timeDisplayed:0,lastChangeTime:0}),r}function o(t,n,r,i,a,o,s,c){let l=Math.max(s/a,c/o),[u,d]=[s/l,c/l],f=r,p=i;return t===`center`?f+=(a-u)/2:t===`right`&&(f+=a-u),n===`center`?p+=(o-d)/2:n===`bottom`&&(p+=o-d),{x:f,y:p,w:u,h:d}}function s(t,n,r,i,a,o,s,c){let l=Math.max(r/s,i/c),[u,d]=[r/l,i/l],f=a,p=o;return t===`center`?f+=(s-u)/2:t===`right`&&(f+=s-u),n===`center`?p+=(c-d)/2:n===`bottom`&&(p+=c-d),{x:f,y:p,w:u,h:d}}function c(t,n,r,i,a,c,l,u,d,f,p){if(t===`cover`){let{x:t,y:i,w:a,h:o}=s(n,r,c,l,u,d,f,p);u=t,d=i,f=a,p=o}if(t===`contain`){let{x:t,y:s,w:u,h:d}=o(n,r,i,a,c,l,f,p);i=t,a=s,c=u,l=d}return{sx:u,sy:d,sw:f,sh:p,dx:i,dy:a,dw:c,dh:l}}function l(t,n){return t>0&&t<n?t:n}n.image=function(t,n,r,i,a,o,s,u,d,f,p,m){let h=t.width,g=t.height;m||=`center`,p||=`center`,t.elt&&(h=h===void 0?t.elt.width:h,g=g===void 0?t.elt.height:g),t.elt&&t.elt.videoWidth&&!t.canvas&&(h=h===void 0?t.elt.videoWidth:h,g=g===void 0?t.elt.videoHeight:g);let _=n,v=r,y=i||h,b=a||g,x=o||0,S=s||0,C=u===void 0?h:u,w=d===void 0?g:d;C=l(C,h),w=l(w,g);let T=1;t.elt&&!t.canvas&&t.elt.style.width&&(T=t.elt.videoWidth&&!i?t.elt.videoWidth:t.elt.width,T/=parseInt(t.elt.style.width,10)),x*=T,S*=T,w*=T,C*=T;let E=lo.modeAdjust(_,v,y,b,this._renderer.states.imageMode);E=c(f,p,m,E.x,E.y,E.w,E.h,x,S,C,w),this._renderer.image(t,E.sx,E.sy,E.sw,E.sh,E.dx,E.dy,E.dw,E.dh)},n.tint=function(...t){return t.length===0?this._renderer.states.tint:(this._renderer.states.setValue(`tint`,this.color(...t)),this)},n.noTint=function(){return this._renderer.states.setValue(`tint`,null),this},n.imageMode=function(t){if(t===void 0)return this._renderer.states.imageMode;(t===`corner`||t===`corners`||t===`center`)&&this._renderer.states.setValue(`imageMode`,t)}}typeof p5<`u`&&Oo(p5,p5.prototype);function ko(t,n){n.blend=function(...n){this._renderer?this._renderer.blend(...n):t.Renderer2D.prototype.blend.apply(this,n)},n.copy=function(...t){let r,i,a,o,s,c,l,u,d;if(t.length===9)r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8];else if(t.length===8)r=this,i=t[0],a=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7];else throw Error(`Signature not supported`);n._copyHelper(this,r,i,a,o,s,c,l,u,d)},n._copyHelper=(t,n,r,i,a,o,s,c,l,u)=>{let d=n.canvas.width/n.width,f=0,p=0;n._renderer&&n._renderer.isP3D&&(f=n.width/2,p=n.height/2),t._renderer&&t._renderer.isP3D?(t.push(),t.resetMatrix(),t.noLights(),t.blendMode(t.BLEND),t.imageMode(t.CORNER),t._renderer.image(n,r+f,i+p,a,o,s,c,l,u),t.pop()):t.drawingContext.drawImage(n.canvas,d*(r+f),d*(i+p),d*a,d*o,s,c,l,u)},n.getFilterGraphicsLayer=function(){return this._renderer.getFilterGraphicsLayer()},n.filter=function(...t){let{shader:n,operation:i,value:a,useWebGL:o}=r(...t);this._renderer.isP3D&&n?this._renderer.filter(n):!o&&!this._renderer.isP3D?this.canvas===void 0?ra.apply(this.elt,ra[i],a):ra.apply(this.canvas,ra[i],a):(!o&&this._renderer.isP3D&&console.warn(`filter() with useWebGL=false is not supported in WEBGL`),this._renderer.isP3D?this._renderer.filter(i,a):(n?this._renderer.filterRenderer.setOperation(i,a,n):this._renderer.filterRenderer.setOperation(i,a),this._renderer.filterRenderer.applyFilter()))};function r(...n){let r={shader:void 0,operation:void 0,value:void 0,useWebGL:!0};return n[0]instanceof t.Shader?(r.shader=n[0],r):(r.operation=n[0],n.length>1&&typeof n[1]==`number`&&(r.value=n[1]),n[n.length-1]===!1&&(r.useWebGL=!1),r)}n.get=function(t,n,r,i){return this._renderer.get(...arguments)},n.loadPixels=function(...t){return this._renderer.loadPixels()},n.set=function(t,n,r){this._renderer.set(t,n,r)},n.updatePixels=function(t,n,r,i){this.pixels.length!==0&&this._renderer.updatePixels(t,n,r,i)}}typeof p5<`u`&&ko(p5,p5.prototype);var Ao=class t{constructor(...n){if(this.constructor===t)throw Error(`Class is of abstract type and can't be instantiated`)}};const jo=t=>{if(Math.sqrt(t.length)%1!=0)throw Error(`Array length must be a perfect square.`);return!0};let Mo=Array,No=t=>Array.isArray(t);typeof Float32Array<`u`&&(Mo=Float32Array,No=t=>Array.isArray(t)||t instanceof Float32Array);var Po=class t extends Ao{matrix;#e;isMatrix=!0;constructor(...t){if(super(...t),No(t[0])&&jo(t[0])){let n=Math.sqrt(t[0].length);this.#e=n,this.matrix=Mo.from(t[0])}else typeof t[0]==`number`&&(this.#e=Number(t[0]),this.matrix=this.#t(t[0]));return this}get mat3(){if(this.#e===3)return this.matrix}get mat4(){if(this.#e===4)return this.matrix}add(t){if(this.matrix.length!==t.matrix.length)throw Error(`Matrices must be of the same dimension to add.`);for(let n=0;n<this.matrix.length;n++)this.matrix[n]+=t.matrix[n];return this}setElement(t,n){return t>=0&&t<this.matrix.length&&(this.matrix[t]=n),this}reset(){return this.matrix=this.#t(this.#e),this}set(n){let r=Mo.from([...arguments]);return n instanceof t?r=Mo.from(n.matrix):No(n)&&(r=Mo.from(n)),r.length===this.matrix.length?(this.matrix=r,this):(this._friendlyError(`Expected same dimensions values but received different ${r.length}.`,`p5.Matrix.set`),this)}get(){return new t(this.matrix)}copy(){return new t(this.matrix)}clone(){return this.copy()}diagonal(){let t=[];for(let n=0;n<this.#e;n++)t.push(this.matrix[n*(this.#e+1)]);return t}row(t){let n=[];for(let r=0;r<this.#e;r++)n.push(this.matrix[r*this.#e+t]);return new I(...n)}column(t){let n=[];for(let r=0;r<this.#e;r++)n.push(this.matrix[t*this.#e+r]);return new I(...n)}transpose(t){return this.#e===4?this.#o(t):this.#e===3?this.#s(t):this.#a(t)}mult(n){let r;if(n===this||n===this.matrix)r=this.copy().matrix;else if(n instanceof t)r=n.matrix;else if(No(n)&&jo(n))r=n;else if(jo(Array.from(arguments)))r=Array.from(arguments);else return;return this.#e===4&&r.length===16?this.#n(r):this.#e===3&&r.length===9?this.#i(r):this.#r(r)}multiplyVec(t,n){n===void 0&&(n=t.copy());for(let r=0;r<this.#e;r++)n.values[r]=this.row(r).dot(t);return n}invert(t){if(this.#e===4)return this.#c(t);if(this.#e===3)return this.#l(t);throw Error(`Invert is not implemented for N>4 at the moment, we are working on it`)}createSubMatrix3x3(){if(this.#e===4){let n=new t(3);return n.mat3[0]=this.matrix[0],n.mat3[1]=this.matrix[1],n.mat3[2]=this.matrix[2],n.mat3[3]=this.matrix[4],n.mat3[4]=this.matrix[5],n.mat3[5]=this.matrix[6],n.mat3[6]=this.matrix[8],n.mat3[7]=this.matrix[9],n.mat3[8]=this.matrix[10],n}throw Error(`Matrix dimension must be 4 to create a 3x3 submatrix.`)}inverseTranspose4x4({mat4:t}){if(this.#e!==3)throw Error(`This function only works with 3×3 matrices.`);this.matrix[0]=t[0],this.matrix[1]=t[1],this.matrix[2]=t[2],this.matrix[3]=t[4],this.matrix[4]=t[5],this.matrix[5]=t[6],this.matrix[6]=t[8],this.matrix[7]=t[9],this.matrix[8]=t[10];let n=this.invert();if(n)n.transpose(this.matrix);else for(let t=0;t<9;t++)this.matrix[t]=0;return this}apply(n){let r;if(n===this||n===this.matrix)r=this.copy().matrix;else if(n instanceof t)r=n.matrix;else if(No(n))r=n;else if(arguments.length===16)r=arguments;else return;let i=this.matrix,a=i[0],o=i[4],s=i[8],c=i[12];i[0]=r[0]*a+r[1]*o+r[2]*s+r[3]*c,i[4]=r[4]*a+r[5]*o+r[6]*s+r[7]*c,i[8]=r[8]*a+r[9]*o+r[10]*s+r[11]*c,i[12]=r[12]*a+r[13]*o+r[14]*s+r[15]*c;let l=i[1],u=i[5],d=i[9],f=i[13];i[1]=r[0]*l+r[1]*u+r[2]*d+r[3]*f,i[5]=r[4]*l+r[5]*u+r[6]*d+r[7]*f,i[9]=r[8]*l+r[9]*u+r[10]*d+r[11]*f,i[13]=r[12]*l+r[13]*u+r[14]*d+r[15]*f;let p=i[2],m=i[6],h=i[10],g=i[14];i[2]=r[0]*p+r[1]*m+r[2]*h+r[3]*g,i[6]=r[4]*p+r[5]*m+r[6]*h+r[7]*g,i[10]=r[8]*p+r[9]*m+r[10]*h+r[11]*g,i[14]=r[12]*p+r[13]*m+r[14]*h+r[15]*g;let _=i[3],v=i[7],y=i[11],b=i[15];return i[3]=r[0]*_+r[1]*v+r[2]*y+r[3]*b,i[7]=r[4]*_+r[5]*v+r[6]*y+r[7]*b,i[11]=r[8]*_+r[9]*v+r[10]*y+r[11]*b,i[15]=r[12]*_+r[13]*v+r[14]*y+r[15]*b,this}scale(t,n,r){return t instanceof I?(n=t.y,r=t.z,t=t.x):t instanceof Array&&(n=t[1],r=t[2],t=t[0]),this.matrix[0]*=t,this.matrix[1]*=t,this.matrix[2]*=t,this.matrix[3]*=t,this.matrix[4]*=n,this.matrix[5]*=n,this.matrix[6]*=n,this.matrix[7]*=n,this.matrix[8]*=r,this.matrix[9]*=r,this.matrix[10]*=r,this.matrix[11]*=r,this}rotate4x4(t,n,r,i){n instanceof I?(r=n.y,i=n.z,n=n.x):n instanceof Array&&(r=n[1],i=n[2],n=n[0]);let a=Math.sqrt(n*n+r*r+i*i);n*=1/a,r*=1/a,i*=1/a;let o=this.matrix[0],s=this.matrix[1],c=this.matrix[2],l=this.matrix[3],u=this.matrix[4],d=this.matrix[5],f=this.matrix[6],p=this.matrix[7],m=this.matrix[8],h=this.matrix[9],g=this.matrix[10],_=this.matrix[11],v=Math.sin(t),y=Math.cos(t),b=1-y,x=n*n*b+y,S=r*n*b+i*v,C=i*n*b-r*v,w=n*r*b-i*v,T=r*r*b+y,E=i*r*b+n*v,D=n*i*b+r*v,O=r*i*b-n*v,k=i*i*b+y;return this.matrix[0]=o*x+u*S+m*C,this.matrix[1]=s*x+d*S+h*C,this.matrix[2]=c*x+f*S+g*C,this.matrix[3]=l*x+p*S+_*C,this.matrix[4]=o*w+u*T+m*E,this.matrix[5]=s*w+d*T+h*E,this.matrix[6]=c*w+f*T+g*E,this.matrix[7]=l*w+p*T+_*E,this.matrix[8]=o*D+u*O+m*k,this.matrix[9]=s*D+d*O+h*k,this.matrix[10]=c*D+f*O+g*k,this.matrix[11]=l*D+p*O+_*k,this}translate(t){let n=t[0],r=t[1],i=t[2]||0;return this.matrix[12]+=this.matrix[0]*n+this.matrix[4]*r+this.matrix[8]*i,this.matrix[13]+=this.matrix[1]*n+this.matrix[5]*r+this.matrix[9]*i,this.matrix[14]+=this.matrix[2]*n+this.matrix[6]*r+this.matrix[10]*i,this.matrix[15]+=this.matrix[3]*n+this.matrix[7]*r+this.matrix[11]*i,this}rotateX(t){this.rotate4x4(t,1,0,0)}rotateY(t){this.rotate4x4(t,0,1,0)}rotateZ(t){this.rotate4x4(t,0,0,1)}perspective(t,n,r,i){let a=1/Math.tan(t/2),o=1/(r-i);return this.matrix[0]=a/n,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=a,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=(i+r)*o,this.matrix[11]=-1,this.matrix[12]=0,this.matrix[13]=0,this.matrix[14]=2*i*r*o,this.matrix[15]=0,this}ortho(t,n,r,i,a,o){let s=1/(t-n),c=1/(r-i),l=1/(a-o);return this.matrix[0]=-2*s,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=-2*c,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=2*l,this.matrix[11]=0,this.matrix[12]=(t+n)*s,this.matrix[13]=(i+r)*c,this.matrix[14]=(o+a)*l,this.matrix[15]=1,this}multiplyVec4(t,n,r,i){let a=[,,,,],o=this.matrix;return a[0]=o[0]*t+o[4]*n+o[8]*r+o[12]*i,a[1]=o[1]*t+o[5]*n+o[9]*r+o[13]*i,a[2]=o[2]*t+o[6]*n+o[10]*r+o[14]*i,a[3]=o[3]*t+o[7]*n+o[11]*r+o[15]*i,a}multiplyPoint({x:t,y:n,z:r}){let i=this.multiplyVec4(t,n,r,1);return new I(i[0],i[1],i[2])}multiplyAndNormalizePoint({x:t,y:n,z:r}){let i=this.multiplyVec4(t,n,r,1);return i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],new I(i[0],i[1],i[2])}multiplyDirection({x:t,y:n,z:r}){let i=this.multiplyVec4(t,n,r,0);return new I(i[0],i[1],i[2])}multiplyVec3(t,n){return n===void 0&&(n=t.copy()),n.x=this.row(0).dot(t),n.y=this.row(1).dot(t),n.z=this.row(2).dot(t),n}#t(t){if(t===3)return new Mo([1,0,0,0,1,0,0,0,1]);if(t===4)return new Mo([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);let n=new Mo(t*t).fill(0);for(let r=0;r<t;r++)n[r*t+r]=1;return n}#n(t){let n=this.matrix[0],r=this.matrix[1],i=this.matrix[2],a=this.matrix[3];return this.matrix[0]=n*t[0]+r*t[4]+i*t[8]+a*t[12],this.matrix[1]=n*t[1]+r*t[5]+i*t[9]+a*t[13],this.matrix[2]=n*t[2]+r*t[6]+i*t[10]+a*t[14],this.matrix[3]=n*t[3]+r*t[7]+i*t[11]+a*t[15],n=this.matrix[4],r=this.matrix[5],i=this.matrix[6],a=this.matrix[7],this.matrix[4]=n*t[0]+r*t[4]+i*t[8]+a*t[12],this.matrix[5]=n*t[1]+r*t[5]+i*t[9]+a*t[13],this.matrix[6]=n*t[2]+r*t[6]+i*t[10]+a*t[14],this.matrix[7]=n*t[3]+r*t[7]+i*t[11]+a*t[15],n=this.matrix[8],r=this.matrix[9],i=this.matrix[10],a=this.matrix[11],this.matrix[8]=n*t[0]+r*t[4]+i*t[8]+a*t[12],this.matrix[9]=n*t[1]+r*t[5]+i*t[9]+a*t[13],this.matrix[10]=n*t[2]+r*t[6]+i*t[10]+a*t[14],this.matrix[11]=n*t[3]+r*t[7]+i*t[11]+a*t[15],n=this.matrix[12],r=this.matrix[13],i=this.matrix[14],a=this.matrix[15],this.matrix[12]=n*t[0]+r*t[4]+i*t[8]+a*t[12],this.matrix[13]=n*t[1]+r*t[5]+i*t[9]+a*t[13],this.matrix[14]=n*t[2]+r*t[6]+i*t[10]+a*t[14],this.matrix[15]=n*t[3]+r*t[7]+i*t[11]+a*t[15],this}#r(t){if(t.length!==this.matrix.length)throw Error(`Matrices must be of the same dimension to multiply.`);let n=new Mo(this.matrix.length).fill(0);for(let r=0;r<this.#e;r++)for(let i=0;i<this.#e;i++)for(let a=0;a<this.#e;a++)n[r*this.#e+i]+=this.matrix[r*this.#e+a]*t[a*this.#e+i];return this.matrix=n,this}#i(t){let n=this.mat3[0],r=this.mat3[1],i=this.mat3[2];return this.mat3[0]=n*t[0]+r*t[3]+i*t[6],this.mat3[1]=n*t[1]+r*t[4]+i*t[7],this.mat3[2]=n*t[2]+r*t[5]+i*t[8],n=this.mat3[3],r=this.mat3[4],i=this.mat3[5],this.mat3[3]=n*t[0]+r*t[3]+i*t[6],this.mat3[4]=n*t[1]+r*t[4]+i*t[7],this.mat3[5]=n*t[2]+r*t[5]+i*t[8],n=this.mat3[6],r=this.mat3[7],i=this.mat3[8],this.mat3[6]=n*t[0]+r*t[3]+i*t[6],this.mat3[7]=n*t[1]+r*t[4]+i*t[7],this.mat3[8]=n*t[2]+r*t[5]+i*t[8],this}#a(){let t=this.#e;for(let n=0;n<t;n++)for(let r=0;r<t;r++)this.matrix[n*t+r]=this.matrix[r*t+n];return this}#o(n){console.log(`====> 4x4`);let r,i,a,o,s,c;return n instanceof t?(r=n.matrix[1],i=n.matrix[2],a=n.matrix[3],o=n.matrix[6],s=n.matrix[7],c=n.matrix[11],this.matrix[0]=n.matrix[0],this.matrix[1]=n.matrix[4],this.matrix[2]=n.matrix[8],this.matrix[3]=n.matrix[12],this.matrix[4]=r,this.matrix[5]=n.matrix[5],this.matrix[6]=n.matrix[9],this.matrix[7]=n.matrix[13],this.matrix[8]=i,this.matrix[9]=o,this.matrix[10]=n.matrix[10],this.matrix[11]=n.matrix[14],this.matrix[12]=a,this.matrix[13]=s,this.matrix[14]=c,this.matrix[15]=n.matrix[15]):No(n)&&(r=n[1],i=n[2],a=n[3],o=n[6],s=n[7],c=n[11],this.matrix[0]=n[0],this.matrix[1]=n[4],this.matrix[2]=n[8],this.matrix[3]=n[12],this.matrix[4]=r,this.matrix[5]=n[5],this.matrix[6]=n[9],this.matrix[7]=n[13],this.matrix[8]=i,this.matrix[9]=o,this.matrix[10]=n[10],this.matrix[11]=n[14],this.matrix[12]=a,this.matrix[13]=s,this.matrix[14]=c,this.matrix[15]=n[15]),this}#s(n){n instanceof t?n=n.mat3:n===void 0&&(n=this.mat3);let r=n[1],i=n[2],a=n[5];return this.mat3[0]=n[0],this.mat3[1]=n[3],this.mat3[2]=n[6],this.mat3[3]=r,this.mat3[4]=n[4],this.mat3[5]=n[7],this.mat3[6]=i,this.mat3[7]=a,this.mat3[8]=n[8],this}#c(n){let r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v;n instanceof t?(r=n.matrix[0],i=n.matrix[1],a=n.matrix[2],o=n.matrix[3],s=n.matrix[4],c=n.matrix[5],l=n.matrix[6],u=n.matrix[7],d=n.matrix[8],f=n.matrix[9],p=n.matrix[10],m=n.matrix[11],h=n.matrix[12],g=n.matrix[13],_=n.matrix[14],v=n.matrix[15]):No(n)&&(r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],d=n[8],f=n[9],p=n[10],m=n[11],h=n[12],g=n[13],_=n[14],v=n[15]);let y=r*c-i*s,b=r*l-a*s,x=r*u-o*s,S=i*l-a*c,C=i*u-o*c,w=a*u-o*l,T=d*g-f*h,E=d*_-p*h,D=d*v-m*h,O=f*_-p*g,k=f*v-m*g,A=p*v-m*_,j=y*A-b*k+x*O+S*D-C*E+w*T;return j?(j=1/j,this.matrix[0]=(c*A-l*k+u*O)*j,this.matrix[1]=(a*k-i*A-o*O)*j,this.matrix[2]=(g*w-_*C+v*S)*j,this.matrix[3]=(p*C-f*w-m*S)*j,this.matrix[4]=(l*D-s*A-u*E)*j,this.matrix[5]=(r*A-a*D+o*E)*j,this.matrix[6]=(_*x-h*w-v*b)*j,this.matrix[7]=(d*w-p*x+m*b)*j,this.matrix[8]=(s*k-c*D+u*T)*j,this.matrix[9]=(i*D-r*k-o*T)*j,this.matrix[10]=(h*C-g*x+v*y)*j,this.matrix[11]=(f*x-d*C-m*y)*j,this.matrix[12]=(c*E-s*O-l*T)*j,this.matrix[13]=(r*O-i*E+a*T)*j,this.matrix[14]=(g*b-h*S-_*y)*j,this.matrix[15]=(d*S-f*b+p*y)*j,this):null}#l(){let t=this.mat3[0],n=this.mat3[1],r=this.mat3[2],i=this.mat3[3],a=this.mat3[4],o=this.mat3[5],s=this.mat3[6],c=this.mat3[7],l=this.mat3[8],u=l*a-o*c,d=-l*i+o*s,f=c*i-a*s,p=t*u+n*d+r*f;return p?(p=1/p,this.mat3[0]=u*p,this.mat3[1]=(-l*n+r*c)*p,this.mat3[2]=(o*n-r*a)*p,this.mat3[3]=d*p,this.mat3[4]=(l*t-r*s)*p,this.mat3[5]=(-o*t+r*i)*p,this.mat3[6]=f*p,this.mat3[7]=(-c*t+n*s)*p,this.mat3[8]=(a*t-n*i)*p,this):null}};function Fo(t,n){Po.prototype._friendlyError=t._friendlyError,t.Matrix=Po}typeof p5<`u`&&Fo(p5,p5.prototype);var Io=class{constructor(t=128){this.length=0,this.data=new Float32Array(t),this.initialLength=t}dataArray(){return this.subArray(0,this.length)}clear(){this.length=0}rescale(){if(this.length<this.data.length/2){let t=1<<Math.ceil(Math.log2(this.length)),n=new Float32Array(t);n.set(this.data.subarray(0,this.length),0),this.data=n}}reset(){this.clear(),this.data=new Float32Array(this.initialLength)}push(...t){this.ensureLength(this.length+t.length),this.data.set(t,this.length),this.length+=t.length}slice(t,n){return this.data.slice(t,Math.min(n,this.length))}subArray(t,n){return this.data.subarray(t,Math.min(n,this.length))}ensureLength(t){for(;this.data.length<t;){let t=new Float32Array(this.data.length*2);t.set(this.data,0),this.data=t}}};function Lo(t,n){t.DataArray=Io}typeof p5<`u`&&Lo(p5,p5.prototype);function Ro(){return{fill:null,ambientColor:null,specularColor:null,shininess:null,texture:null,specularTexture:null,ambientTexture:null,shininessTexture:null,normalTexture:null,normalScale:1,normalMapMode:0}}function zo(t,n,r,i){let a=t.userVertexProperties[n]={name:n,dataSize:i||(r.length?r.length:1),geometry:t,getName(){return this.name},getCurrentData(){return this.currentData===void 0&&(this.currentData=Array(this.getDataSize()).fill(0)),this.currentData},getDataSize(){return this.dataSize},getSrcName(){return this.name.concat(`Src`)},getDstName(){return this.name.concat(`Buffer`)},getSrcArray(){return this.geometry[this.getSrcName()]},setCurrentData(t){this.currentData=t},pushCurrentData(){this.pushDirect(this.getCurrentData())},pushDirect(t){t.length?this.getSrcArray().push(...t):this.getSrcArray().push(t)},resetSrcArray(){this.geometry[this.getSrcName()]=[]},delete(){delete this.geometry[this.getSrcName()]}};return t[a.getSrcName()]=[],t.userVertexProperties[n]}var Bo=class{constructor(t,n){this.gid=t,this.vertices=[],this.vertexNormals=[],this.vertexTangents=[],this.faces=[],this.uvs=[],this.vertexColors=[],this.partState=n||Ro(),this.dirtyFlags={},this.userVertexProperties={}}vertexProperty(t,n,r){let i=this.userVertexProperties[t];i||=zo(this,t,n,r),r?i.pushDirect(n):(i.setCurrentData(n),i.pushCurrentData())}hasFillTransparency(){let t=this.partState&&this.partState.fill;if(t&&t[3]<1)return!0;for(let t=3;t<this.vertexColors.length;t+=4)if(this.vertexColors[t]<1)return!0;return!1}},Vo=class t{constructor(n,r,i,a){this.renderer=a,this.vertices=[],this.boundingBoxCache=null,this.lineVertices=new Io,this.lineTangentsIn=new Io,this.lineTangentsOut=new Io,this.lineSides=new Io,this.vertexNormals=[],this.vertexTangents=[],this.faces=[],this.uvs=[],this.edges=[],this.vertexColors=[],this.vertexStrokeColors=[],this.userVertexProperties={},this.lineVertexColors=new Io,this.detailX=n===void 0?1:n,this.detailY=r===void 0?1:r,this.dirtyFlags={},this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.gid=`_p5_Geometry_${t.nextId}`,t.nextId++,this.partState=Ro(),this.parts=[],i instanceof Function&&i.call(this),this.parts.length===0&&this._wrapInSinglePart()}_wrapInSinglePart(){this.parts=[this]}calculateBoundingBox(){if(this.boundingBoxCache)return this.boundingBoxCache;let t=new I(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new I(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(let r=0;r<this.vertices.length;r++){let i=this.vertices[r];t.x=Math.min(t.x,i.x),t.y=Math.min(t.y,i.y),t.z=Math.min(t.z,i.z),n.x=Math.max(n.x,i.x),n.y=Math.max(n.y,i.y),n.z=Math.max(n.z,i.z)}let r=new I(n.x-t.x,n.y-t.y,n.z-t.z),i=new I((t.x+n.x)/2,(t.y+n.y)/2,(t.z+n.z)/2);return this.boundingBoxCache={min:t,max:n,size:r,offset:i},this.boundingBoxCache}reset(){this.renderer?.onReset?.(this),this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear(),this.vertices.length=0,this.edges.length=0,this.vertexColors.length=0,this.vertexStrokeColors.length=0,this.lineVertexColors.clear(),this.vertexNormals.length=0,this.vertexTangents.length=0,this.uvs.length=0;for(let t in this.userVertexProperties)this.userVertexProperties[t].delete();this.userVertexProperties={},this.dirtyFlags={}}hasFillTransparency(){if(this._hasFillTransparency===void 0){this._hasFillTransparency=!1;for(let t=0;t<this.vertexColors.length;t+=4)if(this.vertexColors[t+3]<1){this._hasFillTransparency=!0;break}}return this._hasFillTransparency}hasStrokeTransparency(){if(this._hasStrokeTransparency===void 0){this._hasStrokeTransparency=!1;for(let t=0;t<this.lineVertexColors.length;t+=4)if(this.lineVertexColors[t+3]<1){this._hasStrokeTransparency=!0;break}}return this._hasStrokeTransparency}clearColors(){return this.vertexColors=[],this}saveObj(t=`model.obj`){let n=``;if(this.vertices.forEach(t=>{n+=`v ${t.x} ${t.y} ${t.z}\n`}),this.uvs&&this.uvs.length>0)for(let t=0;t<this.uvs.length;t+=2)n+=`vt ${this.uvs[t]} ${this.uvs[t+1]}\n`;this.vertexNormals&&this.vertexNormals.length>0&&this.vertexNormals.forEach(t=>{n+=`vn ${t.x} ${t.y} ${t.z}\n`}),this.faces.forEach(t=>{let r=`f`;t.forEach(t=>{r+=` `,r+=t+1,(this.vertexNormals.length>0||this.uvs.length>0)&&(r+=`/`,this.uvs.length>0&&(r+=t+1),r+=`/`,this.vertexNormals.length>0&&(r+=t+1))}),n+=r+`
`}),ua(new Blob([n],{type:`text/plain`}),t,`obj`)}saveStl(t=`model.stl`,{binary:n=!1}={}){let r,i=t.substring(0,t.lastIndexOf(`.`)),a=[];for(let t of this.faces){let n=I.sub(this.vertices[t[1]],this.vertices[t[0]]),r=I.sub(this.vertices[t[2]],this.vertices[t[0]]),i=n.y*r.z-n.z*r.y,o=n.z*r.x-n.x*r.z,s=n.x*r.y-n.y*r.x;a.push(new I(i,o,s).normalize())}if(n){let t=80,n=this.faces.length*2+this.faces.length*3*4*4+80+4,i=new ArrayBuffer(n);r=new DataView(i),r.setUint32(t,this.faces.length,!0),t+=4;for(let[n,i]of Object.entries(this.faces)){let o=a[n];r.setFloat32(t,o.x,!0),t+=4,r.setFloat32(t,o.y,!0),t+=4,r.setFloat32(t,o.z,!0),t+=4;for(let n of i){let i=this.vertices[n];r.setFloat32(t,i.x,!0),t+=4,r.setFloat32(t,i.y,!0),t+=4,r.setFloat32(t,i.z,!0),t+=4}r.setUint16(t,0,!0),t+=2}}else{r=`solid `+i+`
`;for(let[t,n]of Object.entries(this.faces)){let i=a[t];r+=` facet norm `+i.x+` `+i.y+` `+i.z+`
`,r+=`  outer loop
`;for(let t of n){let n=this.vertices[t];r+=`   vertex `+n.x+` `+n.y+` `+n.z+`
`}r+=`  endloop
`,r+=` endfacet
`}r+=`endsolid `+i+`
`}ua(new Blob([r],{type:`text/plain`}),t,`stl`)}flipU(){this.uvs=this.uvs.flat().map((t,n)=>n%2==0?1-t:t)}flipV(){this.uvs=this.uvs.flat().map((t,n)=>n%2==0?t:1-t)}computeFaces(){this.faces.length=0;let t=this.detailX+1,n,r,i,a;for(let o=0;o<this.detailY;o++)for(let s=0;s<this.detailX;s++)n=o*t+s,r=o*t+s+1,i=(o+1)*t+s+1,a=(o+1)*t+s,this.faces.push([n,r,a]),this.faces.push([a,r,i]);return this}_getFaceNormal(t){let n=this.faces[t],r=this.vertices[n[0]],i=this.vertices[n[1]],a=this.vertices[n[2]],o=I.sub(i,r),s=I.sub(a,r),c=I.cross(o,s),l=I.mag(c),u=l/(I.mag(o)*I.mag(s));return u===0||isNaN(u)?(console.warn(`p5.Geometry.prototype._getFaceNormal:`,`face has colinear sides or a repeated vertex`),c):(u>1&&(u=1),c.mult(Math.asin(u)/l))}computeNormals(t=xt,{roundToPrecision:n=3}={}){let r=this.vertexNormals,i=this.vertices,a=this.faces,o;if(t===`smooth`){let t={},s=[],c=[],l=10**n,u=t=>Math.round(t*l)/l,d=t=>`${u(t.x)},${u(t.y)},${u(t.z)}`;for(let n=0;n<i.length;n++){let r=i[n],a=d(r);t[a]===void 0&&(t[a]=s.length,s.push(r)),c[n]=t[a]}let f=[];for(o=0;o<s.length;++o)f.push(new I(0,0,0));for(a.forEach((t,n)=>{let r=this._getFaceNormal(n);for(let n=0;n<3;++n){let i=c[t[n]];f[i].add(r)}}),o=0;o<f.length;++o)f[o].normalize();for(r.length=0,o=0;o<i.length;++o)r.push(f[c[o]].copy())}else if(t===`segmented`){let t=/* @__PURE__ */ new Set,n=[],r=[...i],o=i.map(()=>new I(0,0,0)),s=this.uvs.flat(),c=[...s],l=[...this.vertexColors],u=[...this.vertexStrokeColors],d=[...this.vertexTangents],f={};for(let t in this.userVertexProperties)f[t]=[...this.userVertexProperties[t].getSrcArray()];a.forEach((a,p)=>{let m=this._getFaceNormal(p).normalize(),h=[];for(let n of a){let a=n;if(t.has(n)){a=r.length,r.push(i[n].copy()),o.push(m.copy()),s.length>0&&c.push(...s.slice(n*2,(n+1)*2)),this.vertexColors.length>0&&l.push(...this.vertexColors.slice(n*4,(n+1)*4)),this.vertexStrokeColors.length>0&&u.push(...this.vertexStrokeColors.slice(n*4,(n+1)*4)),this.vertexTangents.length>0&&d.push(...this.vertexTangents.slice(n*4,(n+1)*4));for(let t in this.userVertexProperties){let r=this.userVertexProperties[t],i=r.getDataSize(),a=r.getSrcArray();f[t].push(...a.slice(n*i,(n+1)*i))}}else t.add(n),o[n]=m.copy();h.push(a)}n.push(h)}),this.vertices=r,this.vertexNormals=o,this.faces=n,this.uvs=c,this.vertexColors=l,this.vertexStrokeColors=u,this.vertexTangents=d;for(let t in this.userVertexProperties){let n=this.userVertexProperties[t];this[n.getSrcName()]=f[t]}}else{for(r.length=0,o=0;o<i.length;++o)r.push(new I(0,0,0));for(a.forEach((t,n)=>{let i=this._getFaceNormal(n);for(let n=0;n<3;++n){let a=t[n];r[a].add(i)}}),o=0;o<i.length;++o)r[o].normalize()}return this}computeTangents(){let t=this.vertices,n=this.faces,r=this.uvs.flat(),i=this.vertexNormals;if(r.length===0||i.length===0)return this.vertexTangents=[],this;let a=[],o=[];for(let n=0;n<t.length;n++)a.push(new I(0,0,0)),o.push(new I(0,0,0));let s=t=>({x:r[t*2]||0,y:r[t*2+1]||0});for(let r of n){let[n,i,c]=r,l=I.sub(t[i],t[n]),u=I.sub(t[c],t[n]),d=s(n),f=s(i),p=s(c),m=f.x-d.x,h=f.y-d.y,g=p.x-d.x,_=p.y-d.y,v=m*_-g*h,y=v===0?0:1/v,b=I.sub(I.mult(l,_),I.mult(u,h)).mult(y),x=I.sub(I.mult(u,m),I.mult(l,g)).mult(y);for(let t of r)a[t].add(b),o[t].add(x)}let c=[];for(let n=0;n<t.length;n++){let t=i[n]||new I(0,0,1),r=I.sub(a[n],I.mult(t,t.dot(a[n])));if(r.magSq()===0){let n=Math.abs(t.x)<.9?new I(1,0,0):new I(0,1,0);r=I.sub(n,I.mult(t,t.dot(n)))}r.normalize();let s=I.cross(t,r).dot(o[n])<0?-1:1;c.push(r.x,r.y,r.z,s)}return this.vertexTangents=c,this}averageNormals(){for(let t=0;t<=this.detailY;t++){let n=this.detailX+1,r=I.add(this.vertexNormals[t*n],this.vertexNormals[t*n+this.detailX]);r=I.div(r,2),this.vertexNormals[t*n]=r,this.vertexNormals[t*n+this.detailX]=r}return this}averagePoleNormals(){let t=new I(0,0,0);for(let n=0;n<this.detailX;n++)t.add(this.vertexNormals[n]);t=I.div(t,this.detailX);for(let n=0;n<this.detailX;n++)this.vertexNormals[n]=t;t=new I(0,0,0);for(let n=this.vertices.length-1;n>this.vertices.length-1-this.detailX;n--)t.add(this.vertexNormals[n]);t=I.div(t,this.detailX);for(let n=this.vertices.length-1;n>this.vertices.length-1-this.detailX;n--)this.vertexNormals[n]=t;return this}_makeTriangleEdges(){this.edges.length=0;for(let t=0;t<this.faces.length;t++)this.edges.push([this.faces[t][0],this.faces[t][1]]),this.edges.push([this.faces[t][1],this.faces[t][2]]),this.edges.push([this.faces[t][2],this.faces[t][0]]);return this}makeEdgesFromFaces(){this._makeTriangleEdges()}_edgesToVertices(){this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear();let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r;for(let i=0;i<this.edges.length;i++){let a=this.edges[i-1],o=this.edges[i],s=o[0]===o[1],c=this.vertices[o[0]],l=this.vertices[o[1]],u=this.vertexStrokeColors.length>0&&a?this.vertexStrokeColors.slice(a[1]*4,(a[1]+1)*4):[0,0,0,0],d=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(o[0]*4,(o[0]+1)*4):[0,0,0,0],f=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(o[1]*4,(o[1]+1)*4):[0,0,0,0],p=s?new I(0,1,0):l.copy().sub(c).normalize(),m=p.magSq()>0;if(m&&this._addSegment(c,l,d,f,p),!this.renderer?._simpleLines){if(i>0&&a[1]===o[0])n.has(o[0])||(n.add(o[0]),t.delete(o[0]),r&&m&&p.dot(r)<1-1e-8&&this._addJoin(c,r,p,d));else if(s)this._addCap(c,p.copy().mult(-1),d),this._addCap(c,p,d);else{if(m&&!n.has(o[0])){let r=t.get(o[0]);r?(this._addJoin(c,r.dir,p,d),t.delete(o[0]),n.add(o[0])):t.set(o[0],{point:c,dir:p.copy().mult(-1),color:d})}if(!s&&r&&!n.has(a[1])){let i=t.get(a[1]);i?(this._addJoin(this.vertices[a[1]],r,i.dir.copy().mult(-1),u),t.delete(a[1]),n.add(a[1])):t.set(a[1],{point:this.vertices[a[1]],dir:r,color:u}),r=void 0}}if(i===this.edges.length-1&&!n.has(o[1])){let r=t.get(o[1]);r?(this._addJoin(l,p,r.dir.copy().mult(-1),f),t.delete(o[1]),n.add(o[1])):t.set(o[1],{point:l,dir:p,color:f})}m&&(r=p)}}for(let{point:n,dir:r,color:i}of t.values())this._addCap(n,r,i);return this}_addSegment(t,n,r,i,a){let o=t.array(),s=n.array(),c=a.array();this.lineSides.push(1,1,-1,1,-1,-1);for(let t of[this.lineTangentsIn,this.lineTangentsOut])for(let n=0;n<6;n++)t.push(...c);return this.lineVertices.push(...o,...s,...o,...s,...s,...o),this.renderer?._simpleLines||this.lineVertexColors.push(...r,...i,...r,...i,...i,...r),this}_addCap(t,n,r){let i=t.array(),a=n.array(),o=[0,0,0];for(let t=0;t<6;t++)this.lineVertices.push(...i),this.lineTangentsIn.push(...a),this.lineTangentsOut.push(...o),this.lineVertexColors.push(...r);return this.lineSides.push(-1,2,-2,1,2,-1),this}_addJoin(t,n,r,i){let a=t.array(),o=n.array(),s=r.array();for(let t=0;t<12;t++)this.lineVertices.push(...a),this.lineTangentsIn.push(...o),this.lineTangentsOut.push(...s),this.lineVertexColors.push(...i);return this.lineSides.push(-1,-3,-2,-1,0,-3),this.lineSides.push(3,1,2,3,0,1),this}normalize(){if(this.vertices.length>0){let t=this.vertices[0].copy(),n=this.vertices[0].copy();for(let r=0;r<this.vertices.length;r++)t.x=Math.max(t.x,this.vertices[r].x),n.x=Math.min(n.x,this.vertices[r].x),t.y=Math.max(t.y,this.vertices[r].y),n.y=Math.min(n.y,this.vertices[r].y),t.z=Math.max(t.z,this.vertices[r].z),n.z=Math.min(n.z,this.vertices[r].z);let r=I.lerp(t,n,.5),i=I.sub(t,n),a=200/Math.max(Math.max(i.x,i.y),i.z);for(let t=0;t<this.vertices.length;t++)this.vertices[t].sub(r),this.vertices[t].mult(a)}return this}vertexProperty(t,n,r){let i;this.userVertexProperties[t]||(i=this.userVertexProperties[t]=this._userVertexPropertyHelper(t,n,r)),i=this.userVertexProperties[t],r?i.pushDirect(n):(i.setCurrentData(n),i.pushCurrentData())}_userVertexPropertyHelper(t,n,r){return zo(this,t,n,r)}};Vo.nextId=0;function Ho(t,n){t.Geometry=Vo,t.GeometryPart=Bo}typeof p5<`u`&&Ho(p5,p5.prototype);var Uo=class t{constructor(n){this.renderer=n,n._pInst.push(),this.identityMatrix=new Po(4),n.states.setValue(`uModelMatrix`,new Po(4)),this.geometry=new Vo(void 0,void 0,void 0,this.renderer),this.geometry.gid=`_p5_GeometryBuilder_${t.nextGeometryId}`,t.nextGeometryId++,this.hasTransform=!1,this.parts=[],this.currentPart=null}transformVertices(t){return this.hasTransform?t.map(t=>this.renderer.states.uModelMatrix.multiplyPoint(t)):t}transformNormals(t){return this.hasTransform?t.map(t=>this.renderer.scratchMat3.multiplyVec(t)):t}addGeometry(t){this.hasTransform=!this.renderer.states.uModelMatrix.mat4.every((t,n)=>t===this.identityMatrix.mat4[n]),this.hasTransform&&this.renderer.scratchMat3.inverseTranspose4x4(this.renderer.states.uModelMatrix);let n=this.transformVertices(t.vertices),r=this.transformNormals(t.vertexNormals),i=this.geometry.vertices.length;for(let t of n)this.geometry.vertices.push(t);for(let t of r)this.geometry.vertexNormals.push(t);for(let n of t.uvs)this.geometry.uvs.push(n);let a=t.userVertexProperties,o=this.geometry.userVertexProperties,s=this.geometry.vertices.length-t.vertices.length;for(let n in o){if(n in a)continue;let r=o[n],i=r.getDataSize()*t.vertices.length,s=Array(i).fill(0);r.pushDirect(s)}for(let t in a){let n=a[t],r=n.getSrcArray(),i=n.getDataSize();if(s>0&&!(t in o)){let n=i*s,r=Array(n).fill(0);this.geometry.vertexProperty(t,r,i)}this.geometry.vertexProperty(t,r,i)}if(this.renderer.states.fillColor&&this.geometry.faces.push(...t.faces.map(t=>t.map(t=>t+i))),this.renderer.states.strokeColor)for(let n of t.edges.map(t=>t.map(t=>t+i)))this.geometry.edges.push(n);let c=[...t.vertexColors];for(;c.length<t.vertices.length*4;)c.push(...this.renderer.states.curFillColor);for(let t of c)this.geometry.vertexColors.push(t);this._addToCurrentPart(t,n,r,c)}_snapshotPartState(){let t=this.renderer.states,n=Ro();return t._tex&&(n.texture=t._tex),t._useSpecularMaterial&&(n.specularColor=t.curSpecularColor),t._hasSetAmbient&&(n.ambientColor=t.curAmbientColor),t._useShininess!==1&&(n.shininess=t._useShininess),n}_sameColor(t,n){return t===n?!0:!t||!n?!1:t.length===n.length&&t.every((t,r)=>t===n[r])}_sameMaterial(t,n){return t.texture===n.texture&&t.shininess===n.shininess&&this._sameColor(t.specularColor,n.specularColor)&&this._sameColor(t.ambientColor,n.ambientColor)}_addToCurrentPart(t,n,r,i){if(!this.renderer.states.fillColor)return;let a=this._snapshotPartState();(!this.currentPart||!this._sameMaterial(a,this.currentPart.partState))&&(this.currentPart=new Bo(`${this.geometry.gid}|part${this.parts.length}`,a),this.parts.push(this.currentPart));let o=this.currentPart,s=o.vertices.length;for(let t of n)o.vertices.push(t);for(let t of r)o.vertexNormals.push(t);for(let n of t.uvs)o.uvs.push(n);for(let t of i)o.vertexColors.push(t);for(let n of t.faces)o.faces.push(n.map(t=>t+s));let c=t.userVertexProperties,l=o.userVertexProperties;for(let t in l){if(t in c)continue;let r=l[t].getDataSize();l[t].pushDirect(Array(r*n.length).fill(0))}for(let t in c){let n=c[t],r=n.getDataSize();s>0&&!(t in l)&&o.vertexProperty(t,Array(r*s).fill(0),r),o.vertexProperty(t,n.getSrcArray(),r)}}addImmediate(t,n,{validateFaces:r=!1}={}){let i=[];if(this.renderer.states.fillColor){if(n===5||n===`quad_strip`)for(let n=2;n<t.vertices.length;n++)n%2==0?i.push([n,n-1,n-2]):i.push([n,n-2,n-1]);else if(n===6)for(let n=2;n<t.vertices.length;n++)i.push([0,n-1,n]);else if(n===4)for(let n=0;n<t.vertices.length;n+=3)(!r||t.vertices[n].copy().sub(t.vertices[n+1]).cross(t.vertices[n].copy().sub(t.vertices[n+2])).magSq()>0)&&i.push([n,n+1,n+2])}this.addGeometry(Object.assign({},t,{faces:i}))}addRetained(t){this.addGeometry(t)}finish(){return this.renderer._pInst.pop(),this.parts.length>=2&&(this.geometry.parts=this.parts),this.geometry}};Uo.nextGeometryId=0;var Wo=class t{constructor(t,n,r,i){this.w=t,this.vec=new I(n,r,i)}static fromAxisAngle(n,r,i,a){let o=Math.cos(n/2),s=new I(r,i,a).normalize().mult(Math.sin(n/2));return new t(o,s.x,s.y,s.z)}conjugate(){return new t(this.w,-this.vec.x,-this.vec.y,-this.vec.z)}multiply(n){return new t(this.w*n.w-this.vec.x*n.vec.x-this.vec.y*n.vec.y-this.vec.z*n.vec.z,this.w*n.vec.x+this.vec.x*n.w+this.vec.y*n.vec.z-this.vec.z*n.vec.y,this.w*n.vec.y-this.vec.x*n.vec.z+this.vec.y*n.w+this.vec.z*n.vec.x,this.w*n.vec.z+this.vec.x*n.vec.y-this.vec.y*n.vec.x+this.vec.z*n.w)}rotateVector(t){return I.mult(t,this.w*this.w-this.vec.dot(this.vec)).add(I.mult(this.vec,2*t.dot(this.vec))).add(I.mult(this.vec,2*this.w).cross(t)).clampToZero()}rotateBy(t){return t.multiply(this).multiply(t.conjugate()).vec.clampToZero()}};function Go(t,n){t.Quat=Wo}typeof p5<`u`&&Go(p5,p5.prototype);var Ko=class t{constructor(t){this._renderer=t,this.cameraType=`default`,this.useLinePerspective=!0,this.cameraMatrix=new Po(4),this.projMatrix=new Po(4),this.yScale=1}perspective(t,n,r,i){let a=this._renderer.zClipRange();this.cameraType=arguments.length>0?`custom`:`default`,t===void 0?(t=this.defaultCameraFOV,this.cameraFOV=t):this.cameraFOV=this._renderer._pInst._toRadians(t),n===void 0&&(n=this.defaultAspectRatio),r===void 0&&(r=this.defaultCameraNear),i===void 0&&(i=this.defaultCameraFar),r<=1e-4&&(r=.01,console.log(`Avoid perspective near plane values close to or below 0. Setting value to 0.01.`)),i<r&&console.log(`Perspective far plane value is less than near plane value. Nothing will be shown.`),this.aspectRatio=n,this.cameraNear=r,this.cameraFar=i,this.projMatrix=new Po(4);let o=1/Math.tan(this.cameraFOV/2),s=1/(this.cameraNear-this.cameraFar),c,l;a[0]===0?(c=i/(r-i),l=i*r/(r-i)):(c=(i+r)*s,l=2*i*r*s),this.projMatrix.set(o/n,0,0,0,0,-o*this.yScale,0,0,0,0,c,-1,0,0,l,0),this._isActive()&&(this._renderer.states.setValue(`uPMatrix`,this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix))}ortho(t,n,r,i,a,o){let s=this.fbo||this._renderer;t===void 0&&(t=-s.width/2),n===void 0&&(n=s.width/2),r===void 0&&(r=-s.height/2),i===void 0&&(i=s.height/2),a===void 0&&(a=0),o===void 0&&(o=Math.max(s.width,s.height)+800),this.cameraNear=a,this.cameraFar=o;let c=n-t,l=i-r,u=o-a,d=2/c,f=2/l*this.yScale,p=-2/u,m=-(n+t)/c,h=-(i+r)/l,g=-(o+a)/u;this.projMatrix=new Po(4),this.projMatrix.set(d,0,0,0,0,-f,0,0,0,0,p,0,m,h,g,1),this._isActive()&&(this._renderer.states.setValue(`uPMatrix`,this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType=`custom`}frustum(t,n,r,i,a,o){t===void 0&&(t=-this._renderer.width*.05),n===void 0&&(n=this._renderer.width*.05),r===void 0&&(r=this._renderer.height*.05),i===void 0&&(i=-this._renderer.height*.05),a===void 0&&(a=this.defaultCameraNear),o===void 0&&(o=this.defaultCameraFar),this.cameraNear=a,this.cameraFar=o;let s=n-t,c=i-r,l=o-a,u=+(2*a)/s,d=+(2*a)/c*this.yScale,f=-(2*o*a)/l,p=(n+t)/s,m=(i+r)/c,h=-(o+a)/l;this.projMatrix=new Po(4),this.projMatrix.set(u,0,0,0,0,-d,0,0,p,m,h,-1,0,0,f,0),this._isActive()&&(this._renderer.states.setValue(`uPMatrix`,this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType=`custom`}_rotateView(t,n,r,i){let a=this.centerX,o=this.centerY,s=this.centerZ;a-=this.eyeX,o-=this.eyeY,s-=this.eyeZ;let c=new Po(4);c.rotate4x4(this._renderer._pInst._toRadians(t),n,r,i);let l=[a*c.mat4[0]+o*c.mat4[4]+s*c.mat4[8],a*c.mat4[1]+o*c.mat4[5]+s*c.mat4[9],a*c.mat4[2]+o*c.mat4[6]+s*c.mat4[10]];l[0]+=this.eyeX,l[1]+=this.eyeY,l[2]+=this.eyeZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,l[0],l[1],l[2],this.upX,this.upY,this.upZ)}roll(t){let n=this._getLocalAxes(),r=Wo.fromAxisAngle(this._renderer._pInst._toRadians(t),n.z[0],n.z[1],n.z[2]).rotateVector(new I(this.upX,this.upY,this.upZ));this.camera(this.eyeX,this.eyeY,this.eyeZ,this.centerX,this.centerY,this.centerZ,r.x,r.y,r.z)}pan(t){let n=this._getLocalAxes();this._rotateView(t,n.y[0],n.y[1],n.y[2])}tilt(t){let n=this._getLocalAxes();this._rotateView(t,n.x[0],n.x[1],n.x[2])}lookAt(t,n,r){this.camera(this.eyeX,this.eyeY,this.eyeZ,t,n,r,this.upX,this.upY,this.upZ)}camera(t,n,r,i,a,o,s,c,l){t===void 0&&(t=this.defaultEyeX,n=this.defaultEyeY,r=this.defaultEyeZ,i=t,a=n,o=0,s=0,c=1,l=0),this.eyeX=t,this.eyeY=n,this.eyeZ=r,i!==void 0&&(this.centerX=i,this.centerY=a,this.centerZ=o),s!==void 0&&(this.upX=s,this.upY=c,this.upZ=l);let u=this._getLocalAxes();this.cameraMatrix.set(u.x[0],u.y[0],u.z[0],0,u.x[1],u.y[1],u.z[1],0,u.x[2],u.y[2],u.z[2],0,0,0,0,1);let d=-t,f=-n,p=-r;return this.cameraMatrix.translate([d,f,p]),this._isActive()&&(this._renderer.states.setValue(`uViewMatrix`,this._renderer.states.uViewMatrix.clone()),this._renderer.states.uViewMatrix.set(this.cameraMatrix)),this}move(t,n,r){let i=this._getLocalAxes(),a=[i.x[0]*t,i.x[1]*t,i.x[2]*t],o=[i.y[0]*n,i.y[1]*n,i.y[2]*n],s=[i.z[0]*r,i.z[1]*r,i.z[2]*r];this.camera(this.eyeX+a[0]+o[0]+s[0],this.eyeY+a[1]+o[1]+s[1],this.eyeZ+a[2]+o[2]+s[2],this.centerX+a[0]+o[0]+s[0],this.centerY+a[1]+o[1]+s[1],this.centerZ+a[2]+o[2]+s[2],this.upX,this.upY,this.upZ)}setPosition(t,n,r){let i=t-this.eyeX,a=n-this.eyeY,o=r-this.eyeZ;this.camera(t,n,r,this.centerX+i,this.centerY+a,this.centerZ+o,this.upX,this.upY,this.upZ)}set(t){for(let n of[`eyeX`,`eyeY`,`eyeZ`,`centerX`,`centerY`,`centerZ`,`upX`,`upY`,`upZ`,`cameraFOV`,`aspectRatio`,`cameraNear`,`cameraFar`,`cameraType`,`yScale`,`useLinePerspective`])this[n]=t[n];this.cameraMatrix=t.cameraMatrix.copy(),this.projMatrix=t.projMatrix.copy(),this._isActive()&&(this._renderer.states.setValue(`uModelMatrix`,this._renderer.states.uModelMatrix.clone()),this._renderer.states.setValue(`uViewMatrix`,this._renderer.states.uViewMatrix.clone()),this._renderer.states.setValue(`uPMatrix`,this._renderer.states.uPMatrix.clone()),this._renderer.states.uModelMatrix.reset(),this._renderer.states.uViewMatrix.set(this.cameraMatrix),this._renderer.states.uPMatrix.set(this.projMatrix))}slerp(t,n,r){if(r===0){this.set(t);return}if(r===1){this.set(n);return}this.projMatrix.mat4[15]!==0&&(this.projMatrix.setElement(0,t.projMatrix.mat4[0]*(n.projMatrix.mat4[0]/t.projMatrix.mat4[0])**+r),this.projMatrix.setElement(5,t.projMatrix.mat4[5]*(n.projMatrix.mat4[5]/t.projMatrix.mat4[5])**+r),this._isActive()&&this._renderer.states.setValue(`uPMatrix`,this.projMatrix.clone()));let i=new I(t.eyeX,t.eyeY,t.eyeZ),a=new I(n.eyeX,n.eyeY,n.eyeZ),o=new I(t.centerX,t.centerY,t.centerZ),s=new I(n.centerX,n.centerY,n.centerZ),c=I.dist(i,o),l=c*(I.dist(a,s)/c)**+r,u=I.sub(i,a),d=i.copy().sub(a).sub(o).add(s),f=d.magSq(),p=1;f>1e-6&&(p=I.dot(u,d)/f,p=Math.max(0,Math.min(p,1)));let m=I.lerp(I.lerp(i,o,p),I.lerp(a,s,p),r),h=t.cameraMatrix.createSubMatrix3x3(),g=n.cameraMatrix.createSubMatrix3x3(),_=h.row(2),v=g.row(2),y=h.row(1),b=g.row(1),x=new I(0,0,0),S=new I(0,0,0),C=new I(0,0,0),w=new I(0,0,0),T=g.mult(h.copy().transpose()),E=T.diagonal(),D=.5*(E[0]+E[1]+E[2]-1);if(1-D<1e-7){x.set(I.lerp(_,v,r)).normalize(),C.set(x).mult(p*l).add(m),w.set(x).mult((p-1)*l).add(m),S.set(I.lerp(y,b,r)).normalize(),this.camera(C.x,C.y,C.z,w.x,w.y,w.z,S.x,S.y,S.z);return}let O,k,A,j,M=1/(1-D),ee=Math.max(E[0],E[1],E[2]),te=T.mat3[1]+T.mat3[3],N=T.mat3[2]+T.mat3[6],ne=T.mat3[5]+T.mat3[7];ee===E[0]?(O=Math.sqrt((E[0]-D)*M),M/=O,k=.5*te*M,A=.5*N*M,j=.5*(T.mat3[7]-T.mat3[5])/O):ee===E[1]?(k=Math.sqrt((E[1]-D)*M),M/=k,A=.5*ne*M,O=.5*te*M,j=.5*(T.mat3[2]-T.mat3[6])/k):(A=Math.sqrt((E[2]-D)*M),M/=A,O=.5*N*M,k=.5*ne*M,j=.5*(T.mat3[3]-T.mat3[1])/A);let re=r*Math.atan2(j,D),ie=Math.cos(re),P=Math.sin(re),ae=1-ie,oe=O*k,se=k*A,ce=A*O,le=new Po([ie+ae*O*O,ae*oe+P*A,ae*ce-P*k,ae*oe-P*A,ie+ae*k*k,ae*se+P*O,ae*ce+P*k,ae*se-P*O,ie+ae*A*A]);le.multiplyVec(_,x),C.set(x).mult(p*l).add(m),w.set(x).mult((p-1)*l).add(m),le.multiplyVec(y,S),this.camera(C.x,C.y,C.z,w.x,w.y,w.z,S.x,S.y,S.z)}_computeCameraDefaultSettings(){this.defaultAspectRatio=this._renderer.width/this._renderer.height,this.defaultEyeX=0,this.defaultEyeY=0,this.defaultEyeZ=800,this.defaultCameraFOV=2*Math.atan(this._renderer.height/2/this.defaultEyeZ),this.defaultCenterX=0,this.defaultCenterY=0,this.defaultCenterZ=0,this.defaultCameraNear=this.defaultEyeZ*this._renderer.defaultNearScale(),this.defaultCameraFar=this.defaultEyeZ*this._renderer.defaultFarScale()}_setDefaultCamera(){this.cameraFOV=this.defaultCameraFOV,this.aspectRatio=this.defaultAspectRatio,this.eyeX=this.defaultEyeX,this.eyeY=this.defaultEyeY,this.eyeZ=this.defaultEyeZ,this.centerX=this.defaultCenterX,this.centerY=this.defaultCenterY,this.centerZ=this.defaultCenterZ,this.upX=0,this.upY=1,this.upZ=0,this.cameraNear=this.defaultCameraNear,this.cameraFar=this.defaultCameraFar,this.perspective(),this.camera(),this.cameraType=`default`}_resize(){this.cameraType==="default"&&(this._computeCameraDefaultSettings(),this.cameraFOV=this.defaultCameraFOV,this.aspectRatio=this.defaultAspectRatio,this.perspective())}copy(){let n=new t(this._renderer);return n.cameraFOV=this.cameraFOV,n.aspectRatio=this.aspectRatio,n.eyeX=this.eyeX,n.eyeY=this.eyeY,n.eyeZ=this.eyeZ,n.centerX=this.centerX,n.centerY=this.centerY,n.centerZ=this.centerZ,n.upX=this.upX,n.upY=this.upY,n.upZ=this.upZ,n.cameraNear=this.cameraNear,n.cameraFar=this.cameraFar,n.cameraType=this.cameraType,n.useLinePerspective=this.useLinePerspective,n.cameraMatrix=this.cameraMatrix.copy(),n.projMatrix=this.projMatrix.copy(),n.yScale=this.yScale,n.cameraType=this.cameraType,n.defaultAspectRatio=this.defaultAspectRatio,n.defaultEyeX=this.defaultEyeX,n.defaultEyeY=this.defaultEyeY,n.defaultEyeZ=this.defaultEyeZ,n.defaultCameraFOV=this.defaultCameraFOV,n.defaultCenterX=this.defaultCenterX,n.defaultCenterY=this.defaultCenterY,n.defaultCenterZ=this.defaultCenterZ,n.defaultCameraNear=this.defaultCameraNear,n.defaultCameraFar=this.defaultCameraFar,n}clone(){return this.copy()}_getLocalAxes(){let t=this.eyeX-this.centerX,n=this.eyeY-this.centerY,r=this.eyeZ-this.centerZ,i=Math.sqrt(t*t+n*n+r*r);i!==0&&(t/=i,n/=i,r/=i);let a=this.upX,o=this.upY,s=this.upZ,c=o*r-s*n,l=-a*r+s*t,u=a*n-o*t;a=n*u-r*l,o=-t*u+r*c,s=t*l-n*c;let d=Math.sqrt(c*c+l*l+u*u);d!==0&&(c/=d,l/=d,u/=d);let f=Math.sqrt(a*a+o*o+s*s);return f!==0&&(a/=f,o/=f,s/=f),{x:[c,l,u],y:[a,o,s],z:[t,n,r]}}_orbit(t,n,r){let i=this.eyeX-this.centerX,a=this.eyeY-this.centerY,o=this.eyeZ-this.centerZ,s=Math.hypot(i,a,o),c=new I(i,a,o).normalize(),l=new I(this.upX,this.upY,this.upZ).normalize(),u=I.cross(l,c).normalize(),d=I.cross(u,l);s*=10**r,s<this.cameraNear&&(s=this.cameraNear),s>this.cameraFar&&(s=this.cameraFar);let f=Math.acos(Math.max(-1,Math.min(1,I.dot(c,l))))+n,p=t;(f<=0||f>=Math.PI)&&(this.upX*=-1,this.upY*=-1,this.upZ*=-1),l.mult(Math.cos(f)),d.mult(Math.cos(p)*Math.sin(f)),u.mult(Math.sin(p)*Math.sin(f)),c.set(l).add(d).add(u),this.eyeX=s*c.x+this.centerX,this.eyeY=s*c.y+this.centerY,this.eyeZ=s*c.z+this.centerZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,this.centerX,this.centerY,this.centerZ,this.upX,this.upY,this.upZ)}_orbitFree(t,n,r){let i=this.eyeX-this.centerX,a=this.eyeY-this.centerY,o=this.eyeZ-this.centerZ,s=Math.hypot(i,a,o),c=new I(i,a,o).normalize(),l=new I(this.upX,this.upY,this.upZ),u=I.cross(l,c).normalize(),d=I.cross(c,u),f=Math.atan2(n,t);d.mult(Math.sin(f)),u.mult(Math.cos(f)).add(d);let p=Math.sqrt(t*t+n*n),m=I.cross(c,u);s*=10**r,s<this.cameraNear&&(s=this.cameraNear),s>this.cameraFar&&(s=this.cameraFar);let h=Math.cos(p),g=Math.sin(p),_=l.dot(c),v=l.dot(u),y=_*h+v*g,b=-_*g+v*h,x=l.dot(m);l.x=y*c.x+b*u.x+x*m.x,l.y=y*c.y+b*u.y+x*m.y,l.z=y*c.z+b*u.z+x*m.z,u.mult(-g),c.mult(h).add(u).mult(s),this.camera(c.x+this.centerX,c.y+this.centerY,c.z+this.centerZ,this.centerX,this.centerY,this.centerZ,l.x,l.y,l.z)}_isActive(){return this===this._renderer.states.curCamera}};function qo(t,n){n.camera=function(...t){return this._assert3d(`camera`),this._renderer.camera(...t),this},n.perspective=function(...t){return this._assert3d(`perspective`),this._renderer.perspective(...t),this},n.linePerspective=function(t){if(!(this._renderer instanceof z))throw Error(`linePerspective() must be called in WebGL mode.`);return this._renderer.linePerspective(t)},n.ortho=function(...t){return this._assert3d(`ortho`),this._renderer.ortho(...t),this},n.frustum=function(...t){return this._assert3d(`frustum`),this._renderer.frustum(...t),this},n.createCamera=function(){return this._assert3d(`createCamera`),this._renderer.createCamera()},n.setCamera=function(t){this._renderer.setCamera(t)},t.Camera=Ko,z.prototype.camera=function(...t){this.states.setValue(`curCamera`,this.states.curCamera.clone()),this.states.curCamera.camera(...t)},z.prototype.perspective=function(...t){this.states.setValue(`curCamera`,this.states.curCamera.clone()),this.states.curCamera.perspective(...t)},z.prototype.linePerspective=function(t){if(t!==void 0)this.states.setValue(`curCamera`,this.states.curCamera.clone()),this.states.curCamera.useLinePerspective=t;else return this.states.curCamera.useLinePerspective},z.prototype.ortho=function(...t){this.states.setValue(`curCamera`,this.states.curCamera.clone()),this.states.curCamera.ortho(...t)},z.prototype.frustum=function(...t){this.states.setValue(`curCamera`,this.states.curCamera.clone()),this.states.curCamera.frustum(...t)},z.prototype.createCamera=function(){let t=new Ko(this);return t._computeCameraDefaultSettings(),t._setDefaultCamera(),t},z.prototype.setCamera=function(t){this.states.setValue(`curCamera`,t),this.states.setValue(`uPMatrix`,this.states.uPMatrix.clone()),this.states.uPMatrix.set(t.projMatrix),this.states.setValue(`uViewMatrix`,this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(t.cameraMatrix)}}typeof p5<`u`&&qo(p5,p5.prototype);var Jo=/* @__PURE__ */ u((/* @__PURE__ */ s(((t,n,r)=>{var i;function a(t,n){return t.b===n.b&&t.a===n.a}function o(t,n){return t.b<n.b||t.b===n.b&&t.a<=n.a}function s(t,n,r){var i=n.b-t.b,a=r.b-n.b;return 0<i+a?i<a?n.a-t.a+i/(i+a)*(t.a-r.a):n.a-r.a+a/(i+a)*(r.a-t.a):0}function c(t,n,r){var i=n.b-t.b,a=r.b-n.b;return 0<i+a?(n.a-r.a)*i+(n.a-t.a)*a:0}function l(t,n){return t.a<n.a||t.a===n.a&&t.b<=n.b}function u(t,n,r){var i=n.a-t.a,a=r.a-n.a;return 0<i+a?i<a?n.b-t.b+i/(i+a)*(t.b-r.b):n.b-r.b+a/(i+a)*(r.b-t.b):0}function d(t,n,r){var i=n.a-t.a,a=r.a-n.a;return 0<i+a?(n.b-r.b)*i+(n.b-t.b)*a:0}function f(t){return o(t.b.a,t.a)}function p(t){return o(t.a,t.b.a)}function m(t,n,r,i){return t=0>t?0:t,r=0>r?0:r,t<=r?r===0?(n+i)/2:n+t/(t+r)*(i-n):i+r/(t+r)*(n-i)}function h(t){var n=b(t.b);return S(n,t.c),S(n.b,t.c),C(n,t.a),n}function g(t,n){var r=!1,i=!1;t!==n&&(n.a!==t.a&&(i=!0,T(n.a,t.a)),n.d!==t.d&&(r=!0,E(n.d,t.d)),x(n,t),i||(S(n,t.a),t.a.c=t),r||(C(n,t.d),t.d.a=t))}function _(t){var n=t.b,r=!1;t.d!==t.b.d&&(r=!0,E(t.d,t.b.d)),t.c===t?T(t.a,null):(t.b.d.a=xe(t),t.a.c=t.c,x(t,xe(t)),r||C(t,t.d)),n.c===n?(T(n.a,null),E(n.d,null)):(t.d.a=xe(n),n.a.c=n.c,x(n,xe(n))),w(t)}function v(t){var n=b(t),r=n.b;return x(n,t.e),n.a=t.b.a,S(r,n.a),n.d=r.d=t.d,n=n.b,x(t.b,xe(t.b)),x(t.b,n),t.b.a=n.a,n.b.a.c=n.b,n.b.d=t.b.d,n.f=t.f,n.b.f=t.b.f,n}function y(t,n){var r=!1,i=b(t),a=i.b;return n.d!==t.d&&(r=!0,E(n.d,t.d)),x(i,t.e),x(a,n),i.a=t.b.a,a.a=n.a,i.d=a.d=t.d,t.d.a=a,r||C(i,t.d),i}function b(t){var n=new be,r=new be,i=t.b.h;return r.h=i,i.b.h=n,n.h=t,t.b.h=r,n.b=r,n.c=n,n.e=r,r.b=n,r.c=r,r.e=n}function x(t,n){var r=t.c,i=n.c;r.b.e=n,i.b.e=t,t.c=i,n.c=r}function S(t,n){var r=n.f,i=new Ce(n,r);r.e=i,n.f=i,r=i.c=t;do r.a=i,r=r.c;while(r!==t)}function C(t,n){var r=n.d,i=new ye(n,r);r.b=i,n.d=i,i.a=t,i.c=n.c,r=t;do r.d=i,r=r.e;while(r!==t)}function w(t){var n=t.h;t=t.b.h,n.b.h=t,t.b.h=n}function T(t,n){var r=t.c,i=r;do i.a=n,i=i.c;while(i!==r);r=t.f,i=t.e,i.f=r,r.e=i}function E(t,n){var r=t.a,i=r;do i.d=n,i=i.e;while(i!==r);r=t.d,i=t.b,i.d=r,r.b=i}function D(t){var n=0;return Math.abs(t[1])>Math.abs(t[0])&&(n=1),Math.abs(t[2])>Math.abs(t[n])&&(n=2),n}var O=4e150;function k(t,n){t.f+=n.f,t.b.f+=n.b.f}function A(t,n,r){return t=t.a,n=n.a,r=r.a,n.b.a===t?r.b.a===t?o(n.a,r.a)?0>=c(r.b.a,n.a,r.a):0<=c(n.b.a,r.a,n.a):0>=c(r.b.a,t,r.a):r.b.a===t?0<=c(n.b.a,t,n.a):(n=s(n.b.a,t,n.a),t=s(r.b.a,t,r.a),n>=t)}function j(t){t.a.i=null;var n=t.e;n.a.c=n.c,n.c.a=n.a,t.e=null}function M(t,n){_(t.a),t.c=!1,t.a=n,n.i=t}function ee(t){var n=t.a.a;do t=Ie(t);while(t.a.a===n);return t.c&&(n=y(Fe(t).a.b,t.a.e),M(t,n),t=Ie(t)),t}function te(t,n,r){var i=new Pe;return i.a=r,i.e=pe(t.f,n.e,i),r.i=i}function N(t,n){switch(t.s){case 100130:return!!(n&1);case 100131:return n!==0;case 100132:return 0<n;case 100133:return 0>n;case 100134:return 2<=n||-2>=n}return!1}function ne(t){var n=t.a,r=n.d;r.c=t.d,r.a=n,j(t)}function re(t,n,r){for(t=n,n=n.a;t!==r;){t.c=!1;var i=Fe(t),a=i.a;if(a.a!==n.a){if(!i.c){ne(t);break}a=y(n.c.b,a.b),M(i,a)}n.c!==a&&(g(xe(a),a),g(n,a)),ne(t),n=i.a,t=i}return n}function ie(t,n,r,i,a,o){var s=!0;do te(t,n,r.b),r=r.c;while(r!==i);for(a===null&&(a=Fe(n).a.b.c);i=Fe(n),r=i.a.b,r.a===a.a;)r.c!==a&&(g(xe(r),r),g(xe(a),r)),i.f=n.f-r.f,i.d=N(t,i.f),n.b=!0,!s&&se(t,n)&&(k(r,a),j(n),_(a)),s=!1,n=i,a=r;n.b=!0,o&&le(t,n)}function P(t,n,r,i,a){var o=[n.g[0],n.g[1],n.g[2]];n.d=null,n.d=t.o&&t.o(o,r,i,t.c)||null,n.d===null&&(a?t.n||=(ve(t,100156),!0):n.d=r[0])}function ae(t,n,r){var i=[null,null,null,null];i[0]=n.a.d,i[1]=r.a.d,P(t,n.a,i,[.5,.5,0,0],!1),g(n,r)}function oe(t,n,r,i,a){var o=Math.abs(n.b-t.b)+Math.abs(n.a-t.a),s=Math.abs(r.b-t.b)+Math.abs(r.a-t.a),c=a+1;i[a]=.5*s/(o+s),i[c]=.5*o/(o+s),t.g[0]+=i[a]*n.g[0]+i[c]*r.g[0],t.g[1]+=i[a]*n.g[1]+i[c]*r.g[1],t.g[2]+=i[a]*n.g[2]+i[c]*r.g[2]}function se(t,n){var r=Fe(n),i=n.a,s=r.a;if(o(i.a,s.a)){if(0<c(s.b.a,i.a,s.a))return!1;if(!a(i.a,s.a))v(s.b),g(i,xe(s)),n.b=r.b=!0;else if(i.a!==s.a){var r=t.e,l=i.a.h;if(0<=l){var r=r.b,u=r.d,d=r.e,f=r.c,p=f[l];u[p]=u[r.a],f[u[p]]=p,p<=--r.a&&(1>=p||o(d[u[p>>1]],d[u[p]])?Me(r,p):Ne(r,p)),d[l]=null,f[l]=r.b,r.b=l}else for(r.c[-(l+1)]=null;0<r.a&&r.c[r.d[r.a-1]]===null;)--r.a;ae(t,xe(s),i)}}else{if(0>c(i.b.a,s.a,i.a))return!1;Ie(n).b=n.b=!0,v(i.b),g(xe(s),i)}return!0}function ce(t,n){var r=Fe(n),i=n.a,f=r.a,p=i.a,h=f.a,_=i.b.a,y=f.b.a,b=new Ce;if(c(_,t.a,p),c(y,t.a,h),p===h||Math.min(p.a,_.a)>Math.max(h.a,y.a))return!1;if(o(p,h)){if(0<c(y,p,h))return!1}else if(0>c(_,h,p))return!1;var x=_,S=p,C=y,w=h,T,E;if(o(x,S)||(T=x,x=S,S=T),o(C,w)||(T=C,C=w,w=T),o(x,C)||(T=x,x=C,C=T,T=S,S=w,w=T),o(C,S)?o(S,w)?(T=s(x,C,S),E=s(C,S,w),0>T+E&&(T=-T,E=-E),b.b=m(T,C.b,E,S.b)):(T=c(x,C,S),E=-c(x,w,S),0>T+E&&(T=-T,E=-E),b.b=m(T,C.b,E,w.b)):b.b=(C.b+S.b)/2,l(x,S)||(T=x,x=S,S=T),l(C,w)||(T=C,C=w,w=T),l(x,C)||(T=x,x=C,C=T,T=S,S=w,w=T),l(C,S)?l(S,w)?(T=u(x,C,S),E=u(C,S,w),0>T+E&&(T=-T,E=-E),b.a=m(T,C.a,E,S.a)):(T=d(x,C,S),E=-d(x,w,S),0>T+E&&(T=-T,E=-E),b.a=m(T,C.a,E,w.a)):b.a=(C.a+S.a)/2,o(b,t.a)&&(b.b=t.a.b,b.a=t.a.a),x=o(p,h)?p:h,o(x,b)&&(b.b=x.b,b.a=x.a),a(b,p)||a(b,h))return se(t,n),!1;if(!a(_,t.a)&&0<=c(_,t.a,b)||!a(y,t.a)&&0>=c(y,t.a,b)){if(y===t.a)return v(i.b),g(f.b,i),n=ee(n),i=Fe(n).a,re(t,Fe(n),r),ie(t,n,xe(i),i,i,!0),!0;if(_===t.a){v(f.b),g(i.e,xe(f)),p=r=n,h=p.a.b.a;do p=Ie(p);while(p.a.b.a===h);return n=p,p=Fe(n).a.b.c,r.a=xe(f),f=re(t,r,null),ie(t,n,f.c,i.b.c,p,!0),!0}return 0<=c(_,t.a,b)&&(Ie(n).b=n.b=!0,v(i.b),i.a.b=t.a.b,i.a.a=t.a.a),0>=c(y,t.a,b)&&(n.b=r.b=!0,v(f.b),f.a.b=t.a.b,f.a.a=t.a.a),!1}return v(i.b),v(f.b),g(xe(f),i),i.a.b=b.b,i.a.a=b.a,i.a.h=Ee(t.e,i.a),i=i.a,f=[0,0,0,0],b=[p.d,_.d,h.d,y.d],i.g[0]=i.g[1]=i.g[2]=0,oe(i,p,_,f,0),oe(i,h,y,f,2),P(t,i,b,f,!0),Ie(n).b=n.b=r.b=!0,!1}function le(t,n){for(var r=Fe(n);;){for(;r.b;)n=r,r=Fe(r);if(!n.b&&(r=n,n=Ie(n),n===null||!n.b))break;n.b=!1;var i=n.a,a=r.a,s;if(s=i.b.a!==a.b.a)a:{s=n;var l=Fe(s),u=s.a,d=l.a,f=void 0;if(o(u.b.a,d.b.a)){if(0>c(u.b.a,d.b.a,u.a)){s=!1;break a}Ie(s).b=s.b=!0,f=v(u),g(d.b,f),f.d.c=s.d}else{if(0<c(d.b.a,u.b.a,d.a)){s=!1;break a}s.b=l.b=!0,f=v(d),g(u.e,d.b),f.b.d.c=s.d}s=!0}if(s&&(r.c?(j(r),_(a),r=Fe(n),a=r.a):n.c&&(j(n),_(i),n=Ie(r),i=n.a)),i.a!==a.a){if(i.b.a===a.b.a||n.c||r.c||i.b.a!==t.a&&a.b.a!==t.a)se(t,n);else if(ce(t,n))break}i.a===a.a&&i.b.a===a.b.a&&(k(a,i),j(n),_(i),n=Ie(r))}}function ue(t,n){t.a=n;for(var r=n.c;r.i===null;)if(r=r.c,r===n.c){var r=t,i=n,s=new Pe;s.a=i.c.b;var l=r.f,u=l.a;do u=u.a;while(u.b!==null&&!l.c(l.b,s,u.b));var l=u.b,d=Fe(l),s=l.a,u=d.a;if(c(s.b.a,i,s.a)===0)s=l.a,a(s.a,i)||a(s.b.a,i)||(v(s.b),l.c&&(_(s.c),l.c=!1),g(i.c,s),ue(r,i));else{var f=o(u.b.a,s.b.a)?l:d,d=void 0;l.d||f.c?(d=f===l?y(i.c.b,s.e):y(u.b.c.b,i.c).b,f.c?M(f,d):(s=r,l=te(r,l,d),l.f=Ie(l).f+l.a.f,l.d=N(s,l.f)),ue(r,i)):ie(r,l,i.c,i.c,null,!0)}return}if(r=ee(r.i),s=Fe(r),l=s.a,s=re(t,s,null),s.c===l){var l=s,s=l.c,u=Fe(r),d=r.a,f=u.a,p=!1;d.b.a!==f.b.a&&ce(t,r),a(d.a,t.a)&&(g(xe(s),d),r=ee(r),s=Fe(r).a,re(t,Fe(r),u),p=!0),a(f.a,t.a)&&(g(l,xe(f)),l=re(t,u,null),p=!0),p?ie(t,r,l.c,s,s,!0):(i=o(f.a,d.a)?xe(f):d,i=y(l.c.b,i),ie(t,r,i,i.c,i.c,!1),i.b.i.c=!0,le(t,r))}else ie(t,r,s.c,l,l,!0)}function de(t,n){var r=new Pe,i=h(t.b);i.a.b=O,i.a.a=n,i.b.a.b=-4e150,i.b.a.a=n,t.a=i.b.a,r.a=i,r.f=0,r.d=!1,r.c=!1,r.h=!0,r.b=!1,i=t.f,i=pe(i,i.a,r),r.e=i}function fe(t){this.a=new me,this.b=t,this.c=A}function pe(t,n,r){do n=n.c;while(n.b!==null&&!t.c(t.b,n.b,r));return t=new me(r,n.a,n),n.a.c=t,n.a=t}function me(t,n,r){this.b=t||null,this.a=n||this,this.c=r||this}function he(){this.d=ge,this.p=this.b=this.q=null,this.j=[0,0,0],this.s=100130,this.n=!1,this.o=this.a=this.e=this.f=null,this.m=!1,this.c=this.r=this.i=this.k=this.l=this.h=null}var ge=0;i=he.prototype,i.x=function(){_e(this,0)},i.B=function(t,n){switch(t){case 100142:return;case 100140:switch(n){case 100130:case 100131:case 100132:case 100133:case 100134:this.s=n;return}break;case 100141:this.m=!!n;return;default:ve(this,100900);return}ve(this,100901)},i.y=function(t){switch(t){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:ve(this,100900)}return!1},i.A=function(t,n,r){this.j[0]=t,this.j[1]=n,this.j[2]=r},i.z=function(t,n){var r=n||null;switch(t){case 100100:case 100106:this.h=r;break;case 100104:case 100110:this.l=r;break;case 100101:case 100107:this.k=r;break;case 100102:case 100108:this.i=r;break;case 100103:case 100109:this.p=r;break;case 100105:case 100111:this.o=r;break;case 100112:this.r=r;break;default:ve(this,100900)}},i.C=function(t,n){var r=!1,i=[0,0,0];_e(this,2);for(var a=0;3>a;++a){var o=t[a];-1e150>o&&(o=-1e150,r=!0),1e150<o&&(o=1e150,r=!0),i[a]=o}r&&ve(this,100155),r=this.q,r===null?(r=h(this.b),g(r,r.b)):(v(r),r=r.e),r.a.d=n,r.a.g[0]=i[0],r.a.g[1]=i[1],r.a.g[2]=i[2],r.f=1,r.b.f=-1,this.q=r},i.u=function(t){_e(this,0),this.d=1,this.b=new Se,this.c=t},i.t=function(){_e(this,1),this.d=2,this.q=null},i.v=function(){_e(this,2),this.d=1},i.w=function(){_e(this,1),this.d=0;var t=this.j[0],n=this.j[1],r=this.j[2],i=!1,s=[t,n,r];if(t===0&&n===0&&r===0){for(var n=[-2e150,-2e150,-2e150],l=[2e150,2e150,2e150],r=[],u=[],i=this.b.c,t=i.e;t!==i;t=t.e)for(var d=0;3>d;++d){var m=t.g[d];m<l[d]&&(l[d]=m,u[d]=t),m>n[d]&&(n[d]=m,r[d]=t)}if(t=0,n[1]-l[1]>n[0]-l[0]&&(t=1),n[2]-l[2]>n[t]-l[t]&&(t=2),l[t]>=n[t])s[0]=0,s[1]=0,s[2]=1;else{for(n=0,l=u[t],r=r[t],u=[0,0,0],l=[l.g[0]-r.g[0],l.g[1]-r.g[1],l.g[2]-r.g[2]],d=[0,0,0],t=i.e;t!==i;t=t.e)d[0]=t.g[0]-r.g[0],d[1]=t.g[1]-r.g[1],d[2]=t.g[2]-r.g[2],u[0]=l[1]*d[2]-l[2]*d[1],u[1]=l[2]*d[0]-l[0]*d[2],u[2]=l[0]*d[1]-l[1]*d[0],m=u[0]*u[0]+u[1]*u[1]+u[2]*u[2],m>n&&(n=m,s[0]=u[0],s[1]=u[1],s[2]=u[2]);0>=n&&(s[0]=s[1]=s[2]=0,s[D(l)]=1)}i=!0}for(u=D(s),t=this.b.c,n=(u+1)%3,r=(u+2)%3,u=0<s[u]?1:-1,s=t.e;s!==t;s=s.e)s.b=s.g[n],s.a=u*s.g[r];if(i){for(s=0,i=this.b.a,t=i.b;t!==i;t=t.b)if(n=t.a,!(0>=n.f))do s+=(n.a.b-n.b.a.b)*(n.a.a+n.b.a.a),n=n.e;while(n!==t.a);if(0>s)for(s=this.b.c,i=s.e;i!==s;i=i.e)i.a=-i.a}for(this.n=!1,s=this.b.b,t=s.h;t!==s;t=i)i=t.h,n=t.e,a(t.a,t.b.a)&&t.e.e!==t&&(ae(this,n,t),_(t),t=n,n=t.e),n.e===t&&(n!==t&&((n===i||n===i.b)&&(i=i.h),_(n)),(t===i||t===i.b)&&(i=i.h),_(t));for(this.e=s=new we,i=this.b.c,t=i.e;t!==i;t=t.e)t.h=Ee(s,t);for(Te(s),this.f=new fe(this),de(this,-4e150),de(this,O);(s=De(this.e))!==null;){for(;;){a:if(t=this.e,t.a===0)i=Ae(t.b);else if(i=t.c[t.d[t.a-1]],t.b.a!==0&&(t=Ae(t.b),o(t,i))){i=t;break a}if(i===null||!a(i,s))break;i=De(this.e),ae(this,s.c,i.c)}ue(this,s)}for(this.a=this.f.a.a.b.a.a,s=0;(i=this.f.a.a.b)!==null;)i.h||++s,j(i);for(this.f=null,s=this.e,s.b=null,s.d=null,this.e=s.c=null,s=this.b,t=s.a.b;t!==s.a;t=i)i=t.b,t=t.a,t.e.e===t&&(k(t.c,t),_(t));if(!this.n){if(s=this.b,this.m)for(t=s.b.h;t!==s.b;t=i)i=t.h,t.b.d.c===t.d.c?_(t):t.f=t.d.c?1:-1;else for(t=s.a.b;t!==s.a;t=i)if(i=t.b,t.c){for(t=t.a;o(t.b.a,t.a);t=t.c.b);for(;o(t.a,t.b.a);t=t.e);for(n=t.c.b,r=void 0;t.e!==n;)if(o(t.b.a,n.a)){for(;n.e!==t&&(f(n.e)||0>=c(n.a,n.b.a,n.e.b.a));)r=y(n.e,n),n=r.b;n=n.c.b}else{for(;n.e!==t&&(p(t.c.b)||0<=c(t.b.a,t.a,t.c.b.a));)r=y(t,t.c.b),t=r.b;t=t.e}for(;n.e.e!==t;)r=y(n.e,n),n=r.b}if(this.h||this.i||this.k||this.l){if(this.m){for(s=this.b,i=s.a.b;i!==s.a;i=i.b)if(i.c){this.h&&this.h(2,this.c),t=i.a;do this.k&&this.k(t.a.d,this.c),t=t.e;while(t!==i.a);this.i&&this.i(this.c)}}else{for(s=this.b,i=!!this.l,t=!1,n=-1,r=s.a.d;r!==s.a;r=r.d)if(r.c){t||=(this.h&&this.h(4,this.c),!0),u=r.a;do i&&(l=+!u.b.d.c,n!==l&&(n=l,this.l&&this.l(!!n,this.c))),this.k&&this.k(u.a.d,this.c),u=u.e;while(u!==r.a)}t&&this.i&&this.i(this.c)}}if(this.r){for(s=this.b,t=s.a.b;t!==s.a;t=i)if(i=t.b,!t.c){n=t.a,r=n.e,u=void 0;do u=r,r=u.e,u.d=null,u.b.d===null&&(u.c===u?T(u.a,null):(u.a.c=u.c,x(u,xe(u))),l=u.b,l.c===l?T(l.a,null):(l.a.c=l.c,x(l,xe(l))),w(u));while(u!==n);n=t.d,t=t.b,t.d=n,n.b=t}this.r(this.b),this.c=this.b=null;return}}this.b=this.c=null};function _e(t,n){if(t.d!==n)for(;t.d!==n;)if(t.d<n)switch(t.d){case 0:ve(t,100151),t.u(null);break;case 1:ve(t,100152),t.t()}else switch(t.d){case 2:ve(t,100154),t.v();break;case 1:ve(t,100153),t.w()}}function ve(t,n){t.p&&t.p(n,t.c)}function ye(t,n){this.b=t||this,this.d=n||this,this.a=null,this.c=!1}function be(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function xe(t){return t.b.e}function Se(){this.c=new Ce,this.a=new ye,this.b=new be,this.d=new be,this.b.b=this.d,this.d.b=this.b}function Ce(t,n){this.e=t||this,this.f=n||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function we(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new Oe}function Te(t){t.d=[];for(var n=0;n<t.a;n++)t.d[n]=n;t.d.sort(function(t){return function(n,r){return o(t[n],t[r])?1:-1}}(t.c)),t.e=!0,ke(t.b)}function Ee(t,n){if(t.e){var r=t.b,i=++r.a;2*i>r.f&&(r.f*=2,r.c=F(r.c,r.f+1));var a;return r.b===0?a=i:(a=r.b,r.b=r.c[r.b]),r.e[a]=n,r.c[a]=i,r.d[i]=a,r.h&&Ne(r,i),a}return r=t.a++,t.c[r]=n,-(r+1)}function De(t){if(t.a===0)return je(t.b);var n=t.c[t.d[t.a-1]];if(t.b.a!==0&&o(Ae(t.b),n))return je(t.b);do--t.a;while(0<t.a&&t.c[t.d[t.a-1]]===null);return n}function Oe(){this.d=F([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.h=!1,this.d[1]=1}function F(t,n){for(var r=Array(n),i=0;i<t.length;i++)r[i]=t[i];for(;i<n;i++)r[i]=0;return r}function ke(t){for(var n=t.a;1<=n;--n)Me(t,n);t.h=!0}function Ae(t){return t.e[t.d[1]]}function je(t){var n=t.d,r=t.e,i=t.c,a=n[1],o=r[a];return 0<t.a&&(n[1]=n[t.a],i[n[1]]=1,r[a]=null,i[a]=t.b,t.b=a,0<--t.a&&Me(t,1)),o}function Me(t,n){for(var r=t.d,i=t.e,a=t.c,s=n,c=r[s];;){var l=s<<1;l<t.a&&o(i[r[l+1]],i[r[l]])&&(l+=1);var u=r[l];if(l>t.a||o(i[c],i[u])){r[s]=c,a[c]=s;break}r[s]=u,a[u]=s,s=l}}function Ne(t,n){for(var r=t.d,i=t.e,a=t.c,s=n,c=r[s];;){var l=s>>1,u=r[l];if(l===0||o(i[u],i[c])){r[s]=c,a[c]=s;break}r[s]=u,a[u]=s,s=l}}function Pe(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function Fe(t){return t.e.c.b}function Ie(t){return t.e.a.b}r.libtess={GluTesselator:he,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},he.prototype.gluDeleteTess=he.prototype.x,he.prototype.gluTessProperty=he.prototype.B,he.prototype.gluGetTessProperty=he.prototype.y,he.prototype.gluTessNormal=he.prototype.A,he.prototype.gluTessCallback=he.prototype.z,he.prototype.gluTessVertex=he.prototype.C,he.prototype.gluTessBeginPolygon=he.prototype.u,he.prototype.gluTessBeginContour=he.prototype.t,he.prototype.gluTessEndContour=he.prototype.v,he.prototype.gluTessEndPolygon=he.prototype.w,n!==void 0&&(n.exports=r.libtess)})))(),1),Yo=class{constructor(t,n,r,i,a,o){this.size=t,this.src=n,this.dst=r,this.attr=i,this._renderer=a,this.map=o}default(t){return this.default=t,this}_prepareBuffer(t,n){this._renderer._prepareBuffer(this,t,n)}};function Xo(t,n){t.RenderBuffer=Yo}typeof p5<`u`&&Xo(p5,p5.prototype);const Zo={vertices:1,vertexNormals:1,vertexColors:4,vertexStrokeColors:4,uvs:2},Qo=Object.values(Zo).reduce((t,n)=>t+n);var $o=class{constructor(t){this.renderer=t,this.shapeMode=8,this.geometry=new Vo(void 0,void 0,void 0,this.renderer),this.geometry.gid=`__IMMEDIATE_MODE_GEOMETRY__`,this.contourIndices=[],this._useUserVertexProperties=void 0,this._bezierVertex=[],this._quadraticVertex=[],this._curveVertex=[],this.isProcessingVertices=!1,this._tessy=this._initTessy(),this.tessyVertexSize=Qo,this.bufferStrides={...Zo}}friendlyErrorsDisabled(){return!1}constructFromContours(t,n){this._useUserVertexProperties&&this._resetUserVertexProperties(),this.geometry.reset(),this.contourIndices=[],this.shapeMode=t.contours[0].kind;let r=!!this.renderer.states.strokeColor,i={};if(t.userVertexProperties){this._useUserVertexProperties=!0;for(let n in t.userVertexProperties){let r=t.vertexPropertyName(n),a=this.geometry._userVertexPropertyHelper(r,[],t.userVertexProperties[n]);i[n]=a,this.tessyVertexSize+=a.getDataSize(),this.bufferStrides[a.getSrcName()]=a.getDataSize(),this.renderer.buffers.user.push(new Yo(a.getDataSize(),a.getSrcName(),a.getDstName(),r,this.renderer))}}else this._useUserVertexProperties=!1;for(let t of n){this.contourIndices.push(this.geometry.vertices.length);for(let n of t){if(this.shapeMode===`quads`&&this.geometry.vertices.length%6==3)for(let t in this.bufferStrides){let n=this.bufferStrides[t],r=this.geometry[t];r.push(...r.slice(r.length-3*n,r.length-2*n),...r.slice(r.length-n,r.length))}this.geometry.vertices.push(n.position),this.geometry.vertexNormals.push(n.normal||new I(0,0,0)),this.geometry.uvs.push(n.textureCoordinates.x,n.textureCoordinates.y),this.renderer.states.fillColor?this.geometry.vertexColors.push(...n.fill.array()):this.geometry.vertexColors.push(0,0,0,0),this.renderer.states.strokeColor?this.geometry.vertexStrokeColors.push(...n.stroke.array()):this.geometry.vertexStrokeColors.push(0,0,0,0);for(let t in i){let r=i[t];t in n&&r.setCurrentData(n[t]),r.pushCurrentData()}}}if(r&&(this.geometry.edges=this._calculateEdges(this.shapeMode,this.geometry.vertices)),r&&!this.renderer.geometryBuilder&&this.geometry._edgesToVertices(),this.shapeMode===8){let t=this.geometry.vertices.length;if(t>5e4&&!this.friendlyErrorsDisabled()&&!this.renderer._largeTessellationAcknowledged){if(!window.confirm(`🌸 p5.js says:

This shape has ${t} vertices. Tessellating shapes with this many vertices can be very slow and may cause your browser to become unresponsive.

Do you want to continue tessellating this shape?`))return;this.renderer._largeTessellationAcknowledged=!0}this.isProcessingVertices=!0,this._tesselateShape(),this.isProcessingVertices=!1}else this.shapeMode===`quad_strip`?this.shapeMode=5:this.shapeMode===`quads`&&(this.shapeMode=4);!this.renderer.geometryBuilder&&this.shapeMode===6&&!this.renderer.supportsTriangleFan()&&(this._convertFanToTriangles(),this.shapeMode=4),this.renderer.states.textureMode===`image`&&this.renderer.states._tex!==null&&this.renderer.states._tex.width>0&&this.renderer.states._tex.height>0&&(this.geometry.uvs=this.geometry.uvs.map((t,n)=>n%2==0?t/this.renderer.states._tex.width:t/this.renderer.states._tex.height))}_remapVertices(t){this.geometry.vertices=t.map(t=>this.geometry.vertices[t]),this.geometry.vertexNormals=t.map(t=>this.geometry.vertexNormals[t]);let n=(n,r)=>{let i=[];for(let a of t)for(let t=0;t<r;t++)i.push(n[a*r+t]);return i};this.geometry.uvs=n(this.geometry.uvs,2),this.geometry.vertexColors=n(this.geometry.vertexColors,4),this.geometry.vertexStrokeColors=n(this.geometry.vertexStrokeColors,4);for(let n in this.geometry.userVertexProperties){let r=this.geometry.userVertexProperties[n],i=r.getDataSize(),a=r.getSrcArray();r.resetSrcArray();for(let n of t)r.setCurrentData(a.slice(n*i,n*i+i)),r.pushCurrentData()}}_convertFanToTriangles(){let t=this.geometry.vertices.length;if(t<3)return;let n=[];for(let r=2;r<t;r++)n.push(0,r-1,r);this._remapVertices(n)}_resetUserVertexProperties(){let t=this.geometry.userVertexProperties;for(let n in t){let r=t[n];delete this.bufferStrides[n],r.delete()}this._useUserVertexProperties=!1,this.tessyVertexSize=Qo,this.geometry.userVertexProperties={}}_calculateEdges(t,n){let r=[],i=0,a=this.contourIndices.slice(),o=-1;switch(t){case 5:for(i=0;i<n.length-2;i++)r.push([i,i+1]),r.push([i,i+2]);r.push([i,i+1]);break;case 6:for(i=1;i<n.length-1;i++)r.push([0,i]),r.push([i,i+1]);r.push([0,n.length-1]);break;case 4:for(i=0;i<n.length-2;i+=3)r.push([i,i+1]),r.push([i+1,i+2]),r.push([i+2,i]);break;case 1:for(i=0;i<n.length-1;i+=2)r.push([i,i+1]);break;case oe:for(i=0;i<n.length-5;i+=6)r.push([i,i+1]),r.push([i+1,i+2]),r.push([i+2,i+5]),r.push([i+5,i]);break;case se:for(i=0;i<n.length-2;i+=2)r.push([i,i+1]),r.push([i+1,i+3]),r.push([i,i+2]);r.push([i,i+1]);break;default:for(i=0;i<n.length;i++)i===a[0]?o=a.shift():n[o]&&n[i].equals(n[o])?r.push([i-1,o]):r.push([i-1,i])}return r}_tesselateShape(){let t=[];for(let n=0;n<this.geometry.vertices.length;n++){this.contourIndices.length>0&&this.contourIndices[0]===n&&(this.contourIndices.shift(),t.push([])),t[t.length-1].push(this.geometry.vertices[n].x,this.geometry.vertices[n].y,this.geometry.vertices[n].z,this.geometry.uvs[n*2],this.geometry.uvs[n*2+1],this.geometry.vertexColors[n*4],this.geometry.vertexColors[n*4+1],this.geometry.vertexColors[n*4+2],this.geometry.vertexColors[n*4+3],this.geometry.vertexNormals[n].x,this.geometry.vertexNormals[n].y,this.geometry.vertexNormals[n].z);for(let r in this.geometry.userVertexProperties){let i=this.geometry.userVertexProperties[r],a=n*i.getDataSize(),o=a+i.getDataSize(),s=i.getSrcArray().slice(a,o);t[t.length-1].push(...s)}}let n=1e-6;for(let r of t){let t=this.tessyVertexSize;for(let i=t;i<r.length;i+=t){let a=r[i-t],o=r[i-t+1],s=r[i],c=r[i+1];Math.abs(s-a)<n&&(r[i]=a),Math.abs(c-o)<n&&(r[i+1]=o)}}let r=this._triangulate(t);if(r.length===0)return;this.shapeMode=4;let i=this.geometry.vertices;this.geometry.vertices=[],this.geometry.vertexNormals=[],this.geometry.uvs=[];for(let t in this.geometry.userVertexProperties)this.geometry.userVertexProperties[t].resetSrcArray();let a=[];for(let t=0,n=r.length;t<n;t+=this.tessyVertexSize){a.push(...r.slice(t+5,t+9)),this.geometry.vertexNormals.push(new I(...r.slice(t+9,t+12)));{let n=12;for(let i in this.geometry.userVertexProperties){let a=this.geometry.userVertexProperties[i],o=a.getDataSize(),s=t+n,c=s+o;a.setCurrentData(r.slice(s,c)),a.pushCurrentData(),n+=o}}this.geometry.vertices.push(new I(...r.slice(t,t+3))),this.geometry.uvs.push(...r.slice(t+3,t+5))}if(this.renderer.geometryBuilder){let t=/* @__PURE__ */ new Map;this.geometry.edges=this.geometry.edges.map(n=>n.map(n=>{if(!t.has(n)){let r=i[n],a=this.geometry.vertices.findIndex(t=>r.x===t.x&&r.y===t.y&&r.z===t.z);if(a===-1){let t=1/0,n=0;for(let i=0;i<this.geometry.vertices.length;i++){let a=this.geometry.vertices[i],o=r.x-a.x,s=r.y-a.y,c=r.z-a.z,l=o*o+s*s+c*c;l<t&&(t=l,n=i)}a=n}t.set(n,a)}return t.get(n)}))}this.geometry.vertexColors=a}_initTessy(){function t(t,n){for(let r of t)n.push(r)}function n(t){t!==Jo.default.primitiveType.GL_TRIANGLES&&console.log(`expected TRIANGLES but got type: ${t}`)}function r(t){console.log(`error callback`),console.log(`error number: ${t}`)}let i=(t,n,r)=>{let i=Array(this.tessyVertexSize).fill(0);for(let t=0;t<r.length;t++)for(let a=0;a<i.length;a++)r[t]!==0&&n[t]&&(i[a]+=n[t][a]*r[t]);return i};function a(t){}let o=new Jo.default.GluTesselator;return o.gluTessCallback(Jo.default.gluEnum.GLU_TESS_VERTEX_DATA,t),o.gluTessCallback(Jo.default.gluEnum.GLU_TESS_BEGIN,n),o.gluTessCallback(Jo.default.gluEnum.GLU_TESS_ERROR,r),o.gluTessCallback(Jo.default.gluEnum.GLU_TESS_COMBINE,i),o.gluTessCallback(Jo.default.gluEnum.GLU_TESS_EDGE_FLAG,a),o.gluTessProperty(Jo.default.gluEnum.GLU_TESS_WINDING_RULE,Jo.default.windingRule.GLU_TESS_WINDING_NONZERO),o}_triangulate(t){let n=t[0]?t[0][2]:void 0,r=!0;for(let i of t)for(let t=0;t<i.length;t+=this.tessyVertexSize)if(i[t+2]!==n){r=!1;break}r?this._tessy.gluTessNormal(0,0,1):this._tessy.gluTessNormal(0,0,0);let i=[];this._tessy.gluTessBeginPolygon(i);for(let n of t){this._tessy.gluTessBeginContour();for(let t=0;t<n.length;t+=this.tessyVertexSize){let r=n.slice(t,t+this.tessyVertexSize);this._tessy.gluTessVertex(r,r)}this._tessy.gluTessEndContour()}return this._tessy.gluTessEndPolygon(),i}},es=class{constructor(t){this.renderer=t,this.cache={}}numCached(){return Object.keys(this.cache).length}isCached(t){return this.cache[t]!==void 0}getGeometryByID(t){return this.cache[t]?.geometry}getCached(t){return this.getCachedID(t.gid)}getCachedID(t){return this.cache[t]}ensureCached(t){let n=t.gid;if(!n)throw Error(`The p5.Geometry you passed in has no gid property!`);if(this.isCached(n))return this.getCached(t);if(this.freeBuffers(n),Object.keys(this.cache).length>1e3){let t=Object.keys(this.cache)[0];this.freeBuffers(t)}let r={geometry:t};this.cache[n]=r;let i=t.faces.length?t.faces.flat():null,a=null;return i&&(a=i.some(t=>t>65535)?Uint32Array:Uint16Array),this.renderer._ensureGeometryBuffers(r,i,a),r}freeBuffers(t){let n=this.cache[t];n&&(delete this.cache[t],this.renderer._freeBuffers(n))}};const ts={[Ze]:3,[Je]:4,[We]:.5},ns={IDEOGRAPHIC:`ideographic`,RIGHT_TO_LEFT:`rtl`,LEFT_TO_RIGHT:`ltr`,_CTX_MIDDLE:`middle`,_TEXT_BOUNDS:`_textBoundsSingle`,_FONT_BOUNDS:`_fontBoundsSingle`,HANGING:`hanging`,START:`start`,END:`end`};function rs(t,n){let r=/\r?\n/g,i=/,\s+/,a=/^".*"$/,o=/\P{ASCII}/u,s=/\t/g,c=RegExp(`(?:${[`wght`,`wdth`,`ital`,`slnt`,`opsz`].join(`|`)})`);[`text`,`textAlign`,`textAscent`,`textDescent`,`textLeading`,`textMode`,`textFont`,`textSize`,`textStyle`,`textWidth`,`textWrap`,`textBounds`,`textDirection`,`textProperty`,`textProperties`,`fontBounds`,`fontWidth`,`fontAscent`,`fontDescent`,`textWeight`].forEach(r=>{n[r]=function(...t){if(!(r in L.prototype))throw Error(`Renderer2D.prototype.${r} is not defined.`);return this._renderer[r](...t)},t.Graphics.prototype[r]=function(...t){return this._renderer[r](...t)}});let l={textAlign:{default:n.LEFT,type:`Context2d`},textBaseline:{default:n.BASELINE,type:`Context2d`},textFont:{default:{family:`sans-serif`}},textLeading:{default:15},textSize:{default:12},textWrap:{default:n.WORD},fontStretch:{default:n.NORMAL,isShorthand:!0},fontWeight:{default:n.NORMAL,isShorthand:!0},lineHeight:{default:n.NORMAL,isShorthand:!0},fontVariant:{default:n.NORMAL,isShorthand:!0},fontStyle:{default:n.NORMAL,isShorthand:!0},direction:{default:`inherit`}},u=[`font`,`direction`,`fontKerning`,`fontStretch`,`fontVariantCaps`,`letterSpacing`,`textAlign`,`textBaseline`,`textRendering`,`wordSpacing`],d=Object.keys(l).filter(t=>l[t].isShorthand),f=[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`],p,m;L.prototype.text=function(t,n,r,i,a){let o=this.textDrawingContext().textBaseline;({x:n,y:r,width:i,height:a}=this._handleRectMode(n,r,i,a));let s=this._processLines(t,i,a);s=this._positionLines(n,r,i,a,s),s.forEach(t=>this._renderText(t.text,t.x,t.y)),this.textDrawingContext().textBaseline=o},L.prototype.textBounds=function(t,n,r,i,a){return this._computeBounds(ns._TEXT_BOUNDS,t,n,r,i,a).bounds},L.prototype.fontBounds=function(t,n,r,i,a){return this._computeBounds(ns._FONT_BOUNDS,t,n,r,i,a).bounds},L.prototype.textWidth=function(t){let n=this._processLines(t);return Math.max(...n.map(t=>this._textWidthSingle(t)))},L.prototype.fontWidth=function(t){let n=this._processLines(t);return Math.max(...n.map(t=>this._fontWidthSingle(t)))},L.prototype.textAscent=function(t=``){return t.length?this.textDrawingContext().measureText(t).actualBoundingBoxAscent:this.fontAscent()},L.prototype.fontAscent=function(){return this.textDrawingContext().measureText(`_`).fontBoundingBoxAscent},L.prototype.textDescent=function(t=``){return t.length?this.textDrawingContext().measureText(t).actualBoundingBoxDescent:this.fontDescent()},L.prototype.fontDescent=function(){return this.textDrawingContext().measureText(`_`).fontBoundingBoxDescent},L.prototype.textAlign=function(t,r){return arguments.length===0?{horizontal:this.states.textAlign,vertical:this.states.textBaseline}:(typeof t==`object`&&t&&(t.hasOwnProperty(`vertical`)&&(r=t.vertical),t.hasOwnProperty(`horizontal`)&&(t=t.horizontal)),(typeof t==`string`||t instanceof String)&&this.states.setValue(`textAlign`,t),(typeof r==`string`||r instanceof String)&&(r===n.CENTER&&(r=ns._CTX_MIDDLE),this.states.setValue(`textBaseline`,r)),this._applyTextProperties())},L.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},L.prototype.textFont=function(n,r,i){if(arguments.length===0)return this._currentTextFont();let a=n;if(n instanceof t.Font?a=n.face.family:n.data instanceof Uint8Array?(a=n.name.fontFamily,n.name?.fontSubfamily&&(a+=`-`+n.name.fontSubfamily)):typeof n==`string`&&r===void 0&&/[.0-9]+(%|em|p[xt])/.test(a)&&({family:a,size:r}=this._directSetFontString(a)),typeof a!=`string`)throw Error(`null font in textFont()`);return arguments.length===2&&typeof r==`object`&&(i=r,r=void 0),this.states.setValue(`textFont`,{font:n,family:a,size:r}),r!==void 0&&this._setTextSize(r),typeof i==`object`&&this.textProperties(i),this._applyTextProperties()},L.prototype._directSetFontString=function(t,n=0){n&&console.log(`_directSetFontString"`+t+`"`);let r=d.reduce((t,n)=>(t[n]=l[n].default,t),{}),i=this._cachedDiv(r);i.style.font=t;let a=getComputedStyle(i);return d.forEach(t=>{this.states[t]=a[t],n&&console.log(`  this.states.`+t+`="`+a[t]+`"`)}),{family:a.fontFamily,size:a.fontSize}},L.prototype.textLeading=function(t){return typeof t==`number`?(this.states.setValue(`leadingSet`,!0),this.states.setValue(`textLeading`,t),this._applyTextProperties()):this.states.textLeading},L.prototype.textWeight=function(t){if(typeof t==`number`)this.states.setValue(`fontWeight`,t),this._applyTextProperties();else return this.states.fontWeight},L.prototype.textSize=function(t){return t===void 0?this.states.textSize:(this._setTextSize(t),this._applyTextProperties())},L.prototype.textStyle=function(t){return t===void 0?this.states.fontStyle:(this.states.setValue(`fontStyle`,t),this._applyTextProperties())},L.prototype.textWrap=function(t){return t===n.WORD||t===n.CHAR?(this.states.setValue(`textWrap`,t),this._pInst):this.states.textWrap},L.prototype.textDirection=function(t){return t===void 0?this.states.direction:(this.states.setValue(`direction`,t),this._applyTextProperties())},L.prototype.textProperty=function(t,n,r){let i=!1,a=r?.debug||!1;if(n===void 0){let n=this.textProperties();if(t in n)return n[t];throw Error(`Unknown text option "`+t+`"`)}return t in this.states&&this.states[t]!==n?(this.states[t]=n,i=!0,a&&console.log(`this.states.`+t+`="`+options[t]+`"`)):t in this.textDrawingContext()?(this._setContextProperty(t,n,a),i=!0):t in this.textCanvas().style?(this._setCanvasStyleProperty(t,n,a),i=!0):console.warn(`Ignoring unknown text option: "`+t+`"
`),i?this._applyTextProperties():this._pInst},L.prototype.textProperties=function(t){if(t!==void 0)return Object.keys(t).forEach(n=>{this.textProperty(n,t[n])}),this._pInst;let n=this.textDrawingContext();return t=u.reduce((t,r)=>(t[r]=n[r],t),{}),Object.keys(l).forEach(r=>{if(l[r]?.type===`Context2d`)t[r]=n[r];else if(r===`textFont`){let n=this._currentTextFont();typeof n==`object`&&`_pInst`in n&&(n=Object.assign({},n),delete n._pInst),t[r]=n}else t[r]=this.states[r]}),t},L.prototype.textMode=function(){},L.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},L.prototype._computeBounds=function(n,r,i,a,o,s,c){let l=this.textDrawingContext(),u=l.textBaseline,{textLeading:d,textAlign:f}=this.states;({width:o,height:s}=this._rectModeAdjust(i,a,o,s));let p=this._processLines(r,o,s),m=p.map((t,r)=>this[n].bind(this)(t,i,a+r*d));p.length>1&&o!==void 0&&m.forEach(n=>n.x+=t.Renderer2D.prototype._xAlignOffset.call(this,f,o)),t.Renderer2D.prototype._yAlignOffset.call(this,m,s||0);let h=m[0];return p.length>1&&(h=this._aggregateBounds(m),c?.ignoreRectMode||this._rectModeAlign(h,o||0,s||0)),l.textBaseline=u,{bounds:h,lines:p}},L.prototype._rectModeAdjust=function(t,r,i,a){if(i!==void 0)switch(this.states.rectMode){case n.CENTER:break;case n.CORNERS:i-=t,a-=r;break;case n.RADIUS:i*=2,a*=2}return{x:t,y:r,width:i,height:a}},L.prototype._setCanvasStyleProperty=function(t,n,r){let i=n.toString();r&&console.log(`canvas.style.`+t+`="`+i+`"`),t===`fontVariationSettings`&&this._handleFontVariationSettings(i),this.textCanvas().style[t]=i,this.textCanvas().style[t]!==i&&r&&console.warn(`Unable to set '${t}' property on canvas.style. It may not be supported. Expected "`+i+`" but got: "`+this.textCanvas().style[t]+`'`)},L.prototype._handleFontVariationSettings=function(t,n=!1){typeof t==`object`&&(t=Object.keys(t).map(n=>n+` `+t[n]).join(`, `)),t.split(i).forEach(t=>{t=t.replace(/["']/g,``);let r=c.exec(t);if(r&&r.length){let i=r[0],a=parseFloat(parseFloat(t.replace(i,``).trim()).toFixed(3));switch(i){case`wght`:return n&&console.log(`setting font-weight=`+a),this.states.fontWeight!==a&&this.textWeight(a),a;case`wdth`:break;case`ital`:n&&console.log(`setting font-style=`+(a?`italic`:`normal`));break;case`slnt`:n&&console.log(`setting font-style=`+(a?`oblique`:`normal`));break;case`opsz`:n&&console.log(`setting font-optical-size=`+a)}}})},L.prototype._setContextProperty=function(t,n,r=!1){if(this.textDrawingContext()[t]===n)return this._pInst;(p??=[]).push([t,n]),r&&console.log(`queued context2d.`+t+`="`+n+`"`)},L.prototype._handleRectMode=function(t,r,i,a){let o=this.states.rectMode;if(i!==void 0)switch(o){case n.RADIUS:i*=2,t-=i/2,a!==void 0&&(a*=2,r-=a/2);break;case n.CENTER:t-=i/2,a!==void 0&&(r-=a/2);break;case n.CORNERS:i-=t,a!==void 0&&(a-=r)}return{x:t,y:r,width:i,height:a}},L.prototype._fontSizePx=function(t,{family:n}=this.states.textFont){if((t=>!isNaN(t)&&t.trim()!==``)(t))return parseFloat(t);let r=this._cachedDiv({fontSize:t});r.style.fontSize=t,r.style.fontFamily=n;let i=getComputedStyle(r).fontSize,a=parseFloat(i);if(typeof a!=`number`)throw Error(`textSize: invalid font-size`);return a},L.prototype._cachedDiv=function(t){if(m===void 0){let n=document.createElement(`div`);n.ariaHidden=`true`,n.style.display=`none`,Object.entries(t).forEach(([t,r])=>{n.style[t]=r}),this.textCanvas().appendChild(n),m=n}return m},L.prototype._aggregateBounds=function(t){let n=Math.min(...t.map(t=>t.x)),r=Math.min(...t.map(t=>t.y)),i=Math.max(...t.map(t=>t.y+t.h));return{x:n,y:r,w:Math.max(...t.map(t=>t.x+t.w))-n,h:i-r}},L.prototype._processLines=function(t,r,i){r!==void 0&&this.textDrawingContext().textBaseline===n.BASELINE&&(this.drawingContext.textBaseline=n.TOP);let a=this._splitOnBreaks(t.toString()),o=a.length>1,s=r!==void 0,c=s&&a.some(t=>this._textWidthSingle(t)>r),{textLeading:l,textWrap:u}=this.states;if((o||c)&&s&&(a=this._lineate(u,a,r)),s&&i!==void 0){if(l===void 0)throw Error(`leading is required if height is specified`);for(let t=0;t<a.length;t++)if(l*(t+1)>i){a=a.slice(0,t);break}}return a},L.prototype._xAlignOffset=function(t,r){switch(t){case n.LEFT:return 0;case n.CENTER:return r/2;case n.RIGHT:return r;case ns.START:return 0;case ns.END:throw Error(`textBounds: END not yet supported for textAlign`);default:return 0}},L.prototype._rectModeAlign=function(t,r,i){if(r!==void 0){switch(this.states.rectMode){case n.CENTER:t.x-=(r-t.w)/2,t.y-=(i-t.h)/2;break;case n.CORNERS:t.w+=t.x,t.h+=t.y;break;case n.RADIUS:t.x-=(r-t.w)/2,t.y-=(i-t.h)/2,t.w/=2,t.h/=2}return t}},L.prototype._rectModeAlignRevert=function(t,r,i){if(r!==void 0){switch(this.states.rectMode){case n.CENTER:t.x+=(r-t.w)/2,t.y+=(i-t.h)/2;break;case n.CORNERS:t.w-=t.x,t.h-=t.y;break;case n.RADIUS:t.x+=(r-t.w)/2,t.y+=(i-t.h)/2,t.w*=2,t.h*=2}return t}},L.prototype._textWidthSingle=function(t){let n=this.textDrawingContext().measureText(t),r=n.actualBoundingBoxLeft;return n.actualBoundingBoxRight+r},L.prototype._fontWidthSingle=function(t){return this.textDrawingContext().measureText(t).width},L.prototype._textBoundsSingle=function(t,n=0,r=0){let i=this.textDrawingContext().measureText(t),a=i.actualBoundingBoxAscent,o=i.actualBoundingBoxDescent,s=i.actualBoundingBoxLeft,c=i.actualBoundingBoxRight;return{x:n-s,y:r-a,w:c+s,h:a+o}},L.prototype._fontBoundsSingle=function(t,n=0,r=0){let i=this.textDrawingContext().measureText(t),a=i.fontBoundingBoxAscent,o=i.fontBoundingBoxDescent;return n-=this._xAlignOffset(this.states.textAlign,i.width),{x:n,y:r-a,w:i.width,h:a+o}},L.prototype._setTextSize=function(t){if(typeof t==`string`&&(t=this._fontSizePx(t)),typeof t==`number`){if(this.states.textSize!==t)return this.states.setValue(`textSize`,t),this.states.leadingSet||this.states.setValue(`textLeading`,this.states.textSize*1.275),!0}else console.warn(`textSize: invalid size: `+t);return!1},L.prototype._lineate=function(t,r,i=1/0,a={}){let o=a.splitChar??(t===n.WORD?` `:``),s,c,l,u,d=[];for(let t=0;t<r.length;t++){s=``,u=r[t].split(o);for(let t=0;t<u.length;t++)c=`${s+u[t]}`+o,l=this._textWidthSingle(c),s.length>0&&l>i?(d.push(s.trim()),s=`${u[t]}`+o):s=c;d.push(s.trim())}return d},L.prototype._splitOnBreaks=function(t){return!t||t.length===0?[``]:t.replace(s,`  `).split(r)},L.prototype._parseFontFamily=function(t){return t.split(i).map(t=>(t=t.trim(),(t.indexOf(` `)>-1||o.test(t))&&!a.test(t)&&(t=`"${t}"`),t)).join(`, `)},L.prototype._applyFontString=function(){let{textFont:t,textSize:r,lineHeight:i,fontStyle:a,fontWeight:o,fontVariant:s}=this.states,c=this.textDrawingContext(),l=this._parseFontFamily(t.family),u=a===n.NORMAL?``:`${a} `,d=o===n.NORMAL?``:`${o} `,f=`${u}${s===n.NORMAL?``:`${s} `}${d}${`${r}px`+(i===n.NORMAL?` `:`/${i} `)}${l}`.trim();return c.font=f,c.font===f||f===c.font},L.prototype._applyTextProperties=function(t=!1){this._applyFontString();let n=this.textDrawingContext();n.direction=this.states.direction,n.textAlign=this.states.textAlign,n.textBaseline=this.states.textBaseline;let r=this.states.fontStretch;for(f.includes(r)&&n.fontStretch!==r&&(n.fontStretch=r);p?.length;){let[r,i]=p.shift();t&&console.log(`apply context property "`+r+`" = "`+i+`"`),n[r]=i,n[r]!==i&&(console.warn(`Unable to set '${r}' property on context2d. It may not be supported.`),console.log(`Expected "`+i+`" but got: "`+n[r]+`"`))}return this._pInst}}typeof p5<`u`&&rs(p5,p5.prototype);function is(t,n,r){switch(n){case Ge:return t.baseFilterShader().modify(({p5:t})=>{t.getColor((n,r)=>{let i=t.getTexture(r,n.texCoord),a=t.dot(i.rgb,t.vec3(.2126,.7152,.0722));return t.vec4(a,a,a,i.a)})},{p5:r});case qe:return t.baseFilterShader().modify(({p5:t})=>{t.getColor((n,r)=>{let i=t.getTexture(r,n.texCoord),a=t.vec3(1)-i.rgb;return t.vec4(a,i.a)})},{p5:r});case We:return t.baseFilterShader().modify(({p5:t})=>{let n=t.uniformFloat(`filterParameter`);t.getColor((r,i)=>{let a=t.getTexture(i,r.texCoord),o=t.dot(a.rgb,t.vec3(.2126,.7152,.0722)),s=t.floor(n*255)/255,c=t.step(s,o);return t.vec4(t.vec3(c),a.a)})},{p5:r});case Je:return t.baseFilterShader().modify(({p5:t})=>{let n=t.uniformFloat(`filterParameter`),r=(n,r)=>(n*=r,n=t.floor(n),n/=r-1,n);t.getColor((i,a)=>{let o=t.getTexture(a,i.texCoord),s=r(o.rgb,n);return t.vec4(s,o.a)})},{p5:r});case Ze:return t.baseFilterShader().modify(({p5:t})=>{let n=t.uniformFloat(`radius`),r=t.uniformVec2(`direction`),i=(n,r)=>t.pow(r-t.abs(n),2),a=n=>{let r=t.fract(n.xyx*.1031);return r+=t.dot(r,r.yzx+33.33),t.fract((r.x+r.y)*r.z)};t.getColor((o,s)=>{let c=o.texCoord,l=t.floor(n*7);t.mod(l,2)===0&&l++;let u=t.vec4(0),d=0,f=1;l>64&&(f=l/64,l=64);let p=o.texelSize.x*o.canvasSize.x,m=t.max(f-p,0)*t.mix(-.5,.5,a(c*o.canvasSize));for(let n=0;n<l;n++){let a=n*f-(l-1)*.5*f+m,p=c+t.vec2(a,a)/o.canvasSize*r,h=i(a,(l-1)*.5*f),g=t.getTexture(s,p);u+=h*g*t.vec4(g.a,g.a,g.a,1),d+=h}let h=u/d;return t.vec4(h.r/h.a,h.g/h.a,h.b/h.a,h.a)})},{p5:r});case Xe:return t.baseFilterShader().modify(({p5:t})=>{let n=n=>t.dot(n.rgb,t.vec3(.2126,.7152,.0722));t.getColor((r,i)=>{let a=r.texCoord,o=t.getTexture(i,a),s=n(o);for(let c=-1;c<=1;c++)for(let l=-1;l<=1;l++)if(c!==0||l!==0){let u=t.vec2(c,l)*r.texelSize,d=t.getTexture(i,a+u),f=n(d);f<s&&(s=f,o=d)}return o})},{p5:r});case Ye:return t.baseFilterShader().modify(({p5:t})=>{let n=n=>t.dot(n.rgb,t.vec3(.2126,.7152,.0722));t.getColor((r,i)=>{let a=r.texCoord,o=t.getTexture(i,a),s=n(o);for(let c=-1;c<=1;c++)for(let l=-1;l<=1;l++)if(c!==0||l!==0){let u=t.vec2(c,l)*r.texelSize,d=t.getTexture(i,a+u),f=n(d);f>s&&(s=f,o=d)}return o})},{p5:r});case Ke:return t.baseFilterShader().modify(({p5:t})=>{t.getColor((n,r)=>{let i=t.getTexture(r,n.texCoord);return t.vec4(i.rgb,1)})},{p5:r});default:throw Error(`Unknown filter: ${n}`)}}function as(t){let n={},r={},i=``,a=function(r,a){i+=t(`STROKE_CAP_${r}`,`${a}`,`u32`),n[d[r]]=a},o=function(n,a){i+=t(`STROKE_JOIN_${n}`,`${a}`,`u32`),r[d[n]]=a};return a(`ROUND`,0),a(`PROJECT`,1),a(`SQUARE`,2),o(`ROUND`,0),o(`MITER`,1),o(`BEVEL`,2),{STROKE_CAP_ENUM:n,STROKE_JOIN_ENUM:r,lineDefs:i}}const os={webgpu:`WEBGPU mode is experimental, so its functions and constants may change in future versions. You can get involved by giving feedback to help direct its development!`,"p5.strands":`p5.strands shaders are experimental, so functions for building shaders and the hooks available within them may change in future versions. You can get involved by giving feedback to help direct its development!`,"p5.strands.transforms":`p5.strands transforms are experimental, so transform2D(), transform3D(), the matrix constructors, and the functions that build on them may change in future versions. You can get involved by giving feedback to help direct their development!`,"p5.svg":`SVG features are experimental, so SVG export, import, and shape recording functions may change in future versions. You can get involved by giving feedback to help direct its development!`},ss={"p5.strands.transforms":{doc:`p5.strands`,section:`transforms-and-matrices`}};function cs(t){let{doc:n=t,section:r}=ss[t]||{};return`https://p5js.org/contribute/${n}/${r?`#${r}`:``}`}const ls={};function us(t,n,r){let i=n||ls;if(!t.disableFriendlyErrors&&!i.warnedExperimental?.[r]){i.warnedExperimental=i.warnedExperimental||{},i.warnedExperimental[r]=!0;let t=os[r],n=cs(r);R.log`${t} For more info, see ${n}`()}}function ds(t,n,r=t=>t){return function(i){return function(...a){return us(n,r(this),t),i.apply(this,a)}}}const{STROKE_CAP_ENUM:fs,STROKE_JOIN_ENUM:ps}=as(()=>``);var z=class t extends L{constructor(t,n,r,i,a){super(t,n,r,i),this.canvas=this.elt=a||document.createElement(`canvas`),this.contextReady=this.setupContext(),this._isMainCanvas?(this._pInst._curElement=this,this._pInst.canvas=this.canvas):this.canvas.style.display=`none`,this.elt.id=`defaultCanvas0`,this.elt.classList.add(`p5Canvas`),this.wrappedElt=new ta(this.elt,this._pInst);for(let t of Object.getOwnPropertyNames(ta.prototype))t!==`constructor`&&t[0]!==`_`&&Object.defineProperty(this,t,{get(){return this.wrappedElt[t]}});let o=this._adjustDimensions(n,r);if(n=o.adjustedWidth,r=o.adjustedHeight,this.width=n,this.height=r,this.elt.width=n*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${n}px`,this.elt.style.height=`${r}px`,this._updateViewport(),this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(document.getElementsByTagName(`main`).length===0){let t=document.createElement(`main`);document.body.appendChild(t)}document.getElementsByTagName(`main`)[0].appendChild(this.elt)}this.isP3D=!0,this.geometryBuilder=void 0,this.states.uModelMatrix=new Po(4),this.states.uViewMatrix=new Po(4),this.states.uPMatrix=new Po(4),this.mainCamera=new Ko(this),this.states.curCamera||(this.states.curCamera=this.mainCamera),this.states.uPMatrix.set(this.states.curCamera.projMatrix),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this.states.enableLighting=!1,this.states.ambientLightColors=[],this.states.specularColors=[1,1,1],this.states.directionalLightDirections=[],this.states.directionalLightDiffuseColors=[],this.states.directionalLightSpecularColors=[],this.states.pointLightPositions=[],this.states.pointLightDiffuseColors=[],this.states.pointLightSpecularColors=[],this.states.spotLightPositions=[],this.states.spotLightDirections=[],this.states.spotLightDiffuseColors=[],this.states.spotLightSpecularColors=[],this.states.spotLightAngle=[],this.states.spotLightConc=[],this.states.activeImageLight=null,this.states.curFillColor=[1,1,1,1],this.states.curAmbientColor=[1,1,1,1],this.states.curSpecularColor=[0,0,0,0],this.states.curEmissiveColor=[0,0,0,0],this.states.curStrokeColor=[0,0,0,1],this.states.curBlendMode=F,this.states._hasSetAmbient=!1,this.states._useSpecularMaterial=!1,this.states._useEmissiveMaterial=!1,this.states._useNormalMaterial=!1,this.states._useShininess=1,this.states._useMetalness=0,this.states.tint=null,this.states.constantAttenuation=1,this.states.linearAttenuation=0,this.states.quadraticAttenuation=0,this.states._currentNormal=new I(0,0,1),this.states.drawMode=ft,this.states._tex=null,this.states._specularTex=null,this.states._ambientTex=null,this.states._shininessTex=null,this.states._normalTex=null,this.states._normalScale=1,this.states._normalMapMode=0,this.states.textureMode=ht,this.states.textureWrapX=yt,this.states.textureWrapY=yt,this._isErasing=!1,this._simpleLines=!1,this._clipDepths=[],this._textContextSavedStack=[],this._isClipApplied=!1,this._stencilTestOn=!1,this.mixedAmbientLight=[],this.mixedSpecularColor=[],this.diffusedTextures=/* @__PURE__ */ new Map,this.specularTextures=/* @__PURE__ */ new Map,this.preEraseBlend=void 0,this._cachedFillStyle=[1,1,1,1],this._cachedStrokeStyle=[0,0,0,1],this._isBlending=!1,this._useLineColor=!1,this._useVertexColor=!1,this.registerEnabled=/* @__PURE__ */ new Set,this.mainCamera._computeCameraDefaultSettings(),this.mainCamera._setDefaultCamera(),this.filterCamera=new Ko(this),this.filterCamera._computeCameraDefaultSettings(),this.filterCamera._setDefaultCamera(),this.prevTouches=[],this.zoomVelocity=0,this.rotateVelocity=new I(0,0),this.moveVelocity=new I(0,0),this.executeZoom=!1,this.executeRotateAndMove=!1,this._drawingFilter=!1,this._drawingImage=!1,this.specularShader=void 0,this.sphereMapping=void 0,this.diffusedShader=void 0,this._baseFilterShader=void 0,this._defaultLightShader=void 0,this._defaultImmediateModeShader=void 0,this._defaultNormalShader=void 0,this._defaultColorShader=void 0,this.states.userFillShader=void 0,this.states.userStrokeShader=void 0,this.states.userImageShader=void 0,this.states.curveDetail=1/4,this.shapeBuilder=new $o(this),this._largeTessellationAcknowledged=!1,this.geometryBufferCache=new es(this),this.curStrokeCap=me,this.curStrokeJoin=me,this.textures=/* @__PURE__ */ new Map,this.framebuffers=/* @__PURE__ */ new Set,this.activeFramebuffers=[],this.states.filterShader=void 0,this.filterLayer=void 0,this.filterLayerTemp=void 0,this.defaultFilterShaders={},this.fontInfos={},this._curShader=void 0,this.drawShapeCount=1,this._instanceCount=void 0,this.scratchMat3=new Po(3),this._validateFaces=!1,this.buffers={fill:[new Yo(3,`vertices`,`vertexBuffer`,`aPosition`,this,this._vToNArray),new Yo(3,`vertexNormals`,`normalBuffer`,`aNormal`,this,this._vToNArray),new Yo(4,`vertexColors`,`colorBuffer`,`aVertexColor`,this).default(t=>t.vertices.flatMap(()=>[-1,-1,-1,-1])),new Yo(3,`vertexAmbients`,`ambientBuffer`,`aAmbientColor`,this),new Yo(2,`uvs`,`uvBuffer`,`aTexCoord`,this,t=>t.flat()),new Yo(4,`vertexTangents`,`tangentBuffer`,`aTangent`,this).default(t=>t.vertices.flatMap(()=>[0,0,0,1]))],stroke:[new Yo(4,`lineVertexColors`,`lineColorBuffer`,`aVertexColor`,this).default(t=>t.lineVertices.flatMap(()=>[-1,-1,-1,-1])),new Yo(3,`lineVertices`,`lineVerticesBuffer`,`aPosition`,this),new Yo(3,`lineTangentsIn`,`lineTangentsInBuffer`,`aTangentIn`,this),new Yo(3,`lineTangentsOut`,`lineTangentsOutBuffer`,`aTangentOut`,this),new Yo(1,`lineSides`,`lineSidesBuffer`,`aSide`,this)],text:[new Yo(3,`vertices`,`vertexBuffer`,`aPosition`,this,this._vToNArray),new Yo(2,`uvs`,`uvBuffer`,`aTexCoord`,this,t=>t.flat())],user:[]}}async _resetContext(n,r,i=t){let a=this.width,o=this.height,s=this.canvas.id,c=this._pInst instanceof Ts,l={position:this.canvas.style.position,top:this.canvas.style.top,left:this.canvas.style.left};if(c){let t=this._pInst;t.canvas.parentNode.removeChild(t.canvas),t.canvas=document.createElement(`canvas`),(t._pInst._userNode||document.body).appendChild(t.canvas),ta.call(t,t.canvas,t._pInst),t.width=a,t.height=o}else{let t=this.canvas;t&&t.parentNode.removeChild(t),t=document.createElement(`canvas`),t.id=s,this._pInst._userNode?this._pInst._userNode.appendChild(t):document.body.appendChild(t),this._pInst.canvas=t,this.canvas=t,this.canvas.style.position=l.position,this.canvas.style.top=l.top,this.canvas.style.left=l.left}let u=new i(this._pInst,a,o,!c,this._pInst.canvas);this._pInst._renderer=u,u._applyDefaults(),u.contextReady&&await u.contextReady,typeof r==`function`&&setTimeout(()=>{r.apply(window._renderer,n)},0)}beginGeometry(){if(this.geometryBuilder)throw Error("It looks like `beginGeometry()` is being called while another p5.Geometry is already being build.");this.geometryBuilder=new Uo(this),this.geometryBuilder.prevFillColor=this.states.fillColor,this.fill(new Ui([-1,-1,-1,-1]))}endGeometry(){if(!this.geometryBuilder)throw Error(`Make sure you call beginGeometry() before endGeometry()!`);let t=this.geometryBuilder.finish();return this.geometryBuilder.prevFillColor?this.fill(this.geometryBuilder.prevFillColor):this.noFill(),this.geometryBuilder=void 0,t}buildGeometry(t){return this.beginGeometry(),t(),this.endGeometry()}beginShape(...t){super.beginShape(...t)}curveDetail(t){if(t===void 0)return this.states.curveDetail;this.states.setValue(`curveDetail`,t)}drawShape(t){let n=new Va({curveDetail:this.states.curveDetail});t.accept(n),this.shapeBuilder.constructFromContours(t,n.contours),this.geometryBuilder?this.geometryBuilder.addImmediate(this.shapeBuilder.geometry,this.shapeBuilder.shapeMode,{validateFaces:this._validateFaces}):(this.states.fillColor||this.states.strokeColor)&&this._drawGeometry(this.shapeBuilder.geometry,{mode:this.shapeBuilder.shapeMode,count:this.drawShapeCount}),this.drawShapeCount=1}endShape(t,n){this.drawShapeCount=n??this._instanceCount??1,super.endShape(t,n)}vertexProperty(...t){this.currentShape.vertexProperty(...t)}normal(t,n,r){t instanceof I?this.states.setValue(`_currentNormal`,t):this.states.setValue(`_currentNormal`,new I(t,n,r)),this.updateShapeVertexProperties()}model(t,n){n=n??this._instanceCount??1,t.vertices.length>0&&(this.geometryBuilder?this.geometryBuilder.addRetained(t):(this.geometryInHash(t.gid)||(t._edgesToVertices(),this._getOrMakeCachedBuffers(t)),this._drawGeometry(t,{count:n})))}_getOrMakeCachedBuffers(t){return this.geometryBufferCache.ensureCached(t)}_drawGeometry(t,{mode:n=4,count:r=1}={}){for(let n in t.userVertexProperties){let r=t.userVertexProperties[n];this.buffers.user.push(new Yo(r.getDataSize(),r.getSrcName(),r.getDstName(),r.getName(),this))}if(this.states.fillColor&&t.vertices.length>=3&&![1,0].includes(n))for(let i of t.parts){let t=i.partState;t&&(t.fill!=null||t.texture!=null||t.ambientColor!=null||t.specularColor!=null||t.shininess!=null||t.specularTexture!=null||t.ambientTexture!=null||t.shininessTexture!=null)?(this.push(),this._applyPartState(t),this._drawFills(i,{mode:n,count:r}),this.pop()):this._drawFills(i,{mode:n,count:r})}this.states.strokeColor&&t.lineVertices.length>=1&&this._drawStrokes(t,{count:r}),this.buffers.user=[]}_drawFills(t,{count:n,mode:r}={}){this._useVertexColor=t.vertexColors.length>0&&!t.vertexColors.isDefault,this.states._normalTex&&t.computeTangents&&(!t.vertexTangents||t.vertexTangents.length===0)&&t.uvs.length>0&&t.vertexNormals.length>0&&t.computeTangents();let i=!this._drawingFilter&&this.states.userFillShader?this.states.userFillShader:this._getFillShader();i.bindShader(`fill`),this._setGlobalUniforms(i),this._setFillUniforms(i),i.bindTextures();for(let n of this.buffers.fill)n._prepareBuffer(t,i);this._prepareUserAttributes(t,i),this._disableRemainingAttributes(i),this._applyColorBlend(this.states.curFillColor,t.hasFillTransparency()),this._drawBuffers(t,{mode:r,count:n}),i.unbindShader()}_applyPartState(t){t&&(t.fill&&this.states.setValue(`curFillColor`,t.fill),t.texture&&(this.states.setValue(`_tex`,t.texture),this.states.setValue(`drawMode`,pt)),t.ambientColor&&(this.states.setValue(`curAmbientColor`,t.ambientColor),this.states.setValue(`_hasSetAmbient`,!0)),t.ambientTexture&&(this.states.setValue(`_ambientTex`,t.ambientTexture),this.states.setValue(`_hasSetAmbient`,!0)),t.specularColor&&(this.states.setValue(`curSpecularColor`,t.specularColor),this.states.setValue(`_useSpecularMaterial`,!0)),t.specularTexture&&(this.states.setValue(`_specularTex`,t.specularTexture),this.states.setValue(`_useSpecularMaterial`,!0)),t.shininess!=null&&this.states.setValue(`_useShininess`,t.shininess),t.shininessTexture&&this.states.setValue(`_shininessTex`,t.shininessTexture),t.normalTexture&&(this.states.setValue(`_normalTex`,t.normalTexture),t.normalScale!=null&&this.states.setValue(`_normalScale`,t.normalScale),this.states.setValue(`_normalMapMode`,t.normalMapMode??0)))}_drawStrokes(t,{count:n}={}){this._useLineColor=t.vertexStrokeColors.length>0;let r=this._getStrokeShader();r.bindShader(`stroke`),this._setGlobalUniforms(r),this._setStrokeUniforms(r),r.bindTextures();for(let n of this.buffers.stroke)n._prepareBuffer(t,r);this._prepareUserAttributes(t,r),this._disableRemainingAttributes(r),this._applyColorBlend(this.states.curStrokeColor,t.hasStrokeTransparency()),this._drawBuffers(t,{count:n}),r.unbindShader()}_prepareUserAttributes(t,n){for(let r of this.buffers.user){if(!this._pInst.constructor.disableFriendleErrors){let n=t.userVertexProperties[r.attr];if(n){let r=n.getSrcArray().length/n.getDataSize();r>t.vertices.length?this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${n.getName()}' with more values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,`vertexProperty()`):r<t.vertices.length&&this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${n.getName()}' with fewer values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,`vertexProperty()`)}}r._prepareBuffer(t,n)}}_drawGeometryScaled(t,n,r,i){let a=this._instanceCount||1,o=this.states.uModelMatrix;this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone());try{this.states.uModelMatrix.scale(n,r,i),this.geometryBuilder?this.geometryBuilder.addRetained(t):this._drawGeometry(t,{count:a})}finally{this.states.setValue(`uModelMatrix`,o)}}_update(){this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),this.states.uModelMatrix.reset(),this.states.setValue(`uViewMatrix`,this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this.states.setValue(`ambientLightColors`,[]),this.states.setValue(`specularColors`,[1,1,1]),this.states.setValue(`directionalLightDirections`,[]),this.states.setValue(`directionalLightDiffuseColors`,[]),this.states.setValue(`directionalLightSpecularColors`,[]),this.states.setValue(`pointLightPositions`,[]),this.states.setValue(`pointLightDiffuseColors`,[]),this.states.setValue(`pointLightSpecularColors`,[]),this.states.setValue(`spotLightPositions`,[]),this.states.setValue(`spotLightDirections`,[]),this.states.setValue(`spotLightDiffuseColors`,[]),this.states.setValue(`spotLightSpecularColors`,[]),this.states.setValue(`spotLightAngle`,[]),this.states.setValue(`spotLightConc`,[]),this.states.setValue(`enableLighting`,!1),this.states.setValue(`tint`,new Ui([1,1,1,1])),this._resetBuffersBeforeDraw()}background(...t){let n=t[0];if(typeof n==`object`&&n&&typeof n.width==`number`&&typeof n.height==`number`&&(n.canvas!=null||n.elt!=null)){this._pInst.clear(),this._pInst.push(),this._pInst.resetMatrix(),this._pInst.imageMode(ie),this._pInst.image(n,0,0,this._pInst.width,this._pInst.height),this._pInst.pop();return}let r=this._pInst.color(...t);this.clear(...r._getRGBA())}get uModelMatrix(){return this.states.uModelMatrix}get uViewMatrix(){return this.states.uViewMatrix}get uPMatrix(){return this.states.uPMatrix}get uMVMatrix(){let t=this.uModelMatrix.copy();return t.mult(this.uViewMatrix),t}getWorldToScreenMatrix(){let t=this.states.uModelMatrix,n=this.states.uViewMatrix,r=this.states.uPMatrix,i=new Po(4);return i.scale(this.width,this.height,1),i.translate([.5,.5,.5]),i.scale(.5,-.5,.5),t.copy().mult(n).mult(r).mult(i)}fill(...t){super.fill(...t);let n=this.states.fillColor;this.states.setValue(`curFillColor`,n._array),this.states.setValue(`drawMode`,ft),this.states.setValue(`_useNormalMaterial`,!1),this.states.setValue(`_tex`,null)}stroke(...t){super.stroke(...t),this.states.setValue(`curStrokeColor`,this.states.strokeColor._array)}getCommonVertexProperties(){return{...super.getCommonVertexProperties(),stroke:this.states.strokeColor,fill:this.states.fillColor,normal:this.states._currentNormal}}getSupportedIndividualVertexProperties(){return{textureCoordinates:!0}}strokeCap(t){this.curStrokeCap=t}strokeJoin(t){this.curStrokeJoin=t}getFilterLayer(){return this.filterLayer||=new Vs(this),this.filterLayer}getFilterLayerTemp(){return this.filterLayerTemp||=new Vs(this),this.filterLayerTemp}matchSize(t,n){(t.width!==n.width||t.height!==n.height)&&t.resize(n.width,n.height),t.pixelDensity()!==n.pixelDensity()&&t.pixelDensity(n.pixelDensity())}filter(...t){let n=this.getFilterLayer(),r,i;typeof t[0]==`string`?(i=t[0],r=i in ts&&t[1]===void 0?ts[i]:t[1],i in this.defaultFilterShaders||(this.defaultFilterShaders[i]=this._makeFilterShader(n.renderer,i)),this.states.setValue(`filterShader`,this.defaultFilterShaders[i])):this.states.setValue(`filterShader`,t[0]);let a=this.activeFramebuffer()||this;this.matchSize(n,a),n.draw(()=>this.clear());let o=[1/(a.width*a.pixelDensity()),1/(a.height*a.pixelDensity())];if(i===`blur`){let t=this.getFilterLayerTemp();this.matchSize(t,a),this.push(),this.states.setValue(`strokeColor`,null),this.blendMode(F),this.shader(this.states.filterShader),this.states.filterShader.setUniform(`texelSize`,o),this.states.filterShader.setUniform(`canvasSize`,[a.width,a.height]),this.states.filterShader.setUniform(`radius`,Math.max(1,r)),t.draw(()=>{this.states.filterShader.setUniform(`direction`,[1,0]),this.states.filterShader.setUniform(`tex0`,a),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(a.width,a.height)}),n.draw(()=>{this.states.filterShader.setUniform(`direction`,[0,1]),this.states.filterShader.setUniform(`tex0`,t),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(a.width,a.height)}),this.pop()}else n.draw(()=>{this.states.setValue(`strokeColor`,null),this.blendMode(F),this.shader(this.states.filterShader),this.states.filterShader.setUniform(`tex0`,a),this.states.filterShader.setUniform(`texelSize`,o),this.states.filterShader.setUniform(`canvasSize`,[a.width,a.height]),this.states.filterShader.setUniform(`filterParameter`,r),this.noLights(),this.plane(a.width,a.height)});this.push(),this.states.setValue(`strokeColor`,null),this.clear(),this.push(),this.states.setValue(`imageMode`,ee),this.blendMode(F),a.filterCamera._resize(),this.setCamera(a.filterCamera),this.resetMatrix(),this._drawingFilter=!0,this.image(n,0,0,n.width,n.height,-a.width/2,-a.height/2,a.width,a.height),this._drawingFilter=!1,this.clearDepth(),this.pop(),this.pop()}pixelDensity(t){return t?this._pInst.pixelDensity(t):this._pInst.pixelDensity()}blendMode(t){t===`darken`||t===`lighten`||t===`lighter`||t===`source-over`||t===`subtract`||t===`screen`||t===`exclusion`||t===`copy`||t===`multiply`||t===`destination-out`?this.states.setValue(`curBlendMode`,t):(t===`color-burn`||t===`overlay`||t===`hard-light`||t===`soft-light`||t===`color-dodge`)&&console.warn(`BURN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, and DODGE only work for blendMode in 2D mode.`)}erase(t,n){this._isErasing||(this.preEraseBlend=this.states.curBlendMode,this._isErasing=!0,this.blendMode(ke),this._cachedFillStyle=this.states.curFillColor.slice(),this.states.setValue(`curFillColor`,[1,1,1,t/255]),this._cachedStrokeStyle=this.states.curStrokeColor.slice(),this.states.setValue(`curStrokeColor`,[1,1,1,n/255]))}noErase(){this._isErasing&&(this.states.setValue(`curFillColor`,this._cachedFillStyle.slice()),this.states.setValue(`curStrokeColor`,this._cachedStrokeStyle.slice()),this.states.setValue(`curBlendMode`,this.preEraseBlend),this.blendMode(this.preEraseBlend),this._isErasing=!1,this._applyBlendMode())}_applyBlendMode(){}drawTarget(){return this.activeFramebuffers[this.activeFramebuffers.length-1]||this}beginClip(t={}){super.beginClip(t),this.drawTarget()._isClipApplied=!0,this._applyClip(),this.push(),this.resetShader(),this.states.fillColor&&this.fill(0,0),this.states.strokeColor&&this.stroke(0,0)}endClip(){this.pop(),this._unapplyClip(),this._clipDepths.push(this._pushPopDepth),super.endClip()}_clearClip(){this._clearClipBuffer(),this._clipDepths.length>0&&this._clipDepths.pop(),this.drawTarget()._isClipApplied=!1}_getTempFramebuffer(){return this._tempFramebuffer||=new Vs(this,{format:Ft,useDepth:this._pInst._glAttributes.depth,depthFormat:It,antialias:this._pInst._glAttributes.antialias}),this._tempFramebuffer}geometryInHash(t){return this.geometryBufferCache.isCached(t)}resize(t,n){super.resize(t,n);let r={};for(let t in this.drawingContext){let n=this.drawingContext[t];typeof n!=`object`&&typeof n!=`function`&&(r[t]=n)}let i=this._adjustDimensions(t,n);t=i.adjustedWidth,n=i.adjustedHeight,this.width=t,this.height=n,this.canvas.width=t*this._pixelDensity,this.canvas.height=n*this._pixelDensity,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${n}px`,this._updateViewport(),this._updateSize(),this.mainCamera._resize(),this.states.curCamera!==this.mainCamera&&this.states.curCamera._resize(),this.pixels!==void 0&&this._createPixelsArray();for(let t of this.framebuffers)this.flushDraw?.(),t._canvasSizeChanged();this.flushDraw?.();for(let t in r)try{this.drawingContext[t]=r[t]}catch{}}applyMatrix(t,n,r,i,a,o){this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),arguments.length===16?Po.prototype.apply.apply(this.states.uModelMatrix,arguments):this.states.uModelMatrix.apply([t,n,0,0,r,i,0,0,0,0,1,0,a,o,0,1])}translate(t,n,r){return t instanceof I&&(r=t.z,n=t.y,t=t.x),this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),this.states.uModelMatrix.translate([t,n,r]),this}scale(t,n,r){return this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),this.states.uModelMatrix.scale(t,n,r),this}rotate(t,n){return n===void 0?this.rotateZ(t):(this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),Po.prototype.rotate4x4.apply(this.states.uModelMatrix,arguments),this)}rotateX(t){return this.rotate(t,1,0,0),this}rotateY(t){return this.rotate(t,0,1,0),this}rotateZ(t){return this.rotate(t,0,0,1),this}push(){super.push();let t=!!this.states.textFont?.font;t&&this.textDrawingContext().save(),this._textContextSavedStack.push(t)}pop(...t){this._clipDepths.length>0&&this._pushPopDepth===this._clipDepths[this._clipDepths.length-1]&&this._clearClip(),this._textContextSavedStack.pop()&&this.textDrawingContext().restore(),super.pop(...t),this._applyStencilTestIfClipping()}resetMatrix(){return this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone()),this.states.uModelMatrix.reset(),this.states.setValue(`uViewMatrix`,this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(this.states.curCamera.cameraMatrix),this}_getStrokeShader(){return this.states.userStrokeShader||this._getLineShader()}_getFillShader(){return this._drawingImage?this.states.userImageShader&&!this._drawingFilter?this.states.userImageShader:this._getLightShader():this.states.userFillShader?this.states.userFillShader:this.states._useNormalMaterial?this._getNormalShader():this.states.enableLighting||this.states._tex?this._getLightShader(this._hasActiveTextureMap()):this._getColorShader()}_hasActiveTextureMap(){return!!(this.states._specularTex||this.states._ambientTex||this.states._shininessTex||this.states._normalTex)}baseMaterialShader(){return this._getLightShader()}baseNormalShader(){return this._getNormalShader()}baseColorShader(){return this._getColorShader()}baseStrokeShader(){return this._getLineShader()}activeFramebuffer(){return this.activeFramebuffers[this.activeFramebuffers.length-1]||null}createFramebuffer(t){return new Vs(this,t)}_setGlobalUniforms(t){let n=this.states.uModelMatrix,r=this.states.uViewMatrix,i=this.states.uPMatrix,a=n.copy().mult(r);if(t.setUniform(`uPerspective`,+!!this.states.curCamera.useLinePerspective),t.setUniform(`uViewMatrix`,r.mat4),t.setUniform(`uProjectionMatrix`,i.mat4),t.setUniform(`uModelMatrix`,n.mat4),t.setUniform(`uModelViewMatrix`,a.mat4),t.uniforms.uModelViewProjectionMatrix){let n=a.copy();n.mult(i),t.setUniform(`uModelViewProjectionMatrix`,n.mat4)}t.uniforms.uNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(a),t.setUniform(`uNormalMatrix`,this.scratchMat3.mat3)),t.uniforms.uModelNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uModelMatrix),t.setUniform(`uModelNormalMatrix`,this.scratchMat3.mat3)),t.uniforms.uCameraNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix),t.setUniform(`uCameraNormalMatrix`,this.scratchMat3.mat3)),t.setUniform(`uViewport`,this._viewport)}_setStrokeUniforms(t){t.setUniform(`uSimpleLines`,this._simpleLines),t.setUniform(`uUseLineColor`,this._useLineColor),t.setUniform(`uMaterialColor`,this.states.curStrokeColor),t.setUniform(`uStrokeWeight`,this.states.strokeWeight),t.setUniform(`uStrokeCap`,fs[this.curStrokeCap]),t.setUniform(`uStrokeJoin`,ps[this.curStrokeJoin])}_setFillUniforms(t){this.mixedSpecularColor=[...this.states.curSpecularColor];let n=this._getEmptyTexture();if(this.states._useMetalness>0&&(this.mixedSpecularColor=this.mixedSpecularColor.map((t,n)=>this.states.curFillColor[n]*this.states._useMetalness+t*(1-this.states._useMetalness))),t.setUniform(`uUseVertexColor`,this._useVertexColor),t.setUniform(`uMaterialColor`,this.states.curFillColor),t.setUniform(`isTexture`,!!this.states._tex),this._settingFillUniforms=!0,(this.states._tex||!t._userSetSampler)&&t.setUniform(`uSampler`,this.states._tex||n),this._settingFillUniforms=!1,this._hasActiveTextureMap()){t.setUniform(`uHasSpecularTex`,!!this.states._specularTex),t.setUniform(`uSpecularSampler`,this.states._specularTex||n),t.setUniform(`uHasAmbientTex`,!!this.states._ambientTex),t.setUniform(`uAmbientSampler`,this.states._ambientTex||n),t.setUniform(`uHasShininessTex`,!!this.states._shininessTex),t.setUniform(`uShininessSampler`,this.states._shininessTex||n),t.setUniform(`uHasNormalMap`,!!this.states._normalTex),t.setUniform(`uNormalSampler`,this.states._normalTex||n),t.setUniform(`uNormalScale`,this.states._normalScale),t.setUniform(`uNormalMapMode`,this.states._normalMapMode);let r=this.states._normalTex;t.setUniform(`uNormalTexelSize`,[1/(r&&r.width?r.width:256),1/(r&&r.height?r.height:256)])}t.setUniform(`uTint`,this.states.tint?._getRGBA([255,255,255,255])??[255,255,255,255]),t.setUniform(`uHasSetAmbient`,this.states._hasSetAmbient),t.setUniform(`uAmbientMatColor`,this.states.curAmbientColor),t.setUniform(`uSpecularMatColor`,this.mixedSpecularColor),t.setUniform(`uEmissiveMatColor`,this.states.curEmissiveColor),t.setUniform(`uSpecular`,this.states._useSpecularMaterial),t.setUniform(`uEmissive`,this.states._useEmissiveMaterial),t.setUniform(`uShininess`,this.states._useShininess),t.setUniform(`uMetallic`,this.states._useMetalness),this._setImageLightUniforms(t),t.setUniform(`uUseLighting`,this.states.enableLighting);let r=this.states.pointLightDiffuseColors.length/3;t.setUniform(`uPointLightCount`,r),t.setUniform(`uPointLightLocation`,this.states.pointLightPositions),t.setUniform(`uPointLightDiffuseColors`,this.states.pointLightDiffuseColors),t.setUniform(`uPointLightSpecularColors`,this.states.pointLightSpecularColors);let i=this.states.directionalLightDiffuseColors.length/3;t.setUniform(`uDirectionalLightCount`,i),t.setUniform(`uLightingDirection`,this.states.directionalLightDirections),t.setUniform(`uDirectionalDiffuseColors`,this.states.directionalLightDiffuseColors),t.setUniform(`uDirectionalSpecularColors`,this.states.directionalLightSpecularColors);let a=[0,0,0];for(let t=0;t<this.states.ambientLightColors.length;t+=3)for(let n=0;n<3;n++)this.states._useMetalness>0?a[n]+=Math.max(0,this.states.ambientLightColors[t+n]-this.states._useMetalness):a[n]+=this.states.ambientLightColors[t+n];t.setUniform(`uAmbientColor`,a);let o=this.states.spotLightDiffuseColors.length/3;t.setUniform(`uSpotLightCount`,o),t.setUniform(`uSpotLightAngle`,this.states.spotLightAngle),t.setUniform(`uSpotLightConc`,this.states.spotLightConc),t.setUniform(`uSpotLightDiffuseColors`,this.states.spotLightDiffuseColors),t.setUniform(`uSpotLightSpecularColors`,this.states.spotLightSpecularColors),t.setUniform(`uSpotLightLocation`,this.states.spotLightPositions),t.setUniform(`uSpotLightDirection`,this.states.spotLightDirections),t.setUniform(`uConstantAttenuation`,this.states.constantAttenuation),t.setUniform(`uLinearAttenuation`,this.states.linearAttenuation),t.setUniform(`uQuadraticAttenuation`,this.states.quadraticAttenuation)}_setImageLightUniforms(t){if(t.setUniform(`uUseImageLight`,this.states.activeImageLight!=null),this.states.activeImageLight){let n=this.getDiffusedTexture(this.states.activeImageLight);t.setUniform(`environmentMapDiffused`,n);let r=this.getSpecularTexture(this.states.activeImageLight);t.setUniform(`environmentMapSpecular`,r)}else t.setUniform(`environmentMapDiffused`,this._getEmptyTexture()),t.setUniform(`environmentMapSpecular`,this._getEmptyTexture())}_getEmptyTexture(){if(!this._emptyTexture){let t=new fa(1,1);t.set(0,0,255),this._emptyTexture=new Ds(this,t)}return this._emptyTexture}getTexture(t){let n=t;n instanceof Vs&&(n=n.color);let r=this.textures.get(n);if(r&&!this.textureNeedsRecreating(r))return r;r&&(r.remove(),this.textures.delete(n));let i=new Ds(this,n);return this.textures.set(n,i),i}_normalizeBufferData(t,n=Float32Array){return t?t instanceof Io?t.dataArray():t instanceof n?t:new n(t):null}_arraysEqual(t,n){return t.length===n.length&&t.every((t,r)=>t===n[r])}_isTypedArray(t){return[Float32Array,Float64Array,Int16Array,Uint16Array,Uint32Array].some(n=>t instanceof n)}_vToNArray(t){return t.flatMap(t=>[t.x,t.y,t.z])}_beforeDrawText(){}_afterDrawText(){}textCanvas(){return this._textCanvas||(this._textCanvas=document.createElement(`canvas`),this._textCanvas.width=1,this._textCanvas.height=1,this._textCanvas.style.display=`none`,this.canvas.parentElement.insertBefore(this._textCanvas,this.canvas)),this._textCanvas}textDrawingContext(){if(!this._textDrawingContext){let t=this.textCanvas();this._textDrawingContext=t.getContext(`2d`)}return this._textDrawingContext}_positionLines(t,n,r,i,a){let{textLeading:o,textAlign:s}=this.states,c=a.map(t=>this._fontWidthSingle(t)),l,u=Array(a.length),d=r===void 0?Math.max(0,...c):r,f=i===void 0?0:i;for(let i=0;i<a.length;i++){switch(s){case ns.START:throw Error(`textBounds: START not yet supported for textAlign`);case re:l=t;break;case ie:l=t+(d-c[i])/2-d/2+(r||0)/2;break;case ne:l=t+d-c[i]-d+(r||0);break;case ns.END:throw Error(`textBounds: END not yet supported for textAlign`);default:l=t}u[i]={text:a[i],x:l,y:n+i*o}}return this._yAlignOffset(u,f)}_verticalAlignFont=function(){let t=this.textDrawingContext().measureText(`X`);return-t.alphabeticBaseline||-t.fontBoundingBoxAscent+t.fontBoundingBoxDescent};_yAlignOffset(t,n){if(n===void 0)throw Error(`_yAlignOffset: height is required`);let{textLeading:r,textBaseline:i,textSize:a,textFont:o}=this.states,s=0,c=t.length,l=a*c+(r-a)*(c-1);switch(i){case`top`:s=this._verticalAlignFont();break;case ae:break;case ns._CTX_MIDDLE:s=(-l+a+(n||0))/2+this._verticalAlignFont()+this._middleAlignOffset();break;case P:s=-(l-a)+(n||0);break;default:console.warn(`${i} is not supported in WebGL mode.`)}return t.forEach(t=>t.y+=s),t}_makeFilterShader(t,n){let r=this._pInst;return is(this,n,r)}makeDiffusedTexture(t){if(this.diffusedTextures.get(t)!=null)return this.diffusedTextures.get(t);let n,r=Math.floor(200*(t.height/t.width));return n=new Vs(this,{width:200,height:r,density:1}),this.diffusedShader||=this._createImageLightShader(`diffused`),n.draw(()=>{this.shader(this.diffusedShader),this._setImageLightShaderUniforms(this.diffusedShader,t),this.states.setValue(`strokeColor`,null),this.noLights(),this.plane(200,r)}),this.diffusedTextures.set(t,n),n}getDiffusedTexture(t){return this.diffusedTextures.get(t)}makeSpecularTexture(t){if(this.specularTextures.get(t)!=null)return this.specularTextures.get(t);let n,r=Math.floor(Math.log2(512))+1;this.specularShader||=this._createImageLightShader(`specular`);let i=this._prepareMipmapData(512,r),a=new Vs(this,{width:512,height:512,density:1}),o=0;for(let n=512;n>=1;n/=2){a.resize(n,n);let s=1-Math.log(n)/Math.log(2)/r;a.draw(()=>{this.shader(this.specularShader),this.clear(),this._setImageLightShaderUniforms(this.specularShader,t,s),this.states.setValue(`strokeColor`,null),this.noLights(),this.plane(n,n)}),this._accumulateMipLevel(a,i,o,n,n),o++}return a.remove(),n=this._finalizeMipmapTexture(i),this.specularTextures.set(t,n),n}getSpecularTexture(t){return this.specularTextures.get(t)}_getSphereMapping(t){if(!this.sphereMapping){let t=this._pInst;this.sphereMapping=this.baseFilterShader().modify(({p5:t})=>{let n=t.uniformTexture(`uEnvMap`),r=t.uniformFloat(`uFovY`),i=t.uniformFloat(`uAspect`),a=t.uniformVec3(`uN1`),o=t.uniformVec3(`uN2`),s=t.uniformVec3(`uN3`);t.getColor(c=>{let l=r*i,u=t.mix(r/2,-r/2,c.texCoord.y),d=t.mix(l/2,-l/2,c.texCoord.x),f=t.normalize([d,u,1]);f=[t.dot(f,a),t.dot(f,o),t.dot(f,s)];let p=f.z;f.z=f.x,f.x=-p;let m=[t.atan(f.z,f.x)/(2*t.PI)+.5,.5+.5*-f.y];return t.getTexture(n,m)})},{p5:t})}this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix),this.scratchMat3.invert(this.scratchMat3),this.sphereMapping.setUniform(`uFovY`,this.states.curCamera.cameraFOV),this.sphereMapping.setUniform(`uAspect`,this.states.curCamera.aspectRatio);let n=this.scratchMat3.mat3;return this.sphereMapping.setUniform(`uN1`,[n[0],n[3],n[6]]),this.sphereMapping.setUniform(`uN2`,[n[1],n[4],n[7]]),this.sphereMapping.setUniform(`uN3`,[n[2],n[5],n[8]]),this.sphereMapping.setUniform(`uEnvMap`,t),this.sphereMapping}_createImageLightShader(t){throw Error(`_createImageLightShader must be implemented by the renderer`)}_setImageLightShaderUniforms(t,n,r){t.setUniform(`environmentMap`,n),r!==void 0&&t.setUniform(`roughness`,r)}_createMipmapTexture(t){throw Error(`_createMipmapTexture must be implemented by the renderer`)}_prepareMipmapData(t,n){throw Error(`_prepareMipmapData must be implemented by the renderer`)}_accumulateMipLevel(t,n,r,i,a){throw Error(`_accumulateMipLevel must be implemented by the renderer`)}_finalizeMipmapTexture(t){throw Error(`_finalizeMipmapTexture must be implemented by the renderer`)}remove(){this._textCanvas&&this._textCanvas.parentElement.removeChild(this._textCanvas),this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null,super.remove()}};const ms=`Add the WebGPU add-on to your project and pass WEBGPU as the last argument to createCanvas.`;function hs(t,n){t.Renderer3D=z,$o.prototype.friendlyErrorsDisabled=function(){return!!t.disableFriendlyErrors},n.createStorage=function(t){if(!this._renderer.createStorage)throw Error(`createStorage() is only available with the WebGPU renderer. ${ms}`);return this._renderer.createStorage(t)},t.registerDecorator(`p5.prototype.createStorage`,ds(`webgpu`,t)),n.createStorageList=function(t,n){if(!this._renderer.createStorageList)throw Error(`createStorageList() is only available with the WebGPU renderer. ${ms}`);return this._renderer.createStorageList(t,n)},n.baseComputeShader=function(){if(!this._renderer.baseComputeShader)throw Error(`baseComputeShader() is only available with the WebGPU renderer. ${ms}`);return this._renderer.baseComputeShader()},n.buildComputeShader=function(t,n){if(!this._renderer.baseComputeShader)throw Error(`buildComputeShader() is only available with the WebGPU renderer. ${ms}`);return this.baseComputeShader().modify(t,n,{hook:`iteration`})},t.registerDecorator(`p5.prototype.buildComputeShader`,ds(`webgpu`,t)),n.compute=function(t,n,r,i){if(!this._renderer.compute)throw Error(`compute() is only available with the WebGPU renderer. ${ms}`);this._renderer.compute(t,n,r,i)}}typeof p5<`u`&&hs(p5,p5.prototype);function gs(t,n){n.strokeMode=function(t){if(t===void 0)return this._renderer._simpleLines?y:b;if(t===`simple`)this._renderer._simpleLines=!0;else if(t===`full`)this._renderer._simpleLines=!1;else throw Error(`no such parameter`)},n.buildGeometry=function(t){return this._renderer.buildGeometry(t)},n.freeGeometry=function(t){this._renderer.geometryBufferCache.freeBuffers(t.gid)},n.plane=function(t=50,n=t,r=1,i=1){return this._assert3d(`plane`),this._renderer.plane(t,n,r,i),this},n.box=function(t,n,r,i,a){return this._assert3d(`box`),this._renderer.box(t,n,r,i,a),this},n.sphere=function(t=50,n=24,r=16){return this._assert3d(`sphere`),this._renderer.sphere(t,n,r),this},n.cylinder=function(t=50,n=t,r=24,i=1,a=!0,o=!0){return this._assert3d(`cylinder`),this._renderer.cylinder(t,n,r,i,a,o),this},n.cone=function(t=50,n=t,r=24,i=1,a=!0){return this._assert3d(`cone`),this._renderer.cone(t,n,r,i,a),this},n.ellipsoid=function(t=50,n=t,r=t,i=24,a=16){return this._assert3d(`ellipsoid`),this._renderer.ellipsoid(t,n,r,i,a),this},n.torus=function(t,n,r,i){return this._assert3d(`torus`),this._renderer.torus(t,n,r,i),this},z.prototype.point=function(t,n,r=0){return this.beginShape(0),this.vertex(t,n,r),this.endShape(),this},z.prototype.triangle=function(t){let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5];if(!this.geometryInHash(`tri`)){let t=new Vo(1,1,function(){let t=[];t.push(new I(0,0,0)),t.push(new I(1,0,0)),t.push(new I(0,1,0)),this.edges=[[0,1],[1,2],[2,0]],this.vertices=t,this.faces=[[0,1,2]],this.uvs=[0,0,1,0,1,1]},this);t._edgesToVertices(),t.computeNormals(),t.gid=`tri`,this.geometryBufferCache.ensureCached(t)}let c=this.states.uModelMatrix.copy();try{let t=Math.sign(n*a-i*r+i*s-o*a+o*r-n*s),c=new Po([i-n,a-r,0,0,o-n,s-r,0,0,0,0,t,0,n,r,0,1]).mult(this.states.uModelMatrix);this.states.setValue(`uModelMatrix`,c),this.model(this.geometryBufferCache.getGeometryByID(`tri`))}finally{this.states.setValue(`uModelMatrix`,c)}return this},z.prototype.ellipse=function(t){this.arc(t[0],t[1],t[2],t[3],0,A,ue,t[4])},z.prototype.arc=function(...t){let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7]||25,u,d;if(Math.abs(s-o)>=A?(u=`ellipse`,d=`${u}|${l}|`):(u=`arc`,d=`${u}|${o}|${s}|${c}|${l}|`),!this.geometryInHash(d)){let t=new Vo(l,1,function(){if(o.toFixed(10)!==s.toFixed(10)){(c===`pie`||c===void 0)&&(this.vertices.push(new I(.5,.5,0)),this.uvs.push([.5,.5]));for(let t=0;t<=l;t++){let n=t/l,r=(s-o)*n+o,i=.5+Math.cos(r)/2,a=.5+Math.sin(r)/2;this.vertices.push(new I(i,a,0)),this.uvs.push([i,a]),t<l-1&&(this.faces.push([0,t+1,t+2]),this.edges.push([t+1,t+2]))}switch(c){case`pie`:this.faces.push([0,this.vertices.length-2,this.vertices.length-1]),this.edges.push([0,1]),this.edges.push([this.vertices.length-2,this.vertices.length-1]),this.edges.push([0,this.vertices.length-1]);break;case de:this.edges.push([0,1]),this.edges.push([0,this.vertices.length-1]);break;case ue:this.edges.push([0,1]);break;default:this.faces.push([0,this.vertices.length-2,this.vertices.length-1]),this.edges.push([this.vertices.length-2,this.vertices.length-1])}}},this);t.computeNormals(),l<=50?t._edgesToVertices(t):this.states.strokeColor&&console.log(`Cannot apply a stroke to an ${u} with more than 50 detail`),t.gid=d,this.geometryBufferCache.ensureCached(t)}let f=this.states.uModelMatrix;this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.clone());try{this.states.uModelMatrix.translate([n,r,0]),this.states.uModelMatrix.scale(i,a,1),this.model(this.geometryBufferCache.getGeometryByID(d))}finally{this.states.setValue(`uModelMatrix`,f)}return this},z.prototype.rect=function(t){let n=t[0],r=t[1],i=t[2],a=t[3];if(t[4]===void 0){let o=this._pInst._glAttributes?.perPixelLighting??!0,s=t[4]||(o?1:24),c=t[5]||(o?1:16),l=`rect|${s}|${c}`;if(!this.geometryInHash(l)){let t=new Vo(s,c,function(){for(let t=0;t<=this.detailY;t++){let n=t/this.detailY;for(let t=0;t<=this.detailX;t++){let r=t/this.detailX,i=new I(r,n,0);this.vertices.push(i),this.uvs.push(r,n)}}s>0&&c>0&&(this.edges=[[0,s],[s,(s+1)*(c+1)-1],[(s+1)*(c+1)-1,(s+1)*c],[(s+1)*c,0]])},this);t.computeFaces().computeNormals()._edgesToVertices(),t.gid=l,this.geometryBufferCache.ensureCached(t)}let u=this.states.uModelMatrix;this.states.setValue(`uModelMatrix`,this.states.uModelMatrix.copy());try{this.states.uModelMatrix.translate([n,r,0]),this.states.uModelMatrix.scale(i,a,1),this.model(this.geometryBufferCache.getGeometryByID(l))}finally{this.states.setValue(`uModelMatrix`,u)}}else{let o=t[4],s=t[5]===void 0?o:t[5],c=t[6]===void 0?s:t[6],l=t[7]===void 0?c:t[7],u=n,d=r,f=i,p=a;if(f+=u,p+=d,u>f){let t=u;u=f,f=t}if(d>p){let t=d;d=p,p=t}let m=Math.min((f-u)/2,(p-d)/2);o>m&&(o=m),s>m&&(s=m),c>m&&(c=m),l>m&&(l=m);let h=u,g=d,_=f,v=p,y=this.states.textureMode;this.states.setValue(`textureMode`,Qe);let b=this.bezierOrder();this.bezierOrder(3),this.beginShape();let x=(t,n)=>[t,n,0,(t-h)/i,(n-g)/a],S=.5523;s===0?this.vertex(...x(_,g)):(this.vertex(...x(_-s,g)),this.bezierVertex(...x(_-s+s*S,g)),this.bezierVertex(...x(_,g+s-s*S)),this.bezierVertex(...x(_,g+s))),c===0?this.vertex(...x(_,v)):(this.vertex(...x(_,v-c)),this.bezierVertex(...x(_,v-c+c*S)),this.bezierVertex(...x(_-c+S*c,v)),this.bezierVertex(...x(_-c,v))),l===0?this.vertex(...x(h,v)):(this.vertex(...x(h+l,v)),this.bezierVertex(...x(h+l-l*S,v)),this.bezierVertex(...x(h,v-l+l*S)),this.bezierVertex(...x(h,v-l))),o===0?this.vertex(...x(h,g)):(this.vertex(...x(h,g+o)),this.bezierVertex(...x(h,g+o-o*S)),this.bezierVertex(...x(h+o-o*S,g)),this.bezierVertex(...x(h+o,g))),this.endShape(le),this.states.setValue(`textureMode`,y),this.bezierOrder(b)}return this},z.prototype.quad=function(t,n,r,i,a,o,s,c,l,u,d,f,p=2,m=2){let h=`quad|${t}|${n}|${r}|${i}|${a}|${o}|${s}|${c}|${l}|${u}|${d}|${f}|${p}|${m}`;if(!this.geometryInHash(h)){let g=new Vo(p,m,function(){let p=1/(this.detailX-1),m=1/(this.detailY-1);for(let h=0;h<this.detailY;h++)for(let g=0;g<this.detailX;g++){let _=g*p,v=h*m,y=(1-v)*t+v*u,b=(1-v)*n+v*d,x=(1-v)*r+v*f,S=(1-v)*i+v*s,C=(1-v)*a+v*c,w=(1-v)*o+v*l,T=(1-_)*y+_*S,E=(1-_)*b+_*C,D=(1-_)*x+_*w;this.vertices.push(new I(T,E,D)),this.uvs.push([_,v])}},this);g.faces=[];for(let t=0;t<m-1;t++)for(let n=0;n<p-1;n++){let r=n+t*p,i=n+1+t*p,a=n+1+(t+1)*p,o=n+(t+1)*p;g.faces.push([r,i,a]),g.faces.push([r,a,o])}g.computeNormals(),g.edges.length=0;let _=[0,2,3,1];for(let t=0;t<_.length;t++){let n=_[t],r=_[(t+1)%_.length];g.edges.push([n,r])}g._edgesToVertices(),g.gid=h,this.geometryBufferCache.ensureCached(g)}return this.model(this.geometryBufferCache.getGeometryByID(h)),this},z.prototype.bezier=function(t,n,r,i,a,o,s,c,l,u,d,f){arguments.length===8&&(d=c,u=s,c=o,s=a,a=i,i=r,r=o=l=f=0);let p=this.bezierOrder();this.bezierOrder(3),this.beginShape(),this.vertex(t,n,r),this.bezierVertex(i,a,o),this.bezierVertex(s,c,l),this.bezierVertex(u,d,f),this.endShape(),this.bezierOrder(p)},z.prototype.curve=function(t,n,r,i,a,o,s,c,l,u,d,f){arguments.length===8&&(u=s,d=c,s=a,c=i,i=r,a=i,r=o=l=f=0),this.beginShape(),this.splineVertex(t,n,r),this.splineVertex(i,a,o),this.splineVertex(s,c,l),this.splineVertex(u,d,f),this.endShape()},z.prototype.line=function(...t){return t.length===6?(this.beginShape(1),this.vertex(t[0],t[1],t[2]),this.vertex(t[3],t[4],t[5]),this.endShape()):t.length===4&&(this.beginShape(1),this.vertex(t[0],t[1],0),this.vertex(t[2],t[3],0),this.endShape()),this},z.prototype.image=function(t,n,r,i,a,o,s,c,l){this._isErasing&&this.blendMode(this._cachedBlendMode),this.push(),this.noLights(),this.states.setValue(`strokeColor`,null),this.texture(t),this.states.setValue(`textureMode`,Qe);let u=0;n<=t.width&&(u=n/t.width);let d=1;n+i<=t.width&&(d=(n+i)/t.width);let f=0;r<=t.height&&(f=r/t.height);let p=1;r+a<=t.height&&(p=(r+a)/t.height),this._drawingImage=!0,this.beginShape(),this.vertex(o,s,0,u,f),this.vertex(o+c,s,0,d,f),this.vertex(o+c,s+l,0,d,p),this.vertex(o,s+l,0,u,p),this.endShape(le),this._drawingImage=!1,this.pop(),this._isErasing&&this.blendMode(ke)};let r=function(t,n,r,i,a,o,s){t=t<=0?1:t,n=n<0?0:n,r=r<=0?t:r,i=i<3?3:i,a=a<1?1:a,o=o===void 0||o,s=s===void 0?n!==0:s;let c=o?-2:0,l=a+(s?2:0),u=Math.atan2(t-n,r),d=Math.sin(u),f=Math.cos(u),p,m,h;for(p=c;p<=l;++p){let o=p/a,s=r*o,c;for(p<0?(s=0,o=0,c=t):p>a?(s=r,o=1,c=n):c=t+(n-t)*o,(p===-2||p===a+2)&&(c=0),s-=r/2,m=0;m<i;++m){let t=m/(i-1),r=2*Math.PI*t,l=Math.sin(r),u=Math.cos(r);this.vertices.push(new I(l*c,s,u*c));let h;h=p<0?new I(0,-1,0):p>a&&n?new I(0,1,0):new I(l*f,d,u*f),this.vertexNormals.push(h),this.uvs.push(t,o)}}let g=0;if(o){for(h=0;h<i;++h){let t=(h+1)%i;this.faces.push([g+h,g+i+t,g+i+h])}g+=i*2}for(p=0;p<a;++p){for(m=0;m<i;++m){let t=(m+1)%i;this.faces.push([g+m,g+t,g+i+t]),this.faces.push([g+m,g+i+t,g+i+m])}g+=i}if(s)for(g+=i,m=0;m<i;++m)this.faces.push([g+m,g+(m+1)%i,g+i])};z.prototype.plane=function(t=50,n=t,r=1,i=1){let a=`plane|${r}|${i}`;if(!this.geometryInHash(a)){let t=new Vo(r,i,function(){let t,n,r;for(let i=0;i<=this.detailY;i++){n=i/this.detailY;for(let i=0;i<=this.detailX;i++)t=i/this.detailX,r=new I(t-.5,n-.5,0),this.vertices.push(r),this.uvs.push(t,n)}},this);t.computeFaces().computeNormals(),r<=1&&i<=1?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw stroke on plane objects with more than 1 detailX or 1 detailY`),t.gid=a,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(a),t,n,1)},z.prototype.box=function(t=50,n=t,r=n,i,a){let o=this.attributes&&this.attributes.perPixelLighting;i===void 0&&(i=o?1:4),a===void 0&&(a=o?1:4);let s=`box|${i}|${a}`;if(!this.geometryInHash(s)){let t=new Vo(i,a,function(){let t=[[0,4,2,6],[1,3,5,7],[0,1,4,5],[2,6,3,7],[0,2,1,3],[4,5,6,7]];this.edges=[[0,1],[1,3],[3,2],[6,7],[8,9],[9,11],[14,15],[16,17],[17,19],[18,19],[20,21],[22,23]],t.forEach((t,n)=>{let r=n*4;for(let n=0;n<4;n++){let r=t[n],i=new I(((r&1)*2-1)/2,((r&2)-1)/2,((r&4)/2-1)/2);this.vertices.push(i),this.uvs.push(n&1,(n&2)/2)}this.faces.push([r,r+1,r+2]),this.faces.push([r+2,r+1,r+3])})},this);t.computeNormals(),i<=4&&a<=4?t._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw stroke on box objects with more than 4 detailX or 4 detailY`),t.gid=s,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(s),t,n,r)},z.prototype.sphere=function(t=50,n=24,r=16){this.ellipsoid(t,t,t,n,r)},z.prototype.ellipsoid=function(n=50,r=n,i=n,a=24,o=16){let s=`ellipsoid|${a}|${o}`;if(!this.geometryInHash(s)){let n=new Vo(a,o,function(){for(let n=0;n<=this.detailY;n++){let r=n/this.detailY,i=Math.PI*r-Math.PI/2,a=Math.cos(i),o=Math.sin(i);for(let n=0;n<=this.detailX;n++){let i=n/this.detailX,s=2*Math.PI*i,c=Math.cos(s),l=Math.sin(s),u=new t.Vector(a*l,o,a*c);this.vertices.push(u),this.vertexNormals.push(u),this.uvs.push(i,r)}}},this);n.computeFaces(),a<=24&&o<=24?n._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw stroke on ellipsoids with more than 24 detailX or 24 detailY`),n.gid=s,this.geometryBufferCache.ensureCached(n)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(s),n,r,i)},z.prototype.cylinder=function(n=50,i=n,a=24,o=1,s=!0,c=!0){let l=`cylinder|${a}|${o}|${s}|${c}`;if(!this.geometryInHash(l)){let n=new t.Geometry(a,o,function(){r.call(this,1,1,1,a,o,s,c)},this);a<=24&&o<=16?n._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw stroke on cylinder objects with more than 24 detailX or 16 detailY`),n.gid=l,this.geometryBufferCache.ensureCached(n)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(l),n,i,n)},z.prototype.cone=function(t=50,n=t,i=24,a=1,o=!0){let s=`cone|${i}|${a}|${o}`;if(!this.geometryInHash(s)){let t=new Vo(i,a,function(){r.call(this,1,0,1,i,a,o,!1)},this);i<=24&&a<=16?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw stroke on cone objects with more than 24 detailX or 16 detailY`),t.gid=s,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(s),t,n,t)},z.prototype.torus=function(t=50,n=10,r=24,i=16){if(t===0||n===0)return;let a=(n/t).toPrecision(4),o=`torus|${a}|${r}|${i}`;if(!this.geometryInHash(o)){let t=new Vo(r,i,function(){for(let t=0;t<=this.detailY;t++){let n=t/this.detailY,r=2*Math.PI*n,i=Math.cos(r),o=Math.sin(r),s=1+a*i;for(let t=0;t<=this.detailX;t++){let r=t/this.detailX,c=2*Math.PI*r,l=Math.cos(c),u=Math.sin(c),d=new I(s*l,s*u,a*o),f=new I(i*l,i*u,o);this.vertices.push(d),this.vertexNormals.push(f),this.uvs.push(r,n)}}},this);t.computeFaces(),r<=24&&i<=16?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log(`Cannot draw strokes on torus object with more than 24 detailX or 16 detailY`),t.gid=o,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(o),t,t,t)},n.curveDetail=function(t){if(!(this._renderer instanceof z))throw Error(`curveDetail() only works in WebGL mode. Did you mean to call createCanvas(width, height, WEBGL)?`);return this._renderer.curveDetail(t)},n.instances=function(n){this._assert3d(`instances`);let r=n?._isStorageList;n?._isStorageBuffer&&(n=n.length),r||(typeof n!=`number`||!isFinite(n)||n<1?(t._friendlyError(`instances() requires a positive integer count, a StorageBuffer, or a StorageList. Clamping to 1.`,`instances`),n=1):n=Math.round(n));let i=this._renderer,a=(t,a=i)=>function(...o){r?i._instanceList=n:i._instanceCount=n;try{t.apply(a,o)}finally{i._instanceList=void 0,i._instanceCount=void 0}},o={sphere:a(i.sphere),box:a(i.box),plane:a(i.plane),ellipsoid:a(i.ellipsoid),cylinder:a(i.cylinder),cone:a(i.cone),torus:a(i.torus),triangle:a(this.triangle,this),rect:a(this.rect,this),quad:a(this.quad,this),ellipse:a(this.ellipse,this),circle:a(this.circle,this),square:a(this.square,this),arc:a(this.arc,this),model:a(i.model),line:a(this.line,this),point:a(this.point,this),bezier:a(this.bezier,this),spline:a(this.spline,this)};return typeof this.curve==`function`&&(o.curve=a(this.curve,this)),o}}typeof p5<`u`&&gs(p5,p5.prototype);function _s(t,n){n.ambientLight=function(t,n,r,i){return this._assert3d(`ambientLight`),this._renderer.ambientLight(...arguments),this},n.specularColor=function(t,n,r){return this._assert3d(`specularColor`),this._renderer.specularColor(...arguments),this},n.directionalLight=function(t,n,r,i,a,o){return this._assert3d(`directionalLight`),this._renderer.directionalLight(...arguments),this},n.pointLight=function(t,n,r,i,a,o){return this._assert3d(`pointLight`),this._renderer.pointLight(...arguments),this},n.imageLight=function(t){this._renderer.imageLight(t)},n.panorama=function(t){this.filter(this._renderer._getSphereMapping(t))},n.lights=function(){return this._assert3d(`lights`),this._renderer.lights(),this},n.lightFalloff=function(t,n,r){return this._assert3d(`lightFalloff`),this._renderer.lightFalloff(t,n,r),this},n.spotLight=function(t,n,r,i,a,o,s,c,l,u,d){return this._assert3d(`spotLight`),this._renderer.spotLight(...arguments),this},n.noLights=function(...t){return this._assert3d(`noLights`),this._renderer.noLights(),this},z.prototype.ambientLight=function(t,n,r,i){let a=this._pInst.color(...arguments);this.states.setValue(`ambientLightColors`,[...this.states.ambientLightColors]),this.states.ambientLightColors.push(a._array[0],a._array[1],a._array[2]),this.states.setValue(`enableLighting`,!0)},z.prototype.specularColor=function(t,n,r){let i=this._pInst.color(...arguments);this.states.setValue(`specularColors`,[i._array[0],i._array[1],i._array[2]])},z.prototype.directionalLight=function(t,n,r,i,a,o){let s;s=t instanceof Ui?t:this._pInst.color(t,n,r);let c,l,u,d=arguments[arguments.length-1];typeof d==`number`?(c=arguments[arguments.length-3],l=arguments[arguments.length-2],u=arguments[arguments.length-1]):(c=d.x,l=d.y,u=d.z);let f=Math.sqrt(c*c+l*l+u*u);this.states.setValue(`directionalLightDirections`,[...this.states.directionalLightDirections]),this.states.directionalLightDirections.push(c/f,l/f,u/f),this.states.setValue(`directionalLightDiffuseColors`,[...this.states.directionalLightDiffuseColors]),this.states.directionalLightDiffuseColors.push(s._array[0],s._array[1],s._array[2]),this.states.setValue(`directionalLightSpecularColors`,[...this.states.directionalLightSpecularColors]),Array.prototype.push.apply(this.states.directionalLightSpecularColors,this.states.specularColors),this.states.setValue(`enableLighting`,!0)},z.prototype.pointLight=function(t,n,r,i,a,o){let s;s=t instanceof Ui?t:this._pInst.color(t,n,r);let c,l,u,d=arguments[arguments.length-1];typeof d==`number`?(c=arguments[arguments.length-3],l=arguments[arguments.length-2],u=arguments[arguments.length-1]):(c=d.x,l=d.y,u=d.z),this.states.setValue(`pointLightPositions`,[...this.states.pointLightPositions]),this.states.pointLightPositions.push(c,l,u),this.states.setValue(`pointLightDiffuseColors`,[...this.states.pointLightDiffuseColors]),this.states.pointLightDiffuseColors.push(s._array[0],s._array[1],s._array[2]),this.states.setValue(`pointLightSpecularColors`,[...this.states.pointLightSpecularColors]),Array.prototype.push.apply(this.states.pointLightSpecularColors,this.states.specularColors),this.states.setValue(`enableLighting`,!0)},z.prototype.imageLight=function(t){this.states.setValue(`activeImageLight`,t),this.states.setValue(`enableLighting`,!0),this.makeDiffusedTexture(t),this.makeSpecularTexture(t)},z.prototype.lights=function(){let t=this._pInst.color(`rgb(128,128,128)`);this.ambientLight(t),this.directionalLight(t,0,0,-1)},z.prototype.lightFalloff=function(t,n,r){t<0&&(t=0,console.warn(`Value of constant argument in lightFalloff() should be never be negative. Set to 0.`)),n<0&&(n=0,console.warn(`Value of linear argument in lightFalloff() should be never be negative. Set to 0.`)),r<0&&(r=0,console.warn(`Value of quadratic argument in lightFalloff() should be never be negative. Set to 0.`)),t===0&&n===0&&r===0&&(t=1,console.warn(`Either one of the three arguments in lightFalloff() should be greater than zero. Set constant argument to 1.`)),this.states.setValue(`constantAttenuation`,t),this.states.setValue(`linearAttenuation`,n),this.states.setValue(`quadraticAttenuation`,r)},z.prototype.spotLight=function(t,n,r,i,a,o,s,c,l,u,d){if(this.states.spotLightDiffuseColors.length/3>=4)return;let f,p,m,h=arguments.length;switch(h){case 11:case 10:f=this._pInst.color(t,n,r),p=new I(i,a,o),m=new I(s,c,l);break;case 9:t instanceof Ui?(f=t,p=new I(n,r,i),m=new I(a,o,s),u=c,d=l):i instanceof I?(f=this._pInst.color(t,n,r),p=i,m=new I(a,o,s),u=c,d=l):s instanceof I?(f=this._pInst.color(t,n,r),p=new I(i,a,o),m=s,u=c,d=l):(f=this._pInst.color(t,n,r),p=new I(i,a,o),m=new I(s,c,l));break;case 8:t instanceof Ui?(f=t,p=new I(n,r,i),m=new I(a,o,s),u=c):i instanceof I?(f=this._pInst.color(t,n,r),p=i,m=new I(a,o,s),u=c):(f=this._pInst.color(t,n,r),p=new I(i,a,o),m=s,u=c);break;case 7:t instanceof Ui&&n instanceof I?(f=t,p=n,m=new I(r,i,a),u=o,d=s):t instanceof Ui&&a instanceof I?(f=t,p=new I(n,r,i),m=a,u=o,d=s):i instanceof I&&a instanceof I?(f=this._pInst.color(t,n,r),p=i,m=a,u=o,d=s):t instanceof Ui?(f=t,p=new I(n,r,i),m=new I(a,o,s)):i instanceof I?(f=this._pInst.color(t,n,r),p=i,m=new I(a,o,s)):(f=this._pInst.color(t,n,r),p=new I(i,a,o),m=s);break;case 6:i instanceof I&&a instanceof I?(f=this._pInst.color(t,n,r),p=i,m=a,u=o):t instanceof Ui&&a instanceof I?(f=t,p=new I(n,r,i),m=a,u=o):t instanceof Ui&&n instanceof I&&(f=t,p=n,m=new I(r,i,a),u=o);break;case 5:t instanceof Ui&&n instanceof I&&r instanceof I?(f=t,p=n,m=r,u=i,d=a):i instanceof I&&a instanceof I?(f=this._pInst.color(t,n,r),p=i,m=a):t instanceof Ui&&a instanceof I?(f=t,p=new I(n,r,i),m=a):t instanceof Ui&&n instanceof I&&(f=t,p=n,m=new I(r,i,a));break;case 4:f=t,p=n,m=r,u=i;break;case 3:f=t,p=n,m=r;break;default:console.warn(`Sorry, input for spotlight() is not in prescribed format. Too ${h<3?`few`:`many`} arguments were provided`);return}this.states.setValue(`spotLightDiffuseColors`,[...this.states.spotLightDiffuseColors,f._array[0],f._array[1],f._array[2]]),this.states.setValue(`spotLightSpecularColors`,[...this.states.spotLightSpecularColors,...this.states.specularColors]),this.states.setValue(`spotLightPositions`,[...this.states.spotLightPositions,p.x,p.y,p.z]),m.normalize(),this.states.setValue(`spotLightDirections`,[...this.states.spotLightDirections,m.x,m.y,m.z]),u===void 0&&(u=Math.PI/3),d!==void 0&&d<1?(d=1,console.warn(`Value of concentration needs to be greater than 1. Setting it to 1`)):d===void 0&&(d=100),u=this._pInst._toRadians(u),this.states.setValue(`spotLightAngle`,[...this.states.spotLightAngle,Math.cos(u)]),this.states.setValue(`spotLightConc`,[...this.states.spotLightConc,d]),this.states.setValue(`enableLighting`,!0)},z.prototype.noLights=function(){this.states.setValue(`activeImageLight`,null),this.states.setValue(`enableLighting`,!1),this.states.setValue(`ambientLightColors`,[]),this.states.setValue(`specularColors`,[1,1,1]),this.states.setValue(`directionalLightDirections`,[]),this.states.setValue(`directionalLightDiffuseColors`,[]),this.states.setValue(`directionalLightSpecularColors`,[]),this.states.setValue(`pointLightPositions`,[]),this.states.setValue(`pointLightDiffuseColors`,[]),this.states.setValue(`pointLightSpecularColors`,[]),this.states.setValue(`spotLightPositions`,[]),this.states.setValue(`spotLightDirections`,[]),this.states.setValue(`spotLightDiffuseColors`,[]),this.states.setValue(`spotLightSpecularColors`,[]),this.states.setValue(`spotLightAngle`,[]),this.states.setValue(`spotLightConc`,[]),this.states.setValue(`constantAttenuation`,1),this.states.setValue(`linearAttenuation`,0),this.states.setValue(`quadraticAttenuation`,0),this.states.setValue(`_useShininess`,1),this.states.setValue(`_useMetalness`,0)}}typeof p5<`u`&&_s(p5,p5.prototype);const vs=Object.getPrototypeOf(Uint8Array);var ys=class t{constructor(t,n,r,i={}){this._renderer=t,typeof n==`string`&&(r===void 0||typeof r==`object`&&!Array.isArray(r))?(this.shaderType=`compute`,this._computeSrc=n,this._vertSrc=null,this._fragSrc=null,typeof r==`object`&&(i=r)):(this._vertSrc=n,this._fragSrc=r,this._computeSrc=null),this._vertShader=-1,this._fragShader=-1,this._compiled=!1,this._loadedAttributes=!1,this.attributes={},this._loadedUniforms=!1,this.uniforms={},this._bound=!1,this.samplers=[],this.hooks={uniforms:i.uniforms||{},storageUniforms:i.storageUniforms||{},shaderNameMap:i.shaderNameMap||{externalToInternal:{},internalToExternal:{}},shaderNameState:i.shaderNameState||{nextSuffix:0},declarations:i.declarations,varyingVariables:i.varyingVariables||[],instanceIDVarying:i.instanceIDVarying||null,helpers:i.helpers||{},vertex:i.vertex||{},fragment:i.fragment||{},compute:i.compute||{},hookAliases:i.hookAliases||{},modified:{vertex:i.modified&&i.modified.vertex||{},fragment:i.modified&&i.modified.fragment||{},compute:i.modified&&i.modified.compute||{}}}}hookTypes(t){return this._renderer.getShaderHookTypes(this,t)}shaderSrc(t,n){return this._renderer.populateHooks(this,t,n)}version(){let t=/#version (.+)$/m.exec(this.vertSrc());return t?t[1]:`100 es`}vertSrc(){return this.shaderType===`compute`?null:this.shaderSrc(this._vertSrc,`vertex`)}fragSrc(){return this.shaderType===`compute`?null:this.shaderSrc(this._fragSrc,`fragment`)}computeSrc(){return this.shaderType===`compute`?this.shaderSrc(this._computeSrc,`compute`):null}inspectHooks(){if(this.shaderType===`compute`){console.log(`==== Compute shader hooks: ====`);for(let t in this.hooks.compute)console.log((this.hooks.modified.compute[t]?`[MODIFIED] `:``)+t+this.hooks.compute[t])}else{console.log(`==== Vertex shader hooks: ====`);for(let t in this.hooks.vertex)console.log((this.hooks.modified.vertex[t]?`[MODIFIED] `:``)+t+this.hooks.vertex[t]);console.log(``),console.log(`==== Fragment shader hooks: ====`);for(let t in this.hooks.fragment)console.log((this.hooks.modified.fragment[t]?`[MODIFIED] `:``)+t+this.hooks.fragment[t])}console.log(``),console.log(`==== Helper functions: ====`);for(let t in this.hooks.helpers)console.log(t+this.hooks.helpers[t])}modify(n){let r={vertex:{},fragment:{},compute:{},helpers:{}};for(let t in n)t!==`declarations`&&t!==`uniforms`&&t!==`storageUniforms`&&t!==`shaderNameMap`&&t!==`shaderNameState`&&t!==`varyingVariables`&&t!==`instanceIDVarying`&&(t===`vertexDeclarations`?r.vertex.declarations=(r.vertex.declarations||``)+`
`+n[t]:t===`fragmentDeclarations`?r.fragment.declarations=(r.fragment.declarations||``)+`
`+n[t]:t===`computeDeclarations`?r.compute.declarations=(r.compute.declarations||``)+`
`+n[t]:this.hooks.vertex[t]?r.vertex[t]=n[t]:this.hooks.fragment[t]?r.fragment[t]=n[t]:this.hooks.compute[t]?r.compute[t]=n[t]:r.helpers[t]=n[t]);let i=Object.assign({},this.hooks.modified.vertex),a=Object.assign({},this.hooks.modified.fragment),o=Object.assign({},this.hooks.modified.compute);for(let t in r.vertex||{})t!==`declarations`&&(i[t]=!0);for(let t in r.fragment||{})t!==`declarations`&&(a[t]=!0);for(let t in r.compute||{})t!==`declarations`&&(o[t]=!0);let s=[this._renderer];return this.shaderType===`compute`?s.push(this._computeSrc):s.push(this._vertSrc,this._fragSrc),s.push({declarations:(this.hooks.declarations||``)+`
`+(n.declarations||``),uniforms:Object.assign({},this.hooks.uniforms,n.uniforms||{}),storageUniforms:Object.assign({},this.hooks.storageUniforms,n.storageUniforms||{}),shaderNameMap:{externalToInternal:Object.assign({},this.hooks.shaderNameMap?.externalToInternal??{},n.shaderNameMap?.externalToInternal??{}),internalToExternal:Object.assign({},this.hooks.shaderNameMap?.internalToExternal??{},n.shaderNameMap?.internalToExternal??{})},shaderNameState:{nextSuffix:n.shaderNameState?.nextSuffix??this.hooks.shaderNameState?.nextSuffix??0},varyingVariables:(n.varyingVariables||[]).concat(this.hooks.varyingVariables||[]),instanceIDVarying:n.instanceIDVarying||this.hooks.instanceIDVarying||null,fragment:Object.assign({},this.hooks.fragment,r.fragment||{}),vertex:Object.assign({},this.hooks.vertex,r.vertex||{}),compute:Object.assign({},this.hooks.compute,r.compute||{}),helpers:Object.assign({},this.hooks.helpers,r.helpers||{}),hookAliases:Object.assign({},this.hooks.hookAliases,r.hookAliases||{}),modified:{vertex:i,fragment:a,compute:o}}),new t(...s)}init(){if(!this._initialized){try{this._renderer._initShader(this)}catch(t){throw Error(`Whoops! Something went wrong initializing the shader:\n${t.message||t}`)}this.shaderType!==`compute`&&this._loadAttributes(),this._loadUniforms(),this._renderer._finalizeShader(this),this._initialized=!0}return this}setDefaultUniforms(){for(let t in this.hooks.uniforms){let n=this._renderer.uniformNameFromHookKey(t),r=this.hooks.uniforms[t],i;i=r instanceof Function?r():r,i!=null&&this.setUniform(n,i)}for(let t in this.hooks.storageUniforms){let n=this.hooks.storageUniforms[t],r=n instanceof Function?n():n;r!=null&&this.setUniform(t,r)}}copyToContext(n){let r=[n._renderer];this.shaderType===`compute`?r.push(this._computeSrc):r.push(this._vertSrc,this._fragSrc),r.push(this.hooks);let i=new t(...r);return i.ensureCompiledOnContext(n._renderer),i}ensureCompiledOnContext(t){if(this._compiled&&this._renderer!==t)throw Error(`The shader being run is attached to a different context. Do you need to copy it to this context first with .copyToContext()?`);this._compiled||(this._renderer=t?._renderer?.filterRenderer?._renderer||t,this.init())}_loadAttributes(){this._loadedAttributes||=(this.attributes=this._renderer._getShaderAttributes(this),!0)}_loadUniforms(){if(this._loadedUniforms)return;this.uniforms={},this.samplers=[];let t=this._renderer.getUniformMetadata(this);for(let n of t){let t={...n,_cachedData:void 0};t.isSampler&&this.samplers.push(t),this.uniforms[t.name]=t}this._loadedUniforms=!0}bindShader(t,n){if(this.shaderType&&this.shaderType!==t)throw Error(`You've already used this shader as a ${this.shaderType} shader, but are now using it as a ${t}.`);this.shaderType=t,this.init(),this._bound||=(this.useProgram(n),!0)}unbindShader(){return this._bound&&=(this.unbindTextures(),!1),this}bindTextures(){let t=this._renderer._getEmptyTexture();for(let n of this.samplers){if(n.noData)continue;let r=n.texture;(r===void 0||r.isFramebufferTexture&&!r.src.framebuffer.antialias&&r.src.framebuffer===this._renderer.activeFramebuffer())&&(n.texture=r=t),this._renderer._updateTexture(n,r,this)}}unbindTextures(){for(let t of this.samplers)t.texture?.isFramebufferTexture&&this._renderer._unbindFramebufferTexture(t)}useProgram(t){return this._renderer._curShader!==this&&(this._renderer._useShader(this),this._renderer._curShader=this),this}setUniform(t,n){this.init();let r=this.hooks.shaderNameMap?.externalToInternal?.[t]??t,i=this.uniforms[r];if(i){if(t===`uSampler`&&!this._renderer._settingFillUniforms&&(this._userSetSampler=!0),n?.isVector?n=n.values.length===n.dimensions?n.values:n.values.slice(0,n.dimensions):n?.isColor?n=n._getRGBA([1,1,1,1]):n?.isMatrix&&(n=n.matrix),i.isArray){if(i._cachedData&&this._renderer._arraysEqual(i._cachedData,n))return;i._cachedData=n.slice(0)}else if(i._cachedData&&i._cachedData===n)return;else if(Array.isArray(n)||n instanceof vs){if(i._cachedData&&this._renderer._arraysEqual(i._cachedData,n))return;i._cachedData=n.slice(0)}else{if(i._cachedData===n)return;i._cachedData=n}this._renderer.updateUniformValue(this,i,n)}}enableAttrib(t,n,r,i,a,o){return t&&(typeof IS_MINIFIED>`u`&&this.attributes[t.name]!==t&&console.warn(`The attribute "${t.name}"passed to enableAttrib does not belong to this shader.`),t.location!==-1&&this._renderer._enableAttrib(this,t,n,r,i,a,o)),this}};function bs(t,n){t.Shader=ys}typeof p5<`u`&&bs(p5,p5.prototype);async function xs(t){let n=await fetch(t).then(t=>t.text());return Function(n)}function Ss(t,n){let r=t._runStrandsInGlobalMode;t._runStrandsInGlobalMode=!0;try{return n()}finally{t._runStrandsInGlobalMode=r}}function Cs(t,n){n.loadShader=async function(t,n,r,i){let a=new ys;try{return a._vertSrc=(await To(t,`text`)).data,a._fragSrc=(await To(n,`text`)).data,r&&r(a)||a}catch(t){if(i)return i(t);throw t}},n.createShader=function(t,n,r){return new ys(this._renderer,t,n,r)},n.loadFilterShader=async function(t,n,r){try{let r=await(await this.loadStrings(t)).join(`
`),i=/void\s+main/.exec(r)?()=>this.createFilterShader(r,!0):()=>Ss(this,()=>this.baseFilterShader().modify(Function(r))),a=this._internal?this._internal(i):i();return n&&(a=n(a)||a),a}catch(t){r?r(t):console.error(t)}},n.buildFilterShader=function(t,n){return this.baseFilterShader().modify(t,n)},t.registerDecorator(`p5.prototype.buildFilterShader`,ds(`p5.strands`,t)),n.createFilterShader=function(t,n=!1){let r=t.includes(`#version 300 es`)?`#version 300 es
      uniform mat4 uModelViewMatrix;
      uniform mat4 uProjectionMatrix;

      in vec3 aPosition;
      in vec2 aTexCoord;
      out vec2 vTexCoord;

      void main() {
        // transferring texcoords for the frag shader
        vTexCoord = aTexCoord;

        // copy position with a fourth coordinate for projection (1.0 is normal)
        vec4 positionVec4 = vec4(aPosition, 1.0);

        // project to 3D space
        gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;
      }
    `:`
      uniform mat4 uModelViewMatrix;
      uniform mat4 uProjectionMatrix;

      attribute vec3 aPosition;
      // texcoords only come from p5 to vertex shader
      // so pass texcoords on to the fragment shader in a varying variable
      attribute vec2 aTexCoord;
      varying vec2 vTexCoord;

      void main() {
        // transferring texcoords for the frag shader
        vTexCoord = aTexCoord;

        // copy position with a fourth coordinate for projection (1.0 is normal)
        vec4 positionVec4 = vec4(aPosition, 1.0);

        // project to 3D space
        gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;
      }
    `,i=new ys(this._renderer,r,t);return n||(this._renderer.GL?i.ensureCompiledOnContext(this._renderer):i.ensureCompiledOnContext(this)),i},n.shader=function(t){return this._assert3d(`shader`),this._renderer.shader(t),this},n.strokeShader=function(t){return this._assert3d(`strokeShader`),this._renderer.strokeShader(t),this},n.imageShader=function(t){return this._assert3d(`imageShader`),this._renderer.imageShader(t),this},n.buildMaterialShader=function(t,n){return this.baseMaterialShader().modify(t,n)},t.registerDecorator(`p5.prototype.buildMaterialShader`,ds(`p5.strands`,t)),n.loadMaterialShader=async function(t,n,r){try{let r=await xs(t),i=()=>Ss(this,()=>this.buildMaterialShader(r)),a=this._internal?this._internal(i):i();return n&&(a=n(a)||a),a}catch(t){console.error(t),r&&r(t)}},n.baseMaterialShader=function(){return this._assert3d(`baseMaterialShader`),this._renderer.baseMaterialShader()},n.baseFilterShader=function(){return(this._renderer.filterRenderer||this._renderer).baseFilterShader()},n.buildNormalShader=function(t,n){return this.baseNormalShader().modify(t,n)},t.registerDecorator(`p5.prototype.buildNormalShader`,ds(`p5.strands`,t)),n.loadNormalShader=async function(t,n,r){try{let r=await xs(t),i=()=>Ss(this,()=>this.buildNormalShader(r)),a=this._internal?this._internal(i):i();return n&&(a=n(a)||a),a}catch(t){console.error(t),r&&r(t)}},n.baseNormalShader=function(){return this._assert3d(`baseNormalShader`),this._renderer.baseNormalShader()},n.buildColorShader=function(t,n){return this.baseColorShader().modify(t,n)},t.registerDecorator(`p5.prototype.buildColorShader`,ds(`p5.strands`,t)),n.loadColorShader=async function(t,n,r){try{let r=await xs(t),i=()=>Ss(this,()=>this.buildColorShader(r)),a=this._internal?this._internal(i):i();return n&&(a=n(a)||a),a}catch(t){console.error(t),r&&r(t)}},n.baseColorShader=function(){return this._assert3d(`baseColorShader`),this._renderer.baseColorShader()},n.buildStrokeShader=function(t,n){return this.baseStrokeShader().modify(t,n)},t.registerDecorator(`p5.prototype.buildStrokeShader`,ds(`p5.strands`,t)),n.loadStrokeShader=async function(t,n,r){try{let r=await xs(t),i=()=>Ss(this,()=>this.buildStrokeShader(r)),a=this._internal?this._internal(i):i();return n&&(a=n(a)||a),a}catch(t){console.error(t),r&&r(t)}},n.baseStrokeShader=function(){return this._assert3d(`baseStrokeShader`),this._renderer.baseStrokeShader()},n.resetShader=function(){return this._renderer.resetShader(),this},n.texture=function(t){return this._assert3d(`texture`),t.gifProperties&&t._animateGif(this),this._renderer.texture(t),this},n.normalTexture=function(t,n){return this._assert3d(`normalTexture`),this._renderer.normalTexture(t||null,n),this},n.bumpTexture=function(t,n){return this._assert3d(`bumpTexture`),this._renderer.bumpTexture(t||null,n),this},n.specularTexture=function(t){return this._assert3d(`specularTexture`),this._renderer.specularTexture(t||null),this},n.ambientTexture=function(t){return this._assert3d(`ambientTexture`),this._renderer.ambientTexture(t||null),this},n.shininessTexture=function(t){return this._assert3d(`shininessTexture`),this._renderer.shininessTexture(t||null),this},n.textureMode=function(t){if(t===void 0)return this._renderer.states.textureMode;t!==`image`&&t!==`normal`?console.warn(`You tried to set ${t} textureMode only supports IMAGE & NORMAL `):this._renderer.states.setValue(`textureMode`,t)};let r=[yt,vt,bt];function i(n,i,a){t.disableFriendlyErrors||r.includes(i)||n._textureWrapWarned||(n._textureWrapWarned=!0,t._friendlyError(`textureWrap() expects CLAMP, REPEAT, or MIRROR, but received ${i} for ${a}. The texture will fall back to CLAMP.`,`textureWrap`))}n.textureWrap=function(t,n=t){if(t===void 0)return{x:this._renderer.states.textureWrapX,y:this._renderer.states.textureWrapY};if(typeof t==`object`&&t&&Object.hasOwn(t,`x`)&&Object.hasOwn(t,`y`)&&({x:t,y:n}=t),i(this,t,`wrapX`),i(this,n,`wrapY`),this._renderer.states.setValue(`textureWrapX`,t),this._renderer.states.setValue(`textureWrapY`,n),this._renderer.textures)for(let r of this._renderer.textures.values())r.setWrapMode(t,n);return this},n.normalMaterial=function(...t){return this._assert3d(`normalMaterial`),this._renderer.normalMaterial(...t),this},n.ambientMaterial=function(t,r,i){this._assert3d(`ambientMaterial`);let a=n.color.apply(this,arguments);return this._renderer.states.setValue(`_hasSetAmbient`,!0),this._renderer.states.setValue(`curAmbientColor`,a._array),this._renderer.states.setValue(`_useNormalMaterial`,!1),this._renderer.states.setValue(`enableLighting`,!0),this._renderer.states.fillColor||this._renderer.states.setValue(`fillColor`,new Ui([1,1,1])),this},n.emissiveMaterial=function(t,r,i,a){this._assert3d(`emissiveMaterial`);let o=n.color.apply(this,arguments);return this._renderer.states.setValue(`curEmissiveColor`,o._array),this._renderer.states.setValue(`_useEmissiveMaterial`,!0),this._renderer.states.setValue(`_useNormalMaterial`,!1),this._renderer.states.setValue(`enableLighting`,!0),this},n.specularMaterial=function(t,r,i,a){this._assert3d(`specularMaterial`);let o=n.color.apply(this,arguments);return this._renderer.states.setValue(`curSpecularColor`,o._array),this._renderer.states.setValue(`_useSpecularMaterial`,!0),this._renderer.states.setValue(`_useNormalMaterial`,!1),this._renderer.states.setValue(`enableLighting`,!0),this},n.shininess=function(t){return this._assert3d(`shininess`),this._renderer.shininess(t),this},n.metalness=function(t){return this._assert3d(`metalness`),this._renderer.metalness(t),this},z.prototype.shader=function(t){this.states.setValue(`userFillShader`,t),this.states.setValue(`_useNormalMaterial`,!1),t.ensureCompiledOnContext(this),t.setDefaultUniforms()},z.prototype.strokeShader=function(t){this.states.setValue(`userStrokeShader`,t),t.ensureCompiledOnContext(this),t.setDefaultUniforms()},z.prototype.imageShader=function(t){this.states.setValue(`userImageShader`,t),t.ensureCompiledOnContext(this),t.setDefaultUniforms()},z.prototype.resetShader=function(){this.states.setValue(`userFillShader`,null),this.states.setValue(`userStrokeShader`,null),this.states.setValue(`userImageShader`,null)},z.prototype.texture=function(t){this.states.setValue(`drawMode`,pt),this.states.setValue(`_useNormalMaterial`,!1),this.states.setValue(`_tex`,t),this.states.setValue(`fillColor`,new Ui([1,1,1]))},z.prototype.normalTexture=function(t,n=1){this.states.setValue(`_normalTex`,t||null),this.states.setValue(`_normalScale`,t?n:1),this.states.setValue(`_normalMapMode`,0)},z.prototype.bumpTexture=function(t,n=1){this.states.setValue(`_normalTex`,t||null),this.states.setValue(`_normalScale`,t?n:1),this.states.setValue(`_normalMapMode`,+!!t)},z.prototype.specularTexture=function(t){this.states.setValue(`_specularTex`,t||null),t&&this.states.setValue(`_useSpecularMaterial`,!0)},z.prototype.ambientTexture=function(t){this.states.setValue(`_ambientTex`,t||null),t&&this.states.setValue(`_hasSetAmbient`,!0)},z.prototype.shininessTexture=function(t){this.states.setValue(`_shininessTex`,t||null)},z.prototype.normalMaterial=function(...t){this.states.setValue(`drawMode`,ft),this.states.setValue(`_useSpecularMaterial`,!1),this.states.setValue(`_useEmissiveMaterial`,!1),this.states.setValue(`_useNormalMaterial`,!0),this.states.setValue(`curFillColor`,[1,1,1,1]),this.states.setValue(`fillColor`,new Ui([1,1,1])),this.states.setValue(`strokeColor`,null)},z.prototype.shininess=function(t){t<1&&(t=1),this.states.setValue(`_useShininess`,t)},z.prototype.metalness=function(t){let n=1-Math.exp(-t/100);this.states.setValue(`_useMetalness`,n)}}typeof p5<`u`&&loading(p5,p5.prototype);function ws(t,n){let r=n.DEGREES=`degrees`,i=n.RADIANS=`radians`;n._angleMode=i,n.acos=function(t){return this._fromRadians(Math.acos(t))},n.asin=function(t){return this._fromRadians(Math.asin(t))},n.atan=function(t){return this._fromRadians(Math.atan(t))},n.atan2=function(t,n){return this._fromRadians(Math.atan2(t,n))},n.cos=function(t){return Math.cos(this._toRadians(t))},n.sin=function(t){return Math.sin(this._toRadians(t))},n.tan=function(t){return Math.tan(this._toRadians(t))},n.degrees=t=>t*M,n.radians=t=>t*j,n.angleMode=function(t){if(t===void 0)return this._angleMode;if(t===r||t===i){if(t===this._angleMode)return;t===i?(this.pRotationX*=j,this.pRotationY*=j,this.pRotationZ*=j):(this.pRotationX*=M,this.pRotationY*=M,this.pRotationZ*=M),this._angleMode=t}},n._toRadians=function(t){return t!==void 0&&this._angleMode===r?t*j:t},n._toDegrees=function(t){return this._angleMode===i?t*M:t},n._fromRadians=function(t){return this._angleMode===r?t*M:t},n._fromDegrees=function(t){return this._angleMode===i?t*j:t}}typeof p5<`u`&&ws(p5,p5.prototype);var Ts=class{constructor(t,n,r,i,a){let o=r||`p2d`;return this._pInst=i,this._renderer=new Us[o](this,t,n,!1,a),this._initializeInstanceVariables(this),this._renderer._applyDefaults(),this}get elt(){return this.canvas}get deltaTime(){return this._pInst.deltaTime}get canvas(){return this._renderer?.canvas}get drawingContext(){return this._renderer.drawingContext}get width(){return this._renderer?.width}get height(){return this._renderer?.height}get pixels(){return this._renderer?.pixels}pixelDensity(t){let n;return typeof t==`number`?(t!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=t),n=this,this.resizeCanvas(this.width,this.height,!0)):n=this._renderer._pixelDensity,n}resizeCanvas(t,n){this._renderer.resize(t,n)}reset(){this._renderer.resetMatrix(),this._renderer.isP3D&&this._renderer._update()}remove(){this._renderer.remove(),this._renderer=void 0}createFramebuffer(t){return new Vs(this._renderer,t)}_assert3d(t){if(!this._renderer.isP3D)throw Error(`${t}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see  https://p5js.org/examples/form-3d-primitives.html for more information.`)}_initializeInstanceVariables(){this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._styles=[],this._downKeys={}}};function Es(t,n){t.Graphics=Ts,uo(t,t.Graphics.prototype),fo(t,t.Graphics.prototype),po(t,t.Graphics.prototype),mo(t,t.Graphics.prototype),Ua(t,t.Graphics.prototype),ho(t,t.Graphics.prototype),Oo(t,t.Graphics.prototype),_o(t,t.Graphics.prototype),ko(t,t.Graphics.prototype),Ht(t,t.Graphics.prototype),gs(t,t.Graphics.prototype),_s(t,t.Graphics.prototype),Cs(t,t.Graphics.prototype),Yi(t,t.Graphics.prototype),ws(t,t.Graphics.prototype)}var Ds=class{constructor(t,n,r={}){this._renderer=t,this.src=n,this.format=r.format||`rgba8unorm`,this.minFilter=r.minFilter||`linear`,this.magFilter=r.magFilter||`linear`,this.wrapS=r.wrapS||t.states.textureWrapX,this.wrapT=r.wrapT||t.states.textureWrapY,this.dataType=r.dataType||`uint8`,this.textureHandle=null,this._detectSourceType();let i=this._getTextureDataFromSource();this.width=i.width,this.height=i.height,this.init(i)}_detectSourceType(){let t=this.src;this.isFramebufferTexture=t instanceof Bs,this.isSrcP5Image=t instanceof fa,this.isSrcP5Graphics=t instanceof Ts,this.isSrcP5Renderer=t instanceof L,this.isImageData=typeof ImageData<`u`&&t instanceof ImageData,this.isSrcMediaElement=oo!==void 0&&t instanceof oo,this.isSrcHTMLElement=ta!==void 0&&t instanceof ta&&!this.isSrcMediaElement&&!this.isSrcP5Graphics&&!this.isSrcP5Renderer}remove(){this.textureHandle&&=(this._renderer.deleteTexture(this.textureHandle),null)}_getTextureDataFromSource(){let t;return this.isFramebufferTexture?t=this.src.rawTexture():this.isSrcP5Image?t=this.src.canvas:this.isSrcMediaElement||this.isSrcHTMLElement?this.isSrcMediaElement&&(this.src.flipped||!this._renderer.supportsVideoUpload())?(this.src._ensureCanvas(),t=this.src.canvas):(this.src._checkIfTextureNeedsUpdate&&this.src._checkIfTextureNeedsUpdate(),t=this.src.elt):this.isSrcP5Graphics||this.isSrcP5Renderer?t=this.src.canvas:this.isImageData&&(t=this.src),t}init(t){this.textureHandle=this.isFramebufferTexture?this._renderer.createFramebufferTextureHandle(this.src):this._renderer.createTexture({format:this.format,dataType:this.dataType,width:t.width,height:t.height}),this._renderer.setTextureParams(this,{minFilter:this.minFilter,magFilter:this.magFilter,wrapS:this.wrapS,wrapT:this.wrapT}),this.bindTexture(),this._shouldDeferUpload()?this._renderer.uploadTextureFromData(this.textureHandle,/* @__PURE__ */ new Uint8Array(4),1,1):this.isFramebufferTexture||this._renderer.uploadTextureFromSource(this.textureHandle,t),this.unbindTexture()}_shouldDeferUpload(){return this.width===0||this.height===0||this.isSrcMediaElement&&!this.src.loadedmetadata}update(){let t=this._getTextureDataFromSource();if(!t)return!1;let n=!1;return this._shouldUpdate(t)&&(this.bindTexture(),this._renderer.uploadTextureFromSource(this.textureHandle,t),n=!0),n}_shouldUpdate(t){let n=this.src;if(n.width===0||n.height===0)return!1;if(this.isFramebufferTexture)return this.src.update(),!1;let r=!1;return t.width!==this.width||t.height!==this.height?(r=!0,this.width=t.width||n.width,this.height=t.height||n.height,this.isSrcP5Image?n.setModified(!1):(this.isSrcMediaElement||this.isSrcHTMLElement)&&n.setModified&&n.setModified(!0)):this.isSrcP5Image?(n.gifProperties&&n._animateGif(this._renderer._pInst),n.isModified()&&(r=!0,n.setModified(!1))):this.isSrcMediaElement?n.isModified()?(r=!0,n.setModified(!1)):n.loadedmetadata&&this._videoPrevUpdateTime!==n.time()&&(this._videoPrevUpdateTime=n.time(),r=!0):this.isImageData?n._dirty&&(n._dirty=!1,r=!0):r=!0,r}bindTexture(){return this._renderer.bindTexture(this),this}unbindTexture(){this._renderer.unbindTexture()}getTexture(){return this.isFramebufferTexture?this.src.rawTexture():this.textureHandle}getSampler(){return this._renderer.getSampler(this)}setInterpolation(t,n){this.minFilter=t,this.magFilter=n,this._renderer.setTextureParams(this)}setWrapMode(t,n){this.wrapS=t,this.wrapT=n,this._renderer.setTextureParams(this)}},Os=class extends Ds{constructor(t,n,r={}){let i={minFilter:st,magFilter:st,...r};super(t,n,i),this.levels=n}_getTextureDataFromSource(){return this.src}init(t){if(Array.isArray(t)){let n=t[0];this.width=n.width,this.height=n.height,this.textureHandle=this._renderer.createMipmapTextureHandle({levels:t,format:this.format,dataType:this.dataType,width:this.width,height:this.height})}else this.width=t.size,this.height=t.size,this.textureHandle=this._renderer.createMipmapTextureHandle({gpuTexture:t.gpuTexture,format:t.format,dataType:`uint8`,width:this.width,height:this.height});this._renderer.setTextureParams(this,{minFilter:this.minFilter,magFilter:this.magFilter,wrapS:this.wrapS,wrapT:this.wrapT})}update(){}};function ks(t,n){t.Texture=Ds,t.MipmapTexture=Os}typeof p5<`u`&&ks(p5,p5.prototype);function As(t,n,r,i,a,o,s,c,l,u){let d=n.getParameter(n.FRAMEBUFFER_BINDING);n.bindFramebuffer(n.FRAMEBUFFER,r);let f=c===n.RGBA?4:3,p=o*s*f,m=l===n.UNSIGNED_BYTE?Uint8Array:Float32Array;if((!(t instanceof m)||t.length!==p)&&(t=new m(p)),n.readPixels(i,u?u-a-s:a,o,s,c,l,t),n.bindFramebuffer(n.FRAMEBUFFER,d),u){let n=Math.floor(s/2),r=new m(o*f);for(let i=0;i<n;i++){let n=i*o*4,a=(s-i-1)*o*4;r.set(t.subarray(n,n+o*4)),t.copyWithin(n,a,a+o*4),t.set(r,a)}}return t}function js(t,n,r,i,a,o,s){let c=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,n);let l=a===t.RGBA?4:3,u=new(o===t.UNSIGNED_BYTE?Uint8Array:Float32Array)(l);return t.readPixels(r,s?s-i-1:i,1,1,a,o,u),t.bindFramebuffer(t.FRAMEBUFFER,c),Array.from(u)}function Ms(t,n,r){t.bindTexture();let i=t.minFilter===`nearest`?n.NEAREST:t.minFilter===`linear_mipmap`?n.LINEAR_MIPMAP_LINEAR:n.LINEAR,a=t.magFilter===`nearest`?n.NEAREST:n.LINEAR,o=t=>!(t&t-1),s=t._getTextureDataFromSource(),c,l;s.naturalWidth&&s.naturalHeight?(c=s.naturalWidth,l=s.naturalHeight):(c=t.width,l=t.height);let u=o(c),d=o(l),f,p;t.wrapS===`repeat`?r===`webgl2`||u&&d?f=n.REPEAT:(console.warn(`You tried to set the wrap mode to REPEAT but the texture size is not a power of two. Setting to CLAMP instead`),f=n.CLAMP_TO_EDGE):t.wrapS===`mirror`?r===`webgl2`||u&&d?f=n.MIRRORED_REPEAT:(console.warn(`You tried to set the wrap mode to MIRROR but the texture size is not a power of two. Setting to CLAMP instead`),f=n.CLAMP_TO_EDGE):f=n.CLAMP_TO_EDGE,t.wrapT===`repeat`?r===`webgl2`||u&&d?p=n.REPEAT:(console.warn(`You tried to set the wrap mode to REPEAT but the texture size is not a power of two. Setting to CLAMP instead`),p=n.CLAMP_TO_EDGE):t.wrapT===`mirror`?r===`webgl2`||u&&d?p=n.MIRRORED_REPEAT:(console.warn(`You tried to set the wrap mode to MIRROR but the texture size is not a power of two. Setting to CLAMP instead`),p=n.CLAMP_TO_EDGE):p=n.CLAMP_TO_EDGE,n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,a),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,f),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,p),t.unbindTexture()}function Ns(t,n,r,i,a){let o=n.location;switch(t.useProgram(),n.type){case a.BOOL:r===!0?a.uniform1i(o,1):a.uniform1i(o,0);break;case a.INT:n.size>1?r.length&&a.uniform1iv(o,r):a.uniform1i(o,r);break;case a.FLOAT:n.size>1?r.length&&a.uniform1fv(o,r):a.uniform1f(o,r);break;case a.FLOAT_MAT2:a.uniformMatrix2fv(o,!1,r);break;case a.FLOAT_MAT3:a.uniformMatrix3fv(o,!1,r);break;case a.FLOAT_MAT4:a.uniformMatrix4fv(o,!1,r);break;case a.FLOAT_VEC2:n.size>1?r.length&&a.uniform2fv(o,r):a.uniform2f(o,r[0],r[1]);break;case a.FLOAT_VEC3:n.size>1?r.length&&a.uniform3fv(o,r):a.uniform3f(o,r[0],r[1],r[2]);break;case a.FLOAT_VEC4:n.size>1?r.length&&a.uniform4fv(o,r):a.uniform4f(o,r[0],r[1],r[2],r[3]);break;case a.INT_VEC2:n.size>1?r.length&&a.uniform2iv(o,r):a.uniform2i(o,r[0],r[1]);break;case a.INT_VEC3:n.size>1?r.length&&a.uniform3iv(o,r):a.uniform3i(o,r[0],r[1],r[2]);break;case a.INT_VEC4:n.size>1?r.length&&a.uniform4iv(o,r):a.uniform4i(o,r[0],r[1],r[2],r[3]);break;case a.SAMPLER_2D:if(typeof r==`number`){if(r<a.TEXTURE0||r>a.TEXTURE31||r!==Math.ceil(r)){console.log(`🌸 p5.js says: You're trying to use a number as the data for a texture.Please use a texture.`);return}a.activeTexture(r),a.uniform1i(o,r)}else a.activeTexture(a.TEXTURE0+n.samplerIndex),n.texture=r instanceof Ds?r:i(r),a.uniform1i(o,n.samplerIndex);break;case a.SAMPLER_CUBE:case a.SAMPLER_3D:case a.SAMPLER_2D_SHADOW:case a.SAMPLER_2D_ARRAY:case a.SAMPLER_2D_ARRAY_SHADOW:case a.SAMPLER_CUBE_SHADOW:case a.INT_SAMPLER_2D:case a.INT_SAMPLER_3D:case a.INT_SAMPLER_CUBE:case a.INT_SAMPLER_2D_ARRAY:case a.UNSIGNED_INT_SAMPLER_2D:case a.UNSIGNED_INT_SAMPLER_3D:case a.UNSIGNED_INT_SAMPLER_CUBE:case a.UNSIGNED_INT_SAMPLER_2D_ARRAY:if(typeof r!=`number`)break;if(r<a.TEXTURE0||r>a.TEXTURE31||r!==Math.ceil(r)){console.log(`🌸 p5.js says: You're trying to use a number as the data for a texture.Please use a texture.`);break}a.activeTexture(r),a.uniform1i(o,r)}}function Ps(t,n){let r=t._glProgram,i=n.getProgramParameter(r,n.ACTIVE_UNIFORMS),a=[],o=0;for(let t=0;t<i;++t){let i=n.getActiveUniform(r,t),s={};s.location=n.getUniformLocation(r,i.name),s.size=i.size;let c=i.name;i.size>1&&(c=c.substring(0,c.indexOf(`[0]`))),s.name=c,s.type=i.type,s._cachedData=void 0,s.type===n.SAMPLER_2D&&(s.isSampler=!0,s.samplerIndex=o,o++),s.isArray=i.size>1||s.type===n.FLOAT_MAT2||s.type===n.FLOAT_MAT3||s.type===n.FLOAT_MAT4||s.type===n.FLOAT_VEC2||s.type===n.FLOAT_VEC3||s.type===n.FLOAT_VEC4||s.type===n.INT_VEC2||s.type===n.INT_VEC4||s.type===n.INT_VEC3,a.push(s)}return a}function Fs(t,n){let r={},i=n.getProgramParameter(t._glProgram,n.ACTIVE_ATTRIBUTES);for(let a=0;a<i;++a){let i=n.getActiveAttrib(t._glProgram,a),o=i.name,s=n.getAttribLocation(t._glProgram,o),c={};c.name=o,c.location=s,c.index=a,c.type=i.type,c.size=i.size,r[o]=c}return r}function Is(t,n,r){let i=`void main`;if(!n.includes(i))return n;let[a,o]=n.split(i),s=``,c=``;for(let n in t.hooks.uniforms)s+=`uniform ${n};\n`;if(t.hooks.declarations&&(s+=t.hooks.declarations+`
`),t.hooks[r].declarations&&(s+=t.hooks[r].declarations+`
`),t.hooks.varyingVariables&&t.hooks.varyingVariables.length>0)for(let n of t.hooks.varyingVariables)r===`vertex`?s+=`OUT ${n};\n`:r===`fragment`&&(s+=`IN ${n};\n`);if(t.hooks.instanceIDVarying){let{declaration:n,source:i,interpolation:a}=t.hooks.instanceIDVarying,c=a?`${a} `:``;r===`vertex`?(s+=`${c}OUT ${n};\n`,o=o.replace(/\{/,`{\n  ${n.split(` `).pop()} = ${i};`)):r===`fragment`&&(s+=`${c}IN ${n};\n`)}for(let n in t.hooks.helpers)s+=`${n}${t.hooks.helpers[n]}\n`;for(let n in t.hooks[r]){if(n===`declarations`)continue;let[i,a]=n.split(` `);(t.hooks.modified.vertex[n]||t.hooks.modified.fragment[n])&&(c+=`#define AUGMENTED_HOOK_`+a+`
`),s+=i+` HOOK_`+a+t.hooks[r][n]+`
`}return a.indexOf(`#define HOOK_DEFINES`)!==-1&&(a=a.replace(`#define HOOK_DEFINES`,`
`+c+`
`),c=``),a+`
`+c+s+i+o}function Ls({GL:t,webglVersion:n}){let r=t,i=n===`webgl2`?r.getExtension(`EXT_color_buffer_float`)&&r.getExtension(`EXT_float_blend`):r.getExtension(`OES_texture_float`),a=i&&r.getExtension(`OES_texture_float_linear`),o=n===`webgl2`?r.getExtension(`EXT_color_buffer_float`):r.getExtension(`OES_texture_half_float`);return{float:i,floatLinear:a,halfFloat:o,halfFloatLinear:o&&r.getExtension(`OES_texture_half_float_linear`)}}const Rs=(t,n,r)=>Math.max(Math.min(t,r),n);var zs=class extends Ko{constructor(t){super(t.renderer),this.fbo=t,this.yScale=t.renderer.framebufferYScale()}_computeCameraDefaultSettings(){super._computeCameraDefaultSettings(),this.defaultAspectRatio=this.fbo.width/this.fbo.height,this.defaultCameraFOV=2*Math.atan(this.fbo.height/2/this.defaultEyeZ)}copy(){let t=super.copy();return t.fbo=this.fbo,t}},Bs=class{constructor(t,n){this.framebuffer=t,this.property=n}get width(){return this.framebuffer.width*this.framebuffer.density}get height(){return this.framebuffer.height*this.framebuffer.density}update(){this.framebuffer._update(this.property)}rawTexture(){return{texture:this.framebuffer[this.property]}}},Vs=class{constructor(t,n={}){if(this.renderer=t,this.renderer.framebuffers.add(this),this._isClipApplied=!1,this._useCanvasFormat=n._useCanvasFormat||!1,this.dirty={colorTexture:!1,depthTexture:!1},this.pixels=[],this.format=n.format||`unsigned-byte`,this.channels=n.channels||(this.renderer.defaultFramebufferAlpha()?`rgba`:`rgb`),this.useDepth=n.depth===void 0||n.depth,this.depthFormat=n.depthFormat||`float`,this.textureFiltering=n.textureFiltering||`linear`,this.antialiasSamples=n.antialias===void 0?this.renderer.defaultFramebufferAntialias()?2:0:typeof n.antialias==`number`?n.antialias:n.antialias?2:0,this.antialias=this.antialiasSamples>0,this.antialias&&!this.renderer.supportsFramebufferAntialias()&&(console.warn(`Framebuffer antialiasing is unsupported in this context`),this.antialias=!1),this.density=n.density||this.renderer._pixelDensity,n.width&&n.height){let t=this.renderer._adjustDimensions(n.width,n.height,this.density);this.width=t.adjustedWidth,this.height=t.adjustedHeight,this._autoSized=!1}else n.width===void 0!=(n.height===void 0)&&console.warn(`Please supply both width and height for a framebuffer to give it a size. Only one was given, so the framebuffer will match the size of its canvas.`),this.width=this.renderer.width,this.height=this.renderer.height,this._autoSized=!0;this.renderer.validateFramebufferFormats(this),n.stencil&&!this.useDepth&&console.warn(`A stencil buffer can only be used if also using depth. Since the framebuffer has no depth buffer, the stencil buffer will be ignored.`),this.useStencil=this.useDepth&&(n.stencil===void 0||n.stencil),this.renderer.createFramebufferResources(this),this._recreateTextures(),this.defaultCamera=this.createCamera(),this.filterCamera=this.createCamera(),this.draw(()=>this.renderer.clear())}resize(t,n){this._autoSized=!1;let r=this.renderer._adjustDimensions(t,n,this.density);t=r.adjustedWidth,n=r.adjustedHeight,this.width=t,this.height=n,this._handleResize()}pixelDensity(t){if(t)this._autoSized=!1,this.density=t,this._handleResize();else return this.density}autoSized(t){if(t===void 0)return this._autoSized;this._autoSized=t,this._handleResize()}_checkIfFormatsAvailable(){let t=this.gl;this.useDepth&&this.renderer.webglVersion===`webgl`&&!t.getExtension(`WEBGL_depth_texture`)&&(console.warn(`Unable to create depth textures in this environment. Falling back to a framebuffer without depth.`),this.useDepth=!1),this.useDepth&&this.renderer.webglVersion===`webgl`&&this.depthFormat===`float`&&(console.warn(`FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT.`),this.depthFormat=It),[`unsigned-byte`,`float`,`half-float`].includes(this.format)||(console.warn(`Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE.`),this.format=Ft),this.useDepth&&![`unsigned-int`,`float`].includes(this.depthFormat)&&(console.warn(`Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT.`),this.depthFormat=Lt);let n=Ls(this.renderer);!n.float&&this.format===`float`&&(console.warn(`This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE.`),this.format=Ft),this.useDepth&&!n.float&&this.depthFormat===`float`&&(console.warn(`This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT.`),this.depthFormat=It),!n.halfFloat&&this.format===`half-float`&&(console.warn(`This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE.`),this.format=Ft),this.channels===`rgb`&&[`float`,`half-float`].includes(this.format)&&(console.warn(`FLOAT and HALF_FLOAT formats do not work cross-platform with only RGB channels. Falling back to RGBA.`),this.channels=Ji)}_deleteTextures(){this.renderer.deleteFramebufferTextures(this)}_recreateTextures(){if(this._updateSize(),this.renderer.recreateFramebufferTextures(this),this.useDepth){this.depth=new Bs(this,`depthTexture`);let t=_t;this.depthP5Texture=new Ds(this.renderer,this.depth,{minFilter:t,magFilter:t}),this.renderer.textures.set(this.depth,this.depthP5Texture)}this.color=new Bs(this,`colorTexture`);let t=this.textureFiltering===`linear`?st:_t;this.colorP5Texture=new Ds(this.renderer,this.color,{minFilter:t,magFilter:t}),this.renderer.textures.set(this.color,this.colorP5Texture)}_updateSize(){this._autoSized&&(this.width=this.renderer.width,this.height=this.renderer.height,this.density=this.renderer._pixelDensity)}_canvasSizeChanged(){this._autoSized&&this._handleResize()}_handleResize(){this._deleteTextures(),this._recreateTextures(),this.defaultCamera._resize()}createCamera(){let t=new zs(this);return t._computeCameraDefaultSettings(),t._setDefaultCamera(),t}remove(){this._deleteTextures(),this.renderer.deleteFramebufferResources(this),this.renderer.framebuffers.delete(this)}begin(){this.prevFramebuffer=this.renderer.activeFramebuffer(),this.prevFramebuffer&&this.prevFramebuffer._beforeEnd(),this.renderer.activeFramebuffers.push(this),this._beforeBegin(),this.renderer.push(),this.renderer.states.setValue(`curCamera`,this.defaultCamera),this.renderer.states.setValue(`uPMatrix`,this.renderer.states.uPMatrix.clone()),this.renderer.states.uPMatrix.set(this.defaultCamera.projMatrix),this.renderer.states.setValue(`uViewMatrix`,this.renderer.states.uViewMatrix.clone()),this.renderer.states.uViewMatrix.set(this.defaultCamera.cameraMatrix),this.renderer.resetMatrix(),this.renderer.states.uViewMatrix.set(this.renderer.states.curCamera.cameraMatrix),this.renderer.states.uModelMatrix.reset(),this.renderer._applyStencilTestIfClipping()}_framebufferToBind(){return this.renderer.getFramebufferToBind(this)}_update(t){this.dirty[t]&&(this.renderer.updateFramebufferTexture(this,t),this.dirty[t]=!1)}_beforeBegin(){this.renderer.bindFramebuffer(this),this.renderer.viewport(this.width*this.density,this.height*this.density),this.renderer.flushDraw&&this.renderer.flushDraw()}_beforeEnd(){this.antialias&&(this.dirty={colorTexture:!0,depthTexture:!0}),this.renderer.flushDraw&&this.renderer.flushDraw()}end(){if(this.renderer.pop(),this.renderer.activeFramebuffers.pop()!==this)throw Error(`It looks like you've called end() while another Framebuffer is active.`);this._beforeEnd(),this.prevFramebuffer?this.prevFramebuffer._beforeBegin():(this.renderer.bindFramebuffer(null),this.renderer.viewport(this.renderer._origViewport.width,this.renderer._origViewport.height)),this.renderer._applyStencilTestIfClipping()}draw(t){this.begin(),t(),this.end()}loadPixels(){this._update(`colorTexture`);let t=this.renderer.readFramebufferPixels(this);return t&&typeof t.then==`function`?t.then(t=>(this.pixels=t,t)):(this.pixels=t,t)}get(t,n,r,i){if(this._update(`colorTexture`),t===void 0&&n===void 0)t=0,n=0,r=this.width,i=this.height;else if(r===void 0&&i===void 0)return(t<0||n<0||t>=this.width||n>=this.height)&&(console.warn(`The x and y values passed to p5.Framebuffer.get are outside of its range and will be clamped.`),t=Rs(t,0,this.width-1),n=Rs(n,0,this.height-1)),this.renderer.readFramebufferPixel(this,t*this.density,n*this.density);return t=Rs(t,0,this.width-1),n=Rs(n,0,this.height-1),r=Rs(r,1,this.width-t),i=Rs(i,1,this.height-n),this.renderer.readFramebufferRegion(this,t,n,r,i)}updatePixels(){this.renderer.updateFramebufferPixels(this)}};function Hs(t,n){t.FramebufferCamera=zs,t.FramebufferTexture=Bs,t.Framebuffer=Vs}typeof p5<`u`&&Hs(p5,p5.prototype);let Us;function Ws(t,n){t.renderers||={},Us=t.renderers,n.createCanvas=function(n,r,i,...a){let o=`p2d`;if(Reflect.ownKeys(Us).includes(i)?o=i:a.unshift(i),!Us[i]&&typeof i==`string`&&(i===`webgpu`?(t.FES.log`To create a WEBGPU canvas, add the WebGPU add-on to your project.`(),Us.webgl&&(t.FES.log`Falling back to WebGL renderer.`(),o=h),a.shift()):t.FES.log`We weren't able to find a renderer called ${i}.`()),this._renderer){this._renderer.remove();let t=this._elements.indexOf(this._renderer);t!==-1&&this._elements.splice(t,1)}return this._renderer=new Us[o](this,n,r,!0,...a),this._defaultGraphicsCreated=!0,this._elements.push(this._renderer),this._renderer._applyDefaults(),Object.hasOwn(this,`pixels`)||Object.defineProperty(this,"pixels",{get(){return this._renderer?.pixels}}),this._renderer.contextReady?this._renderer.contextReady.then(()=>this._renderer).catch(i=>{if(o!==`webgpu`)throw Error(`Failed to create canvas.`);return t.FES.log`${i.message} Falling back to WebGL renderer.`(),this.createCanvas(n,r,h,...a)}):this._renderer},n.resizeCanvas=function(t,n,r){this._renderer&&(this._renderer.resize(t,n),r||this.redraw()),this._addAccsOutput()&&this._updateAccsOutput()},n.noCanvas=function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)},n.createGraphics=function(n,r,...i){return i[0]instanceof HTMLCanvasElement&&(i[1]=i[0],i[0]=`p2d`),new t.Graphics(n,r,i[0],this,i[1])},n.createFramebuffer=function(t){return new Vs(this._renderer,t)},n.clearDepth=function(t){this._assert3d(`clearDepth`),this._renderer.clearDepth(t)}}typeof p5<`u`&&Ws(p5,p5.prototype);var Gs=`precision highp float;

uniform sampler2D tex0;
uniform vec2 canvasSize;
uniform vec2 texelSize;

IN vec2 vTexCoord;

struct FilterInputs {
  vec2 texCoord;
  vec2 canvasSize;
  vec2 texelSize;
};

void main(void) {
  FilterInputs inputs;
  inputs.texCoord = vTexCoord;
  inputs.canvasSize = canvasSize;
  inputs.texelSize = texelSize;
  OUT_COLOR = HOOK_getColor(inputs, tex0);
  OUT_COLOR.rgb *= outColor.a;
}
`,Ks=`precision highp int;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;

IN vec3 aPosition;
IN vec2 aTexCoord;
OUT vec2 vTexCoord;

void main() {
  // transferring texcoords for the frag shader
  vTexCoord = aTexCoord;

  // copy position with a fourth coordinate for projection (1.0 is normal)
  vec4 positionVec4 = vec4(aPosition, 1.0);

  // project to 3D space
  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;
}
`,qs=`#ifdef WEBGL2

#define IN in
#define OUT out

#ifdef FRAGMENT_SHADER
out vec4 outColor;
#define OUT_COLOR outColor
#endif
#define TEXTURE texture

#else

#ifdef FRAGMENT_SHADER
#define IN varying
#else
#define IN attribute
#endif
#define OUT varying
#define TEXTURE texture2D

#ifdef FRAGMENT_SHADER
#define OUT_COLOR gl_FragColor
#endif

#endif

vec4 getTexture(in sampler2D content, vec2 coord) {
  vec4 color = TEXTURE(content, coord);
  if (color.a > 0.) color.rgb /= color.a;
  return color;
}
`,Js=`// Based on https://github.com/stegu/webgl-noise/blob/22434e04d7753f7e949e8d724ab3da2864c17a0f/src/noise3D.glsl
// MIT licensed, adapted for p5.strands

vec3 mod289(vec3 x) {
  return x - floor(x * (1.0 / 289.0)) * 289.0;
}

vec4 mod289(vec4 x) {
  return x - floor(x * (1.0 / 289.0)) * 289.0;
}

vec4 permute(vec4 x) {
  return mod289(((x*34.0)+10.0)*x);
}

vec4 taylorInvSqrt(vec4 r)
{
  return 1.79284291400159 - 0.85373472095314 * r;
}

float baseNoise(vec3 v)
{
  const vec2  C = vec2(1.0/6.0, 1.0/3.0) ;
  const vec4  D = vec4(0.0, 0.5, 1.0, 2.0);

  // First corner
  vec3 i  = floor(v + dot(v, C.yyy) );
  vec3 x0 =   v - i + dot(i, C.xxx) ;

  // Other corners
  vec3 g = step(x0.yzx, x0.xyz);
  vec3 l = 1.0 - g;
  vec3 i1 = min( g.xyz, l.zxy );
  vec3 i2 = max( g.xyz, l.zxy );

  //   x0 = x0 - 0.0 + 0.0 * C.xxx;
  //   x1 = x0 - i1  + 1.0 * C.xxx;
  //   x2 = x0 - i2  + 2.0 * C.xxx;
  //   x3 = x0 - 1.0 + 3.0 * C.xxx;
  vec3 x1 = x0 - i1 + C.xxx;
  vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
  vec3 x3 = x0 - D.yyy;      // -1.0+3.0*C.x = -0.5 = -D.y

  // Permutations
  i = mod289(i);
  vec4 p = permute( permute( permute(
          i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
        + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
      + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));

  // Gradients: 7x7 points over a square, mapped onto an octahedron.
  // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
  float n_ = 0.142857142857; // 1.0/7.0
  vec3  ns = n_ * D.wyz - D.xzx;

  vec4 j = p - 49.0 * floor(p * ns.z * ns.z);  //  mod(p,7*7)

  vec4 x_ = floor(j * ns.z);
  vec4 y_ = floor(j - 7.0 * x_ );    // mod(j,N)

  vec4 x = x_ *ns.x + ns.yyyy;
  vec4 y = y_ *ns.x + ns.yyyy;
  vec4 h = 1.0 - abs(x) - abs(y);

  vec4 b0 = vec4( x.xy, y.xy );
  vec4 b1 = vec4( x.zw, y.zw );

  //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
  //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
  vec4 s0 = floor(b0)*2.0 + 1.0;
  vec4 s1 = floor(b1)*2.0 + 1.0;
  vec4 sh = -step(h, vec4(0.0));

  vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
  vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;

  vec3 p0 = vec3(a0.xy,h.x);
  vec3 p1 = vec3(a0.zw,h.y);
  vec3 p2 = vec3(a1.xy,h.z);
  vec3 p3 = vec3(a1.zw,h.w);

  //Normalise gradients
  vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
  p0 *= norm.x;
  p1 *= norm.y;
  p2 *= norm.z;
  p3 *= norm.w;

  // Mix final noise value
  vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
  m = m * m;
  return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
        dot(p2,x2), dot(p3,x3) ) );
}

float noise(vec3 st, int octaves, float ampFalloff) {
  float result = 0.0;
  float amplitude = 1.0;
  float frequency = 1.0;

  for (int i = 0; i < 8; i++) {
    if (i >= octaves) break;
    result += amplitude * baseNoise(st * frequency);
    frequency *= 2.0;
    amplitude *= ampFalloff;
  }
  return (result + 1.0) * 0.5;
}
`,Ys=`// _p5_hash: "Hash without Sine" by Dave Hoskins (https://www.shadertoy.com/view/4djSRW)
// Mixing constants: R₂ sequence by Martin Roberts (https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/)
//   α₁ = 1/φ₂ = 0.7548776662 (plastic constant reciprocal)
//   α₂ = 1/φ₂² = 0.5698402910
//   1/φ = 0.6180339887 (golden ratio conjugate)

int _p5_randomCallIndex = 0;

float _p5_hash(vec3 p) {
  p = fract(p * vec3(0.1031, 0.1030, 0.0973));
  p += dot(p, p.yxz + 33.33);
  return fract((p.x + p.y) * p.z);
}

float random(float seed) {
  vec2 pixelCoord = gl_FragCoord.xy;
  float callIndex = float(_p5_randomCallIndex);
  _p5_randomCallIndex += 1;
  // fract(seed * α₁) normalizes large seeds (e.g. performance.now()) into [0,1)
  // and spreads them optimally via the R₂ sequence's plastic constant
  float s = fract(seed * 0.7548776662);
  return _p5_hash(vec3(
    pixelCoord.x + s,
    pixelCoord.y + callIndex * 0.5698402910,
    s + callIndex * 0.6180339887
  ));
}
`,Xs=`// _p5_hash: "Hash without Sine" by Dave Hoskins (https://www.shadertoy.com/view/4djSRW)
// Mixing constants: R₂ sequence by Martin Roberts (https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/)
//   α₁ = 1/φ₂ = 0.7548776662 (plastic constant reciprocal)
//   α₂ = 1/φ₂² = 0.5698402910
//   1/φ = 0.6180339887 (golden ratio conjugate)

int _p5_randomCallIndex = 0;

float _p5_hash(vec3 p) {
  p = fract(p * vec3(0.1031, 0.1030, 0.0973));
  p += dot(p, p.yxz + 33.33);
  return fract((p.x + p.y) * p.z);
}

float random(float seed) {
  float vid = float(gl_VertexID);
  float callIndex = float(_p5_randomCallIndex);
  _p5_randomCallIndex += 1;
  float s = fract(seed * 0.7548776662);
  return _p5_hash(vec3(
    vid + s,
    vid * 0.5698402910 + callIndex * 0.6180339887,
    s + callIndex * 0.7548776662
  ));
}
`;const B={OPERATION:`operation`,LITERAL:`literal`,VARIABLE:`variable`,CONSTANT:`constant`,STRUCT:`struct`,PHI:`phi`,STATEMENT:`statement`,ASSIGNMENT:`assignment`},Zs=`_p5_instanceID`,Qs=`_p5_param_`,$s=Object.fromEntries(Object.entries(B).map(([t,n])=>[n,t])),ec={[B.OPERATION]:[`opCode`,`dependsOn`,`dimension`,`baseType`],[B.LITERAL]:[`value`,`dimension`,`baseType`],[B.VARIABLE]:[`identifier`,`dimension`,`baseType`],[B.CONSTANT]:[`value`,`dimension`,`baseType`],[B.STRUCT]:[``],[B.PHI]:[`dependsOn`,`phiBlocks`,`dimension`,`baseType`],[B.STATEMENT]:[`statementType`],[B.ASSIGNMENT]:[`dependsOn`]},tc={DISCARD:`discard`,BREAK:`break`,EARLY_RETURN:`early_return`,EXPRESSION:`expression`,EMPTY:`empty`},V={FLOAT:`float`,INT:`int`,BOOL:`bool`,MAT:`mat`,DEFER:`defer`,ASSIGN_ON_USE:`assign_on_use`,SAMPLER2D:`sampler2D`,SAMPLER:`sampler`},nc={[V.FLOAT]:3,[V.INT]:2,[V.BOOL]:1,[V.MAT]:0,[V.DEFER]:-1,[V.ASSIGN_ON_USE]:-2,[V.SAMPLER2D]:-10,[V.SAMPLER]:-11},H={float1:{fnName:`float`,baseType:V.FLOAT,dimension:1,priority:3},float2:{fnName:`vec2`,baseType:V.FLOAT,dimension:2,priority:3},float3:{fnName:`vec3`,baseType:V.FLOAT,dimension:3,priority:3},float4:{fnName:`vec4`,baseType:V.FLOAT,dimension:4,priority:3},int1:{fnName:`int`,baseType:V.INT,dimension:1,priority:2},int2:{fnName:`ivec2`,baseType:V.INT,dimension:2,priority:2},int3:{fnName:`ivec3`,baseType:V.INT,dimension:3,priority:2},int4:{fnName:`ivec4`,baseType:V.INT,dimension:4,priority:2},bool1:{fnName:`bool`,baseType:V.BOOL,dimension:1,priority:1},bool2:{fnName:`bvec2`,baseType:V.BOOL,dimension:2,priority:1},bool3:{fnName:`bvec3`,baseType:V.BOOL,dimension:3,priority:1},bool4:{fnName:`bvec4`,baseType:V.BOOL,dimension:4,priority:1},mat2:{fnName:`mat2x2`,baseType:V.MAT,dimension:2,priority:0},mat3:{fnName:`mat3x3`,baseType:V.MAT,dimension:3,priority:0},mat4:{fnName:`mat4x4`,baseType:V.MAT,dimension:4,priority:0},defer:{fnName:null,baseType:V.DEFER,dimension:null,priority:-1},assign_on_use:{fnName:null,baseType:V.ASSIGN_ON_USE,dimension:null,priority:-2},sampler2D:{fnName:`sampler2D`,baseType:V.SAMPLER2D,dimension:1,priority:-10},sampler:{fnName:`sampler`,baseType:V.SAMPLER,dimension:1,priority:-11}},rc=function(t){let n=t.type===void 0?t:t.type,r={name:t.name,properties:[],typeName:n.typeName};for(let t of n.properties){let n=t.type.dataType;r.properties.push({name:t.name,dataType:n})}return r};function ic(t){return!!(t&&t.properties)}const U={FLOAT:{baseType:V.FLOAT,dimension:null,priority:3},INT:{baseType:V.INT,dimension:null,priority:2},BOOL:{baseType:V.BOOL,dimension:null,priority:1}};function ac(t,n){return t.dimension===n.dimension&&t.baseType===n.baseType}const oc=Object.fromEntries(Object.values(H).filter(t=>t.fnName!==null).map(t=>[t.fnName,t])),W={Binary:{ADD:0,SUBTRACT:1,MULTIPLY:2,DIVIDE:3,MODULO:4,EQUAL:5,NOT_EQUAL:6,GREATER_THAN:7,GREATER_EQUAL:8,LESS_THAN:9,LESS_EQUAL:10,LOGICAL_AND:11,LOGICAL_OR:12,MEMBER_ACCESS:13,ARRAY_ACCESS:14},Unary:{LOGICAL_NOT:100,NEGATE:101,PLUS:102,SWIZZLE:103,SNAPSHOT:104},Nary:{FUNCTION_CALL:200,CONSTRUCTOR:201,TERNARY:202,ARRAY_ASSIGNMENT:203},ControlFlow:{RETURN:300,JUMP:301,BRANCH_IF_FALSE:302,DISCARD:303,BREAK:304}},sc=[{arity:`unary`,boolean:!0,name:`not`,symbol:`!`,opCode:W.Unary.LOGICAL_NOT},{arity:`unary`,name:`neg`,symbol:`-`,opCode:W.Unary.NEGATE},{arity:`unary`,name:`plus`,symbol:`+`,opCode:W.Unary.PLUS},{arity:`binary`,name:`add`,symbol:`+`,opCode:W.Binary.ADD},{arity:`binary`,name:`sub`,symbol:`-`,opCode:W.Binary.SUBTRACT},{arity:`binary`,name:`mult`,symbol:`*`,opCode:W.Binary.MULTIPLY},{arity:`binary`,name:`div`,symbol:`/`,opCode:W.Binary.DIVIDE},{arity:`binary`,name:`mod`,symbol:`%`,opCode:W.Binary.MODULO},{arity:`binary`,boolean:!0,name:`equalTo`,symbol:`==`,opCode:W.Binary.EQUAL},{arity:`binary`,boolean:!0,name:`notEqual`,symbol:`!=`,opCode:W.Binary.NOT_EQUAL},{arity:`binary`,boolean:!0,name:`greaterThan`,symbol:`>`,opCode:W.Binary.GREATER_THAN},{arity:`binary`,boolean:!0,name:`greaterEqual`,symbol:`>=`,opCode:W.Binary.GREATER_EQUAL},{arity:`binary`,boolean:!0,name:`lessThan`,symbol:`<`,opCode:W.Binary.LESS_THAN},{arity:`binary`,boolean:!0,name:`lessEqual`,symbol:`<=`,opCode:W.Binary.LESS_EQUAL},{arity:`binary`,boolean:!0,name:`and`,symbol:`&&`,opCode:W.Binary.LOGICAL_AND},{arity:`binary`,boolean:!0,name:`or`,symbol:`||`,opCode:W.Binary.LOGICAL_OR}];W.Binary.ADD,W.Binary.SUBTRACT,W.Binary.MULTIPLY,W.Binary.DIVIDE,W.Binary.MODULO,W.Binary.EQUAL,W.Binary.NOT_EQUAL,W.Binary.GREATER_THAN,W.Binary.GREATER_EQUAL,W.Binary.LESS_THAN,W.Binary.LESS_EQUAL,W.Binary.LOGICAL_AND,W.Binary.LOGICAL_OR;const cc={},lc={},uc={},dc={};for(let{symbol:t,opCode:n,name:r,arity:i,boolean:a}of sc)cc[n]=t,i===`unary`&&(lc[t]=r),i===`binary`&&(uc[t]=r),a&&(dc[n]=!0);const fc={GLOBAL:`global`,FUNCTION:`function`,BRANCH:`branch`,IF_COND:`if_cond`,IF_BODY:`if_body`,ELSE_COND:`else_cond`,SCOPE_START:`scope_start`,SCOPE_END:`scope_end`,FOR:`for`,MERGE:`merge`,DEFAULT:`default`};Object.fromEntries(Object.entries(fc).map(([t,n])=>[n,t]));function pc(t){let n=`[p5.strands internal error]: ${t}`;throw Error(n)}function G(t,n){let r=`[p5.strands ${t}]: ${n}`;throw Error(r)}function mc(t,n,r){G(`dimension mismatch`,`Cannot assign a value of dimension ${n} to \`${r}\`, which expects dimension ${t}.`)}function hc(){return{nextID:0,cache:/* @__PURE__ */ new Map,nodeTypes:[],baseTypes:[],dimensions:[],opCodes:[],values:[],identifiers:[],phiBlocks:[],dependsOn:[],usedBy:[],statementTypes:[],swizzles:[]}}function K(t,n){return bc(t,n)}function gc(t={}){let n={nodeType:t.nodeType??null,baseType:t.baseType??null,dimension:t.dimension??null,opCode:t.opCode??null,value:t.value??null,identifier:t.identifier??null,statementType:t.statementType??null,swizzle:t.swizzle??null,dependsOn:Array.isArray(t.dependsOn)?t.dependsOn:[],usedBy:Array.isArray(t.usedBy)?t.usedBy:[],phiBlocks:Array.isArray(t.phiBlocks)?t.phiBlocks:[]};return xc(n),n}function _c(t,n){return{id:n,nodeType:t.nodeTypes[n],opCode:t.opCodes[n],value:t.values[n],identifier:t.identifiers[n],dependsOn:t.dependsOn[n],usedBy:t.usedBy[n],phiBlocks:t.phiBlocks[n],dimension:t.dimensions[n],baseType:t.baseTypes[n],statementType:t.statementTypes[n],swizzle:t.swizzles[n]}}function vc(t,n){return{baseType:t.baseTypes[n],dimension:t.dimensions[n],priority:nc[t.baseTypes[n]]}}function yc(t,n,r,i,a=/* @__PURE__ */ new Set){if(a.has(n))return;a.add(n);let o=_c(t,n);if(o.baseType===V.ASSIGN_ON_USE){if(t.baseTypes[n]=r,t.dimensions[n]=i,o.dependsOn&&o.dependsOn.length>0)for(let n of o.dependsOn)_c(t,n).baseType===V.ASSIGN_ON_USE&&yc(t,n,r,i,a);for(let n of o.usedBy??[])t.opCodes[n]===W.Unary.SNAPSHOT&&yc(t,n,r,i,a)}}function bc(t,n){let r=t.nextID++;t.nodeTypes[r]=n.nodeType,t.opCodes[r]=n.opCode,t.values[r]=n.value,t.identifiers[r]=n.identifier,t.dependsOn[r]=n.dependsOn.slice(),t.usedBy[r]=n.usedBy,t.phiBlocks[r]=n.phiBlocks.slice(),t.baseTypes[r]=n.baseType,t.dimensions[r]=n.dimension,t.statementTypes[r]=n.statementType,t.swizzles[r]=n.swizzle;for(let i of n.dependsOn)Array.isArray(t.usedBy[i])||(t.usedBy[i]=[]),t.usedBy[i].push(r);return r}function xc(t){let n=t.nodeType,r=ec[n];r.length===2&&pc(`Required fields for node type '${$s[n]}' not defined. Please add them to the utils.js file in p5.strands!`);let i=[];for(let n of r)t[n]===null&&i.push(n);if(t.dependsOn?.some(t=>t===void 0))throw Error(`Undefined dependency!`);i.length>0&&pc(`Missing fields ${i.join(`, `)} for a node type '${$s[n]}'.`)}function Sc(){return{blockTypes:[],incomingEdges:[],outgoingEdges:[],blockInstructions:[],nextID:0,blockStack:[],blockOrder:[],blockConditions:{},currentBlock:-1}}function Cc(t,n){t.blockStack.push(n),t.blockOrder.push(n),t.currentBlock=n}function wc(t){t.blockStack.pop();let n=t.blockStack.length;t.currentBlock=t.blockStack[n-1]}function Tc(t,n){t.blockStack.push(n),t.currentBlock=n}function Ec(t,n){let r=t.nextID++;return t.blockTypes[r]=n,t.incomingEdges[r]=[],t.outgoingEdges[r]=[],t.blockInstructions[r]=[],r}function Dc(t,n,r){t.outgoingEdges[n].push(r),t.incomingEdges[r].push(n)}function Oc(t,n,r){r===void 0&&pc("undefined nodeID in `recordInBasicBlock()`"),n===void 0&&pc("undefined blockID in `recordInBasicBlock()"),t.blockInstructions[n]=t.blockInstructions[n]||[],t.blockInstructions[n].push(r)}function kc(t,n){let r=/* @__PURE__ */ new Set,i=[];function a(n){if(!r.has(n)){r.add(n);for(let r of t[n].sort((t,n)=>n-t)||[])a(r);i.push(n)}}return a(n),i.reverse()}var Ac=class{constructor(t,n,r){this.id=t,this.strandsContext=r,this.dimension=n,this.structProperties=null,this._schema=null,this.isStrandsNode=!0;let i=this.strandsContext.dag,a=_c(i,this.id);a&&a.identifier&&(this._originalIdentifier=a.identifier),a&&(this._originalBaseType=a.baseType,this._originalDimension=a.dimension)}withStructProperties(t){return this.structProperties=t,this}copy(){return q(this.id,this.dimension,this.strandsContext)}typeInfo(){return{baseType:this._originalBaseType||V.FLOAT,dimension:this.dimension}}bridge(t){let{dag:n,cfg:r}=this.strandsContext,i=_c(n,this.id)?.baseType??V.FLOAT,a;if(a=t?.isStrandsNode?t.id:qc(this.strandsContext,{baseType:i,dimension:this.dimension},t).id,this._originalIdentifier){let i=t?.isStrandsNode?t.dimension:Array.isArray(t)?t.length:1;i!==this._originalDimension&&i!==1&&mc(this._originalDimension,i,this._originalIdentifier);let{id:o}=Nc(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),s=K(n,gc({nodeType:B.ASSIGNMENT,dependsOn:[o,a],phiBlocks:[]}));Oc(r,r.currentBlock,s);let c=K(n,gc({nodeType:B.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=c}else this.id=a;return this}bridgeSwizzle(t,n){let{dag:r,cfg:i}=this.strandsContext,a=_c(r,this.id)?.baseType??V.FLOAT,o;if(o=n?.isStrandsNode?n.id:qc(this.strandsContext,{baseType:a,dimension:this.dimension},n).id,this._originalIdentifier){let a=n?.isStrandsNode?n.dimension:Array.isArray(n)?n.length:1;a!==t.length&&a!==1&&mc(t.length,a,`${this._originalIdentifier}.${t}`);let{id:s}=Nc(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),c=K(r,gc({nodeType:B.OPERATION,opCode:W.Unary.SWIZZLE,baseType:this._originalBaseType,dimension:t.length,swizzle:t,dependsOn:[s]})),l=K(r,gc({nodeType:B.ASSIGNMENT,dependsOn:[c,o],phiBlocks:[]}));Oc(i,i.currentBlock,l);let u=K(r,gc({nodeType:B.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=u}else this.id=o;return this}getValue(){if(this._originalIdentifier){let{id:t,dimension:n}=Nc(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier);return q(t,n,this.strandsContext)}return this}get(t){if(_c(this.strandsContext.dag,this.id).baseType===`storage`&&this._schema)return tl(this.strandsContext,this,t,this._schema);let{id:n,dimension:r}=el(this.strandsContext,this,t,`read`);return q(n,r,this.strandsContext)}set(t,n){if(_c(this.strandsContext.dag,this.id).baseType!==`storage`)throw Error(`set() can only be used on storage buffers`);if(!this._originalIdentifier)throw Error(`set() can only be used on storage buffers with an identifier`);if(typeof n==`object`&&n&&!n.isStrandsNode&&this._schema){let r=tl(this.strandsContext,this,t,this._schema);for(let[t,i]of Object.entries(n))r[t]=i;return this}return nl(this.strandsContext,this,t,n),this}};function q(t,n,r,i){return new Proxy(new Ac(t,n,r),$c(t,n,r,i))}const jc={acos:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],acosh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],asin:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],asinh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],atan:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0},{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],atanh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],cos:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],cosh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],degrees:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],radians:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],sin:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],sinh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],tan:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],tanh:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],abs:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0},{params:[U.FLOAT],returnType:U.INT,isp5Function:!0}],ceil:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],clamp:[{params:[U.FLOAT,U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1},{params:[U.FLOAT,H.float1,H.float1],returnType:U.FLOAT,isp5Function:!1},{params:[U.INT,U.INT,U.INT],returnType:U.INT,isp5Function:!1},{params:[U.INT,H.int1,H.int1],returnType:U.INT,isp5Function:!1}],dFdx:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],dFdy:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],exp:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],exp2:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],floor:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],fma:[{params:[U.FLOAT,U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],fract:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],fwidth:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],inversesqrt:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],log:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],log2:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],max:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!0},{params:[U.FLOAT,H.float1],returnType:U.FLOAT,isp5Function:!0},{params:[U.INT,U.INT],returnType:U.INT,isp5Function:!0},{params:[U.INT,H.int1],returnType:U.INT,isp5Function:!0}],min:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!0},{params:[U.FLOAT,H.float1],returnType:U.FLOAT,isp5Function:!0},{params:[U.INT,U.INT],returnType:U.INT,isp5Function:!0},{params:[U.INT,H.int1],returnType:U.INT,isp5Function:!0}],mix:[{params:[U.FLOAT,U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1},{params:[U.FLOAT,U.FLOAT,H.float1],returnType:U.FLOAT,isp5Function:!1},{params:[U.FLOAT,U.FLOAT,U.BOOL],returnType:U.FLOAT,isp5Function:!1}],mod:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!0},{params:[U.FLOAT,H.float1],returnType:U.FLOAT,isp5Function:!0}],pow:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],round:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],roundEven:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],sign:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1},{params:[U.INT],returnType:U.INT,isp5Function:!1}],smoothstep:[{params:[U.FLOAT,U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1},{params:[H.float1,H.float1,U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],sqrt:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],step:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],trunc:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],cross:[{params:[H.float3,H.float3],returnType:H.float3,isp5Function:!0}],distance:[{params:[U.FLOAT,U.FLOAT],returnType:H.float1,isp5Function:!0}],dot:[{params:[U.FLOAT,U.FLOAT],returnType:H.float1,isp5Function:!0}],equal:[{params:[U.FLOAT,U.FLOAT],returnType:U.BOOL,isp5Function:!1},{params:[U.INT,U.INT],returnType:U.BOOL,isp5Function:!1},{params:[U.BOOL,U.BOOL],returnType:U.BOOL,isp5Function:!1}],faceforward:[{params:[U.FLOAT,U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],length:[{params:[U.FLOAT],returnType:H.float1,isp5Function:!1}],normalize:[{params:[U.FLOAT],returnType:U.FLOAT,isp5Function:!0}],notEqual:[{params:[U.FLOAT,U.FLOAT],returnType:U.BOOL,isp5Function:!1},{params:[U.INT,U.INT],returnType:U.BOOL,isp5Function:!1},{params:[U.BOOL,U.BOOL],returnType:U.BOOL,isp5Function:!1}],reflect:[{params:[U.FLOAT,U.FLOAT],returnType:U.FLOAT,isp5Function:!1}],refract:[{params:[U.FLOAT,U.FLOAT,H.float1],returnType:U.FLOAT,isp5Function:!1}],inverse:[{params:[H.mat2],returnType:H.mat2,isp5Function:!1},{params:[H.mat3],returnType:H.mat3,isp5Function:!1},{params:[H.mat4],returnType:H.mat4,isp5Function:!1}],transpose:[{params:[H.mat2],returnType:H.mat2,isp5Function:!1},{params:[H.mat3],returnType:H.mat3,isp5Function:!1},{params:[H.mat4],returnType:H.mat4,isp5Function:!1}]};function Mc(t,n,r){let{cfg:i,dag:a}=t,{dimension:o,baseType:s}=n;o!==1&&pc(`Created a scalar literal node with dimension > 1.`);let c=K(a,gc({nodeType:B.LITERAL,dimension:o,baseType:s,value:r}));return Oc(i,i.currentBlock,c),{id:c,dimension:o}}function Nc(t,n,r){let{cfg:i,dag:a}=t,{dimension:o,baseType:s}=n,c=K(a,gc({nodeType:B.VARIABLE,dimension:o,baseType:s,identifier:r}));return Oc(i,i.currentBlock,c),{id:c,dimension:o}}function Pc(t,n,r){let{dag:i,cfg:a}=t,o,s;if(n?.isStrandsNode)s=n;else{let{id:r,dimension:i}=qc(t,{baseType:V.FLOAT,dimension:null},n);s=q(r,i,t)}o=[s.id];let c={baseType:i.baseTypes[s.id],dimension:s.dimension};dc[r]&&(c.baseType=V.BOOL,c.dimension=1);let l=K(i,gc({nodeType:B.OPERATION,opCode:r,dependsOn:o,baseType:c.baseType,dimension:c.dimension}));return Oc(a,a.currentBlock,l),{id:l,dimension:s.dimension}}function Fc(t,n){let{dag:r,cfg:i}=t,{baseType:a,dimension:o}=vc(r,n),s=K(r,gc({nodeType:B.OPERATION,opCode:W.Unary.SNAPSHOT,dependsOn:[n],baseType:a,dimension:o}));return Oc(i,i.currentBlock,s),{id:s,dimension:o}}function Ic(t){return t===W.Binary.ADD||t===W.Binary.SUBTRACT||t===W.Binary.MULTIPLY||t===W.Binary.DIVIDE}function Lc(t,n,r){let i=t.baseType===V.MAT,a=n.baseType===V.MAT,o=i?t:n,s=!i&&t.dimension>1,c=!a&&n.dimension>1;if(r===W.Binary.MULTIPLY){if(i&&a)return t.dimension!==n.dimension&&G(`type error`,`You can only multiply two matrices of the same size, but got mat${t.dimension} * mat${n.dimension}.`),{baseType:V.MAT,dimension:o.dimension};if(i&&c||a&&s){let r=i?n:t;return r.dimension!==o.dimension&&G(`type error`,`A mat${o.dimension} can only be multiplied with a vector of length ${o.dimension}, but got a vector of length ${r.dimension}.`),{baseType:V.FLOAT,dimension:o.dimension}}return{baseType:V.MAT,dimension:o.dimension}}if(i&&a)return t.dimension!==n.dimension&&G(`type error`,`You can only combine two matrices of the same size, but got mat${t.dimension} ${cc[r]} mat${n.dimension}.`),{baseType:V.MAT,dimension:o.dimension};if(i&&!c||a&&!s)return{baseType:V.MAT,dimension:o.dimension};G(`type error`,`A matrix can't be combined with a vector using '${cc[r]}'. Use matrix multiplication (*) to transform a vector by a matrix.`)}function Rc(t,n,r,i){let{dag:a,cfg:o}=t,s;if(r[0]instanceof Ac&&r.length===1)s=r[0];else{let{id:n,dimension:i}=qc(t,{baseType:V.FLOAT,dimension:null},r);s=q(n,i,t)}let c=n.id,l=s.id,u=vc(a,n.id),d=vc(a,s.id);if(u.baseType===V.ASSIGN_ON_USE&&d.baseType!==V.ASSIGN_ON_USE?(yc(a,n.id,d.baseType,d.dimension),u=vc(a,n.id)):d.baseType===V.ASSIGN_ON_USE&&u.baseType!==V.ASSIGN_ON_USE&&(yc(a,s.id,u.baseType,u.dimension),d=vc(a,s.id)),(u.baseType===V.MAT||d.baseType===V.MAT)&&Ic(i)){let t=Lc(u,d,i),n=gc({nodeType:B.OPERATION,opCode:i,dependsOn:[c,l],baseType:t.baseType,dimension:t.dimension}),r=K(a,n);return Oc(o,o.currentBlock,r),{id:r,dimension:n.dimension}}let f={...u},p={...d},m={node:null,toType:u};if(u.baseType===d.baseType&&u.baseType===V.DEFER){m.toType.baseType=V.FLOAT,u.dimension===d.dimension?m.toType.dimension=u.dimension:u.dimension===1&&d.dimension>1?m.toType.dimension=d.dimension:d.dimension===1&&u.dimension>1?m.toType.dimension=u.dimension:G(`type error`,`You have tried to perform a binary operation:\n${u.baseType+u.dimension} ${cc[i]} ${d.baseType+d.dimension}\nIt's only possible to operate on two nodes with the same dimension, or a scalar value and a vector.`);let r=qc(t,m.toType,n),a=qc(t,m.toType,s);c=r.id,l=a.id}else if(u.baseType!==d.baseType||u.dimension!==d.dimension){u.dimension===1&&d.dimension>1?(m.node=n,m.toType=d):d.dimension===1&&u.dimension>1||u.priority>d.priority?(m.node=s,m.toType=u):d.priority>u.priority?(m.node=n,m.toType=d):G(`type error`,`A vector of length ${u.dimension} operated with a vector of length ${d.dimension} is not allowed.`);let r=qc(t,m.toType,m.node);m.node===n?(n=q(r.id,r.dimension,t),c=n.id):(s=q(r.id,r.dimension,t),l=s.id)}let h=a.dimensions[c],g=a.dimensions[l],_=a.baseTypes[c],v=a.baseTypes[l],y=f.baseType===V.DEFER?_:f.baseType,b=f.baseType===V.DEFER?h:f.dimension,x=p.baseType===V.DEFER?v:p.baseType,S=p.baseType===V.DEFER?g:p.dimension,C=[W.Binary.LESS_THAN,W.Binary.LESS_EQUAL,W.Binary.GREATER_THAN,W.Binary.GREATER_EQUAL].includes(i),w=i===W.Binary.EQUAL||i===W.Binary.NOT_EQUAL,T=i===W.Binary.LOGICAL_AND||i===W.Binary.LOGICAL_OR;C?h>1||g>1?G(`type error`,`${cc[i]} is only defined for scalars. Got ${y}${b} ${cc[i]} ${x}${S}.`):(_===V.BOOL||v===V.BOOL)&&G(`type error`,`${cc[i]} is not defined for boolean values. Got ${y}${b} ${cc[i]} ${x}${S}.`):w?(h>1||g>1)&&(h!==g||_!==v)?G(`type error`,`Equality comparisons between vectors require matching dimensions and base types. Got ${y}${b} ${cc[i]} ${x}${S}.`):_===V.BOOL!=(v===V.BOOL)&&G(`type error`,`Equality comparisons between boolean and numeric types are not allowed. Got ${y}${b} ${cc[i]} ${x}${S}.`):T&&(_!==V.BOOL||v!==V.BOOL||h!==1||g!==1)&&G(`type error`,`${cc[i]} requires two bool scalars. Got ${y}${b} ${cc[i]} ${x}${S}.`),dc[i]&&(m.toType.baseType=V.BOOL,m.toType.dimension=1);let E=gc({nodeType:B.OPERATION,opCode:i,dependsOn:[c,l],baseType:m.toType.baseType,dimension:m.toType.dimension}),D=K(a,E);return Oc(o,o.currentBlock,D),{id:D,dimension:E.dimension}}function zc(t,n,r,i){let{cfg:a,dag:o}=t;if(i.length===0)for(let t of n.properties){let n=t.dataType,s=K(o,gc({nodeType:B.VARIABLE,baseType:n.baseType,dimension:n.dimension,identifier:`${r}.${t.name}`}));Oc(a,a.currentBlock,s),i.push(s)}let s=K(o,gc({nodeType:B.VARIABLE,dimension:n.properties.length,baseType:n.typeName,identifier:r,dependsOn:i}));return Oc(a,a.currentBlock,s),{id:s,dimension:0,components:i}}function Bc(t,n,r){let i=Array.isArray(r)?r:[r],a=[],{dimension:o,baseType:s}=n,c=t.dag,l=0,u=null;for(let n of i.flat(1/0))if(n&&n.isStrandsNode){let t=_c(c,n.id);if(u=n.id,s=t.baseType,t.opCode===W.Nary.CONSTRUCTOR)for(let n of t.dependsOn)a.push(n);else a.push(n.id);l+=t.dimension;continue}else if(typeof n==`number`){let{id:r,dimension:i}=Mc(t,{dimension:1,baseType:s},n);a.push(r),l+=i;continue}else if(typeof n==`boolean`){let{id:r,dimension:i}=Mc(t,{dimension:1,baseType:V.BOOL},n);a.push(r),l+=i,s!==V.BOOL&&(s=V.BOOL);continue}else G(`type error`,`You've tried to construct a scalar or vector type with a non-numeric value: ${n}`);o===null?o=l:o>l&&l===1?l=o:l!==1&&l!==o&&G(`type error`,`You've tried to construct a ${s+o} with ${l} components`);let d={dimension:o,baseType:s,priority:nc[s]};return{originalNodeID:u,mappedDependencies:a,inferredTypeInfo:d}}function Vc(t,n,r){let i=gc({nodeType:B.OPERATION,opCode:W.Nary.CONSTRUCTOR,dimension:n.dimension,baseType:n.baseType,dependsOn:r});return K(t.dag,i)}function Hc(t,n,r){let{cfg:i}=t,a=r.map(n=>{if(n?.isStrandsNode)return n.id;let{id:r}=Mc(t,{dimension:1,baseType:V.FLOAT},n);return r}),o=Vc(t,{baseType:V.MAT,dimension:n},a);return Oc(i,i.currentBlock,o),{id:o,dimension:n}}function Uc(t,n,r){let i=[];for(let t=0;t<n;t++)for(let a=0;a<n;a++)i.push(a===t?r:0);return Hc(t,n,i)}function Wc(t,n){return Uc(t,n,1)}function Gc(t,n,r,i){let{dag:a,cfg:o}=t,s=i=>{let{id:s}=Mc(t,{dimension:1,baseType:V.INT},i),c=gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s],dimension:r,baseType:V.FLOAT}),l=K(a,c);return Oc(o,o.currentBlock,l),q(l,r,t)},c=[];for(let n=0;n<i;n++)if(n<r&&i<r){let{id:r,dimension:a}=Qc(t,s(n),`xyzw`.slice(0,i));c.push(q(r,a,t))}else if(n<r){let a=Array(i-r).fill(0),{id:o,dimension:l}=qc(t,{baseType:V.FLOAT,dimension:i},[s(n),...a]);c.push(q(o,l,t))}else{let r=Array.from({length:i},(t,r)=>+(r===n)),{id:a,dimension:o}=qc(t,{baseType:V.FLOAT,dimension:i},r);c.push(q(a,o,t))}return Hc(t,i,c)}function Kc(t,n,r){let i=t.dag,a=n*n,o=t=>vc(i,t.id).baseType;if(r.length===0)return Wc(t,n);if(r.length===1){let i=r[0],a=!!i?.isStrandsNode;if(a&&o(i)===V.MAT&&i.dimension===n)return{id:i.id,dimension:n};if(a&&o(i)===V.MAT)return Gc(t,i,i.dimension,n);if(typeof i==`number`||a&&i.dimension===1&&o(i)!==V.MAT)return Uc(t,n,i)}if(r.length===n&&r.every(t=>t?.isStrandsNode&&t.dimension===n&&o(t)!==V.MAT)||r.length===a)return Hc(t,n,r);G(`parameter validation`,`A mat${n} constructor expects no arguments (identity), a single number (diagonal), a single mat${n}, ${n} column vectors, or ${a} values — but got ${r.length} argument(s).`)}function qc(t,n,r){let i=t.cfg;r=(Array.isArray(r)?r:[r]).flat(1/0).map(n=>n.isStrandsNode&&n.typeInfo().baseType===V.INT&&n.typeInfo().dimension===1?Jc(t,n):n);let{mappedDependencies:a,inferredTypeInfo:o}=Bc(t,n,r),s={baseType:o.baseType===V.BOOL?V.BOOL:n.baseType,dimension:o.dimension},c=Vc(t,s,a);return n.baseType!==V.DEFER&&Oc(i,i.currentBlock,c),{id:c,dimension:s.dimension,components:a}}function Jc(t,n){let{id:r,dimension:i}=Xc(t,t.backend.getTypeName(`float`,n.typeInfo().dimension),[n],{overloads:[{params:[n.typeInfo()],returnType:{...n.typeInfo(),baseType:V.FLOAT}}]});return q(r,i,t)}function Yc(t,n,r){let{cfg:i,dag:a}=t,{properties:o}=n;r.length!==o.length&&G(`type error`,`You've tried to construct a ${n.typeName} struct with ${r.length} properties, but it expects ${o.length} properties.\nThe properties it expects are:\n${o.map(t=>`${t.name}: ${t.dataType.baseType}${t.dataType.dimension}`).join(`, `)}`);let s=K(a,gc({nodeType:B.OPERATION,opCode:W.Nary.CONSTRUCTOR,dimension:o.length,baseType:n.typeName,dependsOn:r}));return Oc(i,i.currentBlock,s),{id:s,dimension:o.length,components:n.components}}function Xc(t,n,r,{overloads:i}={}){let{cfg:a,dag:o}=t,s=i||jc[n],c=r.map(n=>Bc(t,H.defer,n)),l=s.filter(t=>t.params.length===c.length);if(l.length===0){let t=/* @__PURE__ */ new Set,r=[];s.forEach(n=>t.add(n.params.length)),t.forEach(t=>r.push(`${t}`));let i=r.join(`, or `);G(`parameter validation error`,`Function '${n}' has ${s.length} variants which expect ${i} arguments, but ${c.length} arguments were provided.`)}let u=t=>t.dimension===null,d=null,f=0,p=null,m=null;for(let t of l){let n=!0,r=0;for(let i=0;i<c.length;i++){let a=c[i].inferredTypeInfo,o=t.params[i],s=o.dimension;u(o)?((m===null||m===1)&&(m=a.dimension),m!==a.dimension&&!(a.dimension===1&&m>=1)&&(n=!1),s=m):a.dimension>s&&(n=!1),a.baseType===o.baseType?r+=2:o.priority>a.priority&&(r+=1)}n&&(!d||r>f)&&(d=t,f=r,p={...t.returnType},u(p)&&(p.dimension=m))}d===null&&G(`parameter validation`,`No matching overload for ${n} was found!`);let h=[];for(let n=0;n<d.params.length;n++){let r=c[n],i={...d.params[n]};if(u(i)&&(i.dimension=m),r.originalNodeID&&ac(r.inferredTypeInfo,i))h.push(r.originalNodeID);else{let n=Vc(t,i,r.mappedDependencies);Oc(a,a.currentBlock,n),h.push(n)}}let g=K(o,gc({nodeType:B.OPERATION,opCode:W.Nary.FUNCTION_CALL,identifier:n,dependsOn:h,baseType:p.baseType,dimension:p.dimension}));return Oc(a,a.currentBlock,g),{id:g,dimension:p.dimension}}function Zc(t,n){let{dag:r,cfg:i}=t,a=K(r,gc({nodeType:B.STATEMENT,statementType:n}));return Oc(i,i.currentBlock,a),a}function Qc(t,n,r){let{dag:i,cfg:a}=t,o=i.baseTypes[n.id],s=K(i,gc({nodeType:B.OPERATION,baseType:o,dimension:r.length,opCode:W.Unary.SWIZZLE,dependsOn:[n.id],swizzle:r}));return Oc(a,a.currentBlock,s),{id:s,dimension:r.length}}function $c(t,n,r,i){let a=[[`x`,`y`,`z`,`w`],[`r`,`g`,`b`,`a`],[`s`,`t`,`p`,`q`]].map(t=>t.slice(0,n));return{get(t,n,i){if(n in t)return Reflect.get(...arguments);for(let i of a)if([...n.toString()].every(t=>i.includes(t))){let o=Qc(r,t,[...n].map(t=>{let n=i.indexOf(t);return a[0][n]}).join(``));return q(o.id,o.dimension,r)}},set(t,n,o,s){for(let s of a){let a=[...n];if(!(a.every(t=>s.includes(t))&&new Set(a).size===a.length&&t.dimension>=a.length))continue;let c=t.dimension,l=Array(c);for(let n=0;n<c;n++){let{id:i,dimension:a}=Qc(r,t,`xyzw`[n]);l[n]=q(i,a,r)}let u=[];if(o?.isStrandsNode){if(o.dimension===1)u=Array(a.length).fill(o);else if(o.dimension===a.length)for(let t=0;t<a.length;t++){let{id:n,dimension:i}=Qc(r,o,`xyzw`[t]);u.push(q(n,i,r))}else mc(a.length,o.dimension,`${t._originalIdentifier||`value`}.${n}`)}else if(Array.isArray(o)){let t=o.flat(1/0);t.length===1?u=Array(a.length).fill(t[0]):t.length===a.length?u=t:G(`type error`,`Swizzle assignment: RHS length ${t.length} does not match ${a.length}.`)}else typeof o==`number`?u=Array(a.length).fill(o):G(`type error`,`Unsupported RHS for swizzle assignment: ${o}`);for(let t=0;t<a.length;t++){let n=s.indexOf(a[t]);l[n]=u[t]}let{id:d}=qc(r,{baseType:_c(r.dag,t.id)?.baseType??V.FLOAT,dimension:c},l);return t.id=d,typeof i==`function`&&i(d),!0}return Reflect.set(...arguments)}}}function el(t,n,r,i){let{dag:a,cfg:o}=t,s;if(r instanceof Ac)s=r;else{let{id:n,dimension:i}=qc(t,{baseType:V.INT,dimension:1},r);s=q(n,i,t)}let c=K(a,gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s.id],dimension:1,baseType:V.FLOAT,accessMode:i}));return Oc(o,o.currentBlock,c),{id:c,dimension:1}}function tl(t,n,r,i){let{dag:a,cfg:o}=t,s;if(r instanceof Ac)s=r;else{let{id:n,dimension:i}=qc(t,{baseType:V.INT,dimension:1},r);s=q(n,i,t)}let c={};for(let r of i.fields)Object.defineProperty(c,r.name,{get(){let i=gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s.id],dimension:r.dim,baseType:V.FLOAT,identifier:r.name}),c=K(a,i);return Oc(o,o.currentBlock,c),q(c,r.dim,t,t=>{let i=gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s.id],dimension:r.dim,baseType:V.FLOAT,identifier:r.name}),c=K(a,i),l=gc({nodeType:B.ASSIGNMENT,dependsOn:[c,t],phiBlocks:[]}),u=K(a,l);Oc(o,o.currentBlock,u)})},set(i){let c=gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s.id],dimension:r.dim,baseType:V.FLOAT,identifier:r.name}),l=K(a,c),u;if(i?.isStrandsNode)u=i.id;else{let{id:n}=qc(t,{baseType:V.FLOAT,dimension:r.dim},i);u=n}let d=gc({nodeType:B.ASSIGNMENT,dependsOn:[l,u],phiBlocks:[]}),f=K(a,d);Oc(o,o.currentBlock,f)},configurable:!0});return c}function nl(t,n,r,i){let{dag:a,cfg:o}=t,s;if(r instanceof Ac)s=r;else{let{id:n,dimension:i}=qc(t,{baseType:V.INT,dimension:1},r);s=q(n,i,t)}let c;if(i instanceof Ac)c=i.typeInfo().baseType===V.FLOAT?i:Jc(t,i);else{let{id:n,dimension:r}=qc(t,{baseType:V.FLOAT,dimension:1},i);c=q(n,r,t)}let l=K(a,gc({nodeType:B.OPERATION,opCode:W.Binary.ARRAY_ACCESS,dependsOn:[n.id,s.id],dimension:1,baseType:V.FLOAT})),u=K(a,gc({nodeType:B.ASSIGNMENT,dependsOn:[l,c.id],phiBlocks:[]}));return Oc(o,o.currentBlock,u),{id:u}}function rl(t,n){return t.nodeTypes[n]!==B.OPERATION||t.baseTypes[n]===V.SAMPLER2D?!1:t.opCodes[n]===W.Unary.SNAPSHOT||(t.usedBy[n]||[]).length>1}const il={float1:`float`,float2:`vec2`,float3:`vec3`,float4:`vec4`,int1:`int`,int2:`ivec2`,int3:`ivec3`,int4:`ivec4`,bool1:`bool`,bool2:`bvec2`,bool3:`bvec3`,bool4:`bvec4`,mat2:`mat2x2`,mat3:`mat3x3`,mat4:`mat4x4`},al={[fc.DEFAULT]:(t,n,r)=>{let{dag:i,cfg:a}=n,o=a.blockInstructions[t]||[];for(let t of o){let n=i.nodeTypes[t];if(rl(i,t)){let n=ol.generateDeclaration(r,i,t);r.write(n)}n===B.STATEMENT&&ol.generateStatement(r,i,t),n===B.ASSIGNMENT&&(ol.generateAssignment(r,i,t),r.visitedNodes.add(t))}},[fc.BRANCH](t,n,r){let{dag:i,cfg:a}=n,o=a.blockInstructions[t]||[];for(let t of o)if(_c(i,t).nodeType===B.PHI){let n=`T${r.nextTempID++}`;r.tempNames[t]=n;let a=vc(i,t),o=ol.getTypeName(a.baseType,a.dimension);r.write(`${o} ${n};`)}this[fc.DEFAULT](t,n,r)},[fc.IF_COND](t,n,r){let{dag:i,cfg:a}=n,o=a.blockConditions[t],s=ol.generateExpression(r,i,o);r.write(`if (${s})`),this[fc.DEFAULT](t,n,r)},[fc.ELSE_COND](t,n,r){r.write(`else`),this[fc.DEFAULT](t,n,r)},[fc.IF_BODY](t,n,r){this[fc.DEFAULT](t,n,r),this.assignPhiNodeValues(t,n,r)},[fc.SCOPE_START](t,n,r){r.write(`{`),r.indent++},[fc.SCOPE_END](t,n,r){r.indent--,r.write(`}`)},[fc.MERGE](t,n,r){this[fc.DEFAULT](t,n,r)},[fc.FUNCTION](t,n,r){this[fc.DEFAULT](t,n,r)},[fc.FOR](t,n,r){let{dag:i,cfg:a}=n,o=a.blockInstructions[t]||[];r.write(`for (`);let s=r.suppressSemicolon;for(let t=0;t<o.length;t++){let n=o[t],a=_c(i,n);if(r.suppressSemicolon=t===o.length-1,rl(i,n)){let t=ol.generateDeclaration(r,i,n);r.write(t)}a.nodeType===B.STATEMENT&&ol.generateStatement(r,i,n),a.nodeType===B.ASSIGNMENT&&(ol.generateAssignment(r,i,n),r.visitedNodes.add(n))}r.suppressSemicolon=s,r.write(`)`)},assignPhiNodeValues(t,n,r){let{dag:i,cfg:a}=n,o=a.outgoingEdges[t]||[];for(let n of o){let o=a.blockInstructions[n]||[];for(let n of o){let a=_c(i,n);if(a.nodeType===B.PHI){let o=a.phiBlocks?.indexOf(t);if(o!==-1&&o<a.dependsOn.length){let t=a.dependsOn[o],s=r.tempNames[n];if(s&&t!==null){let n=ol.generateExpression(r,i,t);r.write(`${s} = ${n};`)}}}}}}},ol={hookEntry(t){return`(${t.parameters.flatMap(t=>`${t.qualifiers?.length?t.qualifiers.join(` `):``}${t.type.typeName} ${Qs}${t.name}`).join(`, `)}) {`},getNoiseShaderSnippet(){return Js},getRandomFragmentShaderSnippet(){return Ys},getRandomVertexShaderSnippet(){return Xs},getTypeName(t,n){return il[t+n]||t},generateHookUniformKey(t,n){return`${this.getTypeName(n.baseType,n.dimension)} ${t}`},generateVaryingVariable(t,n){return`${n.fnName} ${t}`},generateLocalDeclaration(t,n){return`${n.fnName} ${t};`},generateStatement(t,n,r){let i=_c(n,r),a=t.suppressSemicolon?``:`;`;if(i.statementType===tc.DISCARD)t.write(`discard${a}`);else if(i.statementType===tc.BREAK)t.write(`break${a}`);else if(i.statementType===tc.EXPRESSION){let r=i.dependsOn[0],o=this.generateExpression(t,n,r);t.write(`${o}${a}`)}else if(i.statementType===tc.EMPTY)t.write(a);else if(i.statementType===tc.EARLY_RETURN){let r=i.dependsOn[0],o=this.generateExpression(t,n,r);t.write(`return ${o}${a}`)}},generateAssignment(t,n,r){let i=_c(n,r),a=i.dependsOn[0],o=i.dependsOn[1],s=this.generateExpression(t,n,a),c=this.generateExpression(t,n,o),l=t.suppressSemicolon?``:`;`;s&&c&&s!==c&&t.write(`${s} = ${c}${l}`)},generateDeclaration(t,n,r){let i=this.generateExpression(t,n,r),a=`T${t.nextTempID++}`;t.tempNames[r]=a;let o=vc(n,r);return`${this.getTypeName(o.baseType,o.dimension)} ${a} = ${i};`},generateReturnStatement(t,n,r,i){if(!i){n.write(`return;`);return}let a=t.dag,o=_c(a,r);if(ic(i)&&o.identifier){let t=i;for(let r=0;r<t.properties.length;r++){let i=t.properties[r],s=this.generateExpression(n,a,o.dependsOn[r]);i.name!==s&&n.write(`${o.identifier}.${i.name} = ${s};`)}}n.write(`return ${this.generateExpression(n,a,r)};`)},generateExpression(t,n,r){let i=_c(n,r);if(t.tempNames?.[r])return t.tempNames[r];switch(i.nodeType){case B.LITERAL:return i.baseType===V.FLOAT?i.value.toFixed(4):i.value;case B.VARIABLE:if(t.shaderContext&&t.strandsContext?.sharedVariables?.has(i.identifier)){let n=t.strandsContext.sharedVariables.get(i.identifier);t.shaderContext===`vertex`?n.usedInVertex=!0:t.shaderContext===`fragment`&&(n.usedInFragment=!0)}return i.identifier===this.instanceIdReference()&&t.shaderContext===`fragment`?(t.strandsContext._instanceIDUsedInFragment=!0,Zs):i.identifier;case B.OPERATION:{let r=i.usedBy.length>0;if(i.opCode===W.Nary.CONSTRUCTOR)return i.baseType===V.SAMPLER2D?this.generateExpression(t,n,i.dependsOn[0]):`${this.getTypeName(i.baseType,i.dimension)}(${i.dependsOn.map(r=>this.generateExpression(t,n,r)).join(`, `)})`;if(i.opCode===W.Nary.FUNCTION_CALL){let r=i.dependsOn.map(r=>this.generateExpression(t,n,r));return`${i.identifier}(${r.join(`, `)})`}if(i.opCode===W.Nary.TERNARY){let[r,a,o]=i.dependsOn;return`(${this.generateExpression(t,n,r)} ? ${this.generateExpression(t,n,a)} : ${this.generateExpression(t,n,o)})`}if(i.opCode===W.Binary.MEMBER_ACCESS){let[r,a]=i.dependsOn;return`${this.generateExpression(t,n,r)}.${this.generateExpression(t,n,a)}`}if(i.opCode===W.Unary.SNAPSHOT)return this.generateExpression(t,n,i.dependsOn[0]);if(i.opCode===W.Unary.SWIZZLE){let r=i.dependsOn[0];return`${this.generateExpression(t,n,r)}.${i.swizzle}`}if(i.opCode===W.Binary.ARRAY_ACCESS){let[r,a]=i.dependsOn;return`${this.generateExpression(t,n,r)}[${this.generateExpression(t,n,a)}]`}if(i.dependsOn.length===2){let[a,o]=i.dependsOn,s=this.generateExpression(t,n,a),c=this.generateExpression(t,n,o);if(i.opCode===W.Binary.MODULO){let t=_c(n,a),r=_c(n,o);return t.baseType===V.FLOAT||r.baseType===V.FLOAT?`mod(${s}, ${c})`:`(${s} % ${c})`}let l=cc[i.opCode];return r?`(${s} ${l} ${c})`:`${s} ${l} ${c}`}if(i.opCode===W.Unary.LOGICAL_NOT||i.opCode===W.Unary.NEGATE||i.opCode===W.Unary.PLUS){let[r]=i.dependsOn,a=this.generateExpression(t,n,r);return`${cc[i.opCode]}${a}`}return pc(`Operation with opCode ${i.opCode} is not supported in expressions`)}case B.PHI:if(i.identifier)return i.identifier;if(t.tempNames?.[r])return t.tempNames[r];{let r=i.dependsOn.filter(t=>t!==null);if(r.length>0)return this.generateExpression(t,n,r[0]);throw Error(`No valid inputs for node`)}case B.ASSIGNMENT:return pc(`ASSIGNMENT nodes should not be used as expressions`);default:return pc(`${$s[i.nodeType]} code generation not implemented yet`)}},generateBlock(t,n,r){let i=n.cfg.blockTypes[t];(al[i]||al[fc.DEFAULT]).call(al,t,n,r)},createGetTextureCall(t,n){let{id:r,dimension:i}=Xc(t,`getTexture`,n,{overloads:[{params:[H.sampler2D,H.float2],returnType:H.float4}]});return{id:r,dimension:i}},instanceIdReference(){return`gl_InstanceID`},generateInstanceIDVarying(){return{name:Zs,declaration:`int ${Zs}`,source:`gl_InstanceID`,interpolation:`flat`}}};function sl(t,n){let r=t._vertSrc,i=t.hooks.vertex[n];if(i||(i=t.hooks.fragment[n],r=t._fragSrc),!i)throw Error(`Can't find hook ${n}!`);let a=n.split(/\s+/g),o=a.pop(),s=a.pop(),c=[...a],l=/\(([^)]*)\)/.exec(i);if(!l)throw Error(`Couldn't find function parameters in hook body:\n${i}`);let u=t=>{let n=RegExp(`struct\\s+${t}\\s*{([^}]*)}`).exec(r);if(!n)return;let i=[];for(let t of n[1].split(`;`)){let n=t.trim().split(/\s+|,/g),r=n.shift(),a=[...n],o=u(r);for(let t of a){let n=oc[r]||null;i.push({name:t,type:{typeName:r,qualifiers:[],properties:o,dataType:n}})}}return i},d=l[1].split(`,`).map(t=>{let n=t.trim().split(/\s+/g),r=n.pop(),i=n.pop();return{name:r,type:{typeName:i,qualifiers:[...n],properties:u(i),dataType:oc[i]||null}}}),f=oc[s]||null;return{name:o,returnType:{typeName:s,qualifiers:c,properties:u(s),dataType:f},parameters:d}}var cl=class{constructor(t){this.parentRenderer=t,this.canvas=document.createElement(`canvas`),this.canvas.width=t.width,this.canvas.height=t.height;let n=g;this.gl=this.canvas.getContext(`webgl2`),this.gl||=(n=h,this.canvas.getContext(`webgl`)),this.gl?(this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.textures=/* @__PURE__ */ new Map,this._renderer={GL:this.gl,registerEnabled:/* @__PURE__ */ new Set,_curShader:null,_emptyTexture:null,webglVersion:n,states:{textureWrapX:yt,textureWrapY:yt},_arraysEqual:(t,n)=>JSON.stringify(t)===JSON.stringify(n),_getEmptyTexture:()=>{if(!this._emptyTexture){let t=new fa(1,1);t.set(0,0,255),this._emptyTexture=new Ds(this._renderer,t)}return this._emptyTexture},_initShader:t=>{let n=this.gl,r=n.createShader(n.VERTEX_SHADER);if(n.shaderSource(r,t.vertSrc()),n.compileShader(r),!n.getShaderParameter(r,n.COMPILE_STATUS))throw Error(`Yikes! An error occurred compiling the vertex shader: ${n.getShaderInfoLog(r)}`);let i=n.createShader(n.FRAGMENT_SHADER);if(n.shaderSource(i,t.fragSrc()),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS))throw Error(`Darn! An error occurred compiling the fragment shader: ${n.getShaderInfoLog(i)}`);let a=n.createProgram();if(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS))throw Error(`Snap! Error linking shader program: ${n.getProgramInfoLog(a)}`);t._glProgram=a,t._vertShader=r,t._fragShader=i},getTexture:t=>{let n=t;n instanceof Framebuffer&&(n=n.color);let r=this.textures.get(n);if(r)return r;let i=new Ds(this._renderer,n);return this.textures.set(n,i),i},populateHooks:(t,n,r)=>Is(t,n,r),_getShaderAttributes:t=>Fs(t,this.gl),getUniformMetadata:t=>Ps(t,this.gl),_finalizeShader:()=>{},_useShader:t=>{this.gl.useProgram(t._glProgram)},bindTexture:t=>{this.gl.bindTexture(this.gl.TEXTURE_2D,t.getTexture().texture)},unbindTexture:()=>{this.gl.bindTexture(this.gl.TEXTURE_2D,null)},_unbindFramebufferTexture:t=>{let n=this.gl,r=this._getEmptyTexture();n.activeTexture(n.TEXTURE0+t.samplerIndex),r.bindTexture(),n.uniform1i(t.location,t.samplerIndex)},createTexture:({width:t,height:n,format:r,dataType:i})=>{let a=this.gl,o=a.createTexture();return a.bindTexture(a.TEXTURE_2D,o),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,t,n,0,a.RGBA,a.UNSIGNED_BYTE,null),{texture:o,glFormat:a.RGBA,glDataType:a.UNSIGNED_BYTE}},uploadTextureFromSource:({texture:t,glFormat:n,glDataType:r},i)=>{let a=this.gl;a.bindTexture(a.TEXTURE_2D,t),a.texImage2D(a.TEXTURE_2D,0,n,n,r,i)},uploadTextureFromData:({texture:t,glFormat:n,glDataType:r},i,a,o)=>{let s=this.gl;s.bindTexture(s.TEXTURE_2D,t),s.texImage2D(s.TEXTURE_2D,0,n,a,o,0,n,r,i)},setTextureParams:t=>Ms(t,this.gl,this._renderer.webglVersion),updateUniformValue:(t,n,r)=>Ns(t,n,r,t=>this._renderer.getTexture(t),this.gl),_enableAttrib:(t,n,r,i,a,o,s)=>{let c=n.location,l=this.gl;this._renderer.registerEnabled.has(c)||(l.enableVertexAttribArray(c),this._renderer.registerEnabled.add(c)),l.vertexAttribPointer(c,r,i||l.FLOAT,a||!1,o||0,s||0)},_disableRemainingAttributes:t=>{for(let n of this._renderer.registerEnabled.values())Object.keys(t.attributes).some(r=>t.attributes[r].location===n)||(this.gl.disableVertexAttribArray(n),this._renderer.registerEnabled.delete(n))},_updateTexture:(t,n)=>{let r=this.gl;r.activeTexture(r.TEXTURE0+t.samplerIndex),n.bindTexture(),n.update(),r.uniform1i(t.location,t.samplerIndex)},baseFilterShader:()=>this.baseFilterShader(),strandsBackend:ol,getShaderHookTypes:(t,n)=>sl(t,n),uniformNameFromHookKey:t=>t.slice(t.indexOf(` `)+1)},this._baseFilterShader=void 0,this.filterShaders={},this.operation=null,this.filterParameter=1,this.customShader=null,this._shader=null,this.vertexBuffer=this.gl.createBuffer(),this.texcoordBuffer=this.gl.createBuffer(),this.vertices=new Float32Array([-1,-1,1,-1,-1,1,1,1]),this.texcoords=new Float32Array([0,1,1,1,0,0,1,0]),this._bindBufferData(this.vertexBuffer,this.gl.ARRAY_BUFFER,this.vertices),this._bindBufferData(this.texcoordBuffer,this.gl.ARRAY_BUFFER,this.texcoords)):console.error(`WebGL not supported, cannot apply filter.`)}_webGL2CompatibilityPrefix(t,n){let r=``;return this._renderer.webglVersion===`webgl2`&&(r+=`#version 300 es
#define WEBGL2
`),t===`vert`?r+=`#define VERTEX_SHADER
`:t===`frag`&&(r+=`#define FRAGMENT_SHADER
`),n&&(r+=`precision ${n} float;\n`),r}baseFilterShader(){return this._baseFilterShader||=new ys(this._renderer,this._webGL2CompatibilityPrefix(`vert`,`highp`)+qs+Ks,this._webGL2CompatibilityPrefix(`frag`,`highp`)+qs+Gs,{vertex:{},fragment:{"vec4 getColor":`(FilterInputs inputs, in sampler2D canvasContent) {
              return getTexture(canvasContent, inputs.texCoord);
            }`},hookAliases:{getColor:[`filterColor`]}}),this._baseFilterShader}getRandomFragmentShaderSnippet(){return Ys}getRandomVertexShaderSnippet(){return Xs}setOperation(t,n,r=null){this.operation=t,this.filterParameter=n,t in ts&&n===void 0&&(this.filterParameter=ts[t]),this.customShader=r,this._initializeShader()}_initializeShader(){if(this.customShader){this._shader=this.customShader;return}if(!this.operation){console.error(`No operation set for FilterRenderer2D, cannot initialize shader.`);return}if(this.filterShaders[this.operation]){this._shader=this.filterShaders[this.operation];return}let t=is(this._renderer,this.operation,this.parentRenderer._pInst);this.filterShaders[this.operation]=t,this._shader=t}_bindBufferData(t,n,r){let i=this.gl;i.bindBuffer(n,t),i.bufferData(n,r,i.STATIC_DRAW)}get canvasTexture(){return this._canvasTexture||=new Ds(this._renderer,this.parentRenderer),this._canvasTexture}_renderPass(){let t=this.gl;this._shader.bindShader(`fill`);let n=this.parentRenderer.pixelDensity?this.parentRenderer.pixelDensity():1,r=[1/(this.parentRenderer.width*n),1/(this.parentRenderer.height*n)],i=this.canvasTexture;this._shader.setUniform(`tex0`,i),this._shader.setUniform(`texelSize`,r),this._shader.setUniform(`canvasSize`,[this.parentRenderer.width,this.parentRenderer.height]),this._shader.setUniform(`radius`,Math.max(1,this.filterParameter)),this._shader.setUniform(`filterParameter`,this.filterParameter),this._shader.setDefaultUniforms(),this.parentRenderer.states.setValue(`rectMode`,ee),this.parentRenderer.states.setValue(`imageMode`,ee),this.parentRenderer.blendMode(F),this.parentRenderer.resetMatrix();let a=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];this._shader.setUniform(`uModelViewMatrix`,a),this._shader.setUniform(`uProjectionMatrix`,a),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this._shader.enableAttrib(this._shader.attributes.aPosition,2),t.bindBuffer(t.ARRAY_BUFFER,this.texcoordBuffer),this._shader.enableAttrib(this._shader.attributes.aTexCoord,2),this._shader.bindTextures(),this._renderer._disableRemainingAttributes(this._shader),t.drawArrays(t.TRIANGLE_STRIP,0,4),this._shader.unbindShader()}applyFilter(){this._shader?(this.parentRenderer.push(),this.parentRenderer.resetMatrix(),this.operation===`blur`&&!this.customShader?(this._shader.setUniform(`direction`,[1,0]),this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height),this._shader.setUniform(`direction`,[0,1]),this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height)):(this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.blendMode(F),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height)),this.parentRenderer.pop()):console.error(`Cannot apply filter: shader not initialized.`)}},ll=class extends L{constructor(t,n,r,i,a,o={}){super(t,n,r,i),this.canvas=this.elt=a||document.createElement(`canvas`),i?(this._pInst._curElement=this,this._pInst.canvas=this.canvas):this.canvas.style.display=`none`,this.elt.id||(this.elt.id=`defaultCanvas${_l.sketchCount++}`),this.elt.classList.add(`p5Canvas`);for(let t of Object.getOwnPropertyNames(ta.prototype))t!==`constructor`&&t[0]!==`_`&&Object.defineProperty(this,t,{get(){return this.wrappedElt[t]}});if(this.elt.width=n*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${n}px`,this.elt.style.height=`${r}px`,this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(document.getElementsByTagName(`main`).length===0){let t=document.createElement(`main`);document.body.appendChild(t)}document.getElementsByTagName(`main`)[0].appendChild(this.elt)}this.drawingContext=this.canvas.getContext(`2d`,o),o.colorSpace===`display-p3`&&(this.states.colorMode=Gi),this.scale(this._pixelDensity,this._pixelDensity),this.wrappedElt=new ta(this.elt,this._pInst),this.clipPath=null}get filterRenderer(){return this._filterRenderer||=new cl(this),this._filterRenderer}remove(){this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null}getFilterGraphicsLayer(){if(!this.filterGraphicsLayer){let t=this._pInst;this.filterGraphicsLayer=new Ts(this.width,this.height,h,t)}return(this.filterGraphicsLayer.width!==this.width||this.filterGraphicsLayer.height!==this.height)&&this.filterGraphicsLayer.resizeCanvas(this.width,this.height),this.filterGraphicsLayer.pixelDensity()!==this._pInst.pixelDensity()&&this.filterGraphicsLayer.pixelDensity(this._pInst.pixelDensity()),this.filterGraphicsLayer}_applyDefaults(){this.states.setValue(`_cachedFillStyle`,void 0),this.states.setValue(`_cachedStrokeStyle`,void 0),this._cachedBlendMode=F,this._setFill(Ot),this._setStroke(Dt),this.drawingContext.lineCap=me,this.drawingContext.font=`normal 12px sans-serif`}resize(t,n){super.resize(t,n);let r={};for(let t in this.drawingContext){let n=this.drawingContext[t];typeof n!=`object`&&typeof n!=`function`&&(r[t]=n)}this.canvas.width=t*this._pixelDensity,this.canvas.height=n*this._pixelDensity,this.canvas.style.width=`${t}px`,this.canvas.style.height=`${n}px`,this.drawingContext.scale(this._pixelDensity,this._pixelDensity);for(let t in r)try{this.drawingContext[t]=r[t]}catch{}}background(...t){if(t.length===0)return this;if(this.push(),this.resetMatrix(),t[0]instanceof fa){let n=t[0];t[1]>=0&&(this.drawingContext.globalAlpha=t[1]/255),this._pInst.image(n,0,0,this.width,this.height)}else{let n=this._pInst.color(...t);this._pInst._addAccsOutput?.()&&this._pInst._accsBackground?.(n._getRGBA([255,255,255,255]));let r=n.toString();this._setFill(r),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.fillRect(0,0,this.width,this.height),this._isErasing&&this._pInst.erase()}return this.pop(),this}clear(){this.drawingContext.save(),this.resetMatrix(),this.drawingContext.clearRect(0,0,this.width,this.height),this.drawingContext.restore()}fill(...t){super.fill(...t);let n=this.states.fillColor;if(t.length===0)return n;this._setFill(n.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.(`fill`,n._getRGBA([255,255,255,255]))}stroke(...t){super.stroke(...t);let n=this.states.strokeColor;if(t.length===0)return n;this._setStroke(n.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.(`stroke`,n._getRGBA([255,255,255,255]))}erase(t,n){if(!this._isErasing){this.states.setValue(`_cachedFillStyle`,this.drawingContext.fillStyle);let r=this._pInst.color(255,t).toString();this.drawingContext.fillStyle=r,this.states.setValue(`_cachedStrokeStyle`,this.drawingContext.strokeStyle);let i=this._pInst.color(255,n).toString();this.drawingContext.strokeStyle=i;let a=this._cachedBlendMode;this.blendMode(ke),this._cachedBlendMode=a,this._isErasing=!0}}noErase(){this._isErasing&&=(this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode),!1)}drawShape(t){let n=new Ba({strokeWeight:this.states.strokeWeight,hasFill:!this._clipping&&!!this.states.fillColor,hasStroke:!this._clipping&&!!this.states.strokeColor});if(t.accept(n),this._clipping){let t=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(t);this.clipPath.addPath(n.path,r),this.clipPath.closePath()}else this.states.fillColor&&this.drawingContext.fill(n.fillPath||n.path),this.states.strokeColor&&this.drawingContext.stroke(n.strokePath||n.path)}beginClip(t={}){super.beginClip(t),this._clipBaseTransform=this.drawingContext.getTransform(),this.states.setValue(`_cachedFillStyle`,this.drawingContext.fillStyle);let n=this._pInst.color(255,0).toString();this.drawingContext.fillStyle=n,this.states.setValue(`_cachedStrokeStyle`,this.drawingContext.strokeStyle);let r=this._pInst.color(255,0).toString();this.drawingContext.strokeStyle=r;let i=this._cachedBlendMode;this.blendMode(F),this._cachedBlendMode=i,this.clipPath=new Path2D,this._clipBaseTransform=this.drawingContext.getTransform(),this._clipInvert&&(this.clipPath.moveTo(-2*this.width,-2*this.height),this.clipPath.lineTo(-2*this.width,2*this.height),this.clipPath.lineTo(2*this.width,2*this.height),this.clipPath.lineTo(2*this.width,-2*this.height),this.clipPath.closePath())}endClip(){let t=this.drawingContext.getTransform();this.drawingContext.setTransform(this._clipBaseTransform),this.drawingContext.clip(this.clipPath),this.drawingContext.setTransform(t),this.clipPath=null,super.endClip(),this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode)}image(t,n,r,i,a,o,s,c,l){let u;t.gifProperties&&t._animateGif(this._pInst);try{t instanceof oo&&t._ensureCanvas(),this.states.tint&&t.canvas&&(u=this._getTintedImageCanvas(t)),u||=t.canvas||t.elt;let d=1;t.width&&t.width>0&&(d=u.width/t.width),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.drawImage(u,d*n,d*r,d*i,d*a,o,s,c,l),this._isErasing&&this._pInst.erase()}catch(t){if(t.name!==`NS_ERROR_NOT_AVAILABLE`)throw t}}_getTintedImageCanvas(t){if(!t.canvas)return t;t.tintCanvas||=document.createElement(`canvas`),t.tintCanvas.width!==t.canvas.width&&(t.tintCanvas.width=t.canvas.width),t.tintCanvas.height!==t.canvas.height&&(t.tintCanvas.height=t.canvas.height);let n=t.tintCanvas.getContext(`2d`);n.save(),n.clearRect(0,0,t.canvas.width,t.canvas.height);let r=this.states.tint._getRGBA([255,255,255,255]);return r[0]<255||r[1]<255||r[2]<255?(n.drawImage(t.canvas,0,0),n.globalCompositeOperation=`luminosity`,n.drawImage(t.canvas,0,0),n.globalCompositeOperation=`color`,n.drawImage(t.canvas,0,0),n.globalCompositeOperation=`multiply`,n.fillStyle=`rgb(${r.slice(0,3).join(`, `)})`,n.fillRect(0,0,t.canvas.width,t.canvas.height),n.globalCompositeOperation=`destination-in`,n.globalAlpha=r[3]/255,n.drawImage(t.canvas,0,0)):(n.globalAlpha=r[3]/255,n.drawImage(t.canvas,0,0)),n.restore(),t.tintCanvas}blendMode(t){if(t===void 0)return this._cachedBlendMode;if(t===`subtract`)console.warn(`blendMode(SUBTRACT) only works in WEBGL mode.`);else if(t===`source-over`||t===`destination-out`||t===`darken`||t===`lighten`||t===`difference`||t===`multiply`||t===`exclusion`||t===`screen`||t===`copy`||t===`overlay`||t===`hard-light`||t===`soft-light`||t===`color-dodge`||t===`color-burn`||t===`lighter`)this._cachedBlendMode=t,this.drawingContext.globalCompositeOperation=t;else throw Error(`Mode ${t} not recognized.`)}blend(...t){let n=this.drawingContext.globalCompositeOperation,r=t[t.length-1],i=Array.prototype.slice.call(t,0,t.length-1);this.drawingContext.globalCompositeOperation=r,_l.prototype.copy.apply(this,i),this.drawingContext.globalCompositeOperation=n}_getPixel(t,n){let r,i;return r=this.drawingContext.getImageData(t,n,1,1).data,i=0,[r[i+0],r[i+1],r[i+2],r[i+3]]}loadPixels(){let t=this._pixelDensity,n=this.width*t,r=this.height*t,i=this.drawingContext.getImageData(0,0,n,r);this.imageData=i,this.pixels=i.data}set(t,n,r){if(t=Math.floor(t),n=Math.floor(n),r instanceof Ts||r instanceof fa){this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity);let i=r.width,a=r.height;this.drawingContext.clearRect(t,n,i,a),this.drawingContext.drawImage(r.canvas,t,n,i,a),this.drawingContext.restore()}else{let i=0,a=0,o=0,s=0,c=4*(n*this._pixelDensity*(this.width*this._pixelDensity)+t*this._pixelDensity);if(this.imageData||this.loadPixels(),typeof r==`number`)c<this.pixels.length&&(i=r,a=r,o=r,s=255);else if(Array.isArray(r)){if(r.length<4)throw Error(`pixel array must be of the form [R, G, B, A]`);c<this.pixels.length&&(i=r[0],a=r[1],o=r[2],s=r[3])}else r instanceof _l.Color&&c<this.pixels.length&&([i,a,o,s]=r._getRGBA([255,255,255,255]));for(let r=0;r<this._pixelDensity;r++)for(let l=0;l<this._pixelDensity;l++)c=4*((n*this._pixelDensity+l)*this.width*this._pixelDensity+(t*this._pixelDensity+r)),this.pixels[c]=i,this.pixels[c+1]=a,this.pixels[c+2]=o,this.pixels[c+3]=s}}updatePixels(t,n,r,i){let a=this._pixelDensity;t===void 0&&n===void 0&&r===void 0&&i===void 0&&(t=0,n=0,r=this.width,i=this.height),t*=a,n*=a,r*=a,i*=a,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=this.imageData),this.drawingContext.putImageData(this.imageData,0,0,t,n,r,i)}arc(t,n,r,i,a,o,s){let c=new _l.Shape({position:new _l.Vector(0,0)});return c.beginShape(),c.arcPrimitive(t,n,r,i,a,o,s),c.endShape(),this.drawShape(c),this}ellipse(t){let n=parseFloat(t[0]),r=parseFloat(t[1]),i=parseFloat(t[2]),a=parseFloat(t[3]),o=new _l.Shape({position:new _l.Vector(0,0)});return o.beginShape(),o.ellipsePrimitive(n,r,i,a),o.endShape(),this.drawShape(o),this}line(t,n,r,i){let a=new _l.Shape({position:new _l.Vector(0,0)});return a.beginShape(),a.line(t,n,r,i),a.endShape(),this.drawShape(a),this}point(t,n){let r=new _l.Shape({position:new _l.Vector(0,0)});return r.beginShape(),r.point(t,n),r.endShape(),this.drawShape(r),this}quad(t,n,r,i,a,o,s,c){let l=new _l.Shape({position:new _l.Vector(0,0)});return l.beginShape(),l.quad(t,n,r,i,a,o,s,c),l.endShape(),this.drawShape(l),this}rect(t){let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=new _l.Shape({position:new _l.Vector(0,0)});return u.beginShape(),u.rectPrimitive(n,r,i,a,o,s,c,l),u.endShape(),this.drawShape(u),this}triangle(t){let n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=new _l.Shape({position:new _l.Vector(0,0)});return c.beginShape(),c.triangle(n,r,i,a,o,s),c.endShape(),this.drawShape(c),this}strokeCap(t){return t===void 0?this.drawingContext.lineCap:((t===`round`||t===`butt`||t===`square`)&&(this.drawingContext.lineCap=t),this)}strokeJoin(t){return t===void 0?this.drawingContext.lineJoin:((t===`round`||t===`bevel`||t===`miter`)&&(this.drawingContext.lineJoin=t),this)}strokeWeight(t){return super.strokeWeight(t),t===void 0?this.states.strokeWeight:(t===0?this.drawingContext.lineWidth=1e-4:this.drawingContext.lineWidth=t,this)}_getFill(){return this.states._cachedFillStyle||this.states.setValue(`_cachedFillStyle`,this.drawingContext.fillStyle),this.states._cachedFillStyle}_setFill(t){t!==this.states._cachedFillStyle&&(this.drawingContext.fillStyle=t,this.states.setValue(`_cachedFillStyle`,t))}_getStroke(){return this.states._cachedStrokeStyle||this.states.setValue(`_cachedStrokeStyle`,this.drawingContext.strokeStyle),this.states._cachedStrokeStyle}_setStroke(t){t!==this.states._cachedStrokeStyle&&(this.drawingContext.strokeStyle=t,this.states.setValue(`_cachedStrokeStyle`,t))}applyMatrix(t,n,r,i,a,o){this.drawingContext.transform(t,n,r,i,a,o)}getWorldToScreenMatrix(){return new Po(new DOMMatrix().scale(1/this._pixelDensity).multiply(this.drawingContext.getTransform()).toFloat32Array())}resetMatrix(){return this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this}rotate(t){return this.drawingContext.rotate(t),this}scale(t,n){return typeof t==`object`&&`x`in t&&`y`in t&&(n=t.y,t=t.x),this.drawingContext.scale(t,n),this}translate(t,n){return typeof t==`object`&&`x`in t&&`y`in t&&(n=t.y,t=t.x),this.drawingContext.translate(t,n),this}push(){return this.drawingContext.save(),super.push()}pop(t){this.drawingContext.restore(),super.pop(t)}textCanvas(){return this.canvas}textDrawingContext(){return this.drawingContext}_renderText(t,n,r,i,a){let o=this.states,s=this.textDrawingContext();r<a||r>=i||(this.push(),o.strokeColor&&o.strokeSet&&s.strokeText(t,n,r),!this._clipping&&o.fillColor&&(o.fillSet||this._setFill(`#000000`),s.fillText(t,n,r)),this.pop())}_positionLines(t,n,r,i,a){let{textLeading:o,textAlign:s}=this.states,c,l=Array(a.length),u=r===void 0?0:r,d=i===void 0?0:i;for(let r=0;r<a.length;r++){switch(s){case ns.START:throw Error(`textBounds: START not yet supported for textAlign`);case re:c=t;break;case ie:c=t+u/2;break;case ne:c=t+u;break;case ns.END:throw Error(`textBounds: END not yet supported for textAlign`)}l[r]={text:a[r],x:c,y:n+r*o}}return this._yAlignOffset(l,d)}_yAlignOffset(t,n){if(n===void 0)throw Error(`_yAlignOffset: height is required`);let{textLeading:r,textBaseline:i}=this.states,a=0,o=n-r*(t.length-1);switch(i){case`top`:break;case ae:break;case ns._CTX_MIDDLE:a=o/2+this._middleAlignOffset();break;case P:a=o;break;case ns.IDEOGRAPHIC:console.warn(`textBounds: IDEOGRAPHIC not yet supported for textBaseline`);break;case ns.HANGING:console.warn(`textBounds: HANGING not yet supported for textBaseline`)}return t.forEach(t=>t.y+=a),t}};function ul(t,n){t.Renderer2D=ll,t.renderers.p2d=ll,t.renderers[`p2d-p3`]=new Proxy(ll,{construct(t,[n,r,i,a,o]){return new t(n,r,i,a,o,{colorSpace:`display-p3`})}})}function dl(t,n,r){t.registerDecorator(`p5.prototype.createCanvas`,gl(!0)),t.registerDecorator(`p5.prototype.resizeCanvas`,gl(!0)),t.registerDecorator(`p5.prototype.noCanvas`,gl(!1)),n.loadingAnimation=function(t){return this._hasCustomLoading=!0,this._loadingAnimation=t,typeof t!=`function`&&ml(this),this},r.presetup=function(){this._isSketchLoading=!0},r.postsetup=function(){this._isSketchLoading=!1,ml(this)}}function fl(t){if(t.constructor.loadingAnimation===!1||t._hasCustomLoading&&typeof t._loadingAnimation!=`function`)return;let n=t.canvas?.elt||t.canvas;if(!n)return;let r=t._loadingOverlay;if(!r){r=document.createElement(`canvas`),r.id=`${n.id||`defaultCanvas0`}_loadingOverlay`,r.classList.add(`loading-indicator`),t._loadingOverlay=r;let i=r.getContext(`2d`),a=0,o=()=>{if(!t._isSketchLoading)return;let n=t.canvas?.elt||t.canvas;n&&(n.parentNode&&r.parentNode!==n.parentNode&&n.parentNode.insertBefore(r,n.nextSibling),pl(r,n)),i.clearRect(0,0,r.width,r.height);let s=a++;t._hasCustomLoading?t._loadingAnimation.call(t,i,r.width,r.height,s):hl(i,r.width/2,r.height/2,s),t._loadingOverlayFrame=requestAnimationFrame(o)};o()}r.parentNode!==n.parentNode&&n.parentNode.insertBefore(r,n.nextSibling),pl(r,n)}function pl(t,n){t.width!==n.width&&(t.width=n.width),t.height!==n.height&&(t.height=n.height);let r=n.style.width||`${n.offsetWidth||n.width}px`,i=n.style.height||`${n.offsetHeight||n.height}px`,a=`${n.offsetTop}px`,o=`${n.offsetLeft}px`;t.style.top!==a&&(t.style.top=a),t.style.left!==o&&(t.style.left=o),t.style.width!==r&&(t.style.width=r),t.style.height!==i&&(t.style.height=i),t.style.position!==`absolute`&&Object.assign(t.style,{position:`absolute`,margin:`0`,padding:`0`,pointerEvents:`none`,zIndex:`9999`})}function ml(t){t._loadingOverlay&&=(cancelAnimationFrame(t._loadingOverlayFrame),t._loadingOverlay.remove(),null)}function hl(t,n,r,i){let a=1.5;t.fillStyle=`rgba(255, 255, 255, 0.5)`,t.fillRect(0,0,t.canvas.width,t.canvas.height),t.save(),t.translate(n,r),t.scale(a,a),t.rotate(i*3.25*Math.PI/180),t.translate(-14,-14),t.fillStyle=`#ED225D`,t.beginPath(),t.moveTo(16.909,10.259),t.lineTo(25.442,7.683),t.lineTo(27.118,12.839),t.lineTo(18.62,15.738),t.lineTo(23.895,23.218),t.lineTo(19.448,26.443),t.lineTo(13.895,19.095),t.lineTo(8.487,26.25),t.lineTo(4.169,22.961),t.lineTo(9.444,15.738),t.lineTo(.88,12.647),t.lineTo(2.558,7.487),t.lineTo(11.156,10.258),t.lineTo(11.156,1.364),t.lineTo(16.91,1.364),t.closePath(),t.fill(),t.restore()}function gl(t){return function(n){return function(...r){let i=n.call(this,...r);return t?this._isSketchLoading&&fl(this):ml(this),i}}}var _l=class t{static loadingAnimation=!0;static VERSION=p;static instance=null;static sketchCount=0;static lifecycleHooks={presetup:[],postsetup:[],predraw:[],postdraw:[],remove:[]};static _checkForUserDefinedFunctions=()=>{};static _friendlyFileLoadError=()=>{};static _friendlyError=()=>{};static _checkForUserDefinedFunctions=()=>{};static FES={log:()=>()=>{},warn:()=>()=>{},error:()=>()=>{},debug:()=>()=>{},info:()=>()=>{}};constructor(n,r){t.decorations.size>0&&(bl(t,t.decorations,`p5`),t.decorations.clear()),this.hitCriticalError=!1,this._setupDone=!1,this._userNode=r,this._curElement=null,this._elements=[],this._glAttributes=null,this._webgpuAttributes=null,this._requestAnimId=0,this._isGlobal=!1,this._loop=!0,this._startListener=null,this._initializeInstanceVariables(),this._events={},this._removeAbortController=new AbortController,this._removeSignal=this._removeAbortController.signal,this._millisStart=-1,this._recording=!1,this._lcg_random_state=null,this._gaussian_previous=!1,this._updateWindowSize();let i=vl(this);if(n)n(this),t._checkForUserDefinedFunctions(this);else{if(this._isGlobal=!0,window.hitCriticalError)return;t.instance=this;for(let n of Object.getOwnPropertyNames(t.prototype))n[0]!==`_`&&i(n);let n=[`constructor`,`length`];for(let t in this)if(this.hasOwnProperty(t)){if(t[0]===`_`||n.includes(t))continue;i(t)}}typeof window<`u`?(window.addEventListener(`focus`,()=>{this.focused=!0},{signal:this._removeSignal}),window.addEventListener(`blur`,()=>{this.focused=!1},{signal:this._removeSignal}),document.readyState===`complete`?this.#t():(this._startListener=this.#t.bind(this),window.addEventListener(`load`,this._startListener,!1))):this.#t()}get pixels(){return this._renderer?.pixels}get drawingContext(){return this._renderer?.drawingContext}static _registeredAddons=/* @__PURE__ */ new Set;static registerAddon(n){let r={};if(t._registeredAddons.has(n))return;t._registeredAddons.add(n),n(t,t.prototype,r);let i=Object.keys(t.lifecycleHooks);for(let n of i)typeof r[n]==`function`&&t.lifecycleHooks[n].push(r[n])}static decorations=/* @__PURE__ */ new Map;static registerDecorator(n,r){if(typeof n==`string`){let t=n;n=({path:n})=>t===n}else if(Array.isArray(n)&&n.every(t=>typeof t==`string`)){let t=n;n=({path:n})=>t.includes(n)}else if(typeof n!=`function`)throw Error(`Decorator matching pattern must be a function, a string, or an array of strings`);t.decorations.set(n,r)}#e={};_customActions=new Proxy({},{get:(t,n)=>{if(!this.#e[n]){let t=this._isGlobal?window:this;typeof t[n]==`function`&&(this.#e[n]=t[n].bind(this))}return this.#e[n]}});async#t(){if(!this.hitCriticalError){this._userNode&&typeof this._userNode==`string`&&(this._userNode=document.getElementById(this._userNode));try{await this.#n()}catch(t){throw this._isSketchLoading&&await this._runLifecycleHook(`postsetup`),t}this.hitCriticalError||this._recording||this._draw()}}async#n(){if(await this._runLifecycleHook(`presetup`),this.hitCriticalError)return;typeof window<`u`&&this.createCanvas(100,100,`p2d`),this._millisStart=globalThis.performance.now();let t=this._isGlobal?window:this;try{typeof t.setup==`function`&&await t.setup()}catch(t){throw await this._runLifecycleHook(`postsetup`),t}if(!this.hitCriticalError){if(typeof document<`u`){let t=document.getElementsByTagName(`canvas`);for(let n of t)n.style.touchAction=`none`,n.dataset.hidden===`true`&&(n.style.visibility=``,delete n.dataset.hidden)}this._lastTargetFrameTime=globalThis.performance.now(),this._lastRealFrameTime=globalThis.performance.now(),this._setupDone=!0,(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._updateAccsOutput(),await this._runLifecycleHook(`postsetup`),this._millisStart=globalThis.performance.now()}}async _draw(t){if(this.hitCriticalError)return;let n=t||globalThis.performance.now(),r=n-this._lastTargetFrameTime,i=1e3/this._targetFrameRate;if((!this._loop||r>=i-5)&&(this.deltaTime=n-this._lastRealFrameTime,this._frameRate=1e3/this.deltaTime,await this.redraw(),this._lastTargetFrameTime=Math.max(this._lastTargetFrameTime+i,n),this._lastRealFrameTime=n,this._updateMouseCoords!==void 0&&(this._updateMouseCoords(),this.movedX=0,this.movedY=0)),this._loop){let t=this._draw.bind(this);this._requestAnimId=typeof window<`u`?window.requestAnimationFrame(t):setImmediate(t)}}async remove(){if(this._startListener&&window.removeEventListener(`load`,this._startListener,!1),this._curElement){this._loop=!1,this._requestAnimId&&window.cancelAnimationFrame(this._requestAnimId),this._removeAbortController.abort();let t=this._elements.slice();for(let n of t)n.remove();await this._runLifecycleHook(`remove`)}if(this._isGlobal){for(let n in t.prototype)try{delete window[n]}catch{window[n]=void 0}for(let t in this)if(this.hasOwnProperty(t))try{delete window[t]}catch{window[t]=void 0}t.instance=null}}async _runLifecycleHook(n){await Promise.all(t.lifecycleHooks[n].map(t=>t.call(this)))}_initializeInstanceVariables(){this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._styles=[],this._downKeys={},this._downKeyCodes={}}};for(let t in d)_l.prototype[t]=d[t];function vl(t){return function(n){if(n===`constructor`)return;let r=Object.getOwnPropertyDescriptor(t,n),i=Object.getOwnPropertyDescriptor(_l.prototype,n),a=r&&r.get||i&&i.get,o=!1,s=!1,c;if(!a){let t=_l.prototype[n];o=typeof t==`function`,!o&&d[n]!==void 0&&(s=!0,c=t)}if(o){let r=_l.prototype[n].bind(t);Object.defineProperty(window,n,{configurable:!0,enumerable:!0,value:r})}else if(s)Object.defineProperty(window,n,{configurable:!0,enumerable:!0,value:c});else if(a||!o){let r=null,i=null,a=null;Object.defineProperty(window,n,{configurable:!0,enumerable:!0,get:()=>{let o=t[n];return a===null?(a=typeof o==`function`,a?(r=o,i=o.bind(t),i):o):a?(o!==r&&(r=o,i=o.bind(t)),i):o}})}}}function yl(t,n){if(typeof t==`function`&&typeof n==`function`&&t!==n)for(let r of Object.keys(t))r in n||(n[r]=t[r])}function bl(t,n,r){for(let i in t)if(!i.startsWith(`_`)){for(let[a,o]of n)if(a({path:`${r}.${i}`})){if(typeof t[i]==`function`){let n=o(t[i],{kind:`method`,name:i,static:!0});n&&(yl(t[i],n),Object.defineProperty(t,i,{enumerable:!0,writable:!0,value:n}))}else{let n=o(void 0,{kind:`field`,name:i,static:!0});n&&typeof n==`function`&&(t[i]=n(t[i]))}}typeof t[i]==`function`&&t[i].prototype&&bl(t[i],n,`${r}.${i}`)}for(let i of Object.getOwnPropertyNames(t.prototype))if(i!==`constructor`&&!i.startsWith(`_`)){for(let[a,o]of n)if(a({path:`${r}.prototype.${i}`})){if(typeof t.prototype[i]==`function`){let n=o(t.prototype[i],{kind:`method`,name:i,static:!1});n&&(yl(t.prototype[i],n),Object.defineProperty(t.prototype,i,{enumerable:!0,writable:!0,value:n}))}else{let n=Object.getOwnPropertyDescriptor(t.prototype,i);if(n.hasOwnProperty(`value`)){let n=o(void 0,{kind:`field`,name:i,static:!1});Object.defineProperty(t.prototype,i,{enumerable:!0,writable:!0,value:n&&typeof n==`function`?n(t.prototype[i]):t.prototype[i]})}else{let{get:r,set:a}=n,s=o(r,{kind:`getter`,name:i,static:!1}),c=o(a,{kind:`setter`,name:i,static:!1});Object.defineProperty(t.prototype,i,{enumerable:!0,get:s??r,set:c??a})}}}}}_l.registerAddon(Ht),_l.registerAddon(Ut),_l.registerAddon(Wt),_l.registerAddon(Ws),_l.registerAddon(Ka),_l.registerAddon(ul),_l.registerAddon(Es),typeof window<`u`&&_l.registerAddon(dl);function xl(t){t.registerAddon(uo),t.registerAddon(fo),t.registerAddon(po),t.registerAddon(mo),t.registerAddon(Ua)}function Sl(t,n){let r=`_Description`,i=`_fallbackDesc`,a=`_fallbackTable`,o=`_fte_`,s=`_Label`,c=`_labelDesc`,l=`_labelTable`,u=`_lte_`;n.describe=function(t,n,r){if(typeof t!=`string`)return;let i=this.canvas.id;t=p(t),this.dummyDOM||=document.getElementById(i).parentNode,this.descriptions||={},this.descriptions.fallback?this.descriptions.fallback.innerHTML!==t&&(this.descriptions.fallback.innerHTML=t):this._describeHTML(`fallback`,t),n===this.LABEL&&(this.descriptions.label?this.descriptions.label.innerHTML!==t&&(this.descriptions.label.innerHTML=t):this._describeHTML(`label`,t)),f(this,r)},n.describeElement=function(t,n,r,i){if(typeof n!=`string`||typeof t!=`string`)return;let a=this.canvas.id;n=p(n);let o=m(t);t=t.replace(/[^a-zA-Z0-9]/g,``);let s=typeof i==`string`?` lang="${i}"`:``,c=`<th scope="row"${s}>${o}</th><td${s}>${n}</td>`;this.dummyDOM||=document.getElementById(a).parentNode,this.descriptions?this.descriptions.fallbackElements||(this.descriptions.fallbackElements={}):this.descriptions={fallbackElements:{}},this.descriptions.fallbackElements[t]?this.descriptions.fallbackElements[t].innerHTML!==c&&(this.descriptions.fallbackElements[t].innerHTML=c):this._describeElementHTML(`fallback`,t,c),r===this.LABEL&&(this.descriptions.labelElements||(this.descriptions.labelElements={}),this.descriptions.labelElements[t]?this.descriptions.labelElements[t].innerHTML!==c&&(this.descriptions.labelElements[t].innerHTML=c):this._describeElementHTML(`label`,t,c)),f(this,i)},t.registerDecorator(`p5.prototype.describe`,function(t){return function(n,r,i){if(arguments.length===2&&typeof r==`string`)return r===this.LABEL||r===this.FALLBACK?t.call(this,n,r,void 0):t.call(this,n,void 0,r);if(d(this,`describe`,r,i))return t.call(this,n,r,i)}}),t.registerDecorator(`p5.prototype.describeElement`,function(t){return function(n,r,i,a){if(arguments.length===3&&typeof i==`string`)return i===this.LABEL||i===this.FALLBACK?t.call(this,n,r,i,void 0):t.call(this,n,r,void 0,i);if(d(this,`describeElement`,i,a))return t.call(this,n,r,i,a)}});function d(n,r,i,a){return i!==void 0&&i!==n.LABEL&&i!==n.FALLBACK||a!==void 0&&typeof a!=`string`?(t._friendlyError(`${r}() expects display (LABEL or FALLBACK) before lang.`,r),!1):!0}function f(t,n){let r=t.canvas.elt||t.elt||t.canvas;typeof n==`string`?r.setAttribute(`lang`,n):r.removeAttribute(`lang`),t.descriptions.fallback&&(typeof n==`string`?t.descriptions.fallback.setAttribute(`lang`,n):t.descriptions.fallback.removeAttribute(`lang`)),t.descriptions.label&&(typeof n==`string`?t.descriptions.label.setAttribute(`lang`,n):t.descriptions.label.removeAttribute(`lang`))}function p(t){if(t===`label`||t===`fallback`)throw Error(`description should not be LABEL or FALLBACK`);return!t.endsWith(`.`)&&!t.endsWith(`;`)&&!t.endsWith(`,`)&&!t.endsWith(`?`)&&!t.endsWith(`!`)&&(t+=`.`),t}n._describeHTML=function(t,n){let o=this.canvas.id;if(t===`fallback`){if(this.dummyDOM.querySelector(`#${o+r}`))this.dummyDOM.querySelector(`#`+o+a).insertAdjacentHTML(`beforebegin`,`<p id="${o+i}"></p>`);else{let t=`<div id="${o}${r}" role="region" aria-label="Canvas Description"><p id="${o}${i}"></p></div>`;this.dummyDOM.querySelector(`#${o}accessibleOutput`)?this.dummyDOM.querySelector(`#${o}accessibleOutput`).insertAdjacentHTML(`beforebegin`,t):this.dummyDOM.querySelector(`#${o}`).innerHTML=t}this.descriptions.fallback=this.dummyDOM.querySelector(`#${o}${i}`),this.descriptions.fallback.innerHTML=n}else if(t===`label`){if(this.dummyDOM.querySelector(`#${o+s}`))this.dummyDOM.querySelector(`#${o+l}`)&&this.dummyDOM.querySelector(`#${o+l}`).insertAdjacentHTML(`beforebegin`,`<p id="${o}${c}"></p>`);else{let t=`<div id="${o}${s}" class="p5Label"><p id="${o}${c}"></p></div>`;this.dummyDOM.querySelector(`#${o}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${o}accessibleOutputLabel`).insertAdjacentHTML(`beforebegin`,t):this.dummyDOM.querySelector(`#`+o).insertAdjacentHTML(`afterend`,t)}this.descriptions.label=this.dummyDOM.querySelector(`#`+o+c),this.descriptions.label.innerHTML=n}};function m(t){if(t===`label`||t===`fallback`)throw Error(`element name should not be LABEL or FALLBACK`);return t.endsWith(`.`)||t.endsWith(`;`)||t.endsWith(`,`)?t=t.replace(/.$/,`:`):t.endsWith(`:`)||(t+=`:`),t}n._describeElementHTML=function(t,n,d){let f=this.canvas.id;if(t===`fallback`){if(this.dummyDOM.querySelector(`#${f+r}`))this.dummyDOM.querySelector(`#`+f+a)||this.dummyDOM.querySelector(`#`+f+i).insertAdjacentHTML(`afterend`,`<table id="${f}${a}"><caption>Canvas elements and their descriptions</caption></table>`);else{let t=`<div id="${f}${r}" role="region" aria-label="Canvas Description"><table id="${f}${a}"><caption>Canvas elements and their descriptions</caption></table></div>`;this.dummyDOM.querySelector(`#${f}accessibleOutput`)?this.dummyDOM.querySelector(`#${f}accessibleOutput`).insertAdjacentHTML(`beforebegin`,t):this.dummyDOM.querySelector(`#`+f).innerHTML=t}let t=document.createElement(`tr`);t.id=f+o+n,this.dummyDOM.querySelector(`#`+f+a).appendChild(t),this.descriptions.fallbackElements[n]=this.dummyDOM.querySelector(`#${f}${o}${n}`),this.descriptions.fallbackElements[n].innerHTML=d}else if(t===`label`){if(this.dummyDOM.querySelector(`#${f+s}`))this.dummyDOM.querySelector(`#${f+l}`)||this.dummyDOM.querySelector(`#`+f+c).insertAdjacentHTML(`afterend`,`<table id="${f+l}"></table>`);else{let t=`<div id="${f}${s}" class="p5Label"><table id="${f}${l}"></table></div>`;this.dummyDOM.querySelector(`#${f}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${f}accessibleOutputLabel`).insertAdjacentHTML(`beforebegin`,t):this.dummyDOM.querySelector(`#`+f).insertAdjacentHTML(`afterend`,t)}let t=document.createElement(`tr`);t.id=f+u+n,this.dummyDOM.querySelector(`#`+f+l).appendChild(t),this.descriptions.labelElements[n]=this.dummyDOM.querySelector(`#${f}${u}${n}`),this.descriptions.labelElements[n].innerHTML=d}}}typeof p5<`u`&&Sl(p5,p5.prototype);function Cl(t,n){n._updateGridOutput=function(t){if(this._renderer&&this._renderer.isP3D){this._didOutputGridWebGLMessage||(this._didOutputGridWebGLMessage=!0,console.error(`gridOutput() does not yet work in WebGL mode.`));return}if(!this.dummyDOM.querySelector(`#${t}_summary`))return;let n=this._accessibleOutputs[t],o=a(t,this.ingredients.shapes),s=i(o.numShapes,this.ingredients.colors.background,this.width,this.height),c=r(t,this.ingredients.shapes);s!==n.summary.innerHTML&&(n.summary.innerHTML=s),c!==n.map.innerHTML&&(n.map.innerHTML=c),o.details!==n.shapeDetails.innerHTML&&(n.shapeDetails.innerHTML=o.details),this._accessibleOutputs[t]=n};function r(t,n){let r=0,i=``,a=Array.from(Array(10),()=>Array(10));for(let i in n)for(let o in n[i]){let s;s=i===`line`?`<a href="#${t}shape${r}">${n[i][o].color} ${i} midpoint</a>`:`<a href="#${t}shape${r}">${n[i][o].color} ${i}</a>`,n[i][o].loc.locY<a.length&&n[i][o].loc.locX<a[n[i][o].loc.locY].length&&(a[n[i][o].loc.locY][n[i][o].loc.locX]?a[n[i][o].loc.locY][n[i][o].loc.locX]=a[n[i][o].loc.locY][n[i][o].loc.locX]+`  `+s:a[n[i][o].loc.locY][n[i][o].loc.locX]=s,r++)}for(let t in a){let n=`<tr>`;for(let r in a[t])n+=`<td>`,a[t][r]!==void 0&&(n+=a[t][r]),n+=`</td>`;i=i+n+`</tr>`}return i}function i(t,n,r,i){let a=`${n} canvas, ${r} by ${i} pixels, contains ${t[0]}`;return a=t[0]===1?`${a} shape: ${t[1]}`:`${a} shapes: ${t[1]}`,a}function a(t,n){let r=``,i=``,a=0;for(let o in n){let s=0;for(let i in n[o]){let c=`<li id="${t}shape${a}">${n[o][i].color} ${o},`;o===`line`?c+=` location = ${n[o][i].pos}, length = ${n[o][i].length} pixels`:(c+=` location = ${n[o][i].pos}`,o!==`point`&&(c+=`, area = ${n[o][i].area} %`),c+=`</li>`),r+=c,s++,a++}i=s>1?`${i} ${s} ${o}s`:`${i} ${s} ${o}`}return{numShapes:[a,i],details:r}}}typeof p5<`u`&&Cl(p5,p5.prototype);function wl(t,n){n._updateTextOutput=function(t){if(this._renderer&&this._renderer.isP3D){this._didOutputTextWebGLMessage||(this._didOutputTextWebGLMessage=!0,console.error(`textOutput() does not yet work in WebGL mode.`));return}if(!this.dummyDOM.querySelector(`#${t}_summary`))return;let n=this._accessibleOutputs[t],o=a(t,this.ingredients.shapes),s=r(o.numShapes,this.ingredients.colors.background,this.width,this.height),c=i(t,this.ingredients.shapes);s!==n.summary.innerHTML&&(n.summary.innerHTML=s),o.listShapes!==n.list.innerHTML&&(n.list.innerHTML=o.listShapes),c!==n.shapeDetails.innerHTML&&(n.shapeDetails.innerHTML=c),this._accessibleOutputs[t]=n};function r(t,n,r,i){let a=`Your output is a, ${r} by ${i} pixels, ${n} canvas containing the following`;return a=t===1?`${a} shape:`:`${a} ${t} shapes:`,a}function i(t,n){let r=``,i=0;for(let a in n)for(let o in n[a]){let s=`<tr id="${t}shape${i}"><th>${n[a][o].color} ${a}</th>`;a===`line`?s+=`<td>location = ${n[a][o].pos}</td><td>length = ${n[a][o].length} pixels</td></tr>`:(s+=`<td>location = ${n[a][o].pos}</td>`,a!==`point`&&(s+=`<td> area = ${n[a][o].area}%</td>`),s+=`</tr>`),r+=s,i++}return r}function a(t,n){let r=``,i=0;for(let a in n)for(let o in n[a]){let s=`<li><a href="#${t}shape${i}">${n[a][o].color} ${a}</a>`;a===`line`?s+=`, ${n[a][o].pos}, ${n[a][o].length} pixels long.</li>`:(s+=`, at ${n[a][o].pos}`,a!==`point`&&(s+=`, covering ${n[a][o].area}% of the canvas`),s+=`.</li>`),r+=s,i++}return{numShapes:i,listShapes:r}}}typeof p5<`u`&&wl(p5,p5.prototype);function Tl(t,n){n.textOutput=function(t){this._accessibleOutputs.text||(this._accessibleOutputs.text=!0,this._createOutput(`textOutput`,`Fallback`),t===this.LABEL&&(this._accessibleOutputs.textLabel=!0,this._createOutput(`textOutput`,`Label`)))},n.gridOutput=function(t){this._accessibleOutputs.grid||(this._accessibleOutputs.grid=!0,this._createOutput(`gridOutput`,`Fallback`),t===this.LABEL&&(this._accessibleOutputs.gridLabel=!0,this._createOutput(`gridOutput`,`Label`)))},n._addAccsOutput=function(){return this._accessibleOutputs||={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._accessibleOutputs.grid||this._accessibleOutputs.text},n._createOutput=function(t,n){let r=this.canvas.id;this.ingredients||={shapes:{},colors:{background:`white`,fill:`white`,stroke:`black`},pShapes:``,pBackground:``},this.dummyDOM||=document.getElementById(r).parentNode;let i,a,o,s=``;n===`Fallback`?(i=r+t,a=r+`accessibleOutput`,this.dummyDOM.querySelector(`#${a}`)||(this.dummyDOM.querySelector(`#${r}_Description`)?this.dummyDOM.querySelector(`#${r}_Description`).insertAdjacentHTML(`afterend`,`<div id="${a}" role="region" aria-label="Canvas Outputs"></div>`):this.dummyDOM.querySelector(`#${r}`).innerHTML=`<div id="${a}" role="region" aria-label="Canvas Outputs"></div>`)):n===`Label`&&(s=n,i=r+t+n,a=r+`accessibleOutput`+n,this.dummyDOM.querySelector(`#${a}`)||(this.dummyDOM.querySelector(`#${r}_Label`)?this.dummyDOM.querySelector(`#${r}_Label`).insertAdjacentHTML(`afterend`,`<div id="${a}"></div>`):this.dummyDOM.querySelector(`#${r}`).insertAdjacentHTML(`afterend`,`<div id="${a}"></div>`))),this._accessibleOutputs[i]={},t===`textOutput`?(s=`#${r}gridOutput${s}`,o=`<div id="${i}">Text Output<div id="${i}Summary" aria-label="text output summary"><p id="${i}_summary"></p><ul id="${i}_list"></ul></div><table id="${i}_shapeDetails" summary="text output shape details"></table></div>`,this.dummyDOM.querySelector(s)?this.dummyDOM.querySelector(s).insertAdjacentHTML(`beforebegin`,o):this.dummyDOM.querySelector(`#${a}`).innerHTML=o,this._accessibleOutputs[i].list=this.dummyDOM.querySelector(`#${i}_list`)):t===`gridOutput`&&(s=`#${r}textOutput${s}`,o=`<div id="${i}">Grid Output<p id="${i}_summary" aria-label="grid output summary"><table id="${i}_map" summary="grid output content"></table><ul id="${i}_shapeDetails" aria-label="grid output shape details"></ul></div>`,this.dummyDOM.querySelector(s)?this.dummyDOM.querySelector(s).insertAdjacentHTML(`afterend`,o):this.dummyDOM.querySelector(`#${a}`).innerHTML=o,this._accessibleOutputs[i].map=this.dummyDOM.querySelector(`#${i}_map`)),this._accessibleOutputs[i].shapeDetails=this.dummyDOM.querySelector(`#${i}_shapeDetails`),this._accessibleOutputs[i].summary=this.dummyDOM.querySelector(`#${i}_summary`)},n._updateAccsOutput=function(){let t=this.canvas.id;(JSON.stringify(this.ingredients.shapes)!==this.ingredients.pShapes||this.ingredients.colors.background!==this.ingredients.pBackground)&&(this.ingredients.pShapes=JSON.stringify(this.ingredients.shapes),this._accessibleOutputs.text&&this._updateTextOutput(t+`textOutput`),this._accessibleOutputs.grid&&this._updateGridOutput(t+`gridOutput`),this._accessibleOutputs.textLabel&&this._updateTextOutput(t+`textOutputLabel`),this._accessibleOutputs.gridLabel&&this._updateGridOutput(t+`gridOutputLabel`))},n._accsBackground=function(t){this.ingredients.pShapes=JSON.stringify(this.ingredients.shapes),this.ingredients.pBackground=this.ingredients.colors.background,this.ingredients.shapes={},this.ingredients.colors.backgroundRGBA!==t&&(this.ingredients.colors.backgroundRGBA=t,this.ingredients.colors.background=this._rgbColorName(t))},n._accsCanvasColors=function(t,n){t===`fill`?this.ingredients.colors.fillRGBA!==n&&(this.ingredients.colors.fillRGBA=n,this.ingredients.colors.fill=this._rgbColorName(n)):t===`stroke`&&this.ingredients.colors.strokeRGBA!==n&&(this.ingredients.colors.strokeRGBA=n,this.ingredients.colors.stroke=this._rgbColorName(n))},n._accsOutput=function(t,n){t===`ellipse`&&n[2]===n[3]?t=`circle`:t===`rectangle`&&n[2]===n[3]&&(t=`square`);let a={},o=!0,s=r(t,n);if(t===`line`){a.color=this.ingredients.colors.stroke,a.length=Math.round(Math.hypot(n[2]-n[0],n[3]-n[1]));let t=this._getPos(n[0],[1]),r=this._getPos(n[2],[3]);a.loc=i(s,this.width,this.height),a.pos=t===r?`at ${t}`:`from ${t} to ${r}`}else t===`point`?a.color=this.ingredients.colors.stroke:(a.color=this.ingredients.colors.fill,a.area=this._getArea(t,n)),a.pos=this._getPos(...s),a.loc=i(s,this.width,this.height);if(!this.ingredients.shapes[t])this.ingredients.shapes[t]=[a];else{for(let n in this.ingredients.shapes[t])JSON.stringify(this.ingredients.shapes[t][n])===JSON.stringify(a)&&(o=!1);o===!0&&this.ingredients.shapes[t].push(a)}};function r(t,n){let r,i;return t===`rectangle`||t===`ellipse`||t===`arc`||t===`circle`||t===`square`?(r=Math.round(n[0]+n[2]/2),i=Math.round(n[1]+n[3]/2)):t===`triangle`?(r=(n[0]+n[2]+n[4])/3,i=(n[1]+n[3]+n[5])/3):t===`quadrilateral`?(r=(n[0]+n[2]+n[4]+n[6])/4,i=(n[1]+n[3]+n[5]+n[7])/4):t===`line`?(r=(n[0]+n[2])/2,i=(n[1]+n[3])/2):(r=n[0],i=n[1]),[r,i]}n._getPos=function(n,r){let{x:i,y:a}=this.worldToScreen(new t.Vector(n,r)),o=this.width,s=this.height;return i<.4*o?a<.4*s?`top left`:a>.6*s?`bottom left`:`mid left`:i>.6*o?a<.4*s?`top right`:a>.6*s?`bottom right`:`mid right`:a<.4*s?`top middle`:a>.6*s?`bottom middle`:`middle`};function i(t,n,r){let i=Math.floor(t[0]/n*10),a=Math.floor(t[1]/r*10);return i===10&&--i,a===10&&--a,{locX:i,locY:a}}n._getArea=function(t,n){let r=0;if(t===`arc`){let t=((n[5]-n[4])%(Math.PI*2)+Math.PI*2)%(Math.PI*2);if(r=t*n[2]*n[3]/8,n[6]===`open`||n[6]===`chord`){let i=n[0],a=n[1],o=n[0]+n[2]/2*Math.cos(n[4]).toFixed(2),s=n[1]+n[3]/2*Math.sin(n[4]).toFixed(2),c=n[0]+n[2]/2*Math.cos(n[5]).toFixed(2),l=n[1]+n[3]/2*Math.sin(n[5]).toFixed(2),u=Math.abs(i*(s-l)+o*(l-a)+c*(a-s))/2;t>Math.PI?r+=u:r-=u}}else t===`ellipse`||t===`circle`?r=3.14*n[2]/2*n[3]/2:t===`line`||t===`point`?r=0:t===`quadrilateral`?r=Math.abs((n[6]+n[0])*(n[7]-n[1])+(n[0]+n[2])*(n[1]-n[3])+(n[2]+n[4])*(n[3]-n[5])+(n[4]+n[6])*(n[5]-n[7]))/2:t===`rectangle`||t===`square`?r=n[2]*n[3]:t===`triangle`&&(r=Math.abs(n[0]*(n[3]-n[5])+n[2]*(n[5]-n[1])+n[4]*(n[1]-n[3]))/2);let i=this.width*this._renderer._pixelDensity,a=this.height*this._renderer._pixelDensity,o=[new DOMPoint(0,0),new DOMPoint(i,0),new DOMPoint(i,a),new DOMPoint(0,a)],s=(this._renderer.isP3D?new DOMMatrix(this._renderer.uMVMatrix.mat4):this.drawingContext.getTransform()).inverse(),c=o.map(t=>t.matrixTransform(s)),l=Math.abs((c[3].x+c[0].x)*(c[3].y-c[0].y)+(c[0].x+c[1].x)*(c[0].y-c[1].y)+(c[1].x+c[2].x)*(c[1].y-c[2].y)+(c[2].x+c[3].x)*(c[2].y-c[3].y))/2;return Math.round(r*100/l)}}typeof p5<`u`&&Tl(p5,p5.prototype),_l.ColorConversion={_hsbaToHSLA(t){let n=t[0],r=t[1],i=t[2],a=(2-r)*i/2;return a!==0&&(a===1?r=0:a<.5?r/=2-r:r=r*i/(2-a*2)),[n,r,a,t[3]]},_hsbaToRGBA(t){let n=t[0]*6,r=t[1],i=t[2],a=[];if(r===0)a=[i,i,i,t[3]];else{let o=Math.floor(n),s=i*(1-r),c=i*(1-r*(n-o)),l=i*(1-r*(1+o-n)),u,d,f;o===1?(u=c,d=i,f=s):o===2?(u=s,d=i,f=l):o===3?(u=s,d=c,f=i):o===4?(u=l,d=s,f=i):o===5?(u=i,d=s,f=c):(u=i,d=l,f=s),a=[u,d,f,t[3]]}return a},_hslaToHSBA(t){let n=t[0],r=t[1],i=t[2],a;return a=i<.5?(1+r)*i:i+r-i*r,r=2*(a-i)/a,[n,r,a,t[3]]},_hslaToRGBA(t){let n=t[0]*6,r=t[1],i=t[2],a=[];if(r===0)a=[i,i,i,t[3]];else{let o;o=i<.5?(1+r)*i:i+r-i*r;let s=2*i-o,c=(t,n,r)=>(t<0?t+=6:t>=6&&(t-=6),t<1?n+(r-n)*t:t<3?r:t<4?n+(r-n)*(4-t):n);a=[c(n+2,s,o),c(n,s,o),c(n-2,s,o),t[3]]}return a},_rgbaToHSBA(t){let n=t[0],r=t[1],i=t[2],a=Math.max(n,r,i),o=a-Math.min(n,r,i),s,c;return o===0?(s=0,c=0):(c=o/a,n===a?s=(r-i)/o:r===a?s=2+(i-n)/o:i===a&&(s=4+(n-r)/o),s<0?s+=6:s>=6&&(s-=6)),[s/6,c,a,t[3]]},_rgbaToHSLA(t){let n=t[0],r=t[1],i=t[2],a=Math.max(n,r,i),o=Math.min(n,r,i),s=a+o,c=a-o,l,u;return c===0?(l=0,u=0):(u=s<1?c/s:c/(2-s),n===a?l=(r-i)/c:r===a?l=2+(i-n)/c:i===a&&(l=4+(n-r)/c),l<0?l+=6:l>=6&&(l-=6)),[l/6,u,s/2,t[3]]}};var El=_l.ColorConversion;function Dl(t,n){let r,i=[{h:0,s:0,b:.8275,name:`gray`},{h:0,s:0,b:.8627,name:`gray`},{h:0,s:0,b:.7529,name:`gray`},{h:.0167,s:.1176,b:1,name:`light pink`}],a=[{h:0,s:0,b:0,name:`black`},{h:0,s:0,b:.5,name:`gray`},{h:0,s:0,b:1,name:`white`},{h:0,s:.5,b:.5,name:`dark maroon`},{h:0,s:.5,b:1,name:`salmon pink`},{h:0,s:1,b:0,name:`black`},{h:0,s:1,b:.5,name:`dark red`},{h:0,s:1,b:1,name:`red`},{h:5,s:0,b:1,name:`very light peach`},{h:5,s:.5,b:.5,name:`brown`},{h:5,s:.5,b:1,name:`peach`},{h:5,s:1,b:.5,name:`brick red`},{h:5,s:1,b:1,name:`crimson`},{h:10,s:0,b:1,name:`light peach`},{h:10,s:.5,b:.5,name:`brown`},{h:10,s:.5,b:1,name:`light orange`},{h:10,s:1,b:.5,name:`brown`},{h:10,s:1,b:1,name:`orange`},{h:15,s:0,b:1,name:`very light yellow`},{h:15,s:.5,b:.5,name:`olive green`},{h:15,s:.5,b:1,name:`light yellow`},{h:15,s:1,b:0,name:`dark olive green`},{h:15,s:1,b:.5,name:`olive green`},{h:15,s:1,b:1,name:`yellow`},{h:20,s:0,b:1,name:`very light yellow`},{h:20,s:.5,b:.5,name:`olive green`},{h:20,s:.5,b:1,name:`light yellow green`},{h:20,s:1,b:0,name:`dark olive green`},{h:20,s:1,b:.5,name:`dark yellow green`},{h:20,s:1,b:1,name:`yellow green`},{h:25,s:.5,b:.5,name:`dark yellow green`},{h:25,s:.5,b:1,name:`light green`},{h:25,s:1,b:.5,name:`dark green`},{h:25,s:1,b:1,name:`green`},{h:30,s:.5,b:1,name:`light green`},{h:30,s:1,b:.5,name:`dark green`},{h:30,s:1,b:1,name:`green`},{h:35,s:0,b:.5,name:`light green`},{h:35,s:0,b:1,name:`very light green`},{h:35,s:.5,b:.5,name:`dark green`},{h:35,s:.5,b:1,name:`light green`},{h:35,s:1,b:0,name:`very dark green`},{h:35,s:1,b:.5,name:`dark green`},{h:35,s:1,b:1,name:`green`},{h:40,s:0,b:1,name:`very light green`},{h:40,s:.5,b:.5,name:`dark green`},{h:40,s:.5,b:1,name:`light green`},{h:40,s:1,b:.5,name:`dark green`},{h:40,s:1,b:1,name:`green`},{h:45,s:.5,b:1,name:`light turquoise`},{h:45,s:1,b:.5,name:`dark turquoise`},{h:45,s:1,b:1,name:`turquoise`},{h:50,s:0,b:1,name:`light sky blue`},{h:50,s:.5,b:.5,name:`dark cyan`},{h:50,s:.5,b:1,name:`light cyan`},{h:50,s:1,b:.5,name:`dark cyan`},{h:50,s:1,b:1,name:`cyan`},{h:55,s:0,b:1,name:`light sky blue`},{h:55,s:.5,b:1,name:`light sky blue`},{h:55,s:1,b:.5,name:`dark blue`},{h:55,s:1,b:1,name:`sky blue`},{h:60,s:0,b:.5,name:`gray`},{h:60,s:0,b:1,name:`very light blue`},{h:60,s:.5,b:.5,name:`blue`},{h:60,s:.5,b:1,name:`light blue`},{h:60,s:1,b:.5,name:`navy blue`},{h:60,s:1,b:1,name:`blue`},{h:65,s:0,b:1,name:`lavender`},{h:65,s:.5,b:.5,name:`navy blue`},{h:65,s:.5,b:1,name:`light purple`},{h:65,s:1,b:.5,name:`dark navy blue`},{h:65,s:1,b:1,name:`blue`},{h:70,s:0,b:1,name:`lavender`},{h:70,s:.5,b:.5,name:`navy blue`},{h:70,s:.5,b:1,name:`lavender blue`},{h:70,s:1,b:.5,name:`dark navy blue`},{h:70,s:1,b:1,name:`blue`},{h:75,s:.5,b:1,name:`lavender`},{h:75,s:1,b:.5,name:`dark purple`},{h:75,s:1,b:1,name:`purple`},{h:80,s:.5,b:1,name:`pinkish purple`},{h:80,s:1,b:.5,name:`dark purple`},{h:80,s:1,b:1,name:`purple`},{h:85,s:0,b:1,name:`light pink`},{h:85,s:.5,b:.5,name:`purple`},{h:85,s:.5,b:1,name:`light fuchsia`},{h:85,s:1,b:.5,name:`dark fuchsia`},{h:85,s:1,b:1,name:`fuchsia`},{h:90,s:.5,b:.5,name:`dark fuchsia`},{h:90,s:.5,b:1,name:`hot pink`},{h:90,s:1,b:.5,name:`dark fuchsia`},{h:90,s:1,b:1,name:`fuchsia`},{h:95,s:0,b:1,name:`pink`},{h:95,s:.5,b:1,name:`light pink`},{h:95,s:1,b:.5,name:`dark magenta`},{h:95,s:1,b:1,name:`magenta`}];function o(t){let n;if(t[0]!==0){t[0]=Math.round(t[0]*100);let n=t[0].toString().split(``),r=n.length-1;n[r]=parseInt(n[r]),n[r]<2.5?n[r]=0:n[r]>=2.5&&n[r]<7.5&&(n[r]=5),n.length===2?(n[0]=parseInt(n[0]),n[r]>=7.5&&(n[r]=0,n[0]+=1),t[0]=n[0]*10+n[1]):t[0]=n[r]>=7.5?10:n[r]}t[2]/=255;for(let n=t.length-1;n>=1;n--)t[n]<=.25?t[n]=0:t[n]>.25&&t[n]<.75?t[n]=.5:t[n]=1;if(t[0]===0&&t[1]===0&&t[2]===1){for(let t=2;t>=0;t--)r[t]=Math.round(r[t]*1e4)/1e4;for(let t=0;t<i.length;t++)if(i[t].h===r[0]&&i[t].s===r[1]&&i[t].b===r[2]){n=i[t].name;break}else n=`white`}else for(let r=0;r<a.length;r++)if(a[r].h===t[0]&&a[r].s===t[1]&&a[r].b===t[2]){n=a[r].name;break}return n}n._rgbColorName=function(t){let n=El._rgbaToHSBA(t);return r=n,o([n[0],n[1],n[2]])}}typeof p5<`u`&&Dl(p5,p5.prototype);function Ol(t){t.registerAddon(Sl),t.registerAddon(Cl),t.registerAddon(wl),t.registerAddon(Tl),t.registerAddon(Dl)}function kl(t){t.registerAddon(Yi),t.registerAddon(Wi),t.registerAddon(ho)}const Al={ReferenceError:[{msg:`{{}} is not defined`,type:`NOTDEFINED`,browser:`all`},{msg:`Can't find variable: {{}}`,type:`NOTDEFINED`,browser:`Safari`},{msg:`Cannot access '{{.}}' before initialization`,type:`CANNOTACCESS`,browser:`Chrome`},{msg:`can't access lexical declaration '{{.}}' before initialization`,type:`CANNOTACCESS`,browser:`Firefox`}],SyntaxError:[{msg:`illegal character`,type:`INVALIDTOKEN`,browser:`Firefox`},{msg:`Invalid character`,type:`INVALIDTOKEN`,browser:`Safari`},{msg:`Invalid or unexpected token`,type:`INVALIDTOKEN`,browser:`Chrome`},{msg:`Unexpected token '{{.}}'`,type:`UNEXPECTEDTOKEN`,browser:`Chrome`},{msg:`expected {{.}}, got '{{.}}'`,type:`UNEXPECTEDTOKEN`,browser:`Chrome`},{msg:`Identifier '{{.}}' has already been declared`,type:`REDECLAREDVARIABLE`,browser:`Chrome`},{msg:`redeclaration of {} {{.}}`,type:`REDECLAREDVARIABLE`,browser:`Firefox`},{msg:`Missing initializer in const declaration`,type:`MISSINGINITIALIZER`,browser:`Chrome`},{msg:`missing = in const declaration`,type:`MISSINGINITIALIZER`,browser:`Firefox`},{msg:`Illegal return statement`,type:`BADRETURNORYIELD`,browser:`Chrome`},{msg:`return not in function`,type:`BADRETURNORYIELD`,browser:`Firefox`}],TypeError:[{msg:`{{.}} is not a function`,type:`NOTFUNC`,browser:`all`},{msg:`Cannot read {{.}} null`,type:`READNULL`,browser:`Chrome`},{msg:`{{.}} is null`,type:`READNULL`,browser:`Firefox`},{msg:`Cannot read {{.}} undefined`,type:`READUDEFINED`,browser:`Chrome`},{msg:`{{.}} is undefined`,type:`READUDEFINED`,browser:`Firefox`},{msg:`Assignment to constant variable`,type:`CONSTASSIGN`,browser:`Chrome`},{msg:`invalid assignment to const '{{.}}'`,type:`CONSTASSIGN`,browser:`Firefox`}]},jl=[`setup`,`draw`,`deviceMoved`,`deviceTurned`,`deviceShaken`,`doubleClicked`,`mousePressed`,`mouseReleased`,`mouseMoved`,`mouseDragged`,`mouseClicked`,`mouseWheel`,`touchStarted`,`touchMoved`,`touchEnded`,`keyPressed`,`keyReleased`,`keyTyped`,`windowResized`];function Ml(){let t=/(^|@)\S+:\d+/,n=/^\s*at .*(\S+:\d+|\(native\))/m,r=/^(eval@)?(\[native code])?$/;return{parse:function(t){if(t.stacktrace!==void 0||t[`opera#sourceloc`]!==void 0)return this.parseOpera(t);if(t.stack&&t.stack.match(n))return this.parseV8OrIE(t);if(t.stack)return this.parseFFOrSafari(t)},extractLocation:function(t){if(t.indexOf(`:`)===-1)return[t];let n=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(t.replace(/[()]/g,``));return[n[1],n[2]||void 0,n[3]||void 0]},parseV8OrIE:function(t){return t.stack.split(`
`).filter(function(t){return!!t.match(n)},this).map(function(t){t.indexOf(`(eval `)>-1&&(t=t.replace(/eval code/g,`eval`).replace(/(\(eval at [^()]*)|(\),.*$)/g,``));let n=t.replace(/^\s+/,``).replace(/\(eval code/g,`(`),r=n.match(/ (\((.+):(\d+):(\d+)\)$)/);n=r?n.replace(r[0],``):n;let i=n.split(/\s+/).slice(1),a=this.extractLocation(r?r[1]:i.pop());return{functionName:i.join(` `)||void 0,fileName:[`eval`,`<anonymous>`].indexOf(a[0])>-1?void 0:a[0],lineNumber:a[1],columnNumber:a[2],source:t}},this)},parseFFOrSafari:function(t){return t.stack.split(`
`).filter(function(t){return!t.match(r)},this).map(function(t){if(t.indexOf(` > eval`)>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,`:$1`)),t.indexOf(`@`)===-1&&t.indexOf(`:`)===-1)return{functionName:t};{let n=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=t.match(n),i=r&&r[1]?r[1]:void 0,a=this.extractLocation(t.replace(n,``));return{functionName:i,fileName:a[0],lineNumber:a[1],columnNumber:a[2],source:t}}},this)},parseOpera:function(t){return!t.stacktrace||t.message.indexOf(`
`)>-1&&t.message.split(`
`).length>t.stacktrace.split(`
`).length?this.parseOpera9(t):t.stack?this.parseOpera11(t):this.parseOpera10(t)},parseOpera9:function(t){let n=/Line (\d+).*script (?:in )?(\S+)/i,r=t.message.split(`
`),i=[];for(let t=2,a=r.length;t<a;t+=2){let a=n.exec(r[t]);a&&i.push({fileName:a[2],lineNumber:a[1],source:r[t]})}return i},parseOpera10:function(t){let n=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=t.stacktrace.split(`
`),i=[];for(let t=0,a=r.length;t<a;t+=2){let a=n.exec(r[t]);a&&i.push({functionName:a[3]||void 0,fileName:a[2],lineNumber:a[1],source:r[t]})}return i},parseOpera11:function(n){return n.stack.split(`
`).filter(function(n){return!!n.match(t)&&!n.match(/^Error created at/)},this).map(function(t){let n=t.split(`@`),r=this.extractLocation(n.pop()),i=n.shift()||``,a=i.replace(/<anonymous function(: (\w+))?>/,`$2`).replace(/\([^)]*\)/g,``)||void 0,o;return i.match(/\(([^)]*)\)/)&&(o=i.replace(/^[^(]+\(([^)]*)\)$/,`$1`)),{functionName:a,args:o===void 0||o===`[arguments not available]`?void 0:o.split(`,`),fileName:r[0],lineNumber:r[1],columnNumber:r[2],source:t}},this)}}}const Nl=new Ml,Pl=(t,n)=>{if(!n)return[!1,null];n.forEach(t=>{t.functionName=t.functionName||``});let r=!1,i,a;i=Nl.parse(Error())[0].fileName;for(let t=n.length-1;t>=0;t--){let o=n[t].functionName.split(`.`);if(jl.includes(o[o.length-1])){if(a=n.slice(0,t+1),n[0].fileName===i){r=!0;break}break}}if(a||=n,r){if(a=a.map((t,n)=>(t.frameIndex=n,t)).filter(t=>t.fileName!==i),a.length===0)return[!0,null];let t;if(a[0].fileName&&a[0].lineNumber&&a[0].columnNumber&&(t={location:`${a[0].fileName}:${a[0].lineNumber}:${a[0].columnNumber}`,file:a[0].fileName.split(`/`).slice(-1),line:a[0].lineNumber},p5._fesLogCache[t.location]))return[!0,null]}return[r,a]};function Fl(t){if(t.length>1){let n=``;t.forEach((t,r)=>{let i=`${t.fileName}:${t.lineNumber}:${t.columnNumber}`,a;a=r===0?R.log`┌[${i}] \n\t Error at line ${t.lineNumber} in ${t.functionName}()\n`:R.log`└[${i}] \n\t Called from line ${t.lineNumber} in ${t.functionName}()\n`,n+=a}),R.log`${n}`({prefix:!1})}}function Il(t,n=!1){if(n)return`[${t[0].fileName.split(`/`).slice(-1)}, line ${t[0].lineNumber}]`;if(t.length>1){let n=``;return t.forEach((t,r)=>{let i=`${t.fileName}:${t.lineNumber}:${t.columnNumber}`,a;a=r===0?`┌[${i}] \n\t Error at line ${t.lineNumber} in ${t.functionName}()\n`:`└[${i}] \n\t Called from line ${t.lineNumber} in ${t.functionName}()\n`,n+=a}),n||null}}function Ll(t,n,r){let i=null,a=()=>{let t={};i=(n=>Object.getOwnPropertyNames(n).filter(n=>n[0]===`_`||n in t?!1:(t[n]=!0,!0)).map(t=>{let r;return r=typeof n[t]==`function`?`function`:t===t.toUpperCase()?`constant`:`variable`,{name:t,type:r}}))(n),i.sort((t,n)=>n.name.length-t.name.length)},o=(t,n)=>{let r=``;if(n==null||n.substring(0,4)===`load`)r=t;else{let i=n.split(`.`),a=i.length>1?`${i[0]}.${i[1]}`:`p5`,o=i.length===1?n:i.slice(2).join(`/`);r=o.startsWith(`p5.`)?R.log`${t} (https://p5js.org/reference/${a}.${o})`:R.log`${t} (https://p5js.org/reference/${a}/${o})`}return r};t._report=(t,n)=>{t=o(t,n),R.log`${t}`()},t._friendlyError=function(n,r){t.disableFriendlyErrors||t._report(n,r)},t.isPreloadSupported=function(){return!1};let s=n=>{if(t.disableFriendlyErrors)return;n=n instanceof t?n:window;let r=jl;n.preload&&!t.isPreloadSupported()&&R.log`The preload() function has been removed in p5.js 2.0. Please load assets in setup() using async / await keywords or callbacks instead. See https://github.com/processing/p5.js-compatibility for more information about 2.0 and compatibility, or https://dev.to/limzykenneth/asynchronous-p5js-20-458f for more information about promises and async/await.`();let i={};r.forEach(t=>{i[t.toLowerCase()]=t});for(let t of Object.keys(n)){let r=t.toLowerCase();i.hasOwnProperty(r)&&!n[i[r]]&&typeof n[t]==`function`&&R.log`It seems that you may have accidentally written ${t} instead of ${i[r]}. Please correct it if it's not intentional.`({reference:i[r]})}},c=(t,n)=>{let r={},a=999999;if(i.forEach(n=>{let i=Rl(t,n.name);r[i]?r[i].push(n):r[i]=[n],i<a&&(a=i)}),a>Math.min(2,t.length))return!1;let s=r[a].filter(n=>n.name!==t);if(s.length!==0){let r=Nl.parse(n),i;r&&r[0]&&r[0].fileName&&r[0].lineNumber&&r[0].columnNumber&&(i={location:`${r[0].fileName}:${r[0].lineNumber}:${r[0].columnNumber}`,file:r[0].fileName.split(`/`).slice(-1),line:r[0].lineNumber});let a;if(s.length===1)a=R.log`${i?R.log`[${i.file}, line ${i.line}]`:``} It seems that you may have accidentally written "${t}" instead of "${s[0].name}". Please correct it to ${s[0].name} if you wish to use the ${s[0].type} from p5.js.`;else{let n=s.map(t=>{let n=`▶️ `+t.name+(t.type===`function`?`()`:``);return o(n,t.name)}).join(`
`);a=R.log`${i?R.log`[${i.file}, line ${i.line}]`:``} It seems that you may have accidentally written "${t}".\nYou may have meant one of the following: \n${n}`}return a({reference:s.length===1?s[0].name:void 0}),!0}return!1},l=t=>i.some(n=>{if(t.message&&t.message.match(`\\W?${n.name}\\W`)!==null){let t=n.type===`function`?`${n.name}()`:n.name;return R.log`Did you just try to use p5.js's ${t} ${n.type}? If so, you may want to move it into your sketch's setup() function.\n\nFor more details, see: ${`https://github.com/processing/p5.js/wiki/p5.js-overview#why-cant-i-assign-variables-using-p5-functions-and-variables-before-setup`}`(),!0}}),u=n=>{if(t.disableFriendlyErrors)return;i||a();let r;if(n instanceof Error)r=n;else if(n instanceof ErrorEvent)r=n.error;else if(n instanceof PromiseRejectionEvent&&(r=n.reason,!(r instanceof Error)))return;if(!r)return;let o=Nl.parse(r),[s,u]=Pl(r,o);if(s)return;let d=Al[r.name];if(!d)return;let f;for(let t of d){let n=t.msg;n=n.replace(/* @__PURE__ */ RegExp(`{{}}`,`g`),`([a-zA-Z0-9_]+)`),n=n.replace(/* @__PURE__ */ RegExp(`{{.}}`,`g`),`(.+)`),n=n.replace(/* @__PURE__ */ RegExp(`{}`,`g`),`(?:[a-zA-Z0-9_]+)`);let i=r.message.match(n);if(i){f=Object.assign({},t),f.match=i;break}}if(!f)return;let p=``;switch(o&&o[0].fileName&&o[0].lineNumber&&o[0].columnNumber&&(p=Il(o,!0)),r.name){case`SyntaxError`:switch(f.type){case`INVALIDTOKEN`:R.log`Syntax Error - Found a symbol that JavaScript doesn't recognize or didn't expect at its place.\n\n+ More info: ${`https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Illegal_character#What_went_wrong`}`();break;case`UNEXPECTEDTOKEN`:R.log`Syntax Error - Symbol present at a place that wasn't expected.\nUsually this is due to a typo. Check the line number in the error for anything missing/extra.\n\n+ More info: ${`https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Unexpected_token#What_went_wrong`}`();break;case`REDECLAREDVARIABLE`:{let t=f.match[1];R.log`Syntax Error - "${t}" is being redeclared. JavaScript doesn't allow declaring a variable more than once. Check the line number in error for redeclaration of the variable.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Redeclared_parameter#what_went_wrong`}`();break}case`MISSINGINITIALIZER`:R.log`Syntax Error - A const variable is declared but not initialized. In JavaScript, an initializer for a const is required. A value must be specified in the same statement in which the variable is declared. Check the line number in the error and assign the const variable a value.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_initializer_in_const#what_went_wrong`}`();break;case`BADRETURNORYIELD`:R.log`Syntax Error - return lies outside of a function. Make sure you’re not missing any brackets, so that return lies inside a function.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Bad_return_or_yield#what_went_wrong`}`()}break;case`ReferenceError`:switch(f.type){case`NOTDEFINED`:{let t=f.match[1];if(t&&c(t,r)||l(n))break;if(R.log`${p} "${t}" is not defined in the current scope. If you have defined it in your code, you should check its scope, spelling, and letter-casing (JavaScript is case-sensitive).\n\n+ More info: ${`https://p5js.org/examples/data-variable-scope.html`}`(),u){let t=Il(u);t&&R.log`${t}`({prefix:!1})}break}case`CANNOTACCESS`:{let t=f.match[1];R.log`${p} "${t} is used before declaration. Make sure you have declared the variable before using it.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_lexical_declaration_before_init#what_went_wrong`}`(),u&&Fl(u);break}}break;case`TypeError`:switch(f.type){case`NOTFUNC`:{let t=f.match[1].split(`.`),n=`https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/Not_a_function#What_went_wrong`,r={symbol:t[t.length-1],obj:t.slice(0,t.length-1).join(`.`)};t.length>1?R.log`${p} "${r.symbol}" could not be called as a function.\nVerify whether "${r.obj}" has "${r.symbol}" in it and check the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: ${n}`():R.log`${p} "${r.symbol}" could not be called as a function.\nCheck the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: ${n}`(),u&&Fl(u);break}case`READNULL`:R.log`${p} The property of null can't be read. In javascript the value null indicates that an object has no value.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property#what_went_wrong`}`(),u&&Fl(u);break;case`READUDEFINED`:R.log`${p} Cannot read property of undefined. Check the line number in error and make sure the variable which is being operated is not undefined.\n\n + More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_access_property#what_went_wrong`}`(),u&&Fl(u);break;case`CONSTASSIGN`:R.log`${p} A const variable is being re-assigned. In javascript, re-assigning a value to a constant is not allowed. If you want to re-assign new values to a variable, make sure it is declared as var or let.\n\n+ More info: ${`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_const_assignment#what_went_wrong`}`(),u&&Fl(u)}}};t._checkForUserDefinedFunctions=s,t._fesLogCache={},r.presetup=function(){s(),window.addEventListener(`error`,u,!1),window.addEventListener(`unhandledrejection`,u,!1)}}typeof p5<`u`&&p5.registerAddon(Ll);function Rl(t,n){let r=t.length,i=n.length;if(r===0)return n;if(i===0)return t;let a=[],o=[];for(let t=0;t<i+1;t++)o[t]=t;a=o;for(let s=1;s<r+1;s++){o=[];for(let r=0;r<i+1;r++)if(r===0)o[r]=s;else{let i=t[s-1],c=n[r-1],l=999999,u=i.toLowerCase()===c.toLowerCase()?0:1;l=l>u+a[r-1]?u+a[r-1]:l,l=l>1+o[r-1]?1+o[r-1]:l,l=l>1+a[r]?1+a[r]:l,o[r]=l}a=o}return o[i]}function zl(t,n=`|`){return t.map(t=>tu(t)).join(n)}function Bl(t,n){return typeof n==`bigint`?n.toString():n}var Vl=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Hl(t){return new Vl(t)}function Ul(t){let n=+!!t.startsWith(`^`),r=t.endsWith(`$`)?t.length-1:t.length;return t.slice(n,r)}function Wl(t,n){let r=t/n,i=Math.round(r),a=4*2**-52*Math.max(Math.abs(r),1);return Math.abs(r-i)<a?0:r-i}function Gl(t,n,r){Object.defineProperty(t,n,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kl(t){let n=Object.getOwnPropertyDescriptor(t,`shape`);return n?.get?n.get.raw:n?.value}function ql(t){return JSON.stringify(t)}const Jl=`captureStackTrace`in Error?Error.captureStackTrace:(...t)=>{};function Yl(t){return typeof t==`object`&&!!t&&!Array.isArray(t)}function Xl(t){if(Yl(t)===!1)return!1;let n=t.constructor;if(n===void 0||typeof n!=`function`)return!0;let r=n.prototype;return Yl(r)!==!1&&Object.prototype.hasOwnProperty.call(r,`isPrototypeOf`)!==!1}function Zl(t){return Xl(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Ql(t){return t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function $l(t,n,r){let i=new t._zod.constr(n??t._zod.def);return(!n||r?.parent)&&(i._zod.parent=t),i}function eu(t){let n=t;if(!n)return{};if(typeof n==`string`)return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");n.error=n.message}return delete n.message,typeof n.error==`string`?{...n,error:()=>n.error}:n}function tu(t){return typeof t==`bigint`?t.toString()+`n`:typeof t==`string`?`"${t}"`:`${t}`}function nu(t){return Object.keys(t).filter(n=>t[n]._zod.optin!==void 0&&t[n]._zod.optout===`optional`)}const ru={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function iu(t,n=0){if(t.aborted===!0)return!0;for(let r=n;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function au(t,n=0){if(t.aborted===!0)return!0;for(let r=n;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function ou(t,n){return n.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(t),n})}function su(t){return typeof t==`string`?t:t?.message}function cu(t){let n=[];for(let r of t??[]){let t=r._zod.def;if(!/_(length|size)$|_equals$/.test(t.check))break;let i=t.maximum??t.length??t.size;i>=0&&n.push([i,r])}return n}function lu(t,n,r){var i;for(let a=n;a<t.length;a++)(i=t[a]).schema??(i.schema=r)}function uu(t,n,r){var i;let a=t.inst?._zod?.traits;a?.has(`$ZodType`)&&(a.has(`$ZodCheck`)?(i=t).schema??(i.schema=t.inst):t.schema=t.inst);let o=t.schema===t.inst?void 0:t.schema?._zod.def?.error,s=t.message?t.message:su(t.inst?._zod.def?.error?.(t))??su(o?.(t))??su(n?.error?.(t))??su(r.customError?.(t))??su(r.localeError?.(t))??`Invalid input`,c={};for(let n of Object.keys(t))n!==`inst`&&n!==`schema`&&n!==`continue`&&n!==`input`&&n!==`__proto__`&&(c[n]=t[n]);return c.path??=[],c.message=s,n?.reportInput&&(c.input=t.input),c}const du=/[\uD800-\uDBFF]/;function fu(t){let n=t.length;if(!du.test(t))return n;let r=n;for(let i=0;i<n-1;i++)(t.charCodeAt(i)&64512)==55296&&(t.charCodeAt(i+1)&64512)==56320&&(r--,i++);return r}function pu(t){let n=typeof t;switch(n){case`number`:return Number.isNaN(t)?`nan`:`number`;case`object`:{if(t===null)return`null`;if(Array.isArray(t))return`array`;let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&`constructor`in n&&n.constructor)return n.constructor.name}}return n}function mu(...t){let[n,r,i]=t;return typeof n==`string`?{message:n,code:`custom`,input:r,inst:i}:{...n}}function hu(t,n){for(let r in n){let i=Object.getOwnPropertyDescriptor(n,r);i.get?Object.defineProperty(t,r,{...i,enumerable:!1}):vu(t,r,i.value)}}function gu(t,n,r,i=!0){return Object.defineProperty(t,n,{configurable:!0,writable:!0,enumerable:i,value:r}),r}function _u(t,n,r){return gu(t,n,r,!1)}function vu(t,n,r){Object.defineProperty(t,n,{configurable:!0,get(){return this==null?r:gu(this,n,r.bind(this))},set(t){gu(this,n,t)}})}function yu(t,n){let r=Object.getPrototypeOf(t);return n in r?void 0:r}let bu,xu=!1;const Su={configurable:!0,get(){xu=!0}};function Cu(t,n,r){let i=Object.getPrototypeOf(t._zod);n in i&&bu!==t._zod?bu=void 0:(bu=t._zod,Object.defineProperty(i,n,{configurable:!0,get(){Object.defineProperty(this,n,Su);let t=xu;xu=!1;try{let i=r(this);return xu?delete this[n]:Object.defineProperty(this,n,{configurable:!0,writable:!0,value:i}),xu||=t,i}catch(r){throw delete this[n],xu||=t,r}},set(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:t})}}))}function wu(t,n,r,i){let a=yu(t,n);a&&Object.defineProperty(a,n,{configurable:!0,get(){let t={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,n,t),t.value=r(this),Object.defineProperty(this,n,t),t.value},set(t){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:i,value:t})}})}var Tu;const Eu={value:void 0,enumerable:!1};let Du=`captureStackTrace`in Error?Error:null;function Ou(t){let n=Du;if(n){let r=n.stackTraceLimit;if(typeof r==`number`){try{n.stackTraceLimit=0}catch{return Du=null,new t}try{return new t}finally{n.stackTraceLimit=r}}}return new t}/* @__NO_SIDE_EFFECTS__ */
function ku(t,n,r,i){let a={};function o(t){this.def=t,this.constr=f,this.traits=/* @__PURE__ */ new Set}o.prototype=a;let s=r,c=s&&/* @__PURE__ */ new WeakSet;function l(r,i){if(!r._zod){Eu.value=new o(i);try{Object.defineProperty(r,"_zod",Eu)}finally{Eu.value=void 0}}else if(r._zod.traits.has(t))return;if(r._zod.traits.add(t),n(r,i),c){let t=Object.getPrototypeOf(r),n=r._zod.constr.prototype,i=t;for(;i&&i!==n;)i=Object.getPrototypeOf(i);let a=i??t;c.has(a)||(c.add(a),hu(a,s))}let a=f.prototype;for(let t in a)Object.prototype.hasOwnProperty.call(a,t)&&(t in r||(r[t]=a[t].bind(r)))}let u=i?.Parent??Object;class d extends u{}Object.defineProperty(d,"name",{value:t});function f(t){let n=i?.Parent?Ou(d):this;l(n,t);let r=n._zod.deferred;if(r){for(let t of r)t();n._zod.deferred=void 0}let a=globalThis.__zod_globalConfig?.postProcessor;return a&&a(n),n}return Object.defineProperty(f,"init",{value:l}),Object.defineProperty(f,Symbol.hasInstance,{value:n=>i?.Parent&&n instanceof i.Parent?!0:n?._zod?.traits?.has(t)}),Object.defineProperty(f,"name",{value:t}),f}var Au=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(Tu=globalThis).__zod_globalConfig??(Tu.__zod_globalConfig={});const ju=globalThis.__zod_globalConfig;function Mu(t){return t&&Object.assign(ju,t),ju}var Nu=class{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{--this.indent}}write(t){if(typeof t==`function`){t(this,{execution:`sync`}),t(this,{execution:`async`});return}let n=t.split(`
`).filter(t=>t),r=Math.min(...n.map(t=>t.length-t.trimStart().length)),i=n.map(t=>t.slice(r)).map(t=>` `.repeat(this.indent*2)+t);for(let t of i)this.content.push(t)}compile(){let t=Function,n=this?.content??[``];return new t(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${n.join(`
`)}\n};`)(...Object.values(this.closed))}};function Pu(t){return typeof t==`object`&&!!t}const Fu=/*@__PURE__*/ new WeakMap;function Iu(t,n,r){let i=Fu.get(t);if(i!==void 0)return i?2:0;if(n.has(t))return 2;n.add(t);let a=0,o=t=>{if(a!==2&&t?._zod){let i=Iu(t,n,r);i>a&&(a=i)}},s=(t,i)=>{let a=0;for(let o of Reflect.ownKeys(t)){let s=Object.getOwnPropertyDescriptor(t,o);if(i&&!s.enumerable)continue;let c=s.get?1:s.value?._zod?Iu(s.value,n,r):0;c>a&&(a=c)}return a},c=t=>{t>a&&(a=t)},l=t._zod.def;switch(l.type){case`object`:{let t=Kl(l);c(t?s(t,!0):1),o(l.catchall);break}case`array`:o(l.element);break;case`tuple`:for(let t of l.items)o(t);o(l.rest);break;case`record`:case`map`:o(l.keyType),o(l.valueType);break;case`set`:o(l.valueType);break;case`union`:for(let t of l.options)o(t);break;case`intersection`:o(l.left),o(l.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:o(l.innerType);break;case`pipe`:o(l.in),o(l.out);break;case`function`:o(l.input),o(l.output);break;case`lazy`:{let i=l._cachedInner??(r?t._zod.innerType:void 0);c(i?Iu(i,n,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let t in l){let n=Object.getOwnPropertyDescriptor(l,t);if(!n||n.get)continue;let r=n.value;if(r&&typeof r==`object`){if(r._zod)o(r);else if(Array.isArray(r))for(let t of r)o(t)}}}return n.delete(t),Lu(t,a)}function Lu(t,n){return n!==1&&Fu.set(t,n===2),n}function Ru(t){return Iu(t,/* @__PURE__ */ new Set,!0)!==0}function zu(t,n){let r=t[`~memo`]?.backEdges;return r!==void 0&&Pu(n)&&r.has(n)}const Bu=/^https?$/,Vu=/^\d(?:[ -]?\d){11,18}$/,Hu=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Uu=/^[\s\S]{0,}$/,Wu=/^-?\d+(?:\.\d+)?$/,Gu=/^(?:true|false)$/i,Ku=/*@__PURE__*/ ku(`$ZodCheck`,(t,n)=>{var r;t._zod??={},t._zod.def=n,(r=t._zod).onattach??(r.onattach=[])}),qu=/*@__PURE__*/ ku(`$ZodCheckNumberFormat`,(t,n)=>{Ku.init(t,n),n.format=n.format||`float64`;let r=n.format?.includes(`int`),i=r?`int`:`number`,[a,o]=ru[n.format];t._zod.check=s=>{let c=s.value;if(r){if(!Number.isInteger(c)){s.issues.push({expected:i,format:n.format,code:`invalid_type`,continue:!1,input:c,inst:t});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:t,origin:i,inclusive:!0,continue:!n.abort}):s.issues.push({input:c,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:t,origin:i,inclusive:!0,continue:!n.abort});return}}c<a&&s.issues.push({origin:`number`,input:c,code:`too_small`,minimum:a,inclusive:!0,inst:t,continue:!n.abort}),c>o&&s.issues.push({origin:`number`,input:c,code:`too_big`,maximum:o,inclusive:!0,inst:t,continue:!n.abort})}});function Ju(){let t=this._zod;return t.message??=JSON.stringify(t.def,Bl,2),t.message}function Yu(t){this._zod.message=t}const Xu={get:Ju,set:Yu,enumerable:!0,configurable:!0},Zu={value:void 0,enumerable:!1},Qu=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),$u=/* @__PURE__ */ ku(`$ZodError`,(t,n)=>{t.name=`$ZodError`,Zu.value=n,Object.defineProperty(t,"issues",Zu),Zu.value=void 0,Object.defineProperty(t,"message",Xu);let r=Object.getPrototypeOf(t);Qu.has(r)||(Qu.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let t=()=>this.message;return Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0}),t},set(t){Object.defineProperty(this,"toString",{value:t,configurable:!0,writable:!0})}}))},void 0,{Parent:Error}),ed=/* @__PURE__*/ (t=>{let n=(r,i,a,o)=>{let s=a?{...a,async:!1}:{async:!1},c=r._zod.run({value:i,issues:[]},s);if(c instanceof Promise)throw new Au;if(c.issues.length){let r=new((o?.Err)??t)(c.issues.map(t=>uu(t,s,Mu())));throw Jl(r,o?.callee??n),r}return c.value};return n})($u),td=/* @__PURE__*/ (t=>{let n=async(r,i,a,o)=>{let s=a?{...a,async:!0}:{async:!0},c=r._zod.run({value:i,issues:[]},s);if(c instanceof Promise&&(c=await c),c.issues.length){let r=new((o?.Err)??t)(c.issues.map(t=>uu(t,s,Mu())));throw Jl(r,o?.callee??n),r}return c.value};return n})($u),nd=/* @__PURE__*/ (t=>(n,r,i)=>{let a=i?{...i,async:!1}:{async:!1},o=n._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new Au;return o.issues.length?rd(t,o.issues,a):{success:!0,data:o.value}})($u);function rd(t,n,r){let i;return{success:!1,get error(){return i||(i=new t(n.map(t=>uu(t,r,Mu()))),n=void 0,r=void 0),i},set error(t){i=t,n=void 0,r=void 0}}}const id=/* @__PURE__*/ (t=>async(n,r,i)=>{let a=i?{...i,async:!0}:{async:!0},o=n._zod.run({value:r,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?rd(t,o.issues,a):{success:!0,data:o.value}})($u),ad=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),od=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),sd=((t,n,r)=>{let i=t._zod.bag.validator;if(i!==void 0){if(i(n)!==ad)return!0;if(i.definite===!0&&r===void 0)return!1}return cd(t,n,r)});function cd(t,n,r){let i=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},a=t._zod.bag.fallbackRun,o;if(a?(i[od]=!0,o=a({value:n,issues:[]},i)):o=t._zod.run({value:n,issues:[]},i),o instanceof Promise)throw new Au;return o.issues.length===0}const ld={major:4,minor:6,patch:6},ud=/*@__PURE__*/ ku(`$ZodType`,(t,n)=>{var r;t??={},t._zod.def=n,t._zod.bag=t._zod.bag||{},t._zod.version=ld;let i=t._zod.def.checks,a=t._zod.traits.has(`$ZodCheck`)?[t,...i??[]]:i?.length?[...i]:[];for(let n of a)for(let r of n._zod.onattach)r(t);if(a.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let n=(n,r,i)=>{if(n.memo)return n;let a=iu(n),o;for(let s of r){if(s._zod.def.when){if(au(n)||!s._zod.def.when(n))continue}else if(a)continue;let r=n.issues.length,c=s._zod.check(n);if(c instanceof Promise&&i?.async===!1)throw new Au;if(o||c instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await c,n.issues.length!==r&&(lu(n.issues,r,t),a||=iu(n,r))});else{if(n.issues.length===r)continue;lu(n.issues,r,t),a||=iu(n,r)}}return o?o.then(()=>n):n},r=(r,i,o)=>{if(iu(r))return r.aborted=!0,r;let s=n(i,a,o);if(s instanceof Promise){if(o.async===!1)throw new Au;return s.then(n=>t._zod.parse(n,o))}return t._zod.parse(s,o)};t._zod.run=(i,o)=>{if(o.skipChecks)return t._zod.parse(i,o);if(o.direction===`backward`){let n=t._zod.parse({value:i.value,issues:[]},{...o,skipChecks:!0});return n instanceof Promise?n.then(t=>r(t,i,o)):r(n,i,o)}let s=t._zod.parse(i,o);if(s instanceof Promise){if(o.async===!1)throw new Au;return s.then(t=>n(t,a,o))}return n(s,a,o)}}},{get"~standard"(){return _u(this,`~standard`,pd(this))},set"~standard"(t){gu(this,`~standard`,t)}}),dd=(t,n)=>t.issues.length?{issues:t.issues.map(t=>uu(t,n,Mu()))}:{value:t.value};async function fd(t,n){let r={async:!0};return dd(await t._zod.run({value:n,issues:[]},r),r)}function pd(t){return{validate:n=>{let r={async:!1};try{let i=t._zod.run({value:n,issues:[]},r);if(!(i instanceof Promise))return dd(i,r)}catch{}return fd(t,n)},vendor:`zod`,version:1}}const md=/*@__PURE__*/ ku(`$ZodString`,(t,n)=>{ud.init(t,n),t._zod.pattern=n.pattern??Uu,t._zod.parse=(r,i)=>{if(n.coerce)try{r.value=String(r.value)}catch{}return typeof r.value==`string`||r.issues.push({expected:`string`,code:`invalid_type`,input:r.value,inst:t}),r}});function hd(t){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(t):(new URL(t),!0)}catch{return!1}}function gd(t,n){return!(`normalize`in n)&&!(`hostname`in n)&&!(`protocol`in n)?hd(t)||2:_d(t,n)}function _d(t,n){if(!n.normalize&&n.protocol?.source===Bu.source&&!/^https?:\/\//i.test(t))return 1;try{if(typeof URL<`u`){let n=URL;if(typeof n.parse==`function`)return n.parse(t)??2}return new URL(t)}catch{return 2}}const vd=/[\t\n\r]/g;function yd(t){return t.replace(vd,``)}function bd(t,n){return n.lastIndex=0,n.test(t.hostname)}function xd(t,n){return n.lastIndex=0,n.test(t.protocol.endsWith(`:`)?t.protocol.slice(0,-1):t.protocol)}const Sd=/^[0-9a-fA-F:.]+$/;function Cd(t){return Sd.test(t)?hd(`http://[${t}]`):!1}function wd(t){let n=t.split(`/`);if(n.length!==2)return!1;let[r,i]=n;if(!i)return!1;let a=Number(i);return`${a}`!==i||a<0||a>128?!1:Cd(r)}function Td(t){if(t===``)return!0;if(/\s/.test(t)||t.length%4!=0)return!1;try{return atob(t),!0}catch{return!1}}const Ed=/^[A-Za-z0-9_-]*$/;function Dd(t){if(!Ed.test(t))return!1;let n=t.replace(/[-_]/g,t=>t===`-`?`+`:`/`);return Td(n.padEnd(Math.ceil(n.length/4)*4,`=`))}const Od=/[- ]/g;function kd(t){let n=t.length,r=1,i=0;for(;n;){let a=t.charCodeAt(--n)-48;r^=1,i+=r?[0,2,4,6,8,1,3,5,7,9][a]:a}return i%10==0}function Ad(t){return Vu.test(t)?kd(t.replace(Od,``)):!1}function jd(t){let n=0,r=t.length;for(let i=4;i<r;i++){let r=t.charCodeAt(i);n=(r>=65?n*100+(r-55):n*10+(r-48))%97}for(let r=0;r<4;r++){let i=t.charCodeAt(r);n=(i>=65?n*100+(i-55):n*10+(i-48))%97}return n===1}function Md(t){return Hu.test(t)?jd(t):!1}function Nd(t,n=null){try{let r=t.split(`.`);if(r.length!==3)return!1;let[i]=r;if(!i)return!1;let a=JSON.parse(atob(i));return!(`typ`in a&&a?.typ!==`JWT`||!a.alg||n&&(!(`alg`in a)||a.alg!==n))}catch{return!1}}const Pd=/*@__PURE__*/ ku(`$ZodNumber`,(t,n)=>{ud.init(t,n),t._zod.pattern=Wu,t._zod.parse=(r,i)=>{if(n.coerce)try{r.value=Number(r.value)}catch{}let a=r.value;if(typeof a==`number`&&!Number.isNaN(a)&&Number.isFinite(a))return r;let o=typeof a==`number`?Number.isNaN(a)?`NaN`:Number.isFinite(a)?void 0:String(a):void 0;return r.issues.push({expected:`number`,code:`invalid_type`,input:a,inst:t,...o?{received:o}:{}}),r}}),Fd=/*@__PURE__*/ ku(`$ZodNumberFormat`,(t,n)=>{qu.init(t,n),Pd.init(t,n)}),Id=/*@__PURE__*/ ku(`$ZodBoolean`,(t,n)=>{ud.init(t,n),t._zod.pattern=Gu,t._zod.parse=(r,i)=>{if(n.coerce)try{r.value=!!r.value}catch{}let a=r.value;return typeof a==`boolean`||r.issues.push({expected:`boolean`,code:`invalid_type`,input:a,inst:t}),r}}),Ld=/*@__PURE__*/ ku(`$ZodAny`,(t,n)=>{ud.init(t,n),t._zod.parse=t=>t}),Rd=/*@__PURE__*/ ku(`$ZodUnknown`,(t,n)=>{ud.init(t,n),t._zod.parse=t=>t});function zd(t,n){let r=cu(t._zod.def.checks);if(!r.length)return;let i=Math.min(...r.map(t=>t[0])),a=t._zod.parse;t._zod.parse=(r,o)=>{let s=n(r.value);if(s>i&&!o?.skipChecks&&o?.direction!==`backward`){for(let[n,i]of cu(t._zod.def.checks))if(s>n&&i._zod.def.when(r)){let n=r.issues.length;return i._zod.check(r),r.issues[n].continue=!1,lu(r.issues,n,t),r}}return a(r,o)}}const Bd=t=>Array.isArray(t)?t.length:-1;function Vd(t,n,r){t.issues.length&&n.issues.push(...ou(r,t.issues)),n.value[r]=t.value}const Hd=/*@__PURE__*/ ku(`$ZodArray`,(t,n)=>{ud.init(t,n);let r=ju.memoizer;r?.attach(t),t._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:`array`,code:`invalid_type`,input:o,inst:t}),i;i.value=r?r.alloc(t,i,Array(o.length),a):Array(o.length);let s=[],c=a?.abortEarly;for(let t=0;t<o.length;t++){let r=o[t],l=n.element._zod.run({value:r,issues:[]},a);if(l instanceof Promise)s.push(l.then(n=>Vd(n,i,t)));else if(Vd(l,i,t),c&&l.issues.length!==0&&iu(l))break}return s.length?Promise.all(s).then(()=>i):i},zd(t,Bd)});function Ud(t,n,r,i,a,o){let s=r in i,c=o===`optional`;if(s||!c||a!==`optional`){if(t.issues.length){if(a!==void 0&&c&&!s)return;n.issues.push(...ou(r,t.issues))}!s&&a===void 0?t.issues.length||n.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[r]}):t.value===void 0?(s||a===`defaulted`&&!c)&&(n.value[r]=void 0):n.value[r]=t.value}}const Wd=[];function Gd(t){let n=Object.keys(t.shape),r=Object.getOwnPropertySymbols(t.shape),i=r.length?r:Wd,a=i.length?[...n,...i]:n;for(let n of a)if(!t.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(n)}": expected a Zod schema`);let o=nu(t.shape);return{...t,allKeys:a,symbolKeys:i,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(o)}}function Kd(t,n,r,i,a,o,s){let c=[],l=a.keySet,u=a.catchall._zod,d=u.def.type,f=u.optin,p=u.optout,m=0;for(let a in n){if(s&&r.issues.length!==m){if(iu(r,m))break;m=r.issues.length}if(l.has(a))continue;if(a===`__proto__`){d===`never`&&c.push(a);continue}if(d===`never`){c.push(a);continue}let o=u.run({value:n[a],issues:[]},i);o instanceof Promise?t.push(o.then(t=>Ud(t,r,a,n,f,p))):Ud(o,r,a,n,f,p)}return c.length&&r.issues.push({code:`unrecognized_keys`,keys:c,input:n,inst:o,continue:!0}),t.length?Promise.all(t).then(()=>r):r}const qd=/*@__PURE__*/ ku(`$ZodObject`,(t,n)=>{ud.init(t,n);let r=Object.getOwnPropertyDescriptor(n,`shape`),i=r?.get?r.get.raw:n.shape??{};if(i){let t=()=>{let r={...i};return Object.defineProperty(n,"shape",{value:r}),t.raw=r,r};t.raw=i,Object.defineProperty(n,"shape",{get:t})}let a=Hl(()=>Gd(n));Cu(t,`propValues`,t=>{let n=t.def.shape,r={};for(let t in n){let i=n[t]._zod;if(i.values){Object.prototype.hasOwnProperty.call(r,t)||Gl(r,t,/* @__PURE__ */ new Set);for(let n of i.values)r[t].add(n);i.optin!==void 0&&r[t].add(void 0)}}return r});let o=Yl,s=n.catchall,c,l=ju.memoizer;l?.attach(t),t._zod.parse=(n,r)=>{c??=a.value;let i=n.value;if(!o(i))return n.issues.push({expected:`object`,code:`invalid_type`,input:i,inst:t}),n;n.value=l?l.alloc(t,n,{},r):{};let u=[],d=c.shape,f=r?.abortEarly,p=n.issues.length;for(let t of c.allKeys){if(f&&n.issues.length!==p){if(iu(n,p))break;p=n.issues.length}if(t===`__proto__`)continue;let a=d[t],o=a._zod.optin,s=a._zod.optout,c=a._zod.run({value:i[t],issues:[]},r);c instanceof Promise?u.push(c.then(r=>Ud(r,n,t,i,o,s))):Ud(c,n,t,i,o,s)}return s?Kd(u,i,n,r,a.value,t,f===!0):u.length?Promise.all(u).then(()=>n):n}});function Jd(t,n,r,i){for(let r of t)if(r.issues.length===0)return n.value=r.value,n;let a=t.filter(t=>!iu(t));return a.length===1?(n.value=a[0].value,a[0]):(n.issues.push({code:`invalid_union`,input:n.value,inst:r,errors:t.map(t=>t.issues.map(t=>uu(t,i,Mu())))}),n)}const Yd=/*@__PURE__*/ ku(`$ZodUnion`,(t,n)=>{ud.init(t,n),Cu(t,`optin`,t=>t.def.options.some(t=>t._zod.optin===`defaulted`)?`defaulted`:t.def.options.some(t=>t._zod.optin!==void 0)?`optional`:void 0),Cu(t,`optout`,t=>t.def.options.some(t=>t._zod.optout===`optional`)?`optional`:void 0),Cu(t,`values`,t=>{if(t.def.options.every(t=>t._zod.values))return new Set(t.def.options.flatMap(t=>Array.from(t._zod.values)))}),Cu(t,`pattern`,t=>{if(t.def.options.every(t=>t._zod.pattern)){let n=t.def.options.map(t=>t._zod.pattern);return RegExp(`^(${n.map(t=>Ul(t.source)).join(`|`)})$`)}});let r=n.options.length===1?n.options[0]._zod.run:null;t._zod.parse=(i,a)=>{if(r)return r(i,a);let o=!1,s=[];for(let t of n.options){let n=t._zod.run({value:i.value,issues:[]},a);if(n instanceof Promise)s.push(n),o=!0;else{if(n.issues.length===0)return n;s.push(n)}}return o?Promise.all(s).then(n=>Jd(n,i,t,a)):Jd(s,i,t,a)}});function Xd(t,n){if(t===n||t instanceof Date&&n instanceof Date&&+t==+n)return{valid:!0,data:t};if(Xl(t)&&Xl(n)){let r=Object.keys(n),i=Object.keys(t).filter(t=>r.indexOf(t)!==-1),a={...t,...n};Object.prototype.hasOwnProperty.call(a,`__proto__`)&&delete a.__proto__;for(let r of i){if(r===`__proto__`)continue;let i=Xd(t[r],n[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};a[r]=i.data}return{valid:!0,data:a}}if(Array.isArray(t)&&Array.isArray(n)){if(t.length!==n.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let i=0;i<t.length;i++){let a=t[i],o=n[i],s=Xd(a,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}const Zd=/*@__PURE__*/ ku(`$ZodTuple`,(t,n)=>{ud.init(t,n);let r=n.items,i=ju.memoizer;i?.attach(t),t._zod.parse=(a,o)=>{let s=a.value;if(!Array.isArray(s))return a.issues.push({input:s,inst:t,expected:`tuple`,code:`invalid_type`}),a;a.value=i?i.alloc(t,a,[],o):[];let c=[],l=Qd(r,`optin`),u=Qd(r,`optout`);if(!n.rest){if(s.length<l)return a.issues.push({code:`too_small`,minimum:l,inclusive:!0,input:s,inst:t,origin:`array`}),a;s.length>r.length&&a.issues.push({code:`too_big`,maximum:r.length,inclusive:!0,input:s,inst:t,origin:`array`})}let d=Array(r.length),f=n.rest?o?.abortEarly:void 0,p=!1;for(let t=0;t<r.length;t++){let n=r[t]._zod.run({value:s[t],issues:[]},o);n instanceof Promise?c.push(n.then(n=>{d[t]=n})):(d[t]=n,f&&!p&&n.issues.length&&(p=iu(n)))}if(n.rest&&!p){let t=r.length-1,i=s.slice(r.length),l=a.issues.length;for(let r of i){if(f&&a.issues.length!==l){if(iu(a,l))break;l=a.issues.length}t++;let i=n.rest._zod.run({value:r,issues:[]},o);i instanceof Promise?c.push(i.then(n=>$d(n,a,t))):$d(i,a,t)}}return c.length?Promise.all(c).then(()=>ef(d,a,r,s,u)):ef(d,a,r,s,u)}});function Qd(t,n){for(let r=t.length-1;r>=0;r--)if(!(n===`optin`?t[r]._zod.optin!==void 0:t[r]._zod.optout===`optional`))return r+1;return 0}function $d(t,n,r){t.issues.length&&n.issues.push(...ou(r,t.issues)),n.value[r]=t.value}function ef(t,n,r,i,a){for(let o=0;o<r.length;o++){let s=t[o],c=o<i.length;if(!c&&o>=a&&r[o]._zod.optin===`optional`){n.value.length=o;break}if(s.issues.length){if(!c&&o>=a){n.value.length=o;break}n.issues.push(...ou(o,s.issues))}n.value[o]=s.value}for(let t=n.value.length-1;t>=i.length&&r[t]._zod.optout===`optional`&&n.value[t]===void 0;t--)n.value.length=t;return n}const tf=/*@__PURE__*/ ku(`$ZodLiteral`,(t,n)=>{ud.init(t,n);let r=new Set(n.values);t._zod.values=r,Cu(t,`pattern`,t=>{let n=t.def.values;return RegExp(n.length?`^(${n.map(t=>typeof t==`string`?Ql(t):t?Ql(t.toString()):String(t)).join(`|`)})$`:`^[^\\s\\S]$`)}),t._zod.parse=(i,a)=>{let o=i.value;return r.has(o)||i.issues.push({code:`invalid_value`,values:n.values,input:o,inst:t}),i}});function nf(t,n){return t.value=n.issues.length?void 0:n.value,t}const rf=/*@__PURE__*/ ku(`$ZodOptional`,(t,n)=>{ud.init(t,n),Cu(t,`optin`,t=>t.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),t._zod.optout=`optional`,Cu(t,`values`,t=>{let n=t.def.innerType._zod.values;return n?/* @__PURE__ */ new Set([...n,void 0]):void 0}),Cu(t,`pattern`,t=>{let n=t.def.innerType._zod.pattern;return n?RegExp(`^(${Ul(n.source)})?$`):void 0}),t._zod.parse=(t,r)=>{if(t.value===void 0){if(n.innerType._zod.optin!==`defaulted`)return t;let i=n.innerType._zod.run({value:t.value,issues:[]},r);return i instanceof Promise?i.then(n=>nf(t,n)):nf(t,i)}return n.innerType._zod.run(t,r)}}),af=/*@__PURE__*/ ku(`$ZodFunction`,(t,n)=>(ud.init(t,n),Object.defineProperty(t,"_def",{value:n}),t._zod.def=n,t.implement=n=>{if(typeof n!=`function`)throw Error(`implement() must be called with a function`);return Object.defineProperty(function(...r){let i=t._def.input?ed(t._def.input,r):r,a=Reflect.apply(n,this,i);return t._def.output?ed(t._def.output,a):a},"_zod",{value:t._zod,enumerable:!1})},t.implementAsync=n=>{if(typeof n!=`function`)throw Error(`implementAsync() must be called with a function`);return Object.defineProperty(async function(...r){let i=t._def.input?await td(t._def.input,r):r,a=await Reflect.apply(n,this,i);return t._def.output?await td(t._def.output,a):a},"_zod",{value:t._zod,enumerable:!1})},t._zod.parse=(n,r)=>typeof n.value==`function`?(n.value=t._def.output&&t._def.output._zod.def.type===`promise`?t.implementAsync(n.value):t.implement(n.value),n):(n.issues.push({code:`invalid_type`,expected:`function`,input:n.value,inst:t}),n),t.input=(...n)=>{let r=t.constructor;return Array.isArray(n[0])?new r({type:`function`,input:new Zd({type:`tuple`,items:n[0],rest:n[1]}),output:t._def.output}):new r({type:`function`,input:n[0],output:t._def.output})},t.output=n=>{let r=t.constructor;return new r({type:`function`,input:t._def.input,output:n})},t)),of=/*@__PURE__*/ ku(`$ZodCustom`,(t,n)=>{Ku.init(t,n),ud.init(t,n),t._zod.parse=(t,n)=>t,t._zod.check=r=>{let i=r.value,a=n.fn(i);if(a instanceof Promise)return a.then(n=>sf(n,r,i,t));sf(a,r,i,t)}});function sf(t,n,r,i){if(!t){let t={code:`custom`,input:r,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(t.params=i._zod.def.params),n.issues.push(mu(t))}}const cf=Symbol.for(`zod.compile.invalid`),lf=Symbol.for(`zod.compile.fallback`);var uf=class extends Error{constructor(t=`z.compile does not support async refinements, transforms, or checks`){super(t),this.name=`ZodCompileAsyncError`}},df=class extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name=`ZodCompileUnsupportedError`,this.islandable=n}};function ff(t,n){try{return gf(t,{assertOnly:!0})}catch{return n}}function pf(t,n){try{let n=gf(t),r=mf(t,n);return r._zod.bag.validator=ff(t,n),r}catch(r){if(n?.strict)throw r;return t}}function mf(t,n){if(Ru(t))throw new df(`a schema whose subtree contains a reference cycle`);let r=$l(t),i=t._zod.run,a=i.__originalRun??i,o=(t,r)=>{if(r?.async||r?.direction===`backward`||r?.skipChecks||r?.[lf]||r&&zu(r,t.value))return a(t,r);let i=n(t.value);return i===cf?(r&&(r[lf]=!0),a(t,r)):(t.value=i,t)};return o.__originalRun=a,r._zod.bag.fallbackRun=a,r._zod.bag.validator=n,r._zod.run=o,i.__originalRun||hf(r,t,n),r}function hf(t,n,r){let i=t,a=n;if(typeof a.safeParse==`function`){let t=a.safeParse;i.safeParse=(n,i)=>{let a=r(n);return a===cf?t(n,i):{success:!0,data:a}}}if(typeof a.parse==`function`){let t=a.parse;i.parse=(n,i)=>{let a=r(n);return a===cf?t(n,i):a}}}function gf(t,n){let r=!0;try{r=Ru(t)}catch{}if(r)throw new df(`a schema whose subtree contains a reference cycle`);let i={constants:/* @__PURE__ */ new Map,constantCounter:0,varCounter:0,definite:!0},a=new Nu([`input`]),o=Vf(a,i,t,`input`,!n?.assertOnly);a.write(o===null?`return true;`:`return ${o};`);let s=[`INVALID`,...i.constants.keys()],c=[cf,...i.constants.values()],l=a.content.join(`
`),u=n?.debug?s.length>0?`// Constants: ${s.join(`, `)}\n${l}`:l:``,d=Function,f=`return (input) => {\n${l}\n}`,p;try{p=new d(...s,f)(...c)}catch(t){throw new df(`this schema (generated code failed to evaluate: ${t.message})`)}return n?.debug&&(p.code=u),p.definite=i.definite,p}function _f(t,n){for(let[r,i]of t.constants)if(i===n)return r;let r=`c${t.constantCounter++}`;return t.constants.set(r,n),r}function vf(t,n){return t.definite=!1,_f(t,n)}function J(t){return`v${t.varCounter++}`}function yf(t,n){let r=t._zod.run({value:n,issues:[]},{});if(r&&typeof r.then==`function`)return cf;let i=r;return i.issues.length===0?i.value:cf}function bf(t,n,r,i,a=!0){let o=t.content.length,s=n.constants.size,c=n.constantCounter,l=n.varCounter;try{return Vf(t,n,r,i,a)}catch(a){if(!(a instanceof df)||!a.islandable)throw a;if(t.content.length=o,n.constants.size>s){let t=Array.from(n.constants.keys()).slice(s);for(let r of t)n.constants.delete(r)}return n.constantCounter=c,n.varCounter=l,xf(t,n,r,i)}}function xf(t,n,r,i){n.definite=!1;let a=_f(n,r),o=_f(n,yf),s=J(n);return t.write(`const ${s} = ${o}(${a}, ${i});`),t.write(`if (${s} === INVALID) return INVALID;`),s}const Sf=/* @__PURE__ */ new Set([`max_size`,`min_size`,`size_equals`,`max_length`,`min_length`,`length_equals`]);function Cf(t,n,r,i){let a=r._zod.def.checks;if(!a||a.length===0)return i;let o=i;for(let r of a){let i=r._zod.def;if(i.when&&!Sf.has(i.check))throw new df(`check with a custom "when" condition`);switch(i.check){case`greater_than`:Df(t,n,i,o);break;case`less_than`:Of(t,n,i,o);break;case`multiple_of`:kf(t,n,i,o);break;case`number_format`:Af(t,i,o);break;case`min_length`:{let r=Tf(i.minimum,`min_length`),a=wf(t,n,o,`${o}.length >= ${r} && ${o}.length < ${i.minimum*2}`);t.write(`if (${a} < ${r}) return INVALID;`);break}case`max_length`:{let r=Tf(i.maximum,`max_length`),a=wf(t,n,o,`${o}.length > ${r}`);t.write(`if (${a} > ${r}) return INVALID;`);break}case`length_equals`:{let r=Tf(i.length,`length_equals`),a=wf(t,n,o,`${o}.length >= ${r} && ${o}.length <= ${i.length*2}`);t.write(`if (${a} !== ${r}) return INVALID;`);break}case`min_size`:t.write(`if (${o}.size < ${Tf(i.minimum,`min_size`)}) return INVALID;`);break;case`max_size`:t.write(`if (${o}.size > ${Tf(i.maximum,`max_size`)}) return INVALID;`);break;case`size_equals`:t.write(`if (${o}.size !== ${Tf(i.size,`size_equals`)}) return INVALID;`);break;case`string_format`:o=Bf(t,n,i,o);break;case`custom`:o=Rf(t,n,r,o);break;case`bigint_format`:jf(t,i,o);break;case`mime_type`:Mf(t,n,i,o);break;case`property`:Pf(t,n,i,o);break;case`properties`:Nf(t,n,i,o);break;case`overwrite`:{let i=J(n);Ff(t,n,r,o,i),o=i;break}default:throw new df(`check type ${i.check}`)}}return o}function wf(t,n,r,i){let a=_f(n,fu),o=J(n);return t.write(`const ${o} = typeof ${r} === "string" && ${i} ? ${a}(${r}) : ${r}.length;`),o}function Tf(t,n){if(typeof t!=`number`||!Number.isFinite(t))throw new df(`${n} bound of type ${typeof t}`);return`${t}`}function Ef(t,n){if(typeof n==`bigint`)return`${n}n`;if(typeof n==`number`){if(Number.isNaN(n))throw new df(`comparison check with NaN bound`);return`${n}`}if(n instanceof Date){if(Number.isNaN(n.getTime()))throw new df(`comparison check with Invalid Date bound`);return _f(t,n)}throw new df(`comparison check bound of type ${typeof n}`)}function Df(t,n,r,i){let a=r.inclusive?`<`:`<=`;t.write(`if (${i} ${a} ${Ef(n,r.value)}) return INVALID;`)}function Of(t,n,r,i){let a=r.inclusive?`>`:`>=`;t.write(`if (${i} ${a} ${Ef(n,r.value)}) return INVALID;`)}function kf(t,n,r,i){if(typeof r.value==`bigint`){if(r.value===BigInt(0))throw new df(`multiple_of check with a zero divisor`);t.write(`if (${i} % ${r.value}n !== 0n) return INVALID;`)}else{let a=_f(n,Wl);t.write(`if (${a}(${i}, ${Tf(r.value,`multiple_of`)}) !== 0) return INVALID;`)}}function Af(t,n,r){let i=n.format;switch(i){case`safeint`:t.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case`int32`:t.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case`uint32`:t.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case`float32`:t.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case`float64`:t.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new df(`number format ${i}`)}}function jf(t,n,r){let i=n.format;if(i)switch(i){case`int64`:t.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case`uint64`:t.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new df(`bigint format ${i}`)}}function Mf(t,n,r,i){let a=r.mime;if(a&&a.length>0){let r=_f(n,new Set(a));t.write(`if (!${r}.has(${i}.type)) return INVALID;`)}}function Nf(t,n,r,i){if(r.when)throw new df(`check with a custom "when" condition`);t.write(`if (${i} == null) return INVALID;`);let a=r.shape;for(let r of Reflect.ownKeys(a)){let o=typeof r==`symbol`?_f(n,r):ql(r),s=J(n);t.write(`const ${s} = ${i}[${o}];`),bf(t,n,a[r],s,!1)}}function Pf(t,n,r,i){let a=`${i}[${JSON.stringify(r.property)}]`;Vf(t,n,r.schema,a)}function Ff(t,n,r,i,a){let o=r._zod.def.tx;if(!o)throw new df(`overwrite check without a transform function`);if(kp(o))throw new uf(`z.compile: async overwrite transforms are not supported`);let s=_f(n,o);t.write(`const ${a} = ${s}(${i});`)}function If(){throw new Au}function Lf(t){this.issues.push(t)}function Rf(t,n,r,i){let a=r._zod.def;if(a.fn){if(kp(a.fn))throw new uf(`z.compile: async .refine() predicates are not supported`);let r=vf(n,a.fn),o=_f(n,If),s=J(n);return t.write(`const ${s} = ${r}(${i});`),t.write(`if (${s} instanceof Promise) ${o}();`),t.write(`if (!${s}) return INVALID;`),i}if(r._zod.check){if(kp(r._zod.check))throw new uf(`z.compile: async .superRefine() / check functions are not supported`);let a=r._zod.check,o=vf(n,t=>{let n={value:t,issues:[],addIssue:Lf};return a(n)instanceof Promise&&If(),n.issues.length===0?n.value:cf}),s=J(n);return t.write(`const ${s} = ${o}(${i});`),t.write(`if (${s} === INVALID) return INVALID;`),s}throw new df(`custom check without a predicate or check function`)}const zf=/* @__PURE__ */ new Set([`cidrv4`,`cuid`,`cuid2`,`date`,`datetime`,`duration`,`e164`,`email`,`emoji`,`ends_with`,`guid`,`includes`,`ipv4`,`ksuid`,`lowercase`,`mac`,`nanoid`,`regex`,`starts_with`,`time`,`ulid`,`uppercase`,`uuid`,`xid`]);function Bf(t,n,r,i,a=!0){let o=r.format;if(o===`base64`){let r=_f(n,Td);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(o===`base64url`){let r=_f(n,Dd);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(o===`jwt`){let a=_f(n,Nd),o=_f(n,r.alg??null);return t.write(`if (!${a}(${i}, ${o})) return INVALID;`),i}if(o===`ipv6`){let r=_f(n,Cd);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(o===`cidrv6`){let r=_f(n,wd);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(o===`credit_card`){let r=_f(n,Ad);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(o===`iban`){let r=_f(n,Md);return t.write(`if (!${r}(${i})) return INVALID;`),i}let s=r;if(o===`url`||o===`httpurl`||s.normalize||s.hostname!==void 0||s.protocol!==void 0){let o=_f(n,gd),c=_f(n,r),l=J(n),u=J(n);if(t.write(`const ${l} = ${i}.trim();`),t.write(`const ${u} = ${o}(${l}, ${c});`),t.write(`if (typeof ${u} === "number") return INVALID;`),s.hostname!==void 0){let r=_f(n,bd);t.write(`if (!${r}(${u}, ${c}.hostname)) return INVALID;`)}if(s.protocol!==void 0){let r=_f(n,xd);t.write(`if (!${r}(${u}, ${c}.protocol)) return INVALID;`)}if(!a)return null;let d=J(n),f=s.normalize?`${u}.href`:`${_f(n,yd)}(${l})`;return t.write(`const ${d} = ${f};`),d}let c=r.fn;if(c){if(kp(c))throw new df(`async string format ${o}`);let r=_f(n,c);return t.write(`if (!${r}(${i})) return INVALID;`),i}if(zf.has(o)&&r.pattern){let a=_f(n,r.pattern);return t.write(`${a}.lastIndex = 0;`),t.write(`if (!${a}.test(${i})) return INVALID;`),i}let l=r.format;switch(l){case`regex`:throw new df(`regex format without a pattern`);case`lowercase`:t.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case`uppercase`:t.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case`includes`:t.write(`if (!${i}.includes(${ql(r.includes)})) return INVALID;`);break;case`starts_with`:{let n=r.prefix;t.write(`if (${i}.slice(0, ${n.length}) !== ${ql(n)}) return INVALID;`);break}case`ends_with`:{let n=r.suffix;t.write(`if (${i}.slice(-${n.length}) !== ${ql(n)}) return INVALID;`);break}default:throw new df(`string format ${l}`)}return i}function Vf(t,n,r,i,a=!0){let o=r._zod.def,s=o.type;if(o.coerce)throw new df(`coercion (z.coerce.${s}())`);let c=a||!!o.checks?.length,l;switch(s){case`string`:l=Hf(t,n,r,i,c);break;case`number`:l=Uf(t,r,i);break;case`boolean`:l=Wf(t,i);break;case`bigint`:l=Gf(t,r,i);break;case`symbol`:l=Kf(t,i);break;case`undefined`:l=qf(t,i);break;case`null`:l=Jf(t,i);break;case`any`:case`unknown`:l=i;break;case`never`:t.write(`return INVALID;`),l=i;break;case`void`:l=Yf(t,i);break;case`nan`:l=Xf(t,i);break;case`date`:l=Zf(t,i);break;case`object`:l=Qf(t,n,r,i,c);break;case`optional`:l=$f(t,n,r,i,c);break;case`nullable`:l=op(t,n,r,i,c);break;case`array`:l=cp(t,n,r,i,c);break;case`literal`:l=lp(t,n,r,i);break;case`enum`:l=up(t,n,r,i);break;case`readonly`:{let a=dp(t,n,r,i),o=J(n);t.write(`const ${o} = Object.freeze(${a});`),l=o;break}case`success`:dp(t,n,r,i),l=`true`;break;case`default`:case`prefault`:l=fp(t,n,r,i);break;case`nonoptional`:l=pp(t,n,r,i);break;case`tuple`:l=mp(t,n,r,i);break;case`union`:l=gp(t,n,r,i);break;case`intersection`:l=yp(t,n,r,i);break;case`record`:l=bp(t,n,r,i);break;case`map`:l=Cp(t,n,r,i);break;case`set`:l=wp(t,n,r,i);break;case`file`:l=Tp(t,i);break;case`template_literal`:l=Ep(t,n,r,i);break;case`lazy`:l=Dp(t,n,r,i);break;case`pipe`:l=Op(t,n,r,i);break;case`custom`:l=Ap(t,n,r,i);break;case`transform`:l=Np(t,n,r,i);break;case`catch`:l=Mp(t,n,r,i);break;default:throw new df(`schema type ${s}`)}return l===null?null:Cf(t,n,r,l)}function Hf(t,n,r,i,a=!0){t.write(`if (typeof ${i} !== "string") return INVALID;`);let o=r._zod.def;return o.format===void 0?i:Bf(t,n,o,i,a)}function Uf(t,n,r){t.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let i=n._zod.def;return i.check===`number_format`&&i.format&&Af(t,{format:i.format},r),r}function Wf(t,n){return t.write(`if (typeof ${n} !== "boolean") return INVALID;`),n}function Gf(t,n,r){t.write(`if (typeof ${r} !== "bigint") return INVALID;`);let i=n._zod.def;if(i.format)switch(i.format){case`int64`:t.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case`uint64`:t.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`)}return r}function Kf(t,n){return t.write(`if (typeof ${n} !== "symbol") return INVALID;`),n}function qf(t,n){return t.write(`if (${n} !== undefined) return INVALID;`),n}function Jf(t,n){return t.write(`if (${n} !== null) return INVALID;`),n}function Yf(t,n){return t.write(`if (${n} !== undefined) return INVALID;`),n}function Xf(t,n){return t.write(`if (typeof ${n} !== "number" || !Number.isNaN(${n})) return INVALID;`),n}function Zf(t,n){return t.write(`if (!(${n} instanceof Date) || Number.isNaN(${n}.getTime())) return INVALID;`),n}function Qf(t,n,r,i,a=!0){let o=r._zod.def;t.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let s=o.shape,c=Object.keys(s),l=Object.getOwnPropertySymbols(s),u=l.length?[...c,...l]:c,d=t=>typeof t==`symbol`?_f(n,t):ql(t),f=t=>typeof t==`symbol`?`[${d(t)}]`:ql(t),p=s;if(c.includes(`__proto__`))throw new df(`object shape key "__proto__"`);let m=/* @__PURE__ */ new Map;for(let r of u){let o=p[r],s=d(r),c=J(n);if(t.write(`const ${c} = ${i}[${s}];`),o._zod.optin!==void 0){let a=J(n);t.write(`let ${a} = (() => {`),t.indented(t=>{let r=bf(t,n,o,c);t.write(`return ${r};`)}),t.write(`})();`),o._zod.optout===`optional`?(t.write(`if (${a} === INVALID) {`),t.indented(t=>{t.write(`if (${s} in ${i}) return INVALID;`),t.write(`${a} = undefined;`)}),t.write(`}`)):t.write(`if (${a} === INVALID) return INVALID;`),m.set(r,a)}else{tp(o)&&t.write(`if (!(${s} in ${i})) return INVALID;`);let l=bf(t,n,o,c,a);l!==null&&m.set(r,l)}}let h=o.catchall,g=`none`;if(h){let n=h._zod.def.type;if(n===`never`){let n=c.map(t=>`k !== ${ql(t)}`).join(` && `)||`true`;t.write(`for (const k in ${i}) {`),t.indented(t=>{t.write(`if (${n}) return INVALID;`)}),t.write(`}`)}else g=(n===`unknown`||n===`any`)&&!h._zod.def.checks?.length?`passthrough`:`schema`}let _=J(n),v=u.some(t=>ip(p[t])||rp(p[t]));if(!a){if(g===`schema`){let r=c.length>0?_f(n,new Set(c)):null;t.write(`for (const k in ${i}) {`),t.indented(t=>{t.write(`if (k === "__proto__") continue;`),r&&t.write(`if (${r}.has(k)) continue;`);let a=J(n);t.write(`const ${a} = ${i}[k];`),bf(t,n,h,a,!1)}),t.write(`}`)}return null}if(v){t.write(`const ${_} = {};`);for(let n of u){let r=d(n),a=m.get(n);rp(p[n])?t.write(`if (${r} in ${i}) ${_}[${r}] = ${a};`):ip(p[n])?t.write(`if (${a} !== undefined || ${r} in ${i}) ${_}[${r}] = ${a};`):t.write(`${_}[${r}] = ${a};`)}}else{let n=u.map(t=>`${f(t)}: ${m.get(t)}`).join(`, `);t.write(`const ${_} = { ${n} };`)}if(g!==`none`){let r=c.length>0?_f(n,new Set(c)):null;t.write(`for (const k in ${i}) {`),t.indented(t=>{if(t.write(`if (k === "__proto__") continue;`),r&&t.write(`if (${r}.has(k)) continue;`),g===`passthrough`)t.write(`${_}[k] = ${i}[k];`);else{let r=J(n);t.write(`const ${r} = ${i}[k];`);let a=bf(t,n,h,r);t.write(`${_}[k] = ${a};`)}}),t.write(`}`)}return _}function $f(t,n,r,i,a=!0){let o=r._zod.def;if(ep(r))return Vf(t,n,o.innerType,i,a);if(o.innerType._zod.optin===`defaulted`){let r=J(n),a=J(n);return t.write(`let ${r};`),t.write(`if (${i} === undefined) {`),t.indented(t=>{t.write(`const ${a} = (() => {`),t.indented(t=>{let r=Vf(t,n,o.innerType,i);t.write(`return ${r};`)}),t.write(`})();`),t.write(`if (${a} !== INVALID) ${r} = ${a};`)}),t.write(`} else {`),t.indented(t=>{let a=Vf(t,n,o.innerType,i);t.write(`${r} = ${a};`)}),t.write(`}`),r}let s=a?J(n):null;return s&&t.write(`let ${s};`),t.write(`if (${i} !== undefined) {`),t.indented(t=>{let r=Vf(t,n,o.innerType,i,a);s&&r!==null&&t.write(`${s} = ${r};`)}),t.write(`}`),s}function ep(t){return t._zod.traits?.has(`$ZodExactOptional`)===!0}function tp(t){return t._zod.optin===void 0&&np(t)}function np(t){if(t._zod.def.coerce)return!0;let n=t._zod.def;switch(n.type){case`any`:case`unknown`:case`undefined`:case`void`:case`default`:case`prefault`:case`transform`:case`custom`:case`lazy`:return!0;case`string`:case`number`:case`boolean`:case`bigint`:case`symbol`:case`null`:case`never`:case`nan`:case`date`:case`object`:case`array`:case`tuple`:case`record`:case`map`:case`set`:case`file`:case`template_literal`:return!1;case`nonoptional`:return n.innerType?np(n.innerType):!1;case`literal`:return!!n.values?.includes(void 0);case`enum`:return!!t._zod.values?.has(void 0);case`optional`:case`nullable`:case`readonly`:case`success`:return!n.innerType||np(n.innerType);case`catch`:return!0;case`union`:return!n.options||n.options.some(np);case`intersection`:return!n.left||!n.right||np(n.left)&&np(n.right);case`pipe`:return!n.in||np(n.in);default:return!0}}function rp(t){return t._zod.optin===`optional`&&t._zod.optout===`optional`}function ip(t){return(t._zod.optin!==`defaulted`||t._zod.optout===`optional`)&&ap(t)}function ap(t){let n=t._zod.def;switch(n.type){case`string`:case`number`:case`boolean`:case`bigint`:case`symbol`:case`null`:case`nan`:case`date`:case`object`:case`array`:case`tuple`:case`record`:case`map`:case`set`:case`file`:case`template_literal`:case`never`:case`success`:return!1;case`literal`:return!!n.values?.includes(void 0);case`enum`:return!!t._zod.values?.has(void 0);case`optional`:return!0;case`nullable`:case`readonly`:case`nonoptional`:return!n.innerType||ap(n.innerType);case`union`:return!n.options||n.options.some(ap);case`intersection`:return!n.left||!n.right||ap(n.left)||ap(n.right);case`pipe`:return!n.out||ap(n.out);default:return!0}}function op(t,n,r,i,a=!0){let o=r._zod.def,s=a?J(n):null;return s&&t.write(`let ${s} = null;`),t.write(`if (${i} !== null) {`),t.indented(t=>{let r=Vf(t,n,o.innerType,i,a);s&&r!==null&&t.write(`${s} = ${r};`)}),t.write(`}`),s}function sp(t,n,r){for(let[i,a]of cu(n._zod.def.checks))t.write(`if (${r} > ${Tf(i,a._zod.def.check)}) return INVALID;`)}function cp(t,n,r,i,a=!0){let o=r._zod.def;t.write(`if (!Array.isArray(${i})) return INVALID;`),sp(t,r,`${i}.length`);let s=a?J(n):null,c=J(n),l=J(n);return s&&t.write(`const ${s} = new Array(${i}.length);`),t.write(`for (let ${c} = 0; ${c} < ${i}.length; ${c}++) {`),t.indented(t=>{t.write(`const ${l} = ${i}[${c}];`);let r=bf(t,n,o.element,l,a);s&&r!==null&&t.write(`${s}[${c}] = ${r};`)}),t.write(`}`),s}function lp(t,n,r,i){let a=r._zod.def.values;if(a.length!==1){let r=_f(n,new Set(a));return t.write(`if (!${r}.has(${i})) return INVALID;`),i}let o=a[0];if(typeof o==`number`&&Number.isNaN(o)){let r=_f(n,new Set(a));return t.write(`if (!${r}.has(${i})) return INVALID;`),i}if(typeof o==`string`)t.write(`if (${i} !== ${ql(o)}) return INVALID;`);else if(typeof o==`number`||typeof o==`boolean`)t.write(`if (${i} !== ${o}) return INVALID;`);else if(o===null)t.write(`if (${i} !== null) return INVALID;`);else if(o===void 0)t.write(`if (${i} !== undefined) return INVALID;`);else if(typeof o==`bigint`)t.write(`if (${i} !== ${o}n) return INVALID;`);else throw new df(`literal type ${typeof o}`);return i}function up(t,n,r,i){let a=r._zod.values;if(!a)throw new df(`enum schema without enumerated values`);let o=_f(n,a);return t.write(`if (!${o}.has(${i})) return INVALID;`),i}function dp(t,n,r,i){let a=r._zod.def;return Vf(t,n,a.innerType,i)}function fp(t,n,r,i){let a=r._zod.def,o=Object.getOwnPropertyDescriptor(r._zod.def,`defaultValue`)?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type===`prefault`){if(!o)return Vf(t,n,a.innerType,i);let r=_f(n,o),s=J(n);return t.write(`let ${s} = ${i};`),t.write(`if (${i} === undefined) ${s} = ${r}();`),Vf(t,n,a.innerType,s)}let s=J(n);if(o){let r=_f(n,o),c=_f(n,Zl);t.write(`let ${s};`),t.write(`if (${i} === undefined) {`),t.indented(t=>{t.write(`${s} = ${c}(${r}());`)}),t.write(`} else {`),t.indented(t=>{let o=Vf(t,n,a.innerType,i);t.write(`${s} = ${o} === undefined ? ${c}(${r}()) : ${o};`)}),t.write(`}`)}else t.write(`let ${s};`),t.write(`if (${i} !== undefined) {`),t.indented(t=>{let r=Vf(t,n,a.innerType,i);t.write(`${s} = ${r};`)}),t.write(`}`);return s}function pp(t,n,r,i){let a=r._zod.def,o=Vf(t,n,a.innerType,i),s=J(n);return t.write(`const ${s} = ${o};`),t.write(`if (${s} === undefined) return INVALID;`),s}function mp(t,n,r,i){let a=r._zod.def,o=a.items,s=a.rest;t.write(`if (!Array.isArray(${i})) return INVALID;`);let c=hp(o,`optin`),l=hp(o,`optout`);s?t.write(`if (${i}.length < ${c}) return INVALID;`):t.write(`if (${i}.length < ${c} || ${i}.length > ${o.length}) return INVALID;`);let u=J(n);t.write(`const ${u} = [];`);for(let r=0;r<o.length;r++){let a=o[r];if(r>=l)t.write(`if (${u}.length === ${r}) {`),t.indented(t=>{t.write(`if (${r} < ${i}.length) {`),t.indented(t=>{let o=J(n);t.write(`const ${o} = ${i}[${r}];`);let s=bf(t,n,a,o);t.write(`${u}[${r}] = ${s};`)}),t.write(`} else {`),t.indented(t=>{if(rp(a)){t.write(`${u}.length = ${r};`);return}let i=J(n),o=J(n);t.write(`const ${i} = undefined;`),t.write(`const ${o} = (() => {`),t.indented(t=>{let r=bf(t,n,a,i);t.write(`return ${r};`)}),t.write(`})();`),t.write(`if (${o} === INVALID || ${o} === undefined) ${u}.length = ${r};`),t.write(`else ${u}[${r}] = ${o};`)}),t.write(`}`)}),t.write(`}`);else{let o=J(n);t.write(`const ${o} = ${i}[${r}];`);let s=bf(t,n,a,o);t.write(`${u}[${r}] = ${s};`)}}if(s){let r=J(n),a=J(n);t.write(`for (let ${r} = ${o.length}; ${r} < ${i}.length; ${r}++) {`),t.indented(t=>{t.write(`const ${a} = ${i}[${r}];`);let o=bf(t,n,s,a);t.write(`${u}[${r}] = ${o};`)}),t.write(`}`)}return u}function hp(t,n){for(let r=t.length-1;r>=0;r--)if(!(n===`optin`?t[r]._zod.optin!==void 0:t[r]._zod.optout===`optional`))return r+1;return 0}function gp(t,n,r,i){let a=r._zod.def,o=a.options;if(a.discriminator)return _p(t,n,a,i);if(a.inclusive===!1)throw new df(`exclusive unions (z.xor)`);if(o.length===0)return t.write(`return INVALID;`),i;if(o.length===1)return Vf(t,n,o[0],i);if(o.every(t=>t._zod.def.type===`literal`&&!t._zod.def.checks?.length)){let r=_f(n,new Set(o.flatMap(t=>t._zod.def.values)));return t.write(`if (!${r}.has(${i})) return INVALID;`),i}let s=J(n);t.write(`let ${s};`);for(let r=0;r<o.length;r++){let a=o[r];r===0?t.write(`${s} = (() => {`):t.write(`if (${s} === INVALID) ${s} = (() => {`),t.indented(t=>{let r=Vf(t,n,a,i);t.write(`return ${r};`)}),t.write(`})();`)}return t.write(`if (${s} === INVALID) return INVALID;`),s}function _p(t,n,r,i){if(r.unionFallback)throw new df(`discriminated union with unionFallback`);if(r.options.length===0)return t.write(`return INVALID;`),i;let a=J(n),o=J(n);t.write(`const ${a} = ${i}?.[${ql(r.discriminator)}];`),t.write(`let ${o};`);let s=!0,c=/* @__PURE__ */ new Set;for(let l of r.options){let u=l._zod.propValues?.[r.discriminator];if(!u||u.size===0)throw new df(`discriminated union option without static discriminator values`);for(let t of u){if(c.has(t))throw new df(`duplicate discriminator value ${String(t)}`);c.add(t)}let d=Array.from(u,t=>vp(n,a,t)),f=s?`if`:`else if`;t.write(`${f} (${d.join(` || `)}) {`),t.indented(t=>{let r=Vf(t,n,l,i);t.write(`${o} = ${r};`)}),t.write(`}`),s=!1}return t.write(`else { return INVALID; }`),o}function vp(t,n,r){if(typeof r==`string`)return`${n} === ${ql(r)}`;if(typeof r==`number`)return Number.isNaN(r)?`Number.isNaN(${n})`:`${n} === ${r}`;if(typeof r==`boolean`)return`${n} === ${r}`;if(r===null)return`${n} === null`;if(r===void 0)return`${n} === undefined`;if(typeof r==`bigint`)return`${n} === ${r}n`;if(typeof r==`symbol`)return`${n} === ${_f(t,r)}`;throw new df(`literal discriminator value ${String(r)}`)}function yp(t,n,r,i){let a=r._zod.def;n.definite=!1;let o=bf(t,n,a.left,i),s=bf(t,n,a.right,i),c=_f(n,Xd),l=J(n);return t.write(`const ${l} = ${c}(${o}, ${s});`),t.write(`if (!${l}.valid) return INVALID;`),`${l}.data`}function bp(t,n,r,i){let a=r._zod.def,o=_f(n,Xl);t.write(`if (!${o}(${i})) return INVALID;`);let s=J(n),c=J(n),l=J(n);t.write(`const ${s} = {};`);let u=a,d=u.partial?void 0:a.keyType._zod.values;if(d){let r=[];for(let o of d){if(typeof o!=`string`&&typeof o!=`number`&&typeof o!=`symbol`)throw new df(`record key value ${String(o)}`);let c=typeof o==`number`?o.toString():o;if(c===`__proto__`)throw new df(`record key "__proto__"`);r.push(c);let l=_f(n,o),u=Vf(t,n,a.keyType,l),d=J(n);t.write(`const ${d} = ${i}[${Sp(n,c)}];`);let f=bf(t,n,a.valueType,d);t.write(`${s}[${u}] = ${f};`)}let o=_f(n,new Set(r));return t.write(`for (const ${c} in ${i}) {`),t.indented(t=>{t.write(`if (${o}.has(${c})) continue;`),u.mode===`loose`?t.write(`if (${c} !== "__proto__") ${s}[${c}] = ${i}[${c}];`):t.write(`return INVALID;`)}),t.write(`}`),s}let f=a.keyType._zod.def;if(f.type!==`string`||f.format!==void 0||f.coerce||(f.checks?.length??0)!==0){let r=a.mode===`loose`,o=gf(a.keyType);o.definite===!1&&(n.definite=!1);let l=_f(n,o),u=_f(n,Wu),d=J(n);return xp(t,n,i,c,t=>{t.write(`let ${d} = ${l}(${c});`),t.write(`if (${d} === INVALID && typeof ${c} === "string" && ${u}.test(${c})) ${d} = ${l}(Number(${c}));`),r?t.write(`if (${d} === INVALID) { ${s}[${c}] = ${i}[${c}]; continue; }`):t.write(`if (${d} === INVALID) return INVALID;`),t.write(`if (${d} === "__proto__") continue;`);let o=J(n);t.write(`const ${o} = ${i}[${c}];`);let f=bf(t,n,a.valueType,o);t.write(`${s}[${d}] = ${f};`)}),s}return xp(t,n,i,c,t=>{t.write(`const ${l} = ${i}[${c}];`);let r=bf(t,n,a.valueType,l);t.write(`${s}[${c}] = ${r};`)},`return INVALID;`),s}function xp(t,n,r,i,a,o){let s=_f(n,Object.prototype.propertyIsEnumerable),c=J(n),l=J(n),u=J(n);t.write(`const ${c} = Object.getOwnPropertySymbols(${r});`),t.write(`const ${l} = Object.getOwnPropertyNames(${r});`),t.write(`for (let ${u} = 0; ${u} < ${l}.length; ${u}++) {`),t.indented(t=>{t.write(`const ${i} = ${l}[${u}];`),t.write(`if (${i} === "__proto__" || !${s}.call(${r}, ${i})) continue;`),a(t)}),t.write(`}`),t.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),t.indented(t=>{t.write(`const ${i} = ${c}[${u}];`),t.write(`if (!${s}.call(${r}, ${i})) continue;`),o?t.write(o):a(t)}),t.write(`}`)}function Sp(t,n){return typeof n==`string`?ql(n):_f(t,n)}function Cp(t,n,r,i){let a=r._zod.def;t.write(`if (!(${i} instanceof Map)) return INVALID;`),sp(t,r,`${i}.size`);let o=J(n),s=J(n),c=J(n);return t.write(`const ${o} = new Map();`),t.write(`for (const [${s}, ${c}] of ${i}) {`),t.indented(t=>{let r=Vf(t,n,a.keyType,s),i=Vf(t,n,a.valueType,c);t.write(`${o}.set(${r}, ${i});`)}),t.write(`}`),o}function wp(t,n,r,i){let a=r._zod.def;t.write(`if (!(${i} instanceof Set)) return INVALID;`),sp(t,r,`${i}.size`);let o=J(n),s=J(n);return t.write(`const ${o} = new Set();`),t.write(`for (const ${s} of ${i}) {`),t.indented(t=>{let r=Vf(t,n,a.valueType,s);t.write(`${o}.add(${r});`)}),t.write(`}`),o}function Tp(t,n){return t.write(`if (!(${n} instanceof File)) return INVALID;`),n}function Ep(t,n,r,i){t.write(`if (typeof ${i} !== "string") return INVALID;`);let a=r._zod.pattern;if(a){let r=_f(n,a);t.write(`${r}.lastIndex = 0;`),t.write(`if (!${r}.test(${i})) return INVALID;`)}return i}function Dp(t,n,r,i){let a=r._zod.def,o=vf(n,a.getter),s=_f(n,{parser:null});t.write(`if (!${s}.parser) {`),t.indented(t=>{t.write(`const inner = ${o}();`),t.write(`${s}.parser = function(input) {`),t.indented(t=>{t.write(`const result = inner._zod.run({ value: input, issues: [] }, {});`),t.write(`return result.issues.length === 0 ? result.value : INVALID;`)}),t.write(`};`)}),t.write(`}`);let c=J(n);return t.write(`const ${c} = ${s}.parser(${i});`),t.write(`if (${c} === INVALID) return INVALID;`),c}function Op(t,n,r,i){let a=r._zod.def,o=Vf(t,n,a.in,i);if(a.transform){if(kp(a.transform))throw new uf(`z.compile: async transforms in pipes are not supported`);let r=a.transform,i=vf(n,t=>{let n={value:t,issues:[],addIssue:Lf},i=r(t,n);return i instanceof Promise?cf:n.issues.length===0?i:cf}),s=J(n);return t.write(`const ${s} = ${i}(${o});`),t.write(`if (${s} === INVALID) return INVALID;`),Vf(t,n,a.out,s)}return Vf(t,n,a.out,o)}function kp(t){return typeof t==`function`&&(t.constructor.name===`AsyncFunction`||t[Symbol.toStringTag]===`AsyncFunction`)}function Ap(t,n,r,i){let a=r._zod.def;if(a.fn){if(kp(a.fn))throw new uf(`z.compile: async custom predicates are not supported`);let r=vf(n,a.fn),o=_f(n,If),s=J(n);t.write(`const ${s} = ${r}(${i});`),t.write(`if (${s} instanceof Promise) ${o}();`),t.write(`if (!${s}) return INVALID;`)}else throw new df(`custom schema without a predicate function`);return i}function jp(t,n,r){let i=t._zod.run({value:r,issues:[]},{});if(i&&typeof i.then==`function`)return cf;let a=i;return a.issues.length===0?a.value:n()}function Mp(t,n,r,i){let a=r._zod.def;if(!a.catchValue[`~constantCatch`])throw new df(`catch with a callback (only a constant catch value compiles)`,!1);let o=J(n);t.write(`let ${o} = (() => {`),t.indented(t=>{let r=bf(t,n,a.innerType,i);t.write(`return ${r};`)}),t.write(`})();`);let s=_f(n,a.innerType),c=vf(n,a.catchValue),l=_f(n,jp);return t.write(`if (${o} === INVALID) {`),t.indented(t=>{t.write(`${o} = ${l}(${s}, ${c}, ${i});`),t.write(`if (${o} === INVALID) return INVALID;`)}),t.write(`}`),o}function Np(t,n,r,i){let a=r._zod.def;if(a.transform){if(kp(a.transform))throw new uf(`z.compile: async transforms are not supported`);let r=a.transform,o=vf(n,t=>{let n={value:t,issues:[],addIssue:Lf},i=r(t,n);return i instanceof Promise?cf:n.issues.length===0?i:cf}),s=J(n);return t.write(`const ${s} = ${o}(${i});`),t.write(`if (${s} === INVALID) return INVALID;`),s}return i}const Pp=()=>{let t={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function n(n){return t[n]??null}let r={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},i={nan:`NaN`};function a(t,n){return t===`number`&&typeof n==`number`&&!Number.isFinite(n)?String(n):i[t]??t}return t=>{switch(t.code){case`invalid_type`:return`Invalid input: expected ${a(t.expected)}, received ${a(pu(t.input),t.input)}`;case`invalid_value`:return t.values.length===1?`Invalid input: expected ${tu(t.values[0])}`:`Invalid option: expected one of ${zl(t.values,`|`)}`;case`too_big`:{let r=t.exact?`exactly `:t.inclusive?`<=`:`<`,i=n(t.origin);return i?`Too big: expected ${t.origin??`value`} to have ${r}${t.maximum.toString()} ${i.unit??`elements`}`:`Too big: expected ${t.origin??`value`} to be ${r}${t.maximum.toString()}`}case`too_small`:{let r=t.exact?`exactly `:t.inclusive?`>=`:`>`,i=n(t.origin);return i?`Too small: expected ${t.origin} to have ${r}${t.minimum.toString()} ${i.unit}`:`Too small: expected ${t.origin} to be ${r}${t.minimum.toString()}`}case`invalid_format`:{let n=t;return n.format===`starts_with`?`Invalid string: must start with "${n.prefix}"`:n.format===`ends_with`?`Invalid string: must end with "${n.suffix}"`:n.format===`includes`?`Invalid string: must include "${n.includes}"`:n.format===`regex`?`Invalid string: must match pattern ${n.pattern}`:`Invalid ${r[n.format]??t.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${t.divisor}`;case`unrecognized_keys`:return`Unrecognized key${t.keys.length>1?`s`:``}: ${zl(t.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${t.origin}`;case`invalid_union`:return t.options&&Array.isArray(t.options)&&t.options.length>0?`Invalid discriminator value. Expected ${t.options.map(t=>`'${t}'`).join(` | `)}`:t.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${t.origin}`;default:return`Invalid input`}}};function Fp(){return{localeError:Pp()}}function Ip(t){return t.checks&&=[...t.checks],t}// @__NO_SIDE_EFFECTS__
function Lp(t,n){return new t(Ip({type:`string`,...eu(n)}))}// @__NO_SIDE_EFFECTS__
function Rp(t,n){return new t(Ip({type:`number`,checks:[],...eu(n)}))}// @__NO_SIDE_EFFECTS__
function zp(t,n){return new t({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...eu(n)})}// @__NO_SIDE_EFFECTS__
function Bp(t,n){return new t({type:`boolean`,...eu(n)})}// @__NO_SIDE_EFFECTS__
function Vp(t){return new t({type:`any`})}// @__NO_SIDE_EFFECTS__
function Hp(t){return new t({type:`unknown`})}// @__NO_SIDE_EFFECTS__
function Up(t,n,r){let i=eu(r);return i.abort??=!0,new t({type:`custom`,check:`custom`,fn:n,...i})}let Wp=!1;ju.postProcessor=t=>{if(Wp)return;let n=t._zod?.run;if(typeof n!=`function`)return;let r=(r,i)=>{if(i?.async||i?.direction===`backward`||i?.skipChecks)return n(r,i);Wp=!0;try{if(ju.jitless)return t._zod.run=n,n(r,i);let a=pf(t,{strict:!0});t._zod.run=a._zod.run,t._zod.bag.fallbackRun=a._zod.bag.fallbackRun,t._zod.bag.validator=a._zod.bag.validator}catch{t._zod.run=n}finally{Wp=!1}return t._zod.run(r,i)};r.__originalRun=n,t._zod.run=r};const Gp=/*@__PURE__*/ ku(`ZodMiniType`,(t,n)=>{if(!t._zod)throw Error(`Uninitialized schema in ZodMiniType.`);ud.init(t,n),t.def=n,t.type=n.type},{get with(){return this.check},set with(t){gu(this,`with`,t)},parse(t,n){return ed(this,t,n,{callee:this.parse})},parseAsync(t,n){return td(this,t,n,{callee:this.parseAsync})},safeParse(t,n){return nd(this,t,n)},safeParseAsync(t,n){return id(this,t,n)},check(...t){let n=this.def;return this.clone({...n,checks:[...n.checks??[],...t.map(t=>typeof t==`function`?{_zod:{check:t,def:{check:`custom`},onattach:[]}}:t)]},{parent:!0})},clone(t,n){return $l(this,t,n)},brand(){return this},register(t,n){return t.add(this,n),this},apply(t,...n){return n.length===0?t(this):t(this,...n)}}),Kp=/*@__PURE__*/ ku(`ZodMiniString`,(t,n)=>{md.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function qp(t){return/* @__PURE__ */ Lp(Kp,t)}const Jp=/*@__PURE__*/ ku(`ZodMiniNumber`,(t,n)=>{Pd.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function Yp(t){return/* @__PURE__ */ Rp(Jp,t)}const Xp=/*@__PURE__*/ ku(`ZodMiniNumberFormat`,(t,n)=>{Fd.init(t,n),Jp.init(t,n)});function Zp(t){return/* @__PURE__ */ zp(Xp,t)}const Qp=/*@__PURE__*/ ku(`ZodMiniBoolean`,(t,n)=>{Id.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function $p(t){return/* @__PURE__ */ Bp(Qp,t)}const em=/*@__PURE__*/ ku(`ZodMiniAny`,(t,n)=>{Ld.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function tm(){return/* @__PURE__ */ Vp(em)}const nm=/*@__PURE__*/ ku(`ZodMiniUnknown`,(t,n)=>{Rd.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function rm(){return/* @__PURE__ */ Hp(nm)}const im=/*@__PURE__*/ ku(`ZodMiniArray`,(t,n)=>{Hd.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function am(t,n){return new im({type:`array`,element:t,...eu(n)})}const om=/*@__PURE__*/ ku(`ZodMiniObject`,(t,n)=>{qd.init(t,n),Gp.init(t,n),wu(t,`shape`,t=>t._zod.def.shape,!1)});// @__NO_SIDE_EFFECTS__
function sm(t,n){let r={type:`object`,shape:t??{},...eu(n)};return new om(r)}const cm=/*@__PURE__*/ ku(`ZodMiniUnion`,(t,n)=>{Yd.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function lm(t,n){return new cm({type:`union`,options:t,...eu(n)})}const um=/*@__PURE__*/ ku(`ZodMiniTuple`,(t,n)=>{Zd.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function dm(t,n,r){let i=n instanceof ud;return new um({type:`tuple`,items:t,rest:i?n:null,...eu(i?r:n)})}const fm=/*@__PURE__*/ ku(`ZodMiniLiteral`,(t,n)=>{tf.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function pm(t,n){return new fm({type:`literal`,values:Array.isArray(t)?t:[t],...eu(n)})}const mm=/*@__PURE__*/ ku(`ZodMiniOptional`,(t,n)=>{rf.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function hm(t){return new mm({type:`optional`,innerType:t})}const gm=/*@__PURE__*/ ku(`ZodMiniCustom`,(t,n)=>{of.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function _m(t,n){return/* @__PURE__ */ Up(gm,t??(()=>!0),n)}// @__NO_SIDE_EFFECTS__
function vm(t,n={}){let r=/* @__PURE__ */ _m(n=>n instanceof t,n);return r._zod.bag.Class=t,r._zod.check=n=>{n.value instanceof t||n.issues.push({code:`invalid_type`,expected:t.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}const ym=/*@__PURE__*/ ku(`ZodMiniFunction`,(t,n)=>{af.init(t,n),Gp.init(t,n)});// @__NO_SIDE_EFFECTS__
function bm(t){return new ym({type:`function`,input:Array.isArray(t?.input)?/* @__PURE__ */ dm(t?.input):t?.input??/* @__PURE__ */ am(/* @__PURE__ */ rm()),output:t?.output??/* @__PURE__ */ rm()})}var xm={"p5.Color":{toString:{overloads:[[`String?`]]},contrast:{overloads:[[`Color`]]},setRed:{overloads:[[`Number`]]},setGreen:{overloads:[[`Number`]]},setBlue:{overloads:[[`Number`]]},setAlpha:{overloads:[[`Number`]]}},"p5.Image":{pixelDensity:{overloads:[[`Number?`]]},loadPixels:{overloads:[[]]},updatePixels:{overloads:[[`Integer?`,`Integer?`,`Integer?`,`Integer?`]]},get:{overloads:[[`Number`,`Number`,`Number`,`Number`],[],[`Number`,`Number`]]},set:{overloads:[[`Number`,`Number`,`Number|Number[]|Object`]]},resize:{overloads:[[`Number`,`Number`]]},copy:{overloads:[[`p5.Image|p5.Element`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`],[`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`]]},mask:{overloads:[[`p5.Image`]]},filter:{overloads:[[`THRESHOLD|GRAY|OPAQUE|INVERT|POSTERIZE|ERODE|DILATE|BLUR`,`Number?`]]},blend:{overloads:[[`p5.Image`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|NORMAL`],[`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|NORMAL`]]},save:{overloads:[[`String`,`String?`]]},reset:{overloads:[[]]},getCurrentFrame:{overloads:[[]]},setFrame:{overloads:[[`Number`]]},numFrames:{overloads:[[]]},play:{overloads:[[]]},pause:{overloads:[[]]},delay:{overloads:[[`Number`,`Number?`]]}},p5:{remove:{overloads:[[]]},p5:{overloads:[[`Object`,`String|HTMLElement`]]},isMatrixArray:{overloads:[[]]},fromAxisAngle:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`]]},day:{overloads:[[]]},loadingAnimation:{overloads:[[`Function?`]]},multiply:{overloads:[[`p5.Quat?`]]},print:{overloads:[[`Any`],[`String|Number|Array`]]},hour:{overloads:[[]]},randomSeed:{overloads:[[`Number`]]},float:{overloads:[[`String`],[`String[]`]]},ellipseMode:{overloads:[[`CENTER|RADIUS|CORNER|CORNERS`],[]]},abs:{overloads:[[`Number`]]},rotateBy:{overloads:[[`p5.Quat?`]]},nf:{overloads:[[`Number|String`,`Integer|String?`,`Integer|String?`],[`Number[]`,`Integer|String?`,`Integer|String?`]]},strokeMode:{overloads:[[`String`]]},select:{overloads:[[`String`,`String|p5.Element|HTMLElement?`]]},createVector:{overloads:[[`...Number[]`]]},minute:{overloads:[[]]},noLoop:{overloads:[[]]},storeItem:{overloads:[[`String`,`String|Number|Boolean|Object|Array`]]},textOutput:{overloads:[[`FALLBACK|LABEL?`]]},describe:{overloads:[[`String`,`FALLBACK|LABEL?`,`String?`],[`String`,`String?`]]},blend:{overloads:[[`p5.Image`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|NORMAL`],[`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|NORMAL`]]},createCanvas:{overloads:[[`Number?`,`Number?`,`P2D|WEBGL|P2DP3?`,`HTMLCanvasElement?`],[`Number`,`Number`,`WEBGPU`,`HTMLCanvasElement?`],[`Number?`,`Number?`,`HTMLCanvasElement?`]]},loadImage:{overloads:[[`String|Request`,`function(p5.Image)?`,`function(Event)?`]]},loadShader:{overloads:[[`String|Request`,`String|Request`,`Function?`,`Function?`]]},createImage:{overloads:[[`Integer`,`Integer`]]},orbitControl:{overloads:[[`Number?`,`Number?`,`Number?`,`Object?`]]},noSmooth:{overloads:[[]]},ceil:{overloads:[[`Number`]]},ambientLight:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`Number`,`Number?`],[`String`],[`Number[]`],[`p5.Color`]]},beginClip:{overloads:[[`Object?`]]},selectAll:{overloads:[[`String`,`String|p5.Element|HTMLElement?`]]},bezier:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},acos:{overloads:[[`Number`]]},int:{overloads:[[`String|Boolean|Number`],[`Array`]]},copy:{overloads:[[`p5.Image|p5.Element`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`],[`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`,`Integer`]]},loop:{overloads:[[]]},endClip:{overloads:[[]]},applyMatrix:{overloads:[[`Number[]`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},nfc:{overloads:[[`Number|String`,`Integer|String?`],[`Number[]`,`Integer|String?`]]},constrain:{overloads:[[`Number`,`Number`,`Number`]]},push:{overloads:[[]]},millis:{overloads:[[]]},isLooping:{overloads:[[]]},gridOutput:{overloads:[[`FALLBACK|LABEL?`]]},describeElement:{overloads:[[`String`,`String`,`FALLBACK|LABEL?`,`String?`],[`String`,`String`,`String?`]]},saveCanvas:{overloads:[[`p5.Framebuffer|p5.Element|HTMLCanvasElement`,`String?`,`String?`],[`String?`,`String?`]]},resetMatrix:{overloads:[[]]},resizeCanvas:{overloads:[[`Number`,`Number`,`Boolean?`]]},getItem:{overloads:[[`String`]]},noise:{overloads:[[`Number`,`Number?`,`Number?`]]},arc:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`CHORD|PIE|OPEN?`,`Integer?`]]},month:{overloads:[[]]},rectMode:{overloads:[[`CENTER|RADIUS|CORNER|CORNERS`],[]]},random:{overloads:[[`Number?`,`Number?`],[`Array`]]},saveGif:{overloads:[[`String`,`Number`,`Object?`]]},loadJSON:{overloads:[[`String|Request`,`Function?`,`Function?`]]},createElement:{overloads:[[`String`,`String?`]]},asin:{overloads:[[`Number`]]},cursor:{overloads:[[`ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String`,`Number?`,`Number?`],[]]},dist:{overloads:[[`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},noCanvas:{overloads:[[]]},str:{overloads:[[`String|Boolean|Number`]]},second:{overloads:[[]]},buildGeometry:{overloads:[[`Function`]]},byte:{overloads:[[`String|Boolean|Number`],[`Array`]]},bezierPoint:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`]]},redraw:{overloads:[[`Integer?`]]},year:{overloads:[[]]},transform2D:{overloads:[[`...Number?[]`]]},transform3D:{overloads:[[`...Number?[]`]]},mat2:{overloads:[[`...Number?[]`]]},mat2x2:{overloads:[[`...Number?[]`]]},mat3:{overloads:[[`...Number?[]`]]},mat3x3:{overloads:[[`...Number?[]`]]},mat4:{overloads:[[`...Number?[]`]]},mat4x4:{overloads:[[`...Number?[]`]]},removeElements:{overloads:[[]]},smooth:{overloads:[[]]},nfp:{overloads:[[`Number`,`Integer?`,`Integer?`],[`Number[]`,`Integer?`,`Integer?`]]},clearStorage:{overloads:[[]]},beginShape:{overloads:[[`POINTS|LINES|TRIANGLES|TRIANGLE_FAN|TRIANGLE_STRIP|QUADS|QUAD_STRIP|PATH?`]]},randomGaussian:{overloads:[[`Number?`,`Number?`]]},addElement:{overloads:[[]]},instanceID:{overloads:[[]]},smoothstep:{overloads:[[`Number`,`Number`,`Number`]]},uniformStorage:{overloads:[[`String`,`p5.StorageBuffer|Function|Object?`],[`p5.StorageBuffer|Function|Object?`]]},getTexture:{overloads:[[null,null]]},getWorldInputs:{overloads:[[`Function`]]},getPixelInputs:{overloads:[[`Function`]]},getFinalColor:{overloads:[[`Function`]]},getColor:{overloads:[[`Function`]]},getObjectInputs:{overloads:[[`Function`]]},getCameraInputs:{overloads:[[`Function`]]},mix:{overloads:[[`Number|p5.Vector`,`Number|p5.Vector`,`Number|Boolean`]]},clip:{overloads:[[`Function`,`Object?`]]},set:{overloads:[[`Number`,`Number`,`Number|Number[]|Object`]]},atan:{overloads:[[`Number`]]},freeGeometry:{overloads:[[`p5.Geometry`]]},frameRate:{overloads:[[`Number`],[]]},strokeCap:{overloads:[[`ROUND|SQUARE|PROJECT`]]},saveObj:{overloads:[[`String?`]]},noiseDetail:{overloads:[[`Number`,`Number?`]]},exp:{overloads:[[`Number`]]},specularColor:{overloads:[[`Number`,`Number`,`Number`],[`Number`],[`String`],[`Number[]`],[`p5.Color`]]},color:{overloads:[[`Number`,`Number?`],[`Number`,`Number`,`Number`,`Number?`],[`String`],[`Number[]`],[`p5.Color`]]},createGraphics:{overloads:[[`Number`,`Number`,`P2D|WEBGL?`,`HTMLCanvasElement?`],[`Number`,`Number`,`HTMLCanvasElement?`]]},createDiv:{overloads:[[`String?`]]},loadStrings:{overloads:[[`String|Request`,`Function?`,`Function?`]]},boolean:{overloads:[[`String|Boolean|Number`],[`Array`]]},removeItem:{overloads:[[`String`]]},bezierTangent:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`]]},ellipse:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`Number`,`Number`,`Number`,`Number`,`Integer?`]]},setMoveThreshold:{overloads:[[`Number`]]},createP:{overloads:[[`String?`]]},createShader:{overloads:[[`String`,`String`,`Object?`]]},atan2:{overloads:[[`Number`,`Number`]]},nfs:{overloads:[[`Number`,`Integer?`,`Integer?`],[`Array`,`Integer?`,`Integer?`]]},getTargetFrameRate:{overloads:[[]]},setShakeThreshold:{overloads:[[`Number`]]},noiseSeed:{overloads:[[`Number`]]},circle:{overloads:[[`Number`,`Number`,`Number`]]},clear:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`],[]]},rotate:{overloads:[[`Number`,`p5.Vector|Number[]?`],[null,`Number`]]},noCursor:{overloads:[[]]},floor:{overloads:[[`Number`]]},loadTable:{overloads:[[`String|Request`,`String?`,`String?`,`Function?`,`Function?`]]},rotateAxisAngle:{overloads:[[null,null,`Number`]]},filter:{overloads:[[`THRESHOLD|GRAY|OPAQUE|INVERT|POSTERIZE|BLUR|ERODE|DILATE|BLUR`,`Number?`,`Boolean?`],[`p5.Shader`]]},plane:{overloads:[[`Number?`,`Number?`,`Integer?`,`Integer?`]]},strokeJoin:{overloads:[[`MITER|BEVEL|ROUND`],[]]},createSpan:{overloads:[[`String?`]]},saveStl:{overloads:[[`String?`,`Object?`]]},loadFilterShader:{overloads:[[`String`,`Function?`,`Function?`]]},createFramebuffer:{overloads:[[`Object?`]]},createImg:{overloads:[[`String`,`String`],[`String`,`String`,`String?`,`Function?`]]},loadModel:{overloads:[[`String|Request`,`String?`,`Boolean?`,`function(p5.Geometry)?`,`function(Event)?`],[`String|Request`,`String?`,`function(p5.Geometry)?`,`function(Event)?`],[`String|Request`,`Boolean`,`function(p5.Geometry)?`,`function(Event)?`],[`String|Request`,`Object?`]]},red:{overloads:[[`p5.Color|Number[]|String`]]},strokeWeight:{overloads:[[`Number`],[]]},cos:{overloads:[[`Number`]]},deviceMoved:{overloads:[[]]},deviceTurned:{overloads:[[]]},deviceShaken:{overloads:[[]]},directionalLight:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`p5.Vector`],[`p5.Color|Number[]|String`,`Number`,`Number`,`Number`],[`p5.Color|Number[]|String`,`p5.Vector`]]},background:{overloads:[[`p5.Color`],[`String`,`Number?`],[`Number`,`Number?`],[`Number`,`Number`,`Number`,`Number?`],[`Number[]`],[`p5.Image`,`Number?`]]},splitTokens:{overloads:[[`String`,`String?`]]},keyPressed:{overloads:[[`KeyboardEvent?`]]},lerp:{overloads:[[`Number`,`Number`,`Number`]]},transformPoint:{overloads:[[null,null]]},box:{overloads:[[`Number?`,`Number?`,`Number?`,`Integer?`,`Integer?`]]},createA:{overloads:[[`String`,`String`,`String?`]]},bezierVertex:{overloads:[[`Number`,`Number`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`Number?`,`Number?`]]},saveFrames:{overloads:[[`String`,`String`,`Number`,`Number`,`function(Array)?`]]},line:{overloads:[[`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},clearDepth:{overloads:[[`Number?`]]},rotateX:{overloads:[[`Number`],[null,`Number`]]},char:{overloads:[[`String|Number`],[`Array`]]},debugMode:{overloads:[[],[`GRID|AXES`],[`GRID|AXES`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`],[`GRID|AXES`,`Number?`,`Number?`,`Number?`,`Number?`],[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},spline:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},get:{overloads:[[`Number`,`Number`,`Number`,`Number`],[],[`Number`,`Number`]]},transformNormal:{overloads:[[null,null]]},sin:{overloads:[[`Number`]]},loadXML:{overloads:[[`String|Request`,`Function?`,`Function?`]]},roll:{overloads:[[`Number`]]},setup:{overloads:[[]]},draw:{overloads:[[]]},registerAddon:{overloads:[[`Function`]]},log:{overloads:[[`Number`]]},green:{overloads:[[`p5.Color|Number[]|String`]]},shuffle:{overloads:[[`Array`,`Boolean?`]]},loadPixels:{overloads:[[]]},sphere:{overloads:[[`Number?`,`Integer?`,`Integer?`]]},unchar:{overloads:[[`String`],[`String[]`]]},noDebugMode:{overloads:[[]]},loadBytes:{overloads:[[`String|Request`,`Function?`,`Function?`]]},buildFilterShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},createSlider:{overloads:[[`Number`,`Number`,`Number?`,`Number?`]]},windowResized:{overloads:[[`Event?`]]},mag:{overloads:[[`Number`,`Number`]]},tan:{overloads:[[`Number`]]},keyReleased:{overloads:[[`KeyboardEvent?`]]},loadBlob:{overloads:[[`String|Request`,`Function?`,`Function?`]]},point:{overloads:[[`Number`,`Number`,`Number?`],[`p5.Vector`]]},pointLight:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`],[`Number`,`Number`,`Number`,`p5.Vector`],[`p5.Color|Number[]|String`,`Number`,`Number`,`Number`],[`p5.Color|Number[]|String`,`p5.Vector`]]},fullscreen:{overloads:[[`Boolean?`]]},createButton:{overloads:[[`String`,`String?`]]},rotateY:{overloads:[[`Number`],[null,`Number`]]},createFilterShader:{overloads:[[`String`]]},degrees:{overloads:[[`Number`]]},endShape:{overloads:[[`CLOSE|OPEN?`,`Integer?`],[`Integer`]]},hex:{overloads:[[`Number`,`Number?`],[`Number[]`,`Number?`]]},splinePoint:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`]]},map:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Boolean?`]]},httpGet:{overloads:[[`String|Request`,`String?`,`Function?`,`Function?`],[`String|Request`,`Function`,`Function?`]]},imageLight:{overloads:[[`p5.Image`]]},blue:{overloads:[[`p5.Color|Number[]|String`]]},updatePixels:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`],[]]},pixelDensity:{overloads:[[`Number?`],[]]},keyTyped:{overloads:[[`KeyboardEvent?`]]},radians:{overloads:[[`Number`]]},createCheckbox:{overloads:[[`String?`,`Boolean?`]]},panorama:{overloads:[[`p5.Image`]]},cylinder:{overloads:[[`Number?`,`Number?`,`Integer?`,`Integer?`,`Boolean?`,`Boolean?`]]},displayDensity:{overloads:[[]]},unhex:{overloads:[[`String`],[`String[]`]]},quad:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Integer?`,`Integer?`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Integer?`,`Integer?`]]},httpPost:{overloads:[[`String|Request`,`Object|Boolean?`,`String?`,`Function?`,`Function?`],[`String|Request`,`Object|Boolean`,`Function?`,`Function?`],[`String|Request`,`Function?`,`Function?`]]},max:{overloads:[[`Number`,`Number`,`...Number[]`],[`Number[]`]]},getURL:{overloads:[[]]},lights:{overloads:[[]]},alpha:{overloads:[[`p5.Color|Number[]|String`]]},splineTangent:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`]]},rotateZ:{overloads:[[`Number`],[null,`Number`]]},getURLPath:{overloads:[[]]},normal:{overloads:[[`p5.Vector`],[`Number`,`Number`,`Number`]]},createShape:{overloads:[[]]},colorMode:{overloads:[[`RGB|HSB|HSL|RGBP3|HWB|LAB|LCH|OKLAB|OKLCH`,`Number?`],[`RGB|HSB|HSL|RGBP3|HWB|LAB|LCH|OKLAB|OKLCH`,`Number`,`Number`,`Number`,`Number?`],[]]},keyIsDown:{overloads:[[`Number|String`]]},getURLParams:{overloads:[[]]},lightFalloff:{overloads:[[`Number`,`Number`,`Number`]]},mouseMoved:{overloads:[[`MouseEvent?`]]},mouseDragged:{overloads:[[`MouseEvent?`]]},shader:{overloads:[[`p5.Shader`]]},setContent:{overloads:[[`String`]]},image:{overloads:[[`p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture|p5.Renderer|p5.Graphics`,`Number`,`Number`,`Number?`,`Number?`],[`p5.Image|p5.Element|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number?`,`Number?`,`CONTAIN|COVER?`,`LEFT|RIGHT|CENTER?`,`TOP|BOTTOM|CENTER?`]]},angleMode:{overloads:[[`RADIANS|DEGREES`],[]]},rect:{overloads:[[`Number`,`Number`,`Number`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`Number`,`Integer?`,`Integer?`]]},min:{overloads:[[`Number`,`Number`,`...Number[]`],[`Number[]`]]},httpDo:{overloads:[[`String|Request`,`String?`,`String?`,`Object?`,`Function?`,`Function?`],[`String|Request`,`Function?`,`Function?`]]},buildShape:{overloads:[[`Function`,`Object?`]]},createSelect:{overloads:[[`Boolean?`],[`Object`]]},hue:{overloads:[[`p5.Color|Number[]|String`]]},cone:{overloads:[[`Number?`,`Number?`,`Integer?`,`Integer?`,`Boolean?`]]},norm:{overloads:[[`Number`,`Number`,`Number`]]},getSVG:{overloads:[[`p5.ShapeCollection`]]},worldToScreen:{overloads:[[`Number|p5.Vector`,`Number`,`Number?`]]},square:{overloads:[[`Number`,`Number`,`Number`,`Number?`,`Number?`,`Number?`,`Number?`]]},vertexProperty:{overloads:[[`String`,`Number|Number[]`]]},screenToWorld:{overloads:[[`Number|p5.Vector`,`Number`,`Number?`]]},scale:{overloads:[[`Number|p5.Vector|Number[]`,`Number?`,`Number?`],[`p5.Vector|Number[]`],[null,`Number`,`Number?`,`Number?`]]},mousePressed:{overloads:[[`MouseEvent?`]]},strokeShader:{overloads:[[`p5.Shader`]]},pow:{overloads:[[`Number`,`Number`]]},spotLight:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number?`,`Number?`],[`p5.Color|Number[]|String`,`p5.Vector`,`p5.Vector`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`p5.Vector`,`p5.Vector`,`Number?`,`Number?`],[`p5.Color|Number[]|String`,`Number`,`Number`,`Number`,`p5.Vector`,`Number?`,`Number?`],[`p5.Color|Number[]|String`,`p5.Vector`,`Number`,`Number`,`Number`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`p5.Vector`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`p5.Vector`,`Number`,`Number`,`Number`,`Number?`,`Number?`],[`p5.Color|Number[]|String`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number`,`Number?`,`Number?`]]},createWriter:{overloads:[[`String`,`String?`]]},fill:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`String`],[`Number`,`Number?`],[`Number[]`],[`p5.Color`],[]]},text:{overloads:[[`String|Object|Array|Number|Boolean`,`Number`,`Number`,`Number?`,`Number?`]]},textAlign:{overloads:[[`LEFT|CENTER|RIGHT?`,`TOP|BOTTOM|CENTER|BASELINE?`]]},textAscent:{overloads:[[`String?`]]},textDescent:{overloads:[[`String?`]]},textLeading:{overloads:[[`Number?`]]},textFont:{overloads:[[`p5.Font|String|Object?`,`Number?`]]},textSize:{overloads:[[`Number`],[]]},textStyle:{overloads:[[`NORMAL|ITALIC|BOLD|BOLDITALIC`],[]]},textWidth:{overloads:[[`String`]]},textWrap:{overloads:[[`WORD|CHAR`],[]]},textBounds:{overloads:[[`String`,`Number`,`Number`,`Number?`,`Number?`]]},textDirection:{overloads:[[`String`],[]]},textProperty:{overloads:[[`String`,null],[`String`]]},textProperties:{overloads:[[`Object`],[]]},fontBounds:{overloads:[[`String`,`Number`,`Number`,`Number?`,`Number?`]]},fontWidth:{overloads:[[`String`]]},fontAscent:{overloads:[[]]},fontDescent:{overloads:[[]]},textWeight:{overloads:[[`Number`],[]]},triangle:{overloads:[[`Number`,`Number`,`Number`,`Number`,`Number`,`Number`]]},ellipsoid:{overloads:[[`Number?`,`Number?`,`Number?`,`Integer?`,`Integer?`]]},tint:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`String`],[`Number`,`Number?`],[`Number[]`],[`p5.Color`],[]]},round:{overloads:[[`Number`,`Number?`]]},noFill:{overloads:[[]]},saturation:{overloads:[[`p5.Color|Number[]|String`]]},noLights:{overloads:[[]]},noTint:{overloads:[[]]},model:{overloads:[[`p5.Geometry`,`Number?`]]},shearX:{overloads:[[`Number`],[null,`Number`]]},imageShader:{overloads:[[`p5.Shader`]]},mouseReleased:{overloads:[[`MouseEvent?`]]},noStroke:{overloads:[[]]},createRadio:{overloads:[[`Object?`],[`String?`],[]]},write:{overloads:[[`String|Number|Array`]]},sq:{overloads:[[`Number`]]},createVideo:{overloads:[[`String|String[]?`,`Function?`]]},loadFont:{overloads:[[`String`,`String?`,`Object?`,`Function?`,`Function?`],[`String`,`Function?`,`Function?`]]},createModel:{overloads:[[`String`,`String?`,`Boolean?`,`function(p5.Geometry)?`,`function(Event)?`],[`String`,`String?`,`function(p5.Geometry)?`,`function(Event)?`],[`String`,`String?`,`Object?`]]},createAudio:{overloads:[[`String|String[]?`,`Function?`]]},torus:{overloads:[[`Number?`,`Number?`,`Integer?`,`Integer?`]]},imageMode:{overloads:[[`CORNER|CORNERS|CENTER`],[]]},shearY:{overloads:[[`Number`],[null,`Number`]]},brightness:{overloads:[[`p5.Color|Number[]|String`]]},sqrt:{overloads:[[`Number`]]},close:{overloads:[[]]},mouseClicked:{overloads:[[`MouseEvent?`]]},createSVG:{overloads:[[`String|SVGElement`]]},shape:{overloads:[[`p5.ShapeCollection`,`Number?`,`Number?`,`Object?`]]},buildMaterialShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},fract:{overloads:[[`Number`]]},createCapture:{overloads:[[`AUDIO|VIDEO|Object?`,`Object?`,`Function?`]]},loadSVG:{overloads:[[`String`,`Function?`,`Function?`]]},createColorPicker:{overloads:[[`String|p5.Color?`]]},stroke:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`String`],[`Number`,`Number?`],[`Number[]`],[`p5.Color`],[]]},saveSVG:{overloads:[[`p5.ShapeCollection|String?`,`String?`]]},loadMaterialShader:{overloads:[[`String`,`Function?`,`Function?`]]},save:{overloads:[[`Object|String?`,`String?`,`Boolean|String?`]]},baseMaterialShader:{overloads:[[]]},lightness:{overloads:[[`p5.Color|Number[]|String`]]},doubleClicked:{overloads:[[`MouseEvent?`]]},baseFilterShader:{overloads:[[]]},erase:{overloads:[[`Number?`,`Number?`]]},createInput:{overloads:[[`String?`,`String?`],[`String?`]]},translate:{overloads:[[`Number`,`Number`,`Number?`],[`p5.Vector`],[null,`Number`,`Number?`,`Number?`]]},noErase:{overloads:[[]]},buildNormalShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},saveJSON:{overloads:[[`Array|Object`,`String`,`Boolean?`]]},mouseWheel:{overloads:[[`WheelEvent?`]]},createFileInput:{overloads:[[`Function`,`Boolean?`]]},lerpColor:{overloads:[[`p5.Color`,`p5.Color`,`Number`],[`p5.Color`,`p5.Color`,`Object`]]},loadNormalShader:{overloads:[[`String`,`Function?`,`Function?`]]},requestPointerLock:{overloads:[[]]},paletteLerp:{overloads:[[`[p5.Color|String|Number|Number[], Number][]`,`Number`]]},baseNormalShader:{overloads:[[]]},saveStrings:{overloads:[[`String[]`,`String`,`String?`,`Boolean?`]]},exitPointerLock:{overloads:[[]]},buildColorShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},saveTable:{overloads:[[`p5.Table`,`String`,`String?`]]},loadColorShader:{overloads:[[`String`,`Function?`,`Function?`]]},baseColorShader:{overloads:[[]]},blendMode:{overloads:[[`BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|REMOVE|SUBTRACT`],[]]},bezierOrder:{overloads:[[`Number`],[]]},setAttributes:{overloads:[[`String`,`Boolean`],[`Object`]]},buildStrokeShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},camera:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},pop:{overloads:[[]]},loadStrokeShader:{overloads:[[`String`,`Function?`,`Function?`]]},baseStrokeShader:{overloads:[[]]},createStorage:{overloads:[[`Number|Array|Float32Array|Uint32Array|Int32Array|Object[]`]]},perspective:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`]]},resetShader:{overloads:[[]]},linePerspective:{overloads:[[`Boolean`],[]]},splineVertex:{overloads:[[`Number`,`Number`],[`Number`,`Number`,`Number?`],[`Number`,`Number`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`Number?`,`Number?`]]},createStorageList:{overloads:[[`Number`,`Object|Object[]?`]]},baseComputeShader:{overloads:[[]]},texture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`]]},ortho:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},curveDetail:{overloads:[[`Number`]]},normalTexture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`,`Number?`]]},frustum:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},instances:{overloads:[[`Number|p5.StorageBuffer|p5.StorageList`]]},buildComputeShader:{overloads:[[`Function`,`Object?`],[`Object`,`Object?`]]},createCamera:{overloads:[[]]},bumpTexture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`,`Number?`]]},splineProperty:{overloads:[[`String`,null],[`String`]]},setCamera:{overloads:[[`p5.Camera`]]},specularTexture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`]]},splineProperties:{overloads:[[`Object`]]},compute:{overloads:[[`p5.Shader`,`Number`,`Number?`,`Number?`]]},ambientTexture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`]]},shininessTexture:{overloads:[[`p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture`]]},vertex:{overloads:[[`Number`,`Number`],[`Number`,`Number`,`Number?`,`Number?`],[`Number`,`Number`,`Number`,`Number?`,`Number?`]]},textureMode:{overloads:[[`IMAGE|NORMAL`],[]]},beginContour:{overloads:[[]]},endContour:{overloads:[[`OPEN|CLOSE?`]]},textureWrap:{overloads:[[`CLAMP|REPEAT|MIRROR`,`CLAMP|REPEAT|MIRROR?`],[`Object`],[]]},normalMaterial:{overloads:[[]]},ambientMaterial:{overloads:[[`Number`,`Number`,`Number`],[`Number`],[`p5.Color|Number[]|String`]]},emissiveMaterial:{overloads:[[`Number`,`Number`,`Number`,`Number?`],[`Number`],[`p5.Color|Number[]|String`]]},specularMaterial:{overloads:[[`Number`,`Number?`],[`Number`,`Number`,`Number`,`Number?`],[`p5.Color|Number[]|String`]]},shininess:{overloads:[[`Number`]]},metalness:{overloads:[[`Number`]]}},"p5.Element":{remove:{overloads:[[]]},parent:{overloads:[[`String|p5.Element|Object`],[]]},child:{overloads:[[],[`String|p5.Element?`]]},html:{overloads:[[],[`String?`,`Boolean?`]]},id:{overloads:[[`String`],[]]},class:{overloads:[[`String`],[]]},addClass:{overloads:[[`String`]]},removeClass:{overloads:[[`String`]]},hasClass:{overloads:[[null]]},toggleClass:{overloads:[[null]]},center:{overloads:[[`String?`]]},position:{overloads:[[],[`Number?`,`Number?`,`String?`]]},show:{overloads:[[]]},hide:{overloads:[[]]},size:{overloads:[[],[`Number|AUTO?`,`Number|AUTO?`]]},style:{overloads:[[`String`],[`String`,`String|p5.Color`]]},attribute:{overloads:[[],[`String`,`String`]]},removeAttribute:{overloads:[[`String`]]},value:{overloads:[[],[`String|Number`]]},mousePressed:{overloads:[[`Function|Boolean`]]},doubleClicked:{overloads:[[`Function|Boolean`]]},mouseWheel:{overloads:[[`Function|Boolean`]]},mouseReleased:{overloads:[[`Function|Boolean`]]},mouseClicked:{overloads:[[`Function|Boolean`]]},mouseMoved:{overloads:[[`Function|Boolean`]]},mouseOver:{overloads:[[`Function|Boolean`]]},mouseOut:{overloads:[[`Function|Boolean`]]},dragOver:{overloads:[[`Function|Boolean`]]},dragLeave:{overloads:[[`Function|Boolean`]]},changed:{overloads:[[`Function|Boolean`]]},input:{overloads:[[`Function|Boolean`]]},drop:{overloads:[[`Function`,`Function?`]]},draggable:{overloads:[[`p5.Element?`]]}},"p5.ShapeCollection":{begin:{overloads:[[`Object?`]]},end:{overloads:[[]]}},"p5.XML":{getParent:{overloads:[[]]},getName:{overloads:[[]]},setName:{overloads:[[`String`]]},hasChildren:{overloads:[[]]},listChildren:{overloads:[[]]},getChildren:{overloads:[[`String?`]]},getChild:{overloads:[[`String|Integer`]]},addChild:{overloads:[[`p5.XML`]]},removeChild:{overloads:[[`String|Integer`]]},getAttributeCount:{overloads:[[]]},listAttributes:{overloads:[[]]},hasAttribute:{overloads:[[`String`]]},getNum:{overloads:[[`String`,`Number?`]]},getString:{overloads:[[`String`,`Number?`]]},setAttribute:{overloads:[[`String`,`Number|String|Boolean`]]},getContent:{overloads:[[`String?`]]},serialize:{overloads:[[]]}},"p5.TableRow":{set:{overloads:[[`String|Integer`,`String|Number`]]},setNum:{overloads:[[`String|Integer`,`Number|String`]]},setString:{overloads:[[`String|Integer`,`String|Number|Boolean|Object`]]},get:{overloads:[[`String|Integer`]]},getNum:{overloads:[[`String|Integer`]]},getString:{overloads:[[`String|Integer`]]}},"p5.Vector":{getValue:{overloads:[[`Number`]]},setValue:{overloads:[[`Number`,`Number`]]},set:{overloads:[[`Number?`,`Number?`,`Number?`],[`p5.Vector|Number[]`]]},copy:{overloads:[[]]},add:{overloads:[[`Number|Array`,`Number?`,`Number?`],[`p5.Vector|Number[]`]]},rem:{overloads:[[`Number`,`Number`,`Number`],[`p5.Vector|Number[]`]]},sub:{overloads:[[`Number`,`Number?`,`Number?`],[`p5.Vector|Number[]`]]},mult:{overloads:[[`Number`],[`Number`,`Number`,`Number?`],[`Number[]`],[`p5.Vector`]]},div:{overloads:[[`Number`],[`Number`,`Number`,`Number?`],[`Number[]`],[`p5.Vector`]]},mag:{overloads:[[]]},magSq:{overloads:[[]]},dot:{overloads:[[`Number`,`Number?`,`Number?`],[`p5.Vector`]]},cross:{overloads:[[`p5.Vector`]]},dist:{overloads:[[`p5.Vector`]]},normalize:{overloads:[[]]},limit:{overloads:[[`Number`]]},setMag:{overloads:[[`Number`]]},heading:{overloads:[[]]},setHeading:{overloads:[[`Number`]]},rotate:{overloads:[[`Number`]]},angleBetween:{overloads:[[`p5.Vector`]]},lerp:{overloads:[[`...Number[]`],[`Number[]`,`Number`],[`p5.Vector`,`Number`]]},slerp:{overloads:[[`p5.Vector`,`Number`]]},reflect:{overloads:[[`p5.Vector`]]},array:{overloads:[[]]},equals:{overloads:[[`Number?`,`Number?`,`Number?`],[`p5.Vector|Array`]]},clampToZero:{overloads:[[]]},fromAngle:{overloads:[[`Number`,`Number?`]]},fromAngles:{overloads:[[`Number`,`Number`,`Number?`]]},random2D:{overloads:[[]]},random3D:{overloads:[[]]}},"p5.File":{revoke:{overloads:[[]]}},"p5.Font":{textToPaths:{overloads:[[`String`,`Number`,`Number`,`Number?`,`Number?`]]},textToPoints:{overloads:[[`String`,`Number`,`Number`,`Object?`]]},textToContours:{overloads:[[`String`,`Number`,`Number`,`Object?`]]},textToModel:{overloads:[[`String`,`Number`,`Number`,`Number`,`Number`,`Object?`]]}},"p5.Table":{addRow:{overloads:[[`p5.TableRow?`]]},removeRow:{overloads:[[`Integer`]]},getRow:{overloads:[[`Integer`]]},getRows:{overloads:[[]]},findRow:{overloads:[[`String`,`Integer|String`]]},findRows:{overloads:[[`String`,`Integer|String`]]},matchRow:{overloads:[[`String|RegExp`,`String|Integer`]]},matchRows:{overloads:[[`String`,`String|Integer?`]]},getColumn:{overloads:[[`String|Number`]]},clearRows:{overloads:[[]]},addColumn:{overloads:[[`String?`]]},getColumnCount:{overloads:[[]]},getRowCount:{overloads:[[]]},removeTokens:{overloads:[[`String`,`String|Integer?`]]},trim:{overloads:[[`String|Integer?`]]},removeColumn:{overloads:[[`String|Integer`]]},set:{overloads:[[`Integer`,`String|Integer`,`String|Number`]]},setNum:{overloads:[[`Integer`,`String|Integer`,`Number`]]},setString:{overloads:[[`Integer`,`String|Integer`,`String`]]},get:{overloads:[[`Integer`,`String|Integer`]]},getNum:{overloads:[[`Integer`,`String|Integer`]]},getString:{overloads:[[`Integer`,`String|Integer`]]},getObject:{overloads:[[`String?`]]},getArray:{overloads:[[]]}},"p5.Shader":{version:{overloads:[[]]},inspectHooks:{overloads:[[]]},modify:{overloads:[[`Function`,`Object?`],[`Object?`]]},copyToContext:{overloads:[[`p5|p5.Graphics`]]},setUniform:{overloads:[[`String`,`Boolean|p5.Vector|p5.Color|Number|Number[]|p5.Image|p5.Graphics|p5.MediaElement|p5.Texture|p5.StorageBuffer`]]}},"p5.MediaElement":{play:{overloads:[[]]},stop:{overloads:[[]]},pause:{overloads:[[]]},loop:{overloads:[[]]},noLoop:{overloads:[[]]},autoplay:{overloads:[[`Boolean?`]]},volume:{overloads:[[],[`Number`]]},speed:{overloads:[[],[`Number`]]},time:{overloads:[[`Number?`]]},duration:{overloads:[[]]},onended:{overloads:[[`Function`]]},connect:{overloads:[[`AudioNode|Object`]]},disconnect:{overloads:[[]]},showControls:{overloads:[[]]},hideControls:{overloads:[[]]},addCue:{overloads:[[`Number`,`Function`,`Object?`]]},removeCue:{overloads:[[`Number`]]},clearCues:{overloads:[[]]}},"p5.StorageBuffer":{update:{overloads:[[`Number[]|Float32Array|Uint32Array|Int32Array|Object[]`]]},read:{overloads:[[]]},set:{overloads:[[`Number`,`Number|Object`]]}},"p5.StorageList":{update:{overloads:[[`Number[]|Float32Array|Object[]`]]},push:{overloads:[[`Number|Object`]]},read:{overloads:[[]]},clear:{overloads:[[]]}},"p5.Framebuffer":{resize:{overloads:[[`Number`,`Number`]]},pixelDensity:{overloads:[[`Number?`]]},autoSized:{overloads:[[`Boolean?`]]},createCamera:{overloads:[[]]},remove:{overloads:[[]]},begin:{overloads:[[]]},end:{overloads:[[]]},draw:{overloads:[[`Function`]]},loadPixels:{overloads:[[]]},get:{overloads:[[`Number`,`Number`,`Number`,`Number`],[],[`Number`,`Number`]]}},"p5.Camera":{perspective:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`]]},ortho:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},frustum:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},pan:{overloads:[[`Number`]]},tilt:{overloads:[[`Number`]]},lookAt:{overloads:[[`Number`,`Number`,`Number`]]},camera:{overloads:[[`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`,`Number?`]]},move:{overloads:[[`Number`,`Number`,`Number`]]},setPosition:{overloads:[[`Number`,`Number`,`Number`]]},set:{overloads:[[`p5.Camera`]]},slerp:{overloads:[[`p5.Camera`,`p5.Camera`,`Number`]]}},"p5.Geometry":{calculateBoundingBox:{overloads:[[]]},clearColors:{overloads:[[]]},flipU:{overloads:[[]]},computeFaces:{overloads:[[]]},computeNormals:{overloads:[[`KEEP_CONNECTIONS|SMOOTH|SEGMENTED?`,`Object?`]]},makeEdgesFromFaces:{overloads:[[]]},normalize:{overloads:[[]]},vertexProperty:{overloads:[[`String`,`Number|Number[]`,`Number?`]]},flipV:{overloads:[[]]}},"p5.Graphics":{reset:{overloads:[[]]},remove:{overloads:[[]]},createFramebuffer:{overloads:[[`Object?`]]}}};Mu(Fp());let Sm=xm;function Cm(t,n,r){let i=/* @__PURE__ */ new Map,a=Object.keys(t).reduce((n,r)=>(r.match(/^[A-Z]/)&&!r.match(/^[A-Z][A-Z0-9]*$/)&&t[r]instanceof Function&&(n[r]=t[r]),n),{});function o(){for(let n of Object.keys(t))typeof t[n]==`function`&&n[0]!==n[0].toLowerCase()&&(a[n]=t[n])}let s={};for(let[t,n]of Object.entries(d))s[t]=n;let c={Any:/* @__PURE__ */ tm(),Array:/* @__PURE__ */ am(/* @__PURE__ */ tm()),Boolean:/* @__PURE__ */ $p(),Function:/* @__PURE__ */ bm(),Integer:(/* @__PURE__ */ Yp()).check(Zp()),Number:/* @__PURE__ */ lm([/* @__PURE__ */ Yp(),/* @__PURE__ */ pm(1/0),/* @__PURE__ */ pm(-1/0)]),Object:/* @__PURE__ */ sm({}),String:/* @__PURE__ */ qp()},l=[`AudioNode`,`HTMLCanvasElement`,`HTMLElement`,`KeyboardEvent`,`MouseEvent`,`RegExp`,`TouchEvent`,`UIEvent`,`WheelEvent`];function u(t){return t.reduce((t,n)=>(t[n]=/* @__PURE__ */ _m(t=>t instanceof globalThis[n],{message:`Expected a ${n}`}),t),{})}let f=u(l);Object.assign(c,f);let p=[`first`,`second`,`third`,`fourth`,`fifth`,`sixth`,`seventh`,`eighth`,`ninth`,`tenth`];function m(t){let n=t.lastIndexOf(`.`);return{funcName:t.slice(n+1),funcClass:t.slice(0,n===-1?0:n)||`p5`}}function h(t){let n=0;for(let r=0;r<t.length;r++)if(t[r]===`[`)n++;else if(t[r]===`]`&&(n--,n<0))return!1;return n===0}let g=function(t){let{funcName:r,funcClass:i}=m(t),o=Sm[i][r];if(!o)return;let l=[];o.hasOwnProperty(`overloads`)&&(l=o.overloads);let u=t=>{if(!t)return/* @__PURE__ */ tm();let r;if(t in s)r=/* @__PURE__ */ pm(s[t]);else if(t.match(/^[A-Z][A-Z0-9]*$/)&&t in n)r=/* @__PURE__ */ pm(n[t]);else if(t.startsWith(`function`))r=/* @__PURE__ */ bm();else if(/^p5\.[a-zA-Z0-9]+$/.exec(t)||t===`p5`){let n=t.substring(t.indexOf(`.`)+1);r=/* @__PURE__ */ vm(a[n])}else if(c[t])r=c[t];else if(t.startsWith(`[`)&&t.endsWith(`]`)&&h(t.slice(1,-1)))r=/* @__PURE__ */ dm(t.slice(1,-1).split(/, */g).map(t=>u(t)));else if(t.match(/^[A-Z]/)&&t in window)r=/* @__PURE__ */ vm(window[t]);else if(t.includes(`|`)&&t.split(`|`).every(t=>h(t)))r=/* @__PURE__ */ lm(t.split(`|`).map(t=>u(t)).filter(t=>t!==void 0));else if(t.endsWith(`[]`))r=/* @__PURE__ */ am(u(t.slice(0,-2)));else throw Error(`Unsupported type '${t}' in parameter validation. Please report this issue.`);return r},d=t=>{let n=t?.endsWith(`?`);t=t?.replace(/\?$/,``);let r=t?.startsWith(`...`)&&t?.endsWith(`[]`);t=t?.replace(/^\.\.\.(.+)\[\]$/,`$1`);let i=u(t);return i.def.type===`function`&&(i=/* @__PURE__ */ _m(t=>t instanceof Function)),n&&(i=/* @__PURE__ */ hm(i)),{schema:i,rest:r}},f=t=>{if(!t.some(t=>t?.endsWith(`?`)))return[t];let n=t.filter(t=>t===null||!t.endsWith(`?`)).length,r=[];for(let i=n;i<=t.length;i++)r.push(t.slice(0,i));return r},p=l.flatMap(t=>f(t).map(t=>{let n=t.map(t=>d(t)).filter(t=>t.schema!==void 0),r;return n.at(-1)?.rest&&(r=n.pop()),/* @__PURE__ */ dm(n.map(t=>t.schema),r?.schema)}));return p.length===1?p[0]:/* @__PURE__ */ lm(p)},_=function(t,n){if(!(t instanceof cm))return t;let r=t=>{let r=1/0;if(!(t instanceof um))return console.warn(`Schema below is not a tuple: `),printZodSchema(t),r;let i=n.length,a=t.def.items,o=a.length,s=a.filter(t=>!sd(t,void 0)).length;r=i>=s&&i<=o?0:Math.abs(i<s?s-i:i-o)*4;for(let t=0;t<Math.min(a.length,n.length);t++){let i=a[t],o=n[t];sd(i,o)||r++}return r},i=t.def.options[0],a=1/0;return t.def.options.forEach(t=>{let n=r(t);n<a&&(i=t,a=n)}),i},v=function(t,n,r){let i=``,a=t.issues[0],o=(t,n,r)=>{let i=r?R.log`at the ${p[r]} parameter`:``,a=t?R.log`, but received ${t}`:``;return R.log`Expected ${n} ${i}${a}`},s=t=>{let i=/* @__PURE__ */ new Set,a,s=``,c=n=>{if(n){if(a||=n.message,n.code===`invalid_type`)a=n.message.split(`, received `)[1],i.add(n.expected);else if(n.code===`invalid_value`)Array.isArray(n.values)&&n.values.every(t=>t===1/0||t===-1/0)?i.add(`number`):(i.add(`constant (please refer to documentation for allowed values)`),a=r[t.path[0]]);else if(n.code===`custom`){let t=n.message.match(/Input not instance of (\w+)/);t&&i.add(t[1]),a=void 0}else n.code===`invalid_union`&&n.errors.forEach(t=>{t.forEach(t=>c(t))})}};if(t.errors.forEach(t=>{t.forEach(t=>c(t))}),i.size>0){t.path?.length>0&&r[t.path[0]]instanceof Promise&&(s=R.log`Did you mean to put \`await\` before a loading function? An unexpected Promise was found. `);let c=Array.from(i).join(` or `),l=t.path.join(`.`);s=R.log`${s}${o(a,c,l)} in ${n+`()`}.`}return s},c=t=>{let{funcName:n,funcClass:r}=m(t);return`https://p5js.org/reference/${r}/${n}`};switch(a.code){case`invalid_union`:i=s(a);break;case`too_small`:{let t=a.minimum,r=c(n),o=R.log`For more information, see ${r}.`;i=R.log`Expected at least ${t} argument, but received fewer in ${n}(). ${o}`;break}case`invalid_type`:{let t=R.premade.ordinals[a.path.join(`.`)],r=R.premade.types[a.expected];i=R.log`Expected ${r} at the ${t} parameter in ${n+`()`}.`;break}case`too_big`:{let t=a.maximum,r=c(n),o=R.log`For more information, see ${r}.`;i=R.log`Expected at most ${t} arguments, but received more in ${n}(). ${o}`;break}case`custom`:{let t=R.premade.ordinals[a.path.join(`.`)],r=a.message.match(/Input not instance of (\w+)/);if(r){i=R.log`Expected ${r[1]} at the ${t} parameter in ${n+`()`}.`;break}}default:console.log(`Zod error object`,a)}{let[,t]=Pl(null,Nl.parse(Error()).slice(3)),n=Il(t,!0);R.log`${n} ${i}`()}return i},y=function(n,r){if(t.disableFriendlyErrors)return;if(Array.isArray(r)||(r=Array.from(r)),Array.isArray(r)&&r.length>0&&r.every(t=>t===void 0))return{success:!1,error:`All arguments for ${n}() are undefined. There is likely an error in the code.`};let a=i.get(n);if(!a){if(a=g(n),!a)return;i.set(n,a)}if(sd(a,r))return{success:!0};{let t=_(a,r).safeParse(r).error;return{success:!1,error:v(t,n,r)}}};n._validate=y,n._internal=function(t){let n=this._isUserCall;this._isUserCall=!0;try{return t()}finally{this._isUserCall=n}},t.registerDecorator(({path:t})=>t.startsWith(`p5.prototype`),function(n,{kind:r,name:i}){if(r===`method`)return function(...r){if(t.disableFriendlyErrors)return n.apply(this,r);let a=this._isUserCall;this._isUserCall=!0;try{return!a&&!t.disableFriendlyErrors&&!t.disableParameterValidator&&y(i,r),n.apply(this,r)}finally{this._isUserCall=a}}}),t.extendParameterValidation=t=>{Sm=Tm(Sm,t)},r.presetup=function(){o()}}function wm(t){return t&&typeof t==`object`&&!Array.isArray(t)}function Tm(t,...n){if(!n.length)return t;let r=n.shift();if(wm(t)&&wm(r))for(let n in r)wm(r[n])?(t[n]||Object.assign(t,{[n]:{}}),Tm(t[n],r[n])):Object.assign(t,{[n]:r[n]});return Tm(t,...n)}typeof p5<`u`&&p5.registerAddon(Cm);var Em=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Dm=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],Om=`‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-᫝᫠-᫫ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・`,km=`ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-࢏ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚ౜ౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ೜-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ƛ꟱-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ`,Am={3:`abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile`,5:`class enum extends super const export import`,6:`enum`,strict:`implements interface let package private protected public static yield`,strictBind:`eval arguments`},jm=`break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this`,Mm={5:jm,"5module":jm+` export import`,6:jm+` const class extends export import super`},Nm=/^in(stanceof)?$/,Pm=RegExp(`[`+km+`]`),Fm=RegExp(`[`+km+Om+`]`);function Im(t,n){for(var r=65536,i=0;i<n.length;i+=2){if(r+=n[i],r>t)return!1;if(r+=n[i+1],r>=t)return!0}return!1}function Lm(t,n){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Pm.test(String.fromCharCode(t)):n!==!1&&Im(t,Dm)}function Rm(t,n){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Fm.test(String.fromCharCode(t)):n===!1?!1:Im(t,Dm)||Im(t,Em)}var zm=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function Bm(t,n){return new zm(t,{beforeExpr:!0,binop:n})}var Vm={beforeExpr:!0},Hm={startsExpr:!0},Um={};function Wm(t,n){return n===void 0&&(n={}),n.keyword=t,Um[t]=new zm(t,n)}var Y={num:new zm(`num`,Hm),regexp:new zm(`regexp`,Hm),string:new zm(`string`,Hm),name:new zm(`name`,Hm),privateId:new zm(`privateId`,Hm),eof:new zm(`eof`),bracketL:new zm(`[`,{beforeExpr:!0,startsExpr:!0}),bracketR:new zm(`]`),braceL:new zm(`{`,{beforeExpr:!0,startsExpr:!0}),braceR:new zm(`}`),parenL:new zm(`(`,{beforeExpr:!0,startsExpr:!0}),parenR:new zm(`)`),comma:new zm(`,`,Vm),semi:new zm(`;`,Vm),colon:new zm(`:`,Vm),dot:new zm(`.`),question:new zm(`?`,Vm),questionDot:new zm(`?.`),arrow:new zm(`=>`,Vm),template:new zm(`template`),invalidTemplate:new zm(`invalidTemplate`),ellipsis:new zm(`...`,Vm),backQuote:new zm("`",Hm),dollarBraceL:new zm("${",{beforeExpr:!0,startsExpr:!0}),eq:new zm(`=`,{beforeExpr:!0,isAssign:!0}),assign:new zm(`_=`,{beforeExpr:!0,isAssign:!0}),incDec:new zm(`++/--`,{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new zm(`!/~`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Bm(`||`,1),logicalAND:Bm(`&&`,2),bitwiseOR:Bm(`|`,3),bitwiseXOR:Bm(`^`,4),bitwiseAND:Bm(`&`,5),equality:Bm(`==/!=/===/!==`,6),relational:Bm(`</>/<=/>=`,7),bitShift:Bm(`<</>>/>>>`,8),plusMin:new zm(`+/-`,{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Bm(`%`,10),star:Bm(`*`,10),slash:Bm(`/`,10),starstar:new zm(`**`,{beforeExpr:!0}),coalesce:Bm(`??`,1),_break:Wm(`break`),_case:Wm(`case`,Vm),_catch:Wm(`catch`),_continue:Wm(`continue`),_debugger:Wm(`debugger`),_default:Wm(`default`,Vm),_do:Wm(`do`,{isLoop:!0,beforeExpr:!0}),_else:Wm(`else`,Vm),_finally:Wm(`finally`),_for:Wm(`for`,{isLoop:!0}),_function:Wm(`function`,Hm),_if:Wm(`if`),_return:Wm(`return`,Vm),_switch:Wm(`switch`),_throw:Wm(`throw`,Vm),_try:Wm(`try`),_var:Wm(`var`),_const:Wm(`const`),_while:Wm(`while`,{isLoop:!0}),_with:Wm(`with`),_new:Wm(`new`,{beforeExpr:!0,startsExpr:!0}),_this:Wm(`this`,Hm),_super:Wm(`super`,Hm),_class:Wm(`class`,Hm),_extends:Wm(`extends`,Vm),_export:Wm(`export`),_import:Wm(`import`,Hm),_null:Wm(`null`,Hm),_true:Wm(`true`,Hm),_false:Wm(`false`,Hm),_in:Wm(`in`,{beforeExpr:!0,binop:7}),_instanceof:Wm(`instanceof`,{beforeExpr:!0,binop:7}),_typeof:Wm(`typeof`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:Wm(`void`,{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:Wm(`delete`,{beforeExpr:!0,prefix:!0,startsExpr:!0})},Gm=/\r\n?|\n|\u2028|\u2029/,Km=new RegExp(Gm.source,`g`);function qm(t){return t===10||t===13||t===8232||t===8233}function Jm(t,n,r){r===void 0&&(r=t.length);for(var i=n;i<r;i++){var a=t.charCodeAt(i);if(qm(a))return i<r-1&&a===13&&t.charCodeAt(i+1)===10?i+2:i+1}return-1}var Ym=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Xm=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Zm=Object.prototype,Qm=Zm.hasOwnProperty,$m=Zm.toString,eh=Object.hasOwn||(function(t,n){return Qm.call(t,n)}),th=Array.isArray||(function(t){return $m.call(t)===`[object Array]`}),nh=Object.create(null);function rh(t){return nh[t]||(nh[t]=RegExp(`^(?:`+t.replace(/ /g,`|`)+`)$`))}function ih(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var ah=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,oh=function(t,n){this.line=t,this.column=n};oh.prototype.offset=function(t){return new oh(this.line,this.column+t)};var sh=function(t,n,r){this.start=n,this.end=r,t.sourceFile!==null&&(this.source=t.sourceFile)};function ch(t,n){for(var r=1,i=0;;){var a=Jm(t,i,n);if(a<0)return new oh(r,n-i);++r,i=a}}var lh={ecmaVersion:null,sourceType:`script`,strict:!1,onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,startLocation:null,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},uh=!1;function dh(t){var n={};for(var r in lh)n[r]=t&&eh(t,r)?t[r]:lh[r];if(n.ecmaVersion===`latest`?n.ecmaVersion=1e8:n.ecmaVersion==null?(!uh&&typeof console==`object`&&console.warn&&(uh=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
Defaulting to 2020, but this will stop working in the future.`)),n.ecmaVersion=11):n.ecmaVersion>=2015&&(n.ecmaVersion-=2009),n.allowReserved??=n.ecmaVersion<5,(!t||t.allowHashBang==null)&&(n.allowHashBang=n.ecmaVersion>=14),th(n.onToken)){var i=n.onToken;n.onToken=function(t){return i.push(t)}}if(th(n.onComment)&&(n.onComment=fh(n,n.onComment)),n.sourceType===`commonjs`&&n.allowAwaitOutsideFunction)throw Error(`Cannot use allowAwaitOutsideFunction with sourceType: commonjs`);return n}function fh(t,n){return function(r,i,a,o,s,c){var l={type:r?`Block`:`Line`,value:i,start:a,end:o};t.locations&&(l.loc=new sh(this,s,c)),t.ranges&&(l.range=[a,o]),n.push(l)}}var ph=1,mh=2,hh=4,gh=8,_h=16,vh=32,yh=64,bh=128,xh=256,Sh=512,Ch=1024,wh=ph|mh|xh;function Th(t,n){return mh|(t?hh:0)|(n?gh:0)}var Eh=0,Dh=1,Oh=2,kh=3,Ah=4,jh=5,Mh=function(t,n,r){this.options=t=dh(t),this.sourceFile=t.sourceFile,this.keywords=rh(Mm[t.ecmaVersion>=6?6:t.sourceType===`module`?`5module`:5]);var i=``;t.allowReserved!==!0&&(i=Am[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType===`module`&&(i+=` await`)),this.reservedWords=rh(i);var a=(i?i+` `:``)+Am.strict;this.reservedWordsStrict=rh(a),this.reservedWordsStrictBind=rh(a+` `+Am.strictBind),this.input=String(n),this.containsEsc=!1,this.pos=r||0,this.curLine=1,t.startLocation?(this.lineStart=this.pos-t.startLocation.column,this.curLine=t.startLocation.line):r?(this.lineStart=this.input.lastIndexOf(`
`,r-1)+1,this.options.locations&&(this.curLine=this.input.slice(0,this.lineStart).split(Gm).length)):this.lineStart=0,this.type=Y.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType===`module`,this.strict=this.inModule||t.strict===!0||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)===`#!`&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType===`commonjs`?mh:ph),this.regexpState=null,this.privateNameStack=[]},Nh={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};Mh.prototype.parse=function(){var t=this,n=this.options.program||this.startNode();return this.nextToken(),this.catchStackOverflow(function(){return t.parseTopLevel(n)})},Nh.inFunction.get=function(){return(this.currentVarScope().flags&mh)>0},Nh.inGenerator.get=function(){return(this.currentVarScope().flags&gh)>0},Nh.inAsync.get=function(){return(this.currentVarScope().flags&hh)>0},Nh.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var n=this.scopeStack[t].flags;if(n&(xh|Sh))return!1;if(n&mh)return(n&hh)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Nh.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&ph)},Nh.allowSuper.get=function(){return(this.currentThisScope().flags&yh)>0||this.options.allowSuperOutsideMethod},Nh.allowDirectSuper.get=function(){return(this.currentThisScope().flags&bh)>0},Nh.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Nh.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var n=this.scopeStack[t].flags;if(n&(xh|Sh)||n&mh&&!(n&_h))return!0}return!1},Nh.allowUsing.get=function(){var t=this.currentScope().flags;return!(t&Ch||!this.inModule&&t&ph)},Nh.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&xh)>0},Mh.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var r=this,i=0;i<t.length;i++)r=t[i](r);return r},Mh.parse=function(t,n){return new this(n,t).parse()},Mh.parseExpressionAt=function(t,n,r){var i=new this(r,t,n);return i.nextToken(),i.parseExpression()},Mh.tokenizer=function(t,n){return new this(n,t)},Object.defineProperties(Mh.prototype,Nh);var Ph=Mh.prototype,Fh=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Ph.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){Xm.lastIndex=t,t+=Xm.exec(this.input)[0].length;var n=Fh.exec(this.input.slice(t));if(!n)return!1;if((n[1]||n[2])===`use strict`){Xm.lastIndex=t+n[0].length;var r=Xm.exec(this.input),i=r.index+r[0].length,a=this.input.charAt(i);return a===`;`||a===`}`||Gm.test(r[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(a)||a===`!`&&this.input.charAt(i+1)===`=`)}t+=n[0].length,Xm.lastIndex=t,t+=Xm.exec(this.input)[0].length,this.input[t]===`;`&&t++}},Ph.eat=function(t){return this.type===t&&(this.next(),!0)},Ph.isContextual=function(t){return this.type===Y.name&&this.value===t&&!this.containsEsc},Ph.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1},Ph.catchStackOverflow=function(t){try{return t()}catch(t){if(t instanceof Error&&(/\bstack\b.*\b(exceeded|overflow)\b/i.test(t.message)||/\btoo much recursion\b/i.test(t.message)))this.raise(this.start,`Not enough stack space to parse input`);else throw t}},Ph.expectContextual=function(t){this.eatContextual(t)||this.unexpected()},Ph.canInsertSemicolon=function(){return this.type===Y.eof||this.type===Y.braceR||Gm.test(this.input.slice(this.lastTokEnd,this.start))},Ph.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},Ph.semicolon=function(){!this.eat(Y.semi)&&!this.insertSemicolon()&&this.unexpected()},Ph.afterTrailingComma=function(t,n){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),n||this.next(),!0},Ph.expect=function(t){this.eat(t)||this.unexpected()},Ph.unexpected=function(t){this.raise(t??this.start,`Unexpected token`)};var Ih=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Ph.checkPatternErrors=function(t,n){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,`Comma is not permitted after the rest element`);var r=n?t.parenthesizedAssign:t.parenthesizedBind;r>-1&&this.raiseRecoverable(r,n?`Assigning to rvalue`:`Parenthesized pattern`)}},Ph.checkExpressionErrors=function(t,n){if(!t)return!1;var r=t.shorthandAssign,i=t.doubleProto;if(!n)return r>=0||i>=0;r>=0&&this.raise(r,`Shorthand property assignments are valid only in destructuring patterns`),i>=0&&this.raiseRecoverable(i,`Redefinition of __proto__ property`)},Ph.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,`Yield expression cannot be a default value`),this.awaitPos&&this.raise(this.awaitPos,`Await expression cannot be a default value`)},Ph.isSimpleAssignTarget=function(t){return t.type===`ParenthesizedExpression`?this.isSimpleAssignTarget(t.expression):t.type===`Identifier`||t.type===`MemberExpression`};var X=Mh.prototype;X.parseTopLevel=function(t){var n=Object.create(null);for(t.body||=[];this.type!==Y.eof;){var r=this.parseStatement(null,!0,n);t.body.push(r)}if(this.inModule)for(var i=0,a=Object.keys(this.undefinedExports);i<a.length;i+=1){var o=a[i];this.raiseRecoverable(this.undefinedExports[o].start,`Export '`+o+`' is not defined`)}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType===`commonjs`?`script`:this.options.sourceType,this.finishNode(t,`Program`)};var Lh={kind:`loop`},Rh={kind:`switch`};X.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual(`let`))return!1;Xm.lastIndex=this.pos;var n=Xm.exec(this.input),r=this.pos+n[0].length,i=this.fullCharCodeAt(r);if(i===91||i===92)return!0;if(t)return!1;if(i===123)return!0;if(Lm(i)){var a=r;do r+=i<=65535?1:2;while(Rm(i=this.fullCharCodeAt(r)));if(i===92)return!0;var o=this.input.slice(a,r);if(!Nm.test(o))return!0}return!1},X.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual(`async`))return!1;Xm.lastIndex=this.pos;var t=Xm.exec(this.input),n=this.pos+t[0].length,r;return!Gm.test(this.input.slice(this.pos,n))&&this.input.slice(n,n+8)===`function`&&(n+8===this.input.length||!(Rm(r=this.fullCharCodeAt(n+8))||r===92))},X.isUsingKeyword=function(t,n){if(this.options.ecmaVersion<17||!this.isContextual(t?`await`:`using`))return!1;Xm.lastIndex=this.pos;var r=Xm.exec(this.input),i=this.pos+r[0].length;if(Gm.test(this.input.slice(this.pos,i)))return!1;if(t){var a=i+5,o;if(this.input.slice(i,a)!==`using`||a===this.input.length||Rm(o=this.fullCharCodeAt(a))||o===92)return!1;Xm.lastIndex=a;var s=Xm.exec(this.input);if(i=a+s[0].length,s&&Gm.test(this.input.slice(a,i)))return!1}var c=this.fullCharCodeAt(i);if(!Lm(c)&&c!==92)return!1;var l=i;do i+=c<=65535?1:2;while(Rm(c=this.fullCharCodeAt(i)));if(c===92)return!0;var u=this.input.slice(l,i);if(Nm.test(u))return!1;if(n&&!t&&u===`of`){Xm.lastIndex=i;var d=Xm.exec(this.input);if(i+=d[0].length,this.input.charCodeAt(i)!==61||(c=this.input.charCodeAt(i+1))===61||c===62)return!1}return!0},X.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)},X.isUsing=function(t){return this.isUsingKeyword(!1,t)},X.parseStatement=function(t,n,r){var i=this.type,a=this.startNode(),o;switch(this.isLet(t)&&(i=Y._var,o=`let`),i){case Y._break:case Y._continue:return this.parseBreakContinueStatement(a,i.keyword);case Y._debugger:return this.parseDebuggerStatement(a);case Y._do:return this.parseDoStatement(a);case Y._for:return this.parseForStatement(a);case Y._function:return t&&(this.strict||t!==`if`&&t!==`label`)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(a,!1,!t);case Y._class:return t&&this.unexpected(),this.parseClass(a,!0);case Y._if:return this.parseIfStatement(a);case Y._return:return this.parseReturnStatement(a);case Y._switch:return this.parseSwitchStatement(a);case Y._throw:return this.parseThrowStatement(a);case Y._try:return this.parseTryStatement(a);case Y._const:case Y._var:return o||=this.value,t&&o!==`var`&&this.unexpected(),this.parseVarStatement(a,o);case Y._while:return this.parseWhileStatement(a);case Y._with:return this.parseWithStatement(a);case Y.braceL:return this.parseBlock(!0,a);case Y.semi:return this.parseEmptyStatement(a);case Y._export:case Y._import:if(this.options.ecmaVersion>10&&i===Y._import){Xm.lastIndex=this.pos;var s=Xm.exec(this.input),c=this.pos+s[0].length,l=this.input.charCodeAt(c);if(l===40||l===46)return this.parseExpressionStatement(a,this.parseExpression())}return this.options.allowImportExportEverywhere||(n||this.raise(this.start,`'import' and 'export' may only appear at the top level`),this.inModule||this.raise(this.start,`'import' and 'export' may appear only with 'sourceType: module'`)),i===Y._import?this.parseImport(a):this.parseExport(a,r);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(a,!0,!t);var u=this.isAwaitUsing(!1)?`await using`:this.isUsing(!1)?`using`:null;if(u)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),t&&this.raise(this.start,`Using declaration is not allowed in single-statement positions`),u===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.next(),this.parseVar(a,!1,u),this.semicolon(),this.finishNode(a,`VariableDeclaration`);var d=this.value,f=this.parseExpression();return i===Y.name&&f.type===`Identifier`&&this.eat(Y.colon)?this.parseLabeledStatement(a,d,f,t):this.parseExpressionStatement(a,f)}},X.parseBreakContinueStatement=function(t,n){var r=n===`break`;this.next(),this.eat(Y.semi)||this.insertSemicolon()?t.label=null:this.type===Y.name?(t.label=this.parseIdent(),this.semicolon()):this.unexpected();for(var i=0;i<this.labels.length;++i){var a=this.labels[i];if((t.label==null||a.name===t.label.name)&&(a.kind!=null&&(r||a.kind===`loop`)||t.label&&r))break}return i===this.labels.length&&this.raise(t.start,`Unsyntactic `+n),this.finishNode(t,r?`BreakStatement`:`ContinueStatement`)},X.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,`DebuggerStatement`)},X.parseDoStatement=function(t){return this.next(),this.labels.push(Lh),t.body=this.parseStatement(`do`),this.labels.pop(),this.expect(Y._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(Y.semi):this.semicolon(),this.finishNode(t,`DoWhileStatement`)},X.parseForStatement=function(t){this.next();var n=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual(`await`)?this.lastTokStart:-1;if(this.labels.push(Lh),this.enterScope(0),this.expect(Y.parenL),this.type===Y.semi)return n>-1&&this.unexpected(n),this.parseFor(t,null);var r=this.isLet();if(this.type===Y._var||this.type===Y._const||r){var i=this.startNode(),a=r?`let`:this.value;return this.next(),this.parseVar(i,!0,a),this.finishNode(i,`VariableDeclaration`),this.parseForAfterInit(t,i,n)}var o=this.isContextual(`let`),s=!1,c=this.isUsing(!0)?`using`:this.isAwaitUsing(!0)?`await using`:null;if(c){var l=this.startNode();return this.next(),c===`await using`&&(this.canAwait||this.raise(this.start,`Await using cannot appear outside of async function`),this.next()),this.parseVar(l,!0,c),this.finishNode(l,`VariableDeclaration`),this.parseForAfterInit(t,l,n)}var u=this.containsEsc,d=new Ih,f=this.start,p=n>-1?this.parseExprSubscripts(d,`await`):this.parseExpression(!0,d);return this.type===Y._in||(s=this.options.ecmaVersion>=6&&this.isContextual(`of`))?(n>-1?(this.type===Y._in&&this.unexpected(n),t.await=!0):s&&this.options.ecmaVersion>=8&&(p.start===f&&!u&&p.type===`Identifier`&&p.name===`async`?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),o&&s&&this.raise(p.start,`The left-hand side of a for-of loop may not start with 'let'.`),this.toAssignable(p,!1,d),this.checkLValPattern(p),this.parseForIn(t,p)):(this.checkExpressionErrors(d,!0),n>-1&&this.unexpected(n),this.parseFor(t,p))},X.parseForAfterInit=function(t,n,r){return(this.type===Y._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))&&n.declarations.length===1?(this.type===Y._in?((n.kind===`using`||n.kind===`await using`)&&!n.declarations[0].init&&this.raise(this.start,`Using declaration is not allowed in for-in loops`),this.options.ecmaVersion>=9&&r>-1&&this.unexpected(r)):this.options.ecmaVersion>=9&&(t.await=r>-1),this.parseForIn(t,n)):(r>-1&&this.unexpected(r),this.parseFor(t,n))},X.parseFunctionStatement=function(t,n,r){return this.next(),this.parseFunction(t,Bh|(r?0:Vh),!1,n)},X.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement(`if`),t.alternate=this.eat(Y._else)?this.parseStatement(`if`):null,this.finishNode(t,`IfStatement`)},X.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,`'return' outside of function`),this.next(),this.eat(Y.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,`ReturnStatement`)},X.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(Y.braceL),this.labels.push(Rh),this.enterScope(Ch);for(var n,r=!1;this.type!==Y.braceR;)if(this.type===Y._case||this.type===Y._default){var i=this.type===Y._case;n&&this.finishNode(n,`SwitchCase`),t.cases.push(n=this.startNode()),n.consequent=[],this.next(),i?n.test=this.parseExpression():(r&&this.raiseRecoverable(this.lastTokStart,`Multiple default clauses`),r=!0,n.test=null),this.expect(Y.colon)}else n||this.unexpected(),n.consequent.push(this.parseStatement(null));return this.exitScope(),n&&this.finishNode(n,`SwitchCase`),this.next(),this.labels.pop(),this.finishNode(t,`SwitchStatement`)},X.parseThrowStatement=function(t){return this.next(),Gm.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,`Illegal newline after throw`),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,`ThrowStatement`)};var zh=[];X.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),n=t.type===`Identifier`;return this.enterScope(n?vh:0),this.checkLValPattern(t,n?Ah:Oh),this.expect(Y.parenR),t},X.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===Y._catch){var n=this.startNode();this.next(),this.eat(Y.parenL)?n.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),n.param=null,this.enterScope(0)),n.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(n,`CatchClause`)}return t.finalizer=this.eat(Y._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,`Missing catch or finally clause`),this.finishNode(t,`TryStatement`)},X.parseVarStatement=function(t,n,r){return this.next(),this.parseVar(t,!1,n,r),this.semicolon(),this.finishNode(t,`VariableDeclaration`)},X.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Lh),t.body=this.parseStatement(`while`),this.labels.pop(),this.finishNode(t,`WhileStatement`)},X.parseWithStatement=function(t){return this.strict&&this.raise(this.start,`'with' in strict mode`),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement(`with`),this.finishNode(t,`WithStatement`)},X.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,`EmptyStatement`)},X.parseLabeledStatement=function(t,n,r,i){for(var a=0,o=this.labels;a<o.length;a+=1)o[a].name===n&&this.raise(r.start,`Label '`+n+`' is already declared`);for(var s=this.type.isLoop?`loop`:this.type===Y._switch?`switch`:null,c=this.labels.length-1;c>=0;c--){var l=this.labels[c];if(l.statementStart===t.start)l.statementStart=this.start,l.kind=s;else break}return this.labels.push({name:n,kind:s,statementStart:this.start}),t.body=this.parseStatement(i?i.indexOf(`label`)===-1?i+`label`:i:`label`),this.labels.pop(),t.label=r,this.finishNode(t,`LabeledStatement`)},X.parseExpressionStatement=function(t,n){return t.expression=n,this.semicolon(),this.finishNode(t,`ExpressionStatement`)},X.parseBlock=function(t,n,r){for(t===void 0&&(t=!0),n===void 0&&(n=this.startNode()),n.body=[],this.expect(Y.braceL),t&&this.enterScope(0);this.type!==Y.braceR;){var i=this.parseStatement(null);n.body.push(i)}return r&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(n,`BlockStatement`)},X.parseFor=function(t,n){return t.init=n,this.expect(Y.semi),t.test=this.type===Y.semi?null:this.parseExpression(),this.expect(Y.semi),t.update=this.type===Y.parenR?null:this.parseExpression(),this.expect(Y.parenR),t.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(t,`ForStatement`)},X.parseForIn=function(t,n){var r=this.type===Y._in;return this.next(),n.type===`VariableDeclaration`&&n.declarations[0].init!=null&&(!r||this.options.ecmaVersion<8||this.strict||n.kind!==`var`||n.declarations[0].id.type!==`Identifier`)&&this.raise(n.start,(r?`for-in`:`for-of`)+` loop variable declaration may not have an initializer`),t.left=n,t.right=r?this.parseExpression():this.parseMaybeAssign(),this.expect(Y.parenR),t.body=this.parseStatement(`for`),this.exitScope(),this.labels.pop(),this.finishNode(t,r?`ForInStatement`:`ForOfStatement`)},X.parseVar=function(t,n,r,i){for(t.declarations=[],t.kind=r;;){var a=this.startNode();if(this.parseVarId(a,r),this.eat(Y.eq)?a.init=this.parseMaybeAssign(n):!i&&r===`const`&&!(this.type===Y._in||this.options.ecmaVersion>=6&&this.isContextual(`of`))?this.unexpected():!i&&(r===`using`||r===`await using`)&&this.options.ecmaVersion>=17&&this.type!==Y._in&&!this.isContextual(`of`)?this.raise(this.lastTokEnd,`Missing initializer in `+r+` declaration`):!i&&a.id.type!==`Identifier`&&(!n||this.type!==Y._in&&!this.isContextual(`of`))?this.raise(this.lastTokEnd,`Complex binding patterns require an initialization value`):a.init=null,t.declarations.push(this.finishNode(a,`VariableDeclarator`)),!this.eat(Y.comma))break}return t},X.parseVarId=function(t,n){t.id=n===`using`||n===`await using`?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,n===`var`?Dh:Oh,!1)};var Bh=1,Vh=2,Hh=4;X.parseFunction=function(t,n,r,i,a){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!i)&&(this.type===Y.star&&n&Vh&&this.unexpected(),t.generator=this.eat(Y.star)),this.options.ecmaVersion>=8&&(t.async=!!i),n&Bh&&(t.id=n&Hh&&this.type!==Y.name?null:this.parseIdent(),t.id&&!(n&Vh)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Dh:Oh:kh));var o=this.yieldPos,s=this.awaitPos,c=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Th(t.async,t.generator)),n&Bh||(t.id=this.type===Y.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,r,!1,a),this.yieldPos=o,this.awaitPos=s,this.awaitIdentPos=c,this.finishNode(t,n&Bh?`FunctionDeclaration`:`FunctionExpression`)},X.parseFunctionParams=function(t){this.expect(Y.parenL),t.params=this.parseBindingList(Y.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},X.parseClass=function(t,n){this.next();var r=this.strict;this.strict=!0,this.parseClassId(t,n),this.parseClassSuper(t);var i=this.enterClassBody(),a=this.startNode(),o=!1;for(a.body=[],this.expect(Y.braceL);this.type!==Y.braceR;){var s=this.parseClassElement(t.superClass!==null);s&&(a.body.push(s),s.type===`MethodDefinition`&&s.kind===`constructor`?(o&&this.raiseRecoverable(s.start,`Duplicate constructor in the same class`),o=!0):s.key&&s.key.type===`PrivateIdentifier`&&Uh(i,s)&&this.raiseRecoverable(s.key.start,`Identifier '#`+s.key.name+`' has already been declared`))}return this.strict=r,this.next(),t.body=this.finishNode(a,`ClassBody`),this.exitClassBody(),this.finishNode(t,n?`ClassDeclaration`:`ClassExpression`)},X.parseClassElement=function(t){if(this.eat(Y.semi))return null;var n=this.options.ecmaVersion,r=this.startNode(),i=``,a=!1,o=!1,s=`method`,c=!1;if(this.eatContextual(`static`)){if(n>=13&&this.eat(Y.braceL))return this.parseClassStaticBlock(r),r;this.isClassElementNameStart()||this.type===Y.star?c=!0:i=`static`}if(r.static=c,!i&&n>=8&&this.eatContextual(`async`)&&((this.isClassElementNameStart()||this.type===Y.star)&&!this.canInsertSemicolon()?o=!0:i=`async`),!i&&(n>=9||!o)&&this.eat(Y.star)&&(a=!0),!i&&!o&&!a){var l=this.value;(this.eatContextual(`get`)||this.eatContextual(`set`))&&(this.isClassElementNameStart()?s=l:i=l)}if(i?(r.computed=!1,r.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),r.key.name=i,this.finishNode(r.key,`Identifier`)):this.parseClassElementName(r),n<13||this.type===Y.parenL||s!==`method`||a||o){var u=!r.static&&Wh(r,`constructor`),d=u&&t;u&&s!==`method`&&this.raise(r.key.start,`Constructor can't have get/set modifier`),r.kind=u?`constructor`:s,this.parseClassMethod(r,a,o,d)}else this.parseClassField(r);return r},X.isClassElementNameStart=function(){return this.type===Y.name||this.type===Y.privateId||this.type===Y.num||this.type===Y.string||this.type===Y.bracketL||this.type.keyword},X.parseClassElementName=function(t){this.type===Y.privateId?(this.value===`constructor`&&this.raise(this.start,`Classes can't have an element named '#constructor'`),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)},X.parseClassMethod=function(t,n,r,i){var a=t.key;t.kind===`constructor`?(n&&this.raise(a.start,`Constructor can't be a generator`),r&&this.raise(a.start,`Constructor can't be an async method`)):t.static&&Wh(t,`prototype`)&&this.raise(a.start,`Classes may not have a static property named prototype`);var o=t.value=this.parseMethod(n,r,i);return t.kind===`get`&&o.params.length!==0&&this.raiseRecoverable(o.start,`getter should have no params`),t.kind===`set`&&o.params.length!==1&&this.raiseRecoverable(o.start,`setter should have exactly one param`),t.kind===`set`&&o.params[0].type===`RestElement`&&this.raiseRecoverable(o.params[0].start,`Setter cannot use rest params`),this.finishNode(t,`MethodDefinition`)},X.parseClassField=function(t){return Wh(t,`constructor`)?this.raise(t.key.start,`Classes can't have a field named 'constructor'`):t.static&&Wh(t,`prototype`)&&this.raise(t.key.start,`Classes can't have a static field named 'prototype'`),this.eat(Y.eq)?(this.enterScope(Sh|yh),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,`PropertyDefinition`)},X.parseClassStaticBlock=function(t){t.body=[];var n=this.labels;for(this.labels=[],this.enterScope(xh|yh);this.type!==Y.braceR;){var r=this.parseStatement(null);t.body.push(r)}return this.next(),this.exitScope(),this.labels=n,this.finishNode(t,`StaticBlock`)},X.parseClassId=function(t,n){this.type===Y.name?(t.id=this.parseIdent(),n&&this.checkLValSimple(t.id,Oh,!1)):(n===!0&&this.unexpected(),t.id=null)},X.parseClassSuper=function(t){t.superClass=this.eat(Y._extends)?this.parseExprSubscripts(null,!1):null},X.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared},X.exitClassBody=function(){var t=this.privateNameStack.pop(),n=t.declared,r=t.used;if(this.options.checkPrivateFields)for(var i=this.privateNameStack.length,a=i===0?null:this.privateNameStack[i-1],o=0;o<r.length;++o){var s=r[o];eh(n,s.name)||(a?a.used.push(s):this.raiseRecoverable(s.start,`Private field '#`+s.name+`' must be declared in an enclosing class`))}};function Uh(t,n){var r=n.key.name,i=t[r],a=`true`;return n.type===`MethodDefinition`&&(n.kind===`get`||n.kind===`set`)&&(a=(n.static?`s`:`i`)+n.kind),i===`iget`&&a===`iset`||i===`iset`&&a===`iget`||i===`sget`&&a===`sset`||i===`sset`&&a===`sget`?(t[r]=`true`,!1):i?!0:(t[r]=a,!1)}function Wh(t,n){var r=t.computed,i=t.key;return!r&&(i.type===`Identifier`&&i.name===n||i.type===`Literal`&&i.value===n)}X.parseExportAllDeclaration=function(t,n){return this.options.ecmaVersion>=11&&(this.eatContextual(`as`)?(t.exported=this.parseModuleExportName(),this.checkExport(n,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual(`from`),this.type!==Y.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,`ExportAllDeclaration`)},X.parseExport=function(t,n){if(this.next(),this.eat(Y.star))return this.parseExportAllDeclaration(t,n);if(this.eat(Y._default))return this.checkExport(n,`default`,this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,`ExportDefaultDeclaration`);if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type===`VariableDeclaration`?this.checkVariableExport(n,t.declaration.declarations):this.checkExport(n,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(n),this.eatContextual(`from`))this.type!==Y.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var r=0,i=t.specifiers;r<i.length;r+=1){var a=i[r];this.checkUnreserved(a.local),this.checkLocalExport(a.local),a.local.type===`Literal`&&this.raise(a.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,`ExportNamedDeclaration`)},X.parseExportDeclaration=function(t){return this.parseStatement(null)},X.parseExportDefaultDeclaration=function(){var t;if(this.type===Y._function||(t=this.isAsyncFunction())){var n=this.startNode();return this.next(),t&&this.next(),this.parseFunction(n,Bh|Hh,!1,t)}if(this.type===Y._class){var r=this.startNode();return this.parseClass(r,`nullableID`)}var i=this.parseMaybeAssign();return this.semicolon(),i},X.checkExport=function(t,n,r){t&&(typeof n!=`string`&&(n=n.type===`Identifier`?n.name:n.value),eh(t,n)&&this.raiseRecoverable(r,`Duplicate export '`+n+`'`),t[n]=!0)},X.checkPatternExport=function(t,n){var r=n.type;if(r===`Identifier`)this.checkExport(t,n,n.start);else if(r===`ObjectPattern`)for(var i=0,a=n.properties;i<a.length;i+=1){var o=a[i];this.checkPatternExport(t,o)}else if(r===`ArrayPattern`)for(var s=0,c=n.elements;s<c.length;s+=1){var l=c[s];l&&this.checkPatternExport(t,l)}else r===`Property`?this.checkPatternExport(t,n.value):r===`AssignmentPattern`?this.checkPatternExport(t,n.left):r===`RestElement`&&this.checkPatternExport(t,n.argument)},X.checkVariableExport=function(t,n){if(t)for(var r=0,i=n;r<i.length;r+=1){var a=i[r];this.checkPatternExport(t,a.id)}},X.shouldParseExportStatement=function(){return this.type.keyword===`var`||this.type.keyword===`const`||this.type.keyword===`class`||this.type.keyword===`function`||this.isLet()||this.isAsyncFunction()},X.parseExportSpecifier=function(t){var n=this.startNode();return n.local=this.parseModuleExportName(),n.exported=this.eatContextual(`as`)?this.parseModuleExportName():n.local,this.checkExport(t,n.exported,n.exported.start),this.finishNode(n,`ExportSpecifier`)},X.parseExportSpecifiers=function(t){var n=[],r=!0;for(this.expect(Y.braceL);!this.eat(Y.braceR);){if(r)r=!1;else if(this.expect(Y.comma),this.afterTrailingComma(Y.braceR))break;n.push(this.parseExportSpecifier(t))}return n},X.parseImport=function(t){return this.next(),this.type===Y.string?(t.specifiers=zh,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual(`from`),t.source=this.type===Y.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,`ImportDeclaration`)},X.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual(`as`)?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,Oh),this.finishNode(t,`ImportSpecifier`)},X.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,Oh),this.finishNode(t,`ImportDefaultSpecifier`)},X.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual(`as`),t.local=this.parseIdent(),this.checkLValSimple(t.local,Oh),this.finishNode(t,`ImportNamespaceSpecifier`)},X.parseImportSpecifiers=function(){var t=[],n=!0;if(this.type===Y.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(Y.comma)))return t;if(this.type===Y.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(Y.braceL);!this.eat(Y.braceR);){if(n)n=!1;else if(this.expect(Y.comma),this.afterTrailingComma(Y.braceR))break;t.push(this.parseImportSpecifier())}return t},X.parseWithClause=function(){var t=[];if(!this.eat(Y._with))return t;this.expect(Y.braceL);for(var n={},r=!0;!this.eat(Y.braceR);){if(r)r=!1;else if(this.expect(Y.comma),this.afterTrailingComma(Y.braceR))break;var i=this.parseImportAttribute(),a=i.key.type===`Identifier`?i.key.name:i.key.value;eh(n,a)&&this.raiseRecoverable(i.key.start,`Duplicate attribute key '`+a+`'`),n[a]=!0,t.push(i)}return t},X.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===Y.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`),this.expect(Y.colon),this.type!==Y.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,`ImportAttribute`)},X.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===Y.string){var t=this.parseLiteral(this.value);return ah.test(t.value)&&this.raise(t.start,`An export name cannot include a lone surrogate.`),t}return this.parseIdent(!0)},X.adaptDirectivePrologue=function(t){for(var n=0;n<t.length&&this.isDirectiveCandidate(t[n]);++n)t[n].directive=t[n].expression.raw.slice(1,-1)},X.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type===`ExpressionStatement`&&t.expression.type===`Literal`&&typeof t.expression.value==`string`&&(this.input[t.start]===`"`||this.input[t.start]===`'`)};var Gh=Mh.prototype;Gh.toAssignable=function(t,n,r){if(this.options.ecmaVersion>=6&&t)switch(t.type){case`Identifier`:this.inAsync&&t.name===`await`&&this.raise(t.start,`Cannot use 'await' as identifier inside an async function`);break;case`ObjectPattern`:case`ArrayPattern`:case`AssignmentPattern`:case`RestElement`:break;case`ObjectExpression`:t.type=`ObjectPattern`,r&&this.checkPatternErrors(r,!0);for(var i=0,a=t.properties;i<a.length;i+=1){var o=a[i];this.toAssignable(o,n),o.type===`RestElement`&&(o.argument.type===`ArrayPattern`||o.argument.type===`ObjectPattern`)&&this.raise(o.argument.start,`Unexpected token`)}break;case`Property`:t.kind!==`init`&&this.raise(t.key.start,`Object pattern can't contain getter or setter`),this.toAssignable(t.value,n);break;case`ArrayExpression`:t.type=`ArrayPattern`,r&&this.checkPatternErrors(r,!0),this.toAssignableList(t.elements,n);break;case`SpreadElement`:t.type=`RestElement`,this.toAssignable(t.argument,n),t.argument.type===`AssignmentPattern`&&this.raise(t.argument.start,`Rest elements cannot have a default value`);break;case`AssignmentExpression`:t.operator!==`=`&&this.raise(t.left.end,`Only '=' operator can be used for specifying default value.`),t.type=`AssignmentPattern`,delete t.operator,this.toAssignable(t.left,n);break;case`ParenthesizedExpression`:this.toAssignable(t.expression,n,r);break;case`ChainExpression`:this.raiseRecoverable(t.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:if(!n)break;default:this.raise(t.start,`Assigning to rvalue`)}else r&&this.checkPatternErrors(r,!0);return t},Gh.toAssignableList=function(t,n){for(var r=t.length,i=0;i<r;i++){var a=t[i];a&&this.toAssignable(a,n)}if(r){var o=t[r-1];this.options.ecmaVersion===6&&n&&o&&o.type===`RestElement`&&o.argument.type!==`Identifier`&&this.unexpected(o.argument.start)}return t},Gh.parseSpread=function(t){var n=this.startNode();return this.next(),n.argument=this.parseMaybeAssign(!1,t),this.finishNode(n,`SpreadElement`)},Gh.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==Y.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,`RestElement`)},Gh.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case Y.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(Y.bracketR,!0,!0),this.finishNode(t,`ArrayPattern`);case Y.braceL:return this.parseObj(!0)}return this.parseIdent()},Gh.parseBindingList=function(t,n,r,i){for(var a=[],o=!0;!this.eat(t);)if(o?o=!1:this.expect(Y.comma),n&&this.type===Y.comma)a.push(null);else if(r&&this.afterTrailingComma(t))break;else if(this.type===Y.ellipsis){var s=this.parseRestBinding();this.parseBindingListItem(s),a.push(s),this.type===Y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.expect(t);break}else a.push(this.parseAssignableListItem(i));return a},Gh.parseAssignableListItem=function(t){var n=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(n),n},Gh.parseBindingListItem=function(t){return t},Gh.parseMaybeDefault=function(t,n,r){if(r||=this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(Y.eq))return r;var i=this.startNodeAt(t,n);return i.left=r,i.right=this.parseMaybeAssign(),this.finishNode(i,`AssignmentPattern`)},Gh.checkLValSimple=function(t,n,r){n===void 0&&(n=Eh);var i=n!==Eh;switch(t.type){case`Identifier`:this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(i?`Binding `:`Assigning to `)+t.name+` in strict mode`),i&&(n===Oh&&t.name===`let`&&this.raiseRecoverable(t.start,`let is disallowed as a lexically bound name`),r&&(eh(r,t.name)&&this.raiseRecoverable(t.start,`Argument name clash`),r[t.name]=!0),n!==jh&&this.declareName(t.name,n,t.start));break;case`ChainExpression`:this.raiseRecoverable(t.start,`Optional chaining cannot appear in left-hand side`);break;case`MemberExpression`:i&&this.raiseRecoverable(t.start,`Binding member expression`);break;case`ParenthesizedExpression`:return i&&this.raiseRecoverable(t.start,`Binding parenthesized expression`),this.checkLValSimple(t.expression,n,r);default:this.raise(t.start,(i?`Binding`:`Assigning to`)+` rvalue`)}},Gh.checkLValPattern=function(t,n,r){switch(n===void 0&&(n=Eh),t.type){case`ObjectPattern`:for(var i=0,a=t.properties;i<a.length;i+=1){var o=a[i];this.checkLValInnerPattern(o,n,r)}break;case`ArrayPattern`:for(var s=0,c=t.elements;s<c.length;s+=1){var l=c[s];l&&this.checkLValInnerPattern(l,n,r)}break;default:this.checkLValSimple(t,n,r)}},Gh.checkLValInnerPattern=function(t,n,r){switch(n===void 0&&(n=Eh),t.type){case`Property`:this.checkLValInnerPattern(t.value,n,r);break;case`AssignmentPattern`:this.checkLValPattern(t.left,n,r);break;case`RestElement`:this.checkLValPattern(t.argument,n,r);break;default:this.checkLValPattern(t,n,r)}};var Kh=function(t,n,r,i,a){this.token=t,this.isExpr=!!n,this.preserveSpace=!!r,this.override=i,this.generator=!!a},qh={b_stat:new Kh(`{`,!1),b_expr:new Kh(`{`,!0),b_tmpl:new Kh("${",!1),p_stat:new Kh(`(`,!1),p_expr:new Kh(`(`,!0),q_tmpl:new Kh("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Kh(`function`,!1),f_expr:new Kh(`function`,!0),f_expr_gen:new Kh(`function`,!0,!1,null,!0),f_gen:new Kh(`function`,!1,!1,null,!0)},Jh=Mh.prototype;Jh.initialContext=function(){return[qh.b_stat]},Jh.curContext=function(){return this.context[this.context.length-1]},Jh.braceIsBlock=function(t){var n=this.curContext();return n===qh.f_expr||n===qh.f_stat?!0:t===Y.colon&&(n===qh.b_stat||n===qh.b_expr)?!n.isExpr:t===Y._return||t===Y.name&&this.exprAllowed?Gm.test(this.input.slice(this.lastTokEnd,this.start)):t===Y._else||t===Y.semi||t===Y.eof||t===Y.parenR||t===Y.arrow?!0:t===Y.braceL?n===qh.b_stat:t===Y._var||t===Y._const||t===Y.name?!1:!this.exprAllowed},Jh.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var n=this.context[t];if(n.token===`function`)return n.generator}return!1},Jh.updateContext=function(t){var n,r=this.type;r.keyword&&t===Y.dot?this.exprAllowed=!1:(n=r.updateContext)?n.call(this,t):this.exprAllowed=r.beforeExpr},Jh.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)},Y.parenR.updateContext=Y.braceR.updateContext=function(){if(this.context.length===1)this.exprAllowed=!0;else{var t=this.context.pop();t===qh.b_stat&&this.curContext().token===`function`&&(t=this.context.pop()),this.exprAllowed=!t.isExpr}},Y.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?qh.b_stat:qh.b_expr),this.exprAllowed=!0},Y.dollarBraceL.updateContext=function(){this.context.push(qh.b_tmpl),this.exprAllowed=!0},Y.parenL.updateContext=function(t){var n=t===Y._if||t===Y._for||t===Y._with||t===Y._while;this.context.push(n?qh.p_stat:qh.p_expr),this.exprAllowed=!0},Y.incDec.updateContext=function(){},Y._function.updateContext=Y._class.updateContext=function(t){t.beforeExpr&&t!==Y._else&&(t!==Y.semi||this.curContext()===qh.p_stat)&&!(t===Y._return&&Gm.test(this.input.slice(this.lastTokEnd,this.start)))&&(t!==Y.colon&&t!==Y.braceL||this.curContext()!==qh.b_stat)?this.context.push(qh.f_expr):this.context.push(qh.f_stat),this.exprAllowed=!1},Y.colon.updateContext=function(){this.curContext().token===`function`&&this.context.pop(),this.exprAllowed=!0},Y.backQuote.updateContext=function(){this.curContext()===qh.q_tmpl?this.context.pop():this.context.push(qh.q_tmpl),this.exprAllowed=!1},Y.star.updateContext=function(t){if(t===Y._function){var n=this.context.length-1;this.context[n]===qh.f_expr?this.context[n]=qh.f_expr_gen:this.context[n]=qh.f_gen}this.exprAllowed=!0},Y.name.updateContext=function(t){var n=!1;this.options.ecmaVersion>=6&&t!==Y.dot&&(this.value===`of`&&!this.exprAllowed||this.value===`yield`&&this.inGeneratorContext())&&(n=!0),this.exprAllowed=n};var Yh=Mh.prototype;Yh.checkPropClash=function(t,n,r){if(!(this.options.ecmaVersion>=9&&t.type===`SpreadElement`)&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var i=t.key,a;switch(i.type){case`Identifier`:a=i.name;break;case`Literal`:a=String(i.value);break;default:return}var o=t.kind;if(this.options.ecmaVersion>=6)a===`__proto__`&&o===`init`&&(n.proto&&(r?r.doubleProto<0&&(r.doubleProto=i.start):this.raiseRecoverable(i.start,`Redefinition of __proto__ property`)),n.proto=!0);else{a=`$`+a;var s=n[a];s?(o===`init`?this.strict&&s.init||s.get||s.set:s.init||s[o])&&this.raiseRecoverable(i.start,`Redefinition of property`):s=n[a]={init:!1,get:!1,set:!1},s[o]=!0}}},Yh.parseExpression=function(t,n){var r=this;return this.catchStackOverflow(function(){var i=r.start,a=r.startLoc,o=r.parseMaybeAssign(t,n);if(r.type===Y.comma){var s=r.startNodeAt(i,a);for(s.expressions=[o];r.eat(Y.comma);)s.expressions.push(r.parseMaybeAssign(t,n));return r.finishNode(s,`SequenceExpression`)}return o})},Yh.parseMaybeAssign=function(t,n,r){if(this.isContextual(`yield`)){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var i=!1,a=-1,o=-1,s=-1;n?(a=n.parenthesizedAssign,o=n.trailingComma,s=n.doubleProto,n.parenthesizedAssign=n.trailingComma=-1):(n=new Ih,i=!0);var c=this.start,l=this.startLoc;(this.type===Y.parenL||this.type===Y.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t===`await`);var u=this.parseMaybeConditional(t,n);if(r&&(u=r.call(this,u,c,l)),this.type.isAssign){var d=this.startNodeAt(c,l);return d.operator=this.value,this.type===Y.eq&&(u=this.toAssignable(u,!1,n)),i||(n.parenthesizedAssign=n.trailingComma=n.doubleProto=-1),n.shorthandAssign>=u.start&&(n.shorthandAssign=-1),this.type===Y.eq?this.checkLValPattern(u):this.checkLValSimple(u),d.left=u,this.next(),d.right=this.parseMaybeAssign(t),s>-1&&(n.doubleProto=s),this.finishNode(d,`AssignmentExpression`)}return i&&this.checkExpressionErrors(n,!0),a>-1&&(n.parenthesizedAssign=a),o>-1&&(n.trailingComma=o),u},Yh.parseMaybeConditional=function(t,n){var r=this.start,i=this.startLoc,a=this.parseExprOps(t,n);if(this.checkExpressionErrors(n))return a;if((a.type!==`ArrowFunctionExpression`||a.start!==r)&&this.eat(Y.question)){var o=this.startNodeAt(r,i);return o.test=a,o.consequent=this.parseMaybeAssign(),this.expect(Y.colon),o.alternate=this.parseMaybeAssign(t),this.finishNode(o,`ConditionalExpression`)}return a},Yh.parseExprOps=function(t,n){var r=this.start,i=this.startLoc,a=this.parseMaybeUnary(n,!1,!1,t);return this.checkExpressionErrors(n)||a.start===r&&a.type===`ArrowFunctionExpression`?a:this.parseExprOp(a,r,i,-1,t)},Yh.parseExprOp=function(t,n,r,i,a){var o=this.type.binop;if(o!=null&&(!a||this.type!==Y._in)&&o>i){var s=this.type===Y.logicalOR||this.type===Y.logicalAND,c=this.type===Y.coalesce;c&&(o=Y.logicalAND.binop);var l=this.value;this.next();var u=this.start,d=this.startLoc,f=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,a),u,d,o,a),p=this.buildBinary(n,r,t,f,l,s||c);return(s&&this.type===Y.coalesce||c&&(this.type===Y.logicalOR||this.type===Y.logicalAND))&&this.raiseRecoverable(this.start,`Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses`),this.parseExprOp(p,n,r,i,a)}return t},Yh.buildBinary=function(t,n,r,i,a,o){i.type===`PrivateIdentifier`&&this.raise(i.start,`Private identifier can only be left side of binary expression`);var s=this.startNodeAt(t,n);return s.left=r,s.operator=a,s.right=i,this.finishNode(s,o?`LogicalExpression`:`BinaryExpression`)},Yh.parseMaybeUnary=function(t,n,r,i){var a=this.start,o=this.startLoc,s;if(this.isContextual(`await`)&&this.canAwait)s=this.parseAwait(i),n=!0;else if(this.type.prefix){var c=this.startNode(),l=this.type===Y.incDec;c.operator=this.value,c.prefix=!0,this.next(),c.argument=this.parseMaybeUnary(null,!0,l,i),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(c.argument):this.strict&&c.operator===`delete`&&Xh(c.argument)?this.raiseRecoverable(c.start,`Deleting local variable in strict mode`):c.operator===`delete`&&Zh(c.argument)?this.raiseRecoverable(c.start,`Private fields can not be deleted`):n=!0,s=this.finishNode(c,l?`UpdateExpression`:`UnaryExpression`)}else if(!n&&this.type===Y.privateId)(i||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),s=this.parsePrivateIdent(),this.type!==Y._in&&this.unexpected();else{if(s=this.parseExprSubscripts(t,i),this.checkExpressionErrors(t))return s;for(;this.type.postfix&&!this.canInsertSemicolon();){var u=this.startNodeAt(a,o);u.operator=this.value,u.prefix=!1,u.argument=s,this.checkLValSimple(s),this.next(),s=this.finishNode(u,`UpdateExpression`)}}if(!r&&(s.type!==`ArrowFunctionExpression`||s.start!==a)&&this.eat(Y.starstar)){if(n)this.unexpected(this.lastTokStart);else return this.buildBinary(a,o,s,this.parseMaybeUnary(null,!1,!1,i),`**`,!1)}else return s};function Xh(t){return t.type===`Identifier`||t.type===`ParenthesizedExpression`&&Xh(t.expression)}function Zh(t){return t.type===`MemberExpression`&&t.property.type===`PrivateIdentifier`||t.type===`ChainExpression`&&Zh(t.expression)||t.type===`ParenthesizedExpression`&&Zh(t.expression)}Yh.parseExprSubscripts=function(t,n){var r=this.start,i=this.startLoc,a=this.parseExprAtom(t,n);if(a.type===`ArrowFunctionExpression`&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==`)`)return a;var o=this.parseSubscripts(a,r,i,!1,n);return t&&o.type===`MemberExpression`&&(t.parenthesizedAssign>=o.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=o.start&&(t.parenthesizedBind=-1),t.trailingComma>=o.start&&(t.trailingComma=-1)),o},Yh.parseSubscripts=function(t,n,r,i,a){for(var o=this.options.ecmaVersion>=8&&t.type===`Identifier`&&t.name===`async`&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,s=!1;;){var c=this.parseSubscript(t,n,r,i,o,s,a);if(c.optional&&(s=!0),c===t||c.type===`ArrowFunctionExpression`){if(s){var l=this.startNodeAt(n,r);l.expression=c,c=this.finishNode(l,`ChainExpression`)}return c}t=c}},Yh.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(Y.arrow)},Yh.parseSubscriptAsyncArrow=function(t,n,r,i){return this.parseArrowExpression(this.startNodeAt(t,n),r,!0,i)},Yh.parseSubscript=function(t,n,r,i,a,o,s){var c=this.options.ecmaVersion>=11,l=c&&this.eat(Y.questionDot);i&&l&&this.raise(this.lastTokStart,`Optional chaining cannot appear in the callee of new expressions`);var u=this.eat(Y.bracketL);if(u||l&&this.type!==Y.parenL&&this.type!==Y.backQuote||this.eat(Y.dot)){var d=this.startNodeAt(n,r);d.object=t,u?(d.property=this.parseExpression(),this.expect(Y.bracketR)):d.property=this.type===Y.privateId&&t.type!==`Super`?this.parsePrivateIdent():this.parseIdent(this.options.allowReserved!==`never`),d.computed=!!u,c&&(d.optional=l),t=this.finishNode(d,`MemberExpression`)}else if(!i&&this.eat(Y.parenL)){var f=new Ih,p=this.yieldPos,m=this.awaitPos,h=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var g=this.parseExprList(Y.parenR,this.options.ecmaVersion>=8,!1,f);if(a&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,`Cannot use 'await' as identifier inside an async function`),this.yieldPos=p,this.awaitPos=m,this.awaitIdentPos=h,this.parseSubscriptAsyncArrow(n,r,g,s);this.checkExpressionErrors(f,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=h||this.awaitIdentPos;var _=this.startNodeAt(n,r);_.callee=t,_.arguments=g,c&&(_.optional=l),t=this.finishNode(_,`CallExpression`)}else if(this.type===Y.backQuote){(l||o)&&this.raise(this.start,`Optional chaining cannot appear in the tag of tagged template expressions`);var v=this.startNodeAt(n,r);v.tag=t,v.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(v,`TaggedTemplateExpression`)}return t},Yh.parseExprAtom=function(t,n,r){this.type===Y.slash&&this.readRegexp();var i,a=this.potentialArrowAt===this.start;switch(this.type){case Y._super:return this.allowSuper||this.raise(this.start,`'super' keyword outside a method`),i=this.startNode(),this.next(),this.type===Y.parenL&&!this.allowDirectSuper&&this.raise(i.start,`super() call outside constructor of a subclass`),this.type!==Y.dot&&this.type!==Y.bracketL&&this.type!==Y.parenL&&this.unexpected(),this.finishNode(i,`Super`);case Y._this:return i=this.startNode(),this.next(),this.finishNode(i,`ThisExpression`);case Y.name:var o=this.start,s=this.startLoc,c=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!c&&l.name===`async`&&!this.canInsertSemicolon()&&this.eat(Y._function))return this.overrideContext(qh.f_expr),this.parseFunction(this.startNodeAt(o,s),0,!1,!0,n);if(a&&!this.canInsertSemicolon()){if(this.eat(Y.arrow))return this.parseArrowExpression(this.startNodeAt(o,s),[l],!1,n);if(this.options.ecmaVersion>=8&&l.name===`async`&&this.type===Y.name&&!c&&(!this.potentialArrowInForAwait||this.value!==`of`||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(Y.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(o,s),[l],!0,n)}return l;case Y.regexp:var u=this.value;return i=this.parseLiteral(u.value),i.regex={pattern:u.pattern,flags:u.flags},i;case Y.num:case Y.string:return this.parseLiteral(this.value);case Y._null:case Y._true:case Y._false:return i=this.startNode(),i.value=this.type===Y._null?null:this.type===Y._true,i.raw=this.type.keyword,this.next(),this.finishNode(i,`Literal`);case Y.parenL:var d=this.start,f=this.parseParenAndDistinguishExpression(a,n);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(f)&&(t.parenthesizedAssign=d),t.parenthesizedBind<0&&(t.parenthesizedBind=d)),f;case Y.bracketL:return i=this.startNode(),this.next(),i.elements=this.parseExprList(Y.bracketR,!0,!0,t),this.finishNode(i,`ArrayExpression`);case Y.braceL:return this.overrideContext(qh.b_expr),this.parseObj(!1,t);case Y._function:return i=this.startNode(),this.next(),this.parseFunction(i,0);case Y._class:return this.parseClass(this.startNode(),!1);case Y._new:return this.parseNew();case Y.backQuote:return this.parseTemplate();case Y._import:return this.options.ecmaVersion>=11?this.parseExprImport(r):this.unexpected();default:return this.parseExprAtomDefault()}},Yh.parseExprAtomDefault=function(){this.unexpected()},Yh.parseExprImport=function(t){var n=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword import`),this.next(),this.type===Y.parenL&&!t)return this.parseDynamicImport(n);if(this.type===Y.dot){var r=this.startNodeAt(n.start,n.loc&&n.loc.start);return r.name=`import`,n.meta=this.finishNode(r,`Identifier`),this.parseImportMeta(n)}this.unexpected()},Yh.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(Y.parenR)?t.options=null:(this.expect(Y.comma),this.afterTrailingComma(Y.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(Y.parenR)||(this.expect(Y.comma),this.afterTrailingComma(Y.parenR)||this.unexpected())));else if(!this.eat(Y.parenR)){var n=this.start;this.eat(Y.comma)&&this.eat(Y.parenR)?this.raiseRecoverable(n,`Trailing comma is not allowed in import()`):this.unexpected(n)}return this.finishNode(t,`ImportExpression`)},Yh.parseImportMeta=function(t){this.next();var n=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!==`meta`&&this.raiseRecoverable(t.property.start,`The only valid meta property for import is 'import.meta'`),n&&this.raiseRecoverable(t.start,`'import.meta' must not contain escaped characters`),this.options.sourceType!==`module`&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,`Cannot use 'import.meta' outside a module`),this.finishNode(t,`MetaProperty`)},Yh.parseLiteral=function(t){var n=this.startNode();return n.value=t,n.raw=this.input.slice(this.start,this.end),n.raw.charCodeAt(n.raw.length-1)===110&&(n.bigint=n.value==null?n.raw.slice(0,-1).replace(/_/g,``):n.value.toString()),this.next(),this.finishNode(n,`Literal`)},Yh.parseParenExpression=function(){this.expect(Y.parenL);var t=this.parseExpression();return this.expect(Y.parenR),t},Yh.shouldParseArrow=function(t){return!this.canInsertSemicolon()},Yh.parseParenAndDistinguishExpression=function(t,n){var r=this.start,i=this.startLoc,a,o=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var s=this.start,c=this.startLoc,l=[],u=!0,d=!1,f=new Ih,p=this.yieldPos,m=this.awaitPos,h;for(this.yieldPos=0,this.awaitPos=0;this.type!==Y.parenR;){if(u?u=!1:this.expect(Y.comma),o&&this.afterTrailingComma(Y.parenR,!0)){d=!0;break}if(this.type===Y.ellipsis){h=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===Y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`);break}l.push(this.parseMaybeAssign(!1,f,this.parseParenItem))}var g=this.lastTokEnd,_=this.lastTokEndLoc;if(this.expect(Y.parenR),t&&this.shouldParseArrow(l)&&this.eat(Y.arrow))return this.checkPatternErrors(f,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=m,this.parseParenArrowList(r,i,l,n);(!l.length||d)&&this.unexpected(this.lastTokStart),h&&this.unexpected(h),this.checkExpressionErrors(f,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=m||this.awaitPos,l.length>1?(a=this.startNodeAt(s,c),a.expressions=l,this.finishNodeAt(a,`SequenceExpression`,g,_)):a=l[0]}else a=this.parseParenExpression();if(this.options.preserveParens){var v=this.startNodeAt(r,i);return v.expression=a,this.finishNode(v,`ParenthesizedExpression`)}return a},Yh.parseParenItem=function(t){return t},Yh.parseParenArrowList=function(t,n,r,i){return this.parseArrowExpression(this.startNodeAt(t,n),r,!1,i)};var Qh=[];Yh.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword new`);var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===Y.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);n.name=`new`,t.meta=this.finishNode(n,`Identifier`),this.next();var r=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!==`target`&&this.raiseRecoverable(t.property.start,`The only valid meta property for new is 'new.target'`),r&&this.raiseRecoverable(t.start,`'new.target' must not contain escaped characters`),this.allowNewDotTarget||this.raiseRecoverable(t.start,`'new.target' can only be used in functions and class static block`),this.finishNode(t,`MetaProperty`)}var i=this.start,a=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),i,a,!0,!1),t.callee.type===`Super`&&this.raiseRecoverable(i,`Invalid use of 'super'`),t.arguments=this.eat(Y.parenL)?this.parseExprList(Y.parenR,this.options.ecmaVersion>=8,!1):Qh,this.finishNode(t,`NewExpression`)},Yh.parseTemplateElement=function(t){var n=t.isTagged,r=this.startNode();return this.type===Y.invalidTemplate?(n||this.raiseRecoverable(this.start,`Bad escape sequence in untagged template literal`),r.value={raw:this.value.replace(/\r\n?/g,`
`),cooked:null}):r.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
`),cooked:this.value},this.next(),r.tail=this.type===Y.backQuote,this.finishNode(r,`TemplateElement`)},Yh.parseTemplate=function(t){t===void 0&&(t={});var n=t.isTagged;n===void 0&&(n=!1);var r=this.startNode();this.next(),r.expressions=[];var i=this.parseTemplateElement({isTagged:n});for(r.quasis=[i];!i.tail;)this.type===Y.eof&&this.raise(this.pos,`Unterminated template literal`),this.expect(Y.dollarBraceL),r.expressions.push(this.parseExpression()),this.expect(Y.braceR),r.quasis.push(i=this.parseTemplateElement({isTagged:n}));return this.next(),this.finishNode(r,`TemplateLiteral`)},Yh.isAsyncProp=function(t){return!t.computed&&t.key.type===`Identifier`&&t.key.name===`async`&&(this.type===Y.name||this.type===Y.num||this.type===Y.string||this.type===Y.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===Y.star)&&!Gm.test(this.input.slice(this.lastTokEnd,this.start))},Yh.parseObj=function(t,n){var r=this.startNode(),i=!0,a={};for(r.properties=[],this.next();!this.eat(Y.braceR);){if(i)i=!1;else if(this.expect(Y.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(Y.braceR))break;var o=this.parseProperty(t,n);t||this.checkPropClash(o,a,n),r.properties.push(o)}return this.finishNode(r,t?`ObjectPattern`:`ObjectExpression`)},Yh.parseProperty=function(t,n){var r=this.startNode(),i,a,o,s;if(this.options.ecmaVersion>=9&&this.eat(Y.ellipsis))return t?(r.argument=this.parseIdent(!1),this.type===Y.comma&&this.raiseRecoverable(this.start,`Comma is not permitted after the rest element`),this.finishNode(r,`RestElement`)):(r.argument=this.parseMaybeAssign(!1,n),this.type===Y.comma&&n&&n.trailingComma<0&&(n.trailingComma=this.start),this.finishNode(r,`SpreadElement`));this.options.ecmaVersion>=6&&(r.method=!1,r.shorthand=!1,(t||n)&&(o=this.start,s=this.startLoc),t||(i=this.eat(Y.star)));var c=this.containsEsc;return this.parsePropertyName(r),!t&&!c&&this.options.ecmaVersion>=8&&!i&&this.isAsyncProp(r)?(a=!0,i=this.options.ecmaVersion>=9&&this.eat(Y.star),this.parsePropertyName(r)):a=!1,this.parsePropertyValue(r,t,i,a,o,s,n,c),this.finishNode(r,`Property`)},Yh.parseGetterSetter=function(t){var n=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=n;var r=t.kind===`get`?0:1;if(t.value.params.length!==r){var i=t.value.start;t.kind===`get`?this.raiseRecoverable(i,`getter should have no params`):this.raiseRecoverable(i,`setter should have exactly one param`)}else t.kind===`set`&&t.value.params[0].type===`RestElement`&&this.raiseRecoverable(t.value.params[0].start,`Setter cannot use rest params`)},Yh.parsePropertyValue=function(t,n,r,i,a,o,s,c){(r||i)&&this.type===Y.colon&&this.unexpected(),this.eat(Y.colon)?(t.value=n?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,s),t.kind=`init`):this.options.ecmaVersion>=6&&this.type===Y.parenL?(n&&this.unexpected(),t.method=!0,t.value=this.parseMethod(r,i),t.kind=`init`):!n&&!c&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type===`Identifier`&&(t.key.name===`get`||t.key.name===`set`)&&this.type!==Y.comma&&this.type!==Y.braceR&&this.type!==Y.eq?((r||i)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type===`Identifier`?((r||i)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=a),n?t.value=this.parseMaybeDefault(a,o,this.copyNode(t.key)):this.type===Y.eq&&s?(s.shorthandAssign<0&&(s.shorthandAssign=this.start),t.value=this.parseMaybeDefault(a,o,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind=`init`,t.shorthand=!0):this.unexpected()},Yh.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(Y.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(Y.bracketR),t.key;t.computed=!1}return t.key=this.type===Y.num||this.type===Y.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!==`never`)},Yh.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)},Yh.parseMethod=function(t,n,r){var i=this.startNode(),a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.initFunction(i),this.options.ecmaVersion>=6&&(i.generator=t),this.options.ecmaVersion>=8&&(i.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Th(n,i.generator)|yh|(r?bh:0)),this.expect(Y.parenL),i.params=this.parseBindingList(Y.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(i,!1,!0,!1),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(i,`FunctionExpression`)},Yh.parseArrowExpression=function(t,n,r,i){var a=this.yieldPos,o=this.awaitPos,s=this.awaitIdentPos;return this.enterScope(Th(r,!1)|_h),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(n,!0),this.parseFunctionBody(t,!0,!1,i),this.yieldPos=a,this.awaitPos=o,this.awaitIdentPos=s,this.finishNode(t,`ArrowFunctionExpression`)},Yh.parseFunctionBody=function(t,n,r,i){var a=n&&this.type!==Y.braceL,o=this.strict,s=!1;if(a)t.body=this.parseMaybeAssign(i),t.expression=!0,this.checkParams(t,!1);else{var c=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!o||c)&&(s=this.strictDirective(this.end),s&&c&&this.raiseRecoverable(t.start,`Illegal 'use strict' directive in function with non-simple parameter list`));var l=this.labels;this.labels=[],s&&(this.strict=!0),this.checkParams(t,!o&&!s&&!n&&!r&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,jh),t.body=this.parseBlock(!1,void 0,s&&!o),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()},Yh.isSimpleParamList=function(t){for(var n=0,r=t;n<r.length;n+=1)if(r[n].type!==`Identifier`)return!1;return!0},Yh.checkParams=function(t,n){for(var r=Object.create(null),i=0,a=t.params;i<a.length;i+=1){var o=a[i];this.checkLValInnerPattern(o,Dh,n?null:r)}},Yh.parseExprList=function(t,n,r,i){for(var a=[],o=!0;!this.eat(t);){if(o)o=!1;else if(this.expect(Y.comma),n&&this.afterTrailingComma(t))break;var s=void 0;r&&this.type===Y.comma?s=null:this.type===Y.ellipsis?(s=this.parseSpread(i),i&&this.type===Y.comma&&i.trailingComma<0&&(i.trailingComma=this.start)):s=this.parseMaybeAssign(!1,i),a.push(s)}return a},Yh.checkUnreserved=function(t){var n=t.start,r=t.end,i=t.name;this.inGenerator&&i===`yield`&&this.raiseRecoverable(n,`Cannot use 'yield' as identifier inside a generator`),this.inAsync&&i===`await`&&this.raiseRecoverable(n,`Cannot use 'await' as identifier inside an async function`),!(this.currentThisScope().flags&wh)&&i===`arguments`&&this.raiseRecoverable(n,`Cannot use 'arguments' in class field initializer`),this.inClassStaticBlock&&(i===`arguments`||i===`await`)&&this.raise(n,`Cannot use `+i+` in class static initialization block`),this.keywords.test(i)&&this.raise(n,`Unexpected keyword '`+i+`'`),!(this.options.ecmaVersion<6&&this.input.slice(n,r).indexOf(`\\`)!==-1)&&(this.strict?this.reservedWordsStrict:this.reservedWords).test(i)&&(!this.inAsync&&i===`await`&&this.raiseRecoverable(n,`Cannot use keyword 'await' outside an async function`),this.raiseRecoverable(n,`The keyword '`+i+`' is reserved`))},Yh.parseIdent=function(t){var n=this.parseIdentNode();return this.next(!!t),this.finishNode(n,`Identifier`),t||(this.checkUnreserved(n),n.name===`await`&&!this.awaitIdentPos&&(this.awaitIdentPos=n.start)),n},Yh.parseIdentNode=function(){var t=this.startNode();return this.type===Y.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name===`class`||t.name===`function`)&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=Y.name):this.unexpected(),t},Yh.parsePrivateIdent=function(){var t=this.startNode();return this.type===Y.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,`PrivateIdentifier`),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,`Private field '#`+t.name+`' must be declared in an enclosing class`):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t},Yh.parseYield=function(t){this.yieldPos||=this.start;var n=this.startNode();return this.next(),this.type===Y.semi||this.canInsertSemicolon()||this.type!==Y.star&&!this.type.startsExpr?(n.delegate=!1,n.argument=null):(n.delegate=this.eat(Y.star),n.argument=this.parseMaybeAssign(t)),this.finishNode(n,`YieldExpression`)},Yh.parseAwait=function(t){this.awaitPos||=this.start;var n=this.startNode();return this.next(),n.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(n,`AwaitExpression`)};var $h=Mh.prototype;$h.raise=function(t,n){var r=ch(this.input,t);n+=` (`+r.line+`:`+r.column+`)`,this.sourceFile&&(n+=` in `+this.sourceFile);var i=SyntaxError(n);throw i.pos=t,i.loc=r,i.raisedAt=this.pos,i},$h.raiseRecoverable=$h.raise,$h.curPosition=function(){if(this.options.locations)return new oh(this.curLine,this.pos-this.lineStart)};var eg=Mh.prototype,tg=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};eg.enterScope=function(t){this.scopeStack.push(new tg(t))},eg.exitScope=function(){this.scopeStack.pop()},eg.treatFunctionsAsVarInScope=function(t){return t.flags&mh||!this.inModule&&t.flags&ph},eg.declareName=function(t,n,r){var i=!1;if(n===Oh){var a=this.currentScope();i=a.lexical.indexOf(t)>-1||a.functions.indexOf(t)>-1||a.var.indexOf(t)>-1,a.lexical.push(t),this.inModule&&a.flags&ph&&delete this.undefinedExports[t]}else if(n===Ah)this.currentScope().lexical.push(t);else if(n===kh){var o=this.currentScope();i=this.treatFunctionsAsVar?o.lexical.indexOf(t)>-1:o.lexical.indexOf(t)>-1||o.var.indexOf(t)>-1,o.functions.push(t)}else for(var s=this.scopeStack.length-1;s>=0;--s){var c=this.scopeStack[s];if(c.lexical.indexOf(t)>-1&&!(c.flags&vh&&c.lexical[0]===t)||!this.treatFunctionsAsVarInScope(c)&&c.functions.indexOf(t)>-1){i=!0;break}if(c.var.push(t),this.inModule&&c.flags&ph&&delete this.undefinedExports[t],c.flags&wh)break}i&&this.raiseRecoverable(r,`Identifier '`+t+`' has already been declared`)},eg.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)},eg.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},eg.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var n=this.scopeStack[t];if(n.flags&(wh|Sh|xh))return n}},eg.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var n=this.scopeStack[t];if(n.flags&(wh|Sh|xh)&&!(n.flags&_h))return n}};var ng=function(t,n,r){this.type=``,this.start=n,this.end=0,t.options.locations&&(this.loc=new sh(t,r)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},rg=Mh.prototype;rg.startNode=function(){return new ng(this,this.start,this.startLoc)},rg.startNodeAt=function(t,n){return new ng(this,t,n)};function ig(t,n,r,i){return t.type=n,t.end=r,this.options.locations&&(t.loc.end=i),this.options.ranges&&(t.range[1]=r),t}rg.finishNode=function(t,n){return ig.call(this,t,n,this.lastTokEnd,this.lastTokEndLoc)},rg.finishNodeAt=function(t,n,r,i){return ig.call(this,t,n,r,i)},rg.copyNode=function(t){var n=new ng(this,t.start,this.startLoc);for(var r in t)n[r]=t[r];return n};var ag=`Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz`,og=`ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS`,sg=og+` Extended_Pictographic`,cg=sg,lg=cg+` EBase EComp EMod EPres ExtPict`,ug=lg,dg={9:og,10:sg,11:cg,12:lg,13:ug,14:ug},fg={9:``,10:``,11:``,12:``,13:``,14:`Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji`},pg=`Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu`,mg=`Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb`,hg=mg+` Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd`,gg=hg+` Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho`,_g=gg+` Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi`,vg=_g+` Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith`,yg={9:mg,10:hg,11:gg,12:_g,13:vg,14:vg+` `+ag},bg={};function xg(t){var n=bg[t]={binary:rh(dg[t]+` `+pg),binaryOfStrings:rh(fg[t]),nonBinary:{General_Category:rh(pg),Script:rh(yg[t])}};n.nonBinary.Script_Extensions=n.nonBinary.Script,n.nonBinary.gc=n.nonBinary.General_Category,n.nonBinary.sc=n.nonBinary.Script,n.nonBinary.scx=n.nonBinary.Script_Extensions}for(var Sg=0,Cg=[9,10,11,12,13,14];Sg<Cg.length;Sg+=1){var wg=Cg[Sg];xg(wg)}var Z=Mh.prototype,Tg=function(t,n){this.parent=t,this.base=n||this};Tg.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var r=t;r;r=r.parent)if(n.base===r.base&&n!==r)return!0;return!1},Tg.prototype.sibling=function(){return new Tg(this.parent,this.base)};var Eg=function(t){this.parser=t,this.validFlags=`gim`+(t.options.ecmaVersion>=6?`uy`:``)+(t.options.ecmaVersion>=9?`s`:``)+(t.options.ecmaVersion>=13?`d`:``)+(t.options.ecmaVersion>=15?`v`:``),this.unicodeProperties=bg[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source=``,this.flags=``,this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue=``,this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Eg.prototype.reset=function(t,n,r){var i=r.indexOf(`v`)!==-1,a=r.indexOf(`u`)!==-1;this.start=t|0,this.source=n+``,this.flags=r,i&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=a&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=a&&this.parser.options.ecmaVersion>=9)},Eg.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,`Invalid regular expression: /`+this.source+`/: `+t)},Eg.prototype.at=function(t,n){n===void 0&&(n=!1);var r=this.source,i=r.length;if(t>=i)return-1;var a=r.charCodeAt(t);if(!(n||this.switchU)||a<=55295||a>=57344||t+1>=i)return a;var o=r.charCodeAt(t+1);return o>=56320&&o<=57343?(a<<10)+o-56613888:a},Eg.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var r=this.source,i=r.length;if(t>=i)return i;var a=r.charCodeAt(t),o;return!(n||this.switchU)||a<=55295||a>=57344||t+1>=i||(o=r.charCodeAt(t+1))<56320||o>57343?t+1:t+2},Eg.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)},Eg.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},Eg.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)},Eg.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t&&(this.advance(n),!0)},Eg.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var r=this.pos,i=0,a=t;i<a.length;i+=1){var o=a[i],s=this.at(r,n);if(s===-1||s!==o)return!1;r=this.nextIndex(r,n)}return this.pos=r,!0},Z.validateRegExpFlags=function(t){for(var n=t.validFlags,r=t.flags,i=!1,a=!1,o=0;o<r.length;o++){var s=r.charAt(o);n.indexOf(s)===-1&&this.raise(t.start,`Invalid regular expression flag`),r.indexOf(s,o+1)>-1&&this.raise(t.start,`Duplicate regular expression flag`),s===`u`&&(i=!0),s===`v`&&(a=!0)}this.options.ecmaVersion>=15&&i&&a&&this.raise(t.start,`Invalid regular expression flag`)};function Dg(t){for(var n in t)return!0;return!1}Z.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&Dg(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))},Z.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue=``,t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise(`Unmatched ')'`),(t.eat(93)||t.eat(125))&&t.raise(`Lone quantifier brackets`)),t.maxBackReference>t.numCapturingParens&&t.raise(`Invalid escape`);for(var n=0,r=t.backReferenceNames;n<r.length;n+=1){var i=r[n];t.groupNames[i]||t.raise(`Invalid named capture referenced`)}},Z.regexp_disjunction=function(t){var n=this.options.ecmaVersion>=16;for(n&&(t.branchID=new Tg(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)n&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);n&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise(`Nothing to repeat`),t.eat(123)&&t.raise(`Lone quantifier brackets`)},Z.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););},Z.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise(`Invalid quantifier`),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1},Z.regexp_eatAssertion=function(t){var n=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=n}if(t.eat(40)&&t.eat(63)){var r=!1;if(this.options.ecmaVersion>=9&&(r=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise(`Unterminated group`),t.lastAssertionIsQuantifiable=!r,!0}return t.pos=n,!1},Z.regexp_eatQuantifier=function(t,n){return n===void 0&&(n=!1),this.regexp_eatQuantifierPrefix(t,n)?(t.eat(63),!0):!1},Z.regexp_eatQuantifierPrefix=function(t,n){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,n)},Z.regexp_eatBracedQuantifier=function(t,n){var r=t.pos;if(t.eat(123)){var i=0,a=-1;if(this.regexp_eatDecimalDigits(t)&&(i=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(a=t.lastIntValue),t.eat(125)))return a!==-1&&a<i&&!n&&t.raise(`numbers out of order in {} quantifier`),!0;t.switchU&&!n&&t.raise(`Incomplete quantifier`),t.pos=r}return!1},Z.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)},Z.regexp_eatReverseSolidusAtomEscape=function(t){var n=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=n}return!1},Z.regexp_eatUncapturingGroup=function(t){var n=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var r=this.regexp_eatModifiers(t),i=t.eat(45);if(r||i){for(var a=0;a<r.length;a++){var o=r.charAt(a);r.indexOf(o,a+1)>-1&&t.raise(`Duplicate regular expression modifiers`)}if(i){var s=this.regexp_eatModifiers(t);!r&&!s&&t.current()===58&&t.raise(`Invalid regular expression modifiers`);for(var c=0;c<s.length;c++){var l=s.charAt(c);(s.indexOf(l,c+1)>-1||r.indexOf(l)>-1)&&t.raise(`Duplicate regular expression modifiers`)}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise(`Unterminated group`)}}t.pos=n}return!1},Z.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise(`Invalid group`),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise(`Unterminated group`)}return!1},Z.regexp_eatModifiers=function(t){for(var n=``,r=0;(r=t.current())!==-1&&Og(r);)n+=ih(r),t.advance();return n};function Og(t){return t===105||t===109||t===115}Z.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)},Z.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise(`Nothing to repeat`),!1},Z.regexp_eatSyntaxCharacter=function(t){var n=t.current();return kg(n)?(t.lastIntValue=n,t.advance(),!0):!1};function kg(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}Z.regexp_eatPatternCharacters=function(t){for(var n=t.pos,r=0;(r=t.current())!==-1&&!kg(r);)t.advance();return t.pos!==n},Z.regexp_eatExtendedPatternCharacter=function(t){var n=t.current();return n!==-1&&n!==36&&!(n>=40&&n<=43)&&n!==46&&n!==63&&n!==91&&n!==94&&n!==124&&(t.advance(),!0)},Z.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise(`Invalid group`);var n=this.options.ecmaVersion>=16,r=t.groupNames[t.lastStringValue];if(r){if(n)for(var i=0,a=r;i<a.length;i+=1)a[i].separatedFrom(t.branchID)||t.raise(`Duplicate capture group name`);else t.raise(`Duplicate capture group name`)}n?(r||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}},Z.regexp_eatGroupName=function(t){if(t.lastStringValue=``,t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise(`Invalid capture group name`)}return!1},Z.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue=``,this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=ih(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=ih(t.lastIntValue);return!0}return!1},Z.regexp_eatRegExpIdentifierStart=function(t){var n=t.pos,r=this.options.ecmaVersion>=11,i=t.current(r);return t.advance(r),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,r)&&(i=t.lastIntValue),Ag(i)?(t.lastIntValue=i,!0):(t.pos=n,!1)};function Ag(t){return Lm(t,!0)||t===36||t===95}Z.regexp_eatRegExpIdentifierPart=function(t){var n=t.pos,r=this.options.ecmaVersion>=11,i=t.current(r);return t.advance(r),i===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,r)&&(i=t.lastIntValue),jg(i)?(t.lastIntValue=i,!0):(t.pos=n,!1)};function jg(t){return Rm(t,!0)||t===36||t===95||t===8204||t===8205}Z.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise(`Invalid unicode escape`),t.raise(`Invalid escape`)),!1)},Z.regexp_eatBackReference=function(t){var n=t.pos;if(this.regexp_eatDecimalEscape(t)){var r=t.lastIntValue;if(t.switchU)return r>t.maxBackReference&&(t.maxBackReference=r),!0;if(r<=t.numCapturingParens)return!0;t.pos=n}return!1},Z.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise(`Invalid named reference`)}return!1},Z.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)},Z.regexp_eatCControlLetter=function(t){var n=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=n}return!1},Z.regexp_eatZero=function(t){return t.current()===48&&!Ug(t.lookahead())&&(t.lastIntValue=0,t.advance(),!0)},Z.regexp_eatControlEscape=function(t){var n=t.current();return n===116?(t.lastIntValue=9,t.advance(),!0):n===110?(t.lastIntValue=10,t.advance(),!0):n===118?(t.lastIntValue=11,t.advance(),!0):n===102?(t.lastIntValue=12,t.advance(),!0):n===114&&(t.lastIntValue=13,t.advance(),!0)},Z.regexp_eatControlLetter=function(t){var n=t.current();return Mg(n)?(t.lastIntValue=n%32,t.advance(),!0):!1};function Mg(t){return t>=65&&t<=90||t>=97&&t<=122}Z.regexp_eatRegExpUnicodeEscapeSequence=function(t,n){n===void 0&&(n=!1);var r=t.pos,i=n||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var a=t.lastIntValue;if(i&&a>=55296&&a<=56319){var o=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var s=t.lastIntValue;if(s>=56320&&s<=57343)return t.lastIntValue=(a-55296)*1024+(s-56320)+65536,!0}t.pos=o,t.lastIntValue=a}return!0}if(i&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&Ng(t.lastIntValue))return!0;i&&t.raise(`Invalid unicode escape`),t.pos=r}return!1};function Ng(t){return t>=0&&t<=1114111}Z.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var n=t.current();return n!==99&&(!t.switchN||n!==107)&&(t.lastIntValue=n,t.advance(),!0)},Z.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var n=t.current();if(n>=49&&n<=57){do t.lastIntValue=10*t.lastIntValue+(n-48),t.advance();while((n=t.current())>=48&&n<=57);return!0}return!1};var Pg=0,Fg=1,Ig=2;Z.regexp_eatCharacterClassEscape=function(t){var n=t.current();if(Lg(n))return t.lastIntValue=-1,t.advance(),Fg;var r=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((r=n===80)||n===112)){t.lastIntValue=-1,t.advance();var i;if(t.eat(123)&&(i=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return r&&i===Ig&&t.raise(`Invalid property name`),i;t.raise(`Invalid property name`)}return Pg};function Lg(t){return t===100||t===68||t===115||t===83||t===119||t===87}Z.regexp_eatUnicodePropertyValueExpression=function(t){var n=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var r=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var i=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,r,i),Fg}}if(t.pos=n,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var a=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,a)}return Pg},Z.regexp_validateUnicodePropertyNameAndValue=function(t,n,r){eh(t.unicodeProperties.nonBinary,n)||t.raise(`Invalid property name`),t.unicodeProperties.nonBinary[n].test(r)||t.raise(`Invalid property value`)},Z.regexp_validateUnicodePropertyNameOrValue=function(t,n){if(t.unicodeProperties.binary.test(n))return Fg;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(n))return Ig;t.raise(`Invalid property name`)},Z.regexp_eatUnicodePropertyName=function(t){var n=0;for(t.lastStringValue=``;Rg(n=t.current());)t.lastStringValue+=ih(n),t.advance();return t.lastStringValue!==``};function Rg(t){return Mg(t)||t===95}Z.regexp_eatUnicodePropertyValue=function(t){var n=0;for(t.lastStringValue=``;zg(n=t.current());)t.lastStringValue+=ih(n),t.advance();return t.lastStringValue!==``};function zg(t){return Rg(t)||Ug(t)}Z.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)},Z.regexp_eatCharacterClass=function(t){if(t.eat(91)){var n=t.eat(94),r=this.regexp_classContents(t);return t.eat(93)||t.raise(`Unterminated character class`),n&&r===Ig&&t.raise(`Negated character class may contain strings`),!0}return!1},Z.regexp_classContents=function(t){return t.current()===93?Fg:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),Fg)},Z.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var n=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var r=t.lastIntValue;t.switchU&&(n===-1||r===-1)&&t.raise(`Invalid character class`),n!==-1&&r!==-1&&n>r&&t.raise(`Range out of order in character class`)}}},Z.regexp_eatClassAtom=function(t){var n=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var r=t.current();(r===99||Kg(r))&&t.raise(`Invalid class escape`),t.raise(`Invalid escape`)}t.pos=n}var i=t.current();return i!==93&&(t.lastIntValue=i,t.advance(),!0)},Z.regexp_eatClassEscape=function(t){var n=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=n}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)},Z.regexp_classSetExpression=function(t){var n=Fg,r;if(!this.regexp_eatClassSetRange(t)){if(r=this.regexp_eatClassSetOperand(t)){r===Ig&&(n=Ig);for(var i=t.pos;t.eatChars([38,38]);)t.current()!==38&&(r=this.regexp_eatClassSetOperand(t))?r!==Ig&&(n=Fg):t.raise(`Invalid character in character class`);if(i!==t.pos)return n;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise(`Invalid character in character class`);if(i!==t.pos)return n}else t.raise(`Invalid character in character class`)}for(;;)if(!this.regexp_eatClassSetRange(t)){if(r=this.regexp_eatClassSetOperand(t),!r)return n;r===Ig&&(n=Ig)}},Z.regexp_eatClassSetRange=function(t){var n=t.pos;if(this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;return r!==-1&&i!==-1&&r>i&&t.raise(`Range out of order in character class`),!0}t.pos=n}return!1},Z.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?Fg:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)},Z.regexp_eatNestedClass=function(t){var n=t.pos;if(t.eat(91)){var r=t.eat(94),i=this.regexp_classContents(t);if(t.eat(93))return r&&i===Ig&&t.raise(`Negated character class may contain strings`),i;t.pos=n}if(t.eat(92)){var a=this.regexp_eatCharacterClassEscape(t);if(a)return a;t.pos=n}return null},Z.regexp_eatClassStringDisjunction=function(t){var n=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var r=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return r}else t.raise(`Invalid escape`);t.pos=n}return null},Z.regexp_classStringDisjunctionContents=function(t){for(var n=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===Ig&&(n=Ig);return n},Z.regexp_classString=function(t){for(var n=0;this.regexp_eatClassSetCharacter(t);)n++;return n===1?Fg:Ig},Z.regexp_eatClassSetCharacter=function(t){var n=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=n,!1);var r=t.current();return r<0||r===t.lookahead()&&Bg(r)||Vg(r)?!1:(t.advance(),t.lastIntValue=r,!0)};function Bg(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function Vg(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}Z.regexp_eatClassSetReservedPunctuator=function(t){var n=t.current();return Hg(n)?(t.lastIntValue=n,t.advance(),!0):!1};function Hg(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}Z.regexp_eatClassControlLetter=function(t){var n=t.current();return Ug(n)||n===95?(t.lastIntValue=n%32,t.advance(),!0):!1},Z.regexp_eatHexEscapeSequence=function(t){var n=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise(`Invalid escape`),t.pos=n}return!1},Z.regexp_eatDecimalDigits=function(t){var n=t.pos,r=0;for(t.lastIntValue=0;Ug(r=t.current());)t.lastIntValue=10*t.lastIntValue+(r-48),t.advance();return t.pos!==n};function Ug(t){return t>=48&&t<=57}Z.regexp_eatHexDigits=function(t){var n=t.pos,r=0;for(t.lastIntValue=0;Wg(r=t.current());)t.lastIntValue=16*t.lastIntValue+Gg(r),t.advance();return t.pos!==n};function Wg(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function Gg(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}Z.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var n=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var r=t.lastIntValue;t.lastIntValue=n<=3&&this.regexp_eatOctalDigit(t)?n*64+r*8+t.lastIntValue:n*8+r}else t.lastIntValue=n;return!0}return!1},Z.regexp_eatOctalDigit=function(t){var n=t.current();return Kg(n)?(t.lastIntValue=n-48,t.advance(),!0):(t.lastIntValue=0,!1)};function Kg(t){return t>=48&&t<=55}Z.regexp_eatFixedHexDigits=function(t,n){var r=t.pos;t.lastIntValue=0;for(var i=0;i<n;++i){var a=t.current();if(!Wg(a))return t.pos=r,!1;t.lastIntValue=16*t.lastIntValue+Gg(a),t.advance()}return!0};var qg=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new sh(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},Jg=Mh.prototype;Jg.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,`Escape sequence in keyword `+this.type.keyword),this.options.onToken&&this.options.onToken(new qg(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Jg.getToken=function(){return this.next(),new qg(this)},typeof Symbol<`u`&&(Jg[Symbol.iterator]=function(){var t=this;return{next:function(){var n=t.getToken();return{done:n.type===Y.eof,value:n}}}}),Jg.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(Y.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())},Jg.readToken=function(t){return Lm(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)},Jg.fullCharCodeAt=function(t){var n=this.input.charCodeAt(t);if(n<=55295||n>=56320)return n;var r=this.input.charCodeAt(t+1);return r<=56319||r>=57344?n:(n<<10)+r-56613888},Jg.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)},Jg.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),n=this.pos,r=this.input.indexOf(`*/`,this.pos+=2);if(r===-1&&this.raise(this.pos-2,`Unterminated comment`),this.pos=r+2,this.options.locations)for(var i=void 0,a=n;(i=Jm(this.input,a,this.pos))>-1;)++this.curLine,a=this.lineStart=i;this.options.onComment&&this.options.onComment(!0,this.input.slice(n+2,r),n,this.pos,t,this.curPosition())},Jg.skipLineComment=function(t){for(var n=this.pos,r=this.options.onComment&&this.curPosition(),i=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!qm(i);)i=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(n+t,this.pos),n,this.pos,r,this.curPosition())},Jg.skipSpace=function(){loop:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break loop}break;default:if(t>8&&t<14||t>=5760&&Ym.test(String.fromCharCode(t)))++this.pos;else break loop}}},Jg.finishToken=function(t,n){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=t,this.value=n,this.updateContext(r)},Jg.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var n=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&n===46?(this.pos+=3,this.finishToken(Y.ellipsis)):(++this.pos,this.finishToken(Y.dot))},Jg.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(Y.assign,2):this.finishOp(Y.slash,1)},Jg.readToken_mult_modulo_exp=function(t){var n=this.input.charCodeAt(this.pos+1),r=1,i=t===42?Y.star:Y.modulo;return this.options.ecmaVersion>=7&&t===42&&n===42&&(++r,i=Y.starstar,n=this.input.charCodeAt(this.pos+2)),n===61?this.finishOp(Y.assign,r+1):this.finishOp(i,r)},Jg.readToken_pipe_amp=function(t){var n=this.input.charCodeAt(this.pos+1);return n===t?this.options.ecmaVersion>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(Y.assign,3):this.finishOp(t===124?Y.logicalOR:Y.logicalAND,2):n===61?this.finishOp(Y.assign,2):this.finishOp(t===124?Y.bitwiseOR:Y.bitwiseAND,1)},Jg.readToken_caret=function(){return this.input.charCodeAt(this.pos+1)===61?this.finishOp(Y.assign,2):this.finishOp(Y.bitwiseXOR,1)},Jg.readToken_plus_min=function(t){var n=this.input.charCodeAt(this.pos+1);return n===t?n===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Gm.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(Y.incDec,2):n===61?this.finishOp(Y.assign,2):this.finishOp(Y.plusMin,1)},Jg.readToken_lt_gt=function(t){var n=this.input.charCodeAt(this.pos+1),r=1;return n===t?(r=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+r)===61?this.finishOp(Y.assign,r+1):this.finishOp(Y.bitShift,r)):n===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(n===61&&(r=2),this.finishOp(Y.relational,r))},Jg.readToken_eq_excl=function(t){var n=this.input.charCodeAt(this.pos+1);return n===61?this.finishOp(Y.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&n===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(Y.arrow)):this.finishOp(t===61?Y.eq:Y.prefix,1)},Jg.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var n=this.input.charCodeAt(this.pos+1);if(n===46){var r=this.input.charCodeAt(this.pos+2);if(r<48||r>57)return this.finishOp(Y.questionDot,2)}if(n===63)return t>=12&&this.input.charCodeAt(this.pos+2)===61?this.finishOp(Y.assign,3):this.finishOp(Y.coalesce,2)}return this.finishOp(Y.question,1)},Jg.readToken_numberSign=function(){var t=this.options.ecmaVersion,n=35;if(t>=13&&(++this.pos,n=this.fullCharCodeAtPos(),Lm(n,!0)||n===92))return this.finishToken(Y.privateId,this.readWord1());this.raise(this.pos,`Unexpected character '`+ih(n)+`'`)},Jg.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(Y.parenL);case 41:return++this.pos,this.finishToken(Y.parenR);case 59:return++this.pos,this.finishToken(Y.semi);case 44:return++this.pos,this.finishToken(Y.comma);case 91:return++this.pos,this.finishToken(Y.bracketL);case 93:return++this.pos,this.finishToken(Y.bracketR);case 123:return++this.pos,this.finishToken(Y.braceL);case 125:return++this.pos,this.finishToken(Y.braceR);case 58:return++this.pos,this.finishToken(Y.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(Y.backQuote);case 48:var n=this.input.charCodeAt(this.pos+1);if(n===120||n===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(n===111||n===79)return this.readRadixNumber(8);if(n===98||n===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(Y.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,`Unexpected character '`+ih(t)+`'`)},Jg.finishOp=function(t,n){var r=this.input.slice(this.pos,this.pos+n);return this.pos+=n,this.finishToken(t,r)},Jg.readRegexp=function(){for(var t,n,r=this.pos;;){this.pos>=this.input.length&&this.raise(r,`Unterminated regular expression`);var i=this.input.charAt(this.pos);if(Gm.test(i)&&this.raise(r,`Unterminated regular expression`),t)t=!1;else{if(i===`[`)n=!0;else if(i===`]`&&n)n=!1;else if(i===`/`&&!n)break;t=i===`\\`}++this.pos}var a=this.input.slice(r,this.pos);++this.pos;var o=this.pos,s=this.readWord1();this.containsEsc&&this.unexpected(o);var c=this.regexpState||=new Eg(this);c.reset(r,a,s),this.validateRegExpFlags(c),this.validateRegExpPattern(c);var l=null;try{l=new RegExp(a,s)}catch{}return this.finishToken(Y.regexp,{pattern:a,flags:s,value:l})},Jg.readInt=function(t,n,r){for(var i=this.options.ecmaVersion>=12&&n===void 0,a=r&&this.input.charCodeAt(this.pos)===48,o=this.pos,s=0,c=0,l=0,u=n??1/0;l<u;++l,++this.pos){var d=this.input.charCodeAt(this.pos),f=void 0;if(i&&d===95)a&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed in legacy octal numeric literals`),c===95&&this.raiseRecoverable(this.pos,`Numeric separator must be exactly one underscore`),l===0&&this.raiseRecoverable(this.pos,`Numeric separator is not allowed at the first of digits`),c=d;else{if(f=d>=97?d-97+10:d>=65?d-65+10:d>=48&&d<=57?d-48:1/0,f>=t)break;c=d,s=s*t+f}}return i&&c===95&&this.raiseRecoverable(this.pos-1,`Numeric separator is not allowed at the last of digits`),this.pos===o||n!=null&&this.pos-o!==n?null:s};function Yg(t,n){return n?parseInt(t,8):parseFloat(t.replace(/_/g,``))}function Xg(t){return typeof BigInt==`function`?BigInt(t.replace(/_/g,``)):null}Jg.readRadixNumber=function(t){var n=this.pos;this.pos+=2;var r=this.readInt(t);return r??this.raise(this.start+2,`Expected number in radix `+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(r=Xg(this.input.slice(n,this.pos)),++this.pos):Lm(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(Y.num,r)},Jg.readNumber=function(t){var n=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(n,`Invalid number`);var r=this.pos-n>=2&&this.input.charCodeAt(n)===48;r&&this.strict&&this.raise(n,`Invalid number`);var i=this.input.charCodeAt(this.pos);if(!r&&!t&&this.options.ecmaVersion>=11&&i===110){var a=Xg(this.input.slice(n,this.pos));return++this.pos,Lm(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`),this.finishToken(Y.num,a)}r&&/[89]/.test(this.input.slice(n,this.pos))&&(r=!1),i===46&&!r&&(++this.pos,this.readInt(10),i=this.input.charCodeAt(this.pos)),(i===69||i===101)&&!r&&(i=this.input.charCodeAt(++this.pos),(i===43||i===45)&&++this.pos,this.readInt(10)===null&&this.raise(n,`Invalid number`)),Lm(this.fullCharCodeAtPos())&&this.raise(this.pos,`Identifier directly after number`);var o=Yg(this.input.slice(n,this.pos),r);return this.finishToken(Y.num,o)},Jg.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),n;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var r=++this.pos;n=this.readHexChar(this.input.indexOf(`}`,this.pos)-this.pos),++this.pos,n>1114111&&this.invalidStringToken(r,`Code point out of bounds`)}else n=this.readHexChar(4);return n},Jg.readString=function(t){for(var n=``,r=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated string constant`);var i=this.input.charCodeAt(this.pos);if(i===t)break;i===92?(n+=this.input.slice(r,this.pos),n+=this.readEscapedChar(!1),r=this.pos):i===8232||i===8233?(this.options.ecmaVersion<10&&this.raise(this.start,`Unterminated string constant`),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(qm(i)&&this.raise(this.start,`Unterminated string constant`),++this.pos)}return n+=this.input.slice(r,this.pos++),this.finishToken(Y.string,n)};var Zg={};Jg.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===Zg)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1},Jg.invalidStringToken=function(t,n){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw Zg;this.raise(t,n)},Jg.readTmplToken=function(){for(var t=``,n=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,`Unterminated template`);var r=this.input.charCodeAt(this.pos);if(r===96||r===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===Y.template||this.type===Y.invalidTemplate)?r===36?(this.pos+=2,this.finishToken(Y.dollarBraceL)):(++this.pos,this.finishToken(Y.backQuote)):(t+=this.input.slice(n,this.pos),this.finishToken(Y.template,t));if(r===92)t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!0),n=this.pos;else if(qm(r)){switch(t+=this.input.slice(n,this.pos),++this.pos,r){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
`;break;default:t+=String.fromCharCode(r)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),n=this.pos}else++this.pos}},Jg.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case`\\`:++this.pos;break;case`$`:if(this.input[this.pos+1]!==`{`)break;case"`":return this.finishToken(Y.invalidTemplate,this.input.slice(this.start,this.pos));case`\r`:this.input[this.pos+1]===`
`&&++this.pos;case`
`:case`\u2028`:case`\u2029`:++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,`Unterminated template`)},Jg.readEscapedChar=function(t){var n=this.input.charCodeAt(++this.pos);switch(++this.pos,n){case 110:return`
`;case 114:return`\r`;case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ih(this.readCodePoint());case 116:return`	`;case 98:return`\b`;case 118:return`\v`;case 102:return`\f`;case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),``;case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,`Invalid escape sequence`),t){var r=this.pos-1;this.invalidStringToken(r,`Invalid escape sequence in template string`)}default:if(n>=48&&n<=55){var i=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],a=parseInt(i,8);return a>255&&(i=i.slice(0,-1),a=parseInt(i,8)),this.pos+=i.length-1,n=this.input.charCodeAt(this.pos),(i!==`0`||n===56||n===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-i.length,t?`Octal literal in template string`:`Octal literal in strict mode`),String.fromCharCode(a)}return qm(n)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),``):String.fromCharCode(n)}},Jg.readHexChar=function(t){var n=this.pos,r=this.readInt(16,t);return r===null&&this.invalidStringToken(n,`Bad character escape sequence`),r},Jg.readWord1=function(){this.containsEsc=!1;for(var t=``,n=!0,r=this.pos,i=this.options.ecmaVersion>=6;this.pos<this.input.length;){var a=this.fullCharCodeAtPos();if(Rm(a,i))this.pos+=a<=65535?1:2;else if(a===92){this.containsEsc=!0,t+=this.input.slice(r,this.pos);var o=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,`Expecting Unicode escape sequence \\uXXXX`),++this.pos;var s=this.readCodePoint();(n?Lm:Rm)(s,i)||this.invalidStringToken(o,`Invalid Unicode escape`),t+=ih(s),r=this.pos}else break;n=!1}return t+this.input.slice(r,this.pos)},Jg.readWord=function(){var t=this.readWord1(),n=Y.name;return this.keywords.test(t)&&(n=Um[t]),this.finishToken(n,t)},Mh.acorn={Parser:Mh,version:`8.18.0`,defaultOptions:lh,Position:oh,SourceLocation:sh,getLineInfo:ch,Node:ng,TokenType:zm,tokTypes:Y,keywordTypes:Um,TokContext:Kh,tokContexts:qh,isIdentifierChar:Rm,isIdentifierStart:Lm,Token:qg,isNewLine:qm,lineBreak:Gm,lineBreakG:Km,nonASCIIwhitespace:Ym};function Qg(t,n){return Mh.parse(t,n)}function $g(t,n,r,i,a){r||=Q,(function t(i,a,o){var s=o||i.type;a_(r,s,i,a,t),n[s]&&n[s](i,a)})(t,i,a)}function e_(t,n,r,i,a){var o=[];r||=Q,(function t(i,a,s){var c=s||i.type,l=i!==o[o.length-1];l&&o.push(i),a_(r,c,i,a,t),n[c]&&n[c](i,a||o,o),l&&o.pop()})(t,i,a)}function t_(t,n,r,i,a){var o=r?n_(r,i||void 0):i;(function t(n,r,i){o[i||n.type](n,r,t)})(t,n,a)}function n_(t,n){var r=Object.create(n||Q);for(var i in t)r[i]=t[i];return r}function r_(t,n,r){r(t,n)}function i_(t,n,r){}function a_(t,n,r,i,a){if(t[n]==null)throw Error(`No walker function defined for node type `+n);t[n](r,i,a)}var Q={};Q.Program=Q.BlockStatement=Q.StaticBlock=function(t,n,r){for(var i=0,a=t.body;i<a.length;i+=1){var o=a[i];r(o,n,`Statement`)}},Q.Statement=r_,Q.EmptyStatement=i_,Q.ExpressionStatement=Q.ParenthesizedExpression=Q.ChainExpression=function(t,n,r){return r(t.expression,n,`Expression`)},Q.IfStatement=function(t,n,r){r(t.test,n,`Expression`),r(t.consequent,n,`Statement`),t.alternate&&r(t.alternate,n,`Statement`)},Q.LabeledStatement=function(t,n,r){return r(t.body,n,`Statement`)},Q.BreakStatement=Q.ContinueStatement=i_,Q.WithStatement=function(t,n,r){r(t.object,n,`Expression`),r(t.body,n,`Statement`)},Q.SwitchStatement=function(t,n,r){r(t.discriminant,n,`Expression`);for(var i=0,a=t.cases;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.SwitchCase=function(t,n,r){t.test&&r(t.test,n,`Expression`);for(var i=0,a=t.consequent;i<a.length;i+=1){var o=a[i];r(o,n,`Statement`)}},Q.ReturnStatement=Q.YieldExpression=Q.AwaitExpression=function(t,n,r){t.argument&&r(t.argument,n,`Expression`)},Q.ThrowStatement=Q.SpreadElement=function(t,n,r){return r(t.argument,n,`Expression`)},Q.TryStatement=function(t,n,r){r(t.block,n,`Statement`),t.handler&&r(t.handler,n),t.finalizer&&r(t.finalizer,n,`Statement`)},Q.CatchClause=function(t,n,r){t.param&&r(t.param,n,`Pattern`),r(t.body,n,`Statement`)},Q.WhileStatement=Q.DoWhileStatement=function(t,n,r){r(t.test,n,`Expression`),r(t.body,n,`Statement`)},Q.ForStatement=function(t,n,r){t.init&&r(t.init,n,`ForInit`),t.test&&r(t.test,n,`Expression`),t.update&&r(t.update,n,`Expression`),r(t.body,n,`Statement`)},Q.ForInStatement=Q.ForOfStatement=function(t,n,r){r(t.left,n,`ForInit`),r(t.right,n,`Expression`),r(t.body,n,`Statement`)},Q.ForInit=function(t,n,r){t.type===`VariableDeclaration`?r(t,n):r(t,n,`Expression`)},Q.DebuggerStatement=i_,Q.FunctionDeclaration=function(t,n,r){return r(t,n,`Function`)},Q.VariableDeclaration=function(t,n,r){for(var i=0,a=t.declarations;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.VariableDeclarator=function(t,n,r){r(t.id,n,`Pattern`),t.init&&r(t.init,n,`Expression`)},Q.Function=function(t,n,r){t.id&&r(t.id,n,`Pattern`);for(var i=0,a=t.params;i<a.length;i+=1){var o=a[i];r(o,n,`Pattern`)}r(t.body,n,t.expression?`Expression`:`Statement`)},Q.Pattern=function(t,n,r){t.type===`Identifier`?r(t,n,`VariablePattern`):t.type===`MemberExpression`?r(t,n,`MemberPattern`):r(t,n)},Q.VariablePattern=i_,Q.MemberPattern=r_,Q.RestElement=function(t,n,r){return r(t.argument,n,`Pattern`)},Q.ArrayPattern=function(t,n,r){for(var i=0,a=t.elements;i<a.length;i+=1){var o=a[i];o&&r(o,n,`Pattern`)}},Q.ObjectPattern=function(t,n,r){for(var i=0,a=t.properties;i<a.length;i+=1){var o=a[i];o.type===`Property`?(o.computed&&r(o.key,n,`Expression`),r(o.value,n,`Pattern`)):o.type===`RestElement`&&r(o.argument,n,`Pattern`)}},Q.Expression=r_,Q.ThisExpression=Q.Super=Q.MetaProperty=i_,Q.ArrayExpression=function(t,n,r){for(var i=0,a=t.elements;i<a.length;i+=1){var o=a[i];o&&r(o,n,`Expression`)}},Q.ObjectExpression=function(t,n,r){for(var i=0,a=t.properties;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.FunctionExpression=Q.ArrowFunctionExpression=Q.FunctionDeclaration,Q.SequenceExpression=function(t,n,r){for(var i=0,a=t.expressions;i<a.length;i+=1){var o=a[i];r(o,n,`Expression`)}},Q.TemplateLiteral=function(t,n,r){for(var i=0,a=t.quasis;i<a.length;i+=1){var o=a[i];r(o,n)}for(var s=0,c=t.expressions;s<c.length;s+=1){var l=c[s];r(l,n,`Expression`)}},Q.TemplateElement=i_,Q.UnaryExpression=Q.UpdateExpression=function(t,n,r){r(t.argument,n,`Expression`)},Q.BinaryExpression=Q.LogicalExpression=function(t,n,r){r(t.left,n,`Expression`),r(t.right,n,`Expression`)},Q.AssignmentExpression=Q.AssignmentPattern=function(t,n,r){r(t.left,n,`Pattern`),r(t.right,n,`Expression`)},Q.ConditionalExpression=function(t,n,r){r(t.test,n,`Expression`),r(t.consequent,n,`Expression`),r(t.alternate,n,`Expression`)},Q.NewExpression=Q.CallExpression=function(t,n,r){if(r(t.callee,n,`Expression`),t.arguments)for(var i=0,a=t.arguments;i<a.length;i+=1){var o=a[i];r(o,n,`Expression`)}},Q.MemberExpression=function(t,n,r){r(t.object,n,`Expression`),t.computed&&r(t.property,n,`Expression`)},Q.ExportNamedDeclaration=Q.ExportDefaultDeclaration=function(t,n,r){if(t.declaration&&r(t.declaration,n,t.type===`ExportNamedDeclaration`||t.declaration.id?`Statement`:`Expression`),t.source&&r(t.source,n,`Expression`),t.attributes)for(var i=0,a=t.attributes;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.ExportAllDeclaration=function(t,n,r){if(t.exported&&r(t.exported,n),r(t.source,n,`Expression`),t.attributes)for(var i=0,a=t.attributes;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.ImportAttribute=function(t,n,r){r(t.value,n,`Expression`)},Q.ImportDeclaration=function(t,n,r){for(var i=0,a=t.specifiers;i<a.length;i+=1){var o=a[i];r(o,n)}if(r(t.source,n,`Expression`),t.attributes)for(var s=0,c=t.attributes;s<c.length;s+=1){var l=c[s];r(l,n)}},Q.ImportExpression=function(t,n,r){r(t.source,n,`Expression`),t.options&&r(t.options,n,`Expression`)},Q.ImportSpecifier=Q.ImportDefaultSpecifier=Q.ImportNamespaceSpecifier=Q.Identifier=Q.PrivateIdentifier=Q.Literal=i_,Q.TaggedTemplateExpression=function(t,n,r){r(t.tag,n,`Expression`),r(t.quasi,n,`Expression`)},Q.ClassDeclaration=Q.ClassExpression=function(t,n,r){return r(t,n,`Class`)},Q.Class=function(t,n,r){t.id&&r(t.id,n,`Pattern`),t.superClass&&r(t.superClass,n,`Expression`),r(t.body,n)},Q.ClassBody=function(t,n,r){for(var i=0,a=t.body;i<a.length;i+=1){var o=a[i];r(o,n)}},Q.MethodDefinition=Q.PropertyDefinition=Q.Property=function(t,n,r){t.computed&&r(t.key,n,`Expression`),t.value&&r(t.value,n,`Expression`)};const o_=[`setup`,`draw`,`preload`,`deviceMoved`,`deviceTurned`,`deviceShaken`,`doubleClicked`,`mousePressed`,`mouseReleased`,`mouseMoved`,`mouseDragged`,`mouseClicked`,`mouseWheel`,`touchStarted`,`touchMoved`,`touchEnded`,`keyPressed`,`keyReleased`,`keyTyped`,`windowResized`],s_={fetchScript:async function(t){if(t.src)try{return await fetch(t.src).then(t=>t.text())}catch(t){return console.error(`Error fetching script:`,t),``}return t.textContent},extractUserDefinedVariablesAndFuncs:function(t){let n={variables:[],functions:[]};try{$g(Qg(t,{ecmaVersion:`latest`,sourceType:`module`,locations:!0}),{VariableDeclarator(t){if(t.id.type===`Identifier`){let r=t.init&&[`ArrowFunctionExpression`,`FunctionExpression`].includes(t.init.type)?`functions`:`variables`;n[r].push({name:t.id.name,line:t.loc.start.line+-1})}},FunctionDeclaration(t){t.id&&t.id.type===`Identifier`&&n.functions.push({name:t.id.name,line:t.loc.start.line+-1})},ClassDeclaration(t){t.id&&t.id.type===`Identifier`&&n.variables.push({name:t.id.name,line:t.loc.start.line+-1})}})}catch(t){console.error(`Error parsing code:`,t)}return n},checkForConstsAndFuncs:function(t,n){let r=[...t.variables,...t.functions];function i(t,n,r){let i=`https://p5js.org/reference/p5/${n}`;return R.log`${t} "${n}" on line ${r} is being redeclared and conflicts with a p5.js ${t}. p5.js reference: ${i}`}for(let{name:t,line:n}of r)if(d[t]!==void 0){let r=i(`constant`,t,n+1);return R.log`${r}`(),!0}let a=new Set(Object.getOwnPropertyNames(n.prototype).filter(t=>!t.startsWith(`_`)&&t!==`constructor`));for(let{name:t,line:n}of r)if(!o_.includes(t)&&a.has(t)){let r=i(R.log`function`,t,n+1);return R.log`${r}`(),!0}return!1},getUserCode:async function(){let t=document.querySelectorAll(`script`),n=t[t.length-1];return await s_.fetchScript(n)},runFES:async function(t){let n=await s_.getUserCode(),r=s_.extractUserDefinedVariablesAndFuncs(n);s_.checkForConstsAndFuncs(r,t)}};function c_(t,n,r){r.presetup=async function(){!t.disableFriendlyErrors&&!t.disableSketchChecker&&s_.runFES(t)}}typeof p5<`u`&&p5.registerAddon(c_);function l_(t){t.registerAddon(no),t.registerAddon(Ll),t.registerAddon(Cm),t.registerAddon(c_)}function u_(t,n){n.storeItem=function(n,r){typeof n!=`string`&&t._friendlyError(`The argument that you passed to storeItem() - ${n} is not a string.`,`storeItem`),n.endsWith(`p5TypeID`)&&t._friendlyError(`The argument that you passed to storeItem() - ${n} must not end with 'p5TypeID'.`,`storeItem`),r===void 0&&t._friendlyError(`You cannot store undefined variables using storeItem().`,`storeItem`);let i=typeof r;switch(i){case`number`:case`boolean`:r=r.toString();break;case`object`:r instanceof t.Color?(i=`p5.Color`,r=r.toString()):r instanceof t.Vector&&(i=`p5.Vector`,r=r.values),r=JSON.stringify(r)}localStorage.setItem(n,r);let a=`${n}p5TypeID`;localStorage.setItem(a,i)},n.getItem=function(n){let r=localStorage.getItem(n),i=localStorage.getItem(`${n}p5TypeID`);if(i===void 0)t._friendlyError(`Unable to determine type of item stored under ${n}in local storage. Did you save the item with something other than setItem()?`,`getItem`);else if(r!==null)switch(i){case`number`:r=parseFloat(r);break;case`boolean`:r=r===`true`;break;case`object`:r=JSON.parse(r);break;case`p5.Color`:r=this.color(JSON.parse(r));break;case`p5.Vector`:r=JSON.parse(r),r=this.createVector(...r)}return r},n.clearStorage=function(){Object.keys(localStorage).forEach(t=>{t.endsWith(`p5TypeID`)&&this.removeItem(t.replace(`p5TypeID`,``))})},n.removeItem=function(n){typeof n!=`string`&&t._friendlyError(`The argument that you passed to removeItem() - ${n} is not a string.`,`removeItem`),localStorage.removeItem(n),localStorage.removeItem(`${n}p5TypeID`)}}typeof p5<`u`&&u_(p5,p5.prototype);function d_(t){t.registerAddon(u_)}function f_(t,n){n.select=function(t,n){let r=this._getContainer(n).querySelector(t);return r?this._wrapElement(r):null},n.selectAll=function(t,n){let r=[],i=this._getContainer(n).querySelectorAll(t);if(i)for(let t=0;t<i.length;t++){let n=this._wrapElement(i[t]);r.push(n)}return r},n._getContainer=function(t){let n=document;return typeof t==`string`?n=document.querySelector(t)||document:t instanceof ta?n=t.elt:t instanceof HTMLElement&&(n=t),n},n._wrapElement=function(t){let n=Array.prototype.slice.call(t.children);if(t.tagName===`INPUT`&&t.type===`checkbox`){let n=new ta(t,this);return n.checked=function(...t){return t.length===0?this.elt.checked:(t[0]?this.elt.checked=!0:this.elt.checked=!1,this)},n}return t.tagName===`VIDEO`||t.tagName===`AUDIO`?new oo(t,this):t.tagName===`SELECT`?this.createSelect(new ta(t,this)):n.length>0&&n.every(function(t){return t.tagName===`INPUT`||t.tagName===`LABEL`})&&(t.tagName===`DIV`||t.tagName===`SPAN`)?this.createRadio(new ta(t,this)):new ta(t,this)},n.createElement=function(t,n){let i=document.createElement(t);return n!==void 0&&(i.innerHTML=n),r(i,this)},n.removeElements=function(t){this._elements.filter(t=>!(t.elt instanceof HTMLCanvasElement)).map(t=>t.remove())};function r(t,n,r){(n._userNode?n._userNode:document.body).appendChild(t);let i=r?new oo(t,n):new ta(t,n);return n._elements.push(i),i}n.createDiv=function(t=``){let n=document.createElement(`div`);return n.innerHTML=t,r(n,this)},n.createP=function(t=``){let n=document.createElement(`p`);return n.innerHTML=t,r(n,this)},n.createSpan=function(t=``){let n=document.createElement(`span`);return n.innerHTML=t,r(n,this)},n.createImg=function(){let t=document.createElement(`img`),n=arguments,i;return n.length>1&&typeof n[1]==`string`&&(t.alt=n[1]),n.length>2&&typeof n[2]==`string`&&(t.crossOrigin=n[2]),t.src=n[0],i=r(t,this),t.addEventListener(`load`,function(){i.width=t.offsetWidth||t.width,i.height=t.offsetHeight||t.height;let r=n[n.length-1];typeof r==`function`&&r(i)}),i},n.createA=function(t,n,i){let a=document.createElement(`a`);return a.href=t,a.innerHTML=n,i&&(a.target=i),r(a,this)},n.createSlider=function(t,n,i,a){let o=document.createElement(`input`);return o.type=`range`,o.min=t,o.max=n,a===0?o.step=1e-18:a&&(o.step=a),typeof i==`number`&&(o.value=i),r(o,this)},n.createButton=function(t,n){let i=document.createElement(`button`);return i.innerHTML=t,n&&(i.value=n),r(i,this)},n.createCheckbox=function(...t){let n=document.createElement(`div`),i=document.createElement(`input`);i.type=`checkbox`;let a=document.createElement(`label`);a.appendChild(i),n.appendChild(a);let o=r(n,this);if(o.checked=function(...t){let n=o.elt.firstElementChild.getElementsByTagName(`input`)[0];if(n){if(t.length===0)return n.checked;n.checked=!!t[0]}return o},this.value=function(t){return o.value=t,this},t[0]){o.value(t[0]);let n=document.createElement(`span`);n.innerHTML=t[0],a.appendChild(n)}return t[1]&&(i.checked=!0),o},n.createSelect=function(...t){let n,i=t[0];if(i instanceof ta&&i.elt instanceof HTMLSelectElement)n=i,this.elt=i.elt;else if(i instanceof HTMLSelectElement)n=r(i,this),this.elt=i;else{let t=document.createElement(`select`);i&&typeof i==`boolean`&&t.setAttribute(`multiple`,`true`),n=r(t,this),this.elt=t}return n.option=function(t,n){let r;if(t!==void 0){for(let n=0;n<this.elt.length;n+=1)if(this.elt[n].textContent===t){r=n;break}if(r!==void 0)n===!1?this.elt.remove(r):this.elt[r].value=n;else{let r=document.createElement(`option`);r.textContent=t,r.value=n===void 0?t:n,this.elt.appendChild(r),this._pInst._elements.push(r)}}},n.selected=function(t){if(t!==void 0){for(let n=0;n<this.elt.length;n+=1)this.elt[n].value.toString()===t.toString()&&(this.elt.selectedIndex=n);return this}if(this.elt.getAttribute(`multiple`)){let t=[];for(let n of this.elt.selectedOptions)t.push(n.value);return t}return this.elt.value},n.disable=function(t){if(typeof t==`string`)for(let n=0;n<this.elt.length;n++)this.elt[n].value.toString()===t&&(this.elt[n].disabled=!0,this.elt[n].selected=!1);else this.elt.disabled=!0;return this},n.enable=function(t){if(typeof t==`string`)for(let n=0;n<this.elt.length;n++)this.elt[n].value.toString()===t&&(this.elt[n].disabled=!1,this.elt[n].selected=!1);else{this.elt.disabled=!1;for(let t=0;t<this.elt.length;t++)this.elt[t].disabled=!1,this.elt[t].selected=!1}return this},n};let i=0;n.createRadio=function(...t){let n,a,o,s=t[0];s instanceof ta&&(s.elt instanceof HTMLDivElement||s.elt instanceof HTMLSpanElement)?(n=s,this.elt=s.elt):s instanceof HTMLDivElement||s instanceof HTMLSpanElement?(n=r(s,this),this.elt=s,a=s,typeof t[1]==`string`&&(o=t[1])):(typeof s==`string`&&(o=s),a=document.createElement(`div`),n=r(a,this),this.elt=a),n._name=o||`radioOption_${i++}`;let c=t=>t instanceof HTMLInputElement&&t.type===`radio`,l=t=>t instanceof HTMLLabelElement,u=t=>t instanceof HTMLSpanElement;return n._getOptionsArray=function(){return Array.from(this.elt.children).filter(t=>c(t)||l(t)&&c(t.firstElementChild)).map(t=>c(t)?t:t.firstElementChild)},n.option=function(t,r){let i;for(let r of n._getOptionsArray())if(r.value===t){i=r;break}i===void 0&&(i=document.createElement(`input`),i.setAttribute(`type`,`radio`),i.setAttribute(`value`,t)),i.setAttribute(`name`,n._name);let a;l(i.parentElement)?a=i.parentElement:(a=document.createElement(`label`),a.insertAdjacentElement(`afterbegin`,i));let o;return u(a.lastElementChild)?o=a.lastElementChild:(o=document.createElement(`span`),i.insertAdjacentElement(`afterend`,o)),o.innerHTML=r===void 0?t:r,this.elt.appendChild(a),i},n.remove=function(t){if(arguments.length===0||t===void 0)return ta.prototype.remove.call(this);for(let r of n._getOptionsArray())if(r.value===t){l(r.parentElement)?r.parentElement.remove():r.remove();return}},n.value=function(){let t=``;for(let r of n._getOptionsArray())if(r.checked){t=r.value;break}return t},n.selected=function(t){let r=null;if(t===void 0){for(let t of n._getOptionsArray())if(t.checked){r=t;break}}else{n._getOptionsArray().forEach(t=>{t.checked=!1,t.removeAttribute(`checked`)});for(let i of n._getOptionsArray())i.value===t&&(i.setAttribute(`checked`,!0),i.checked=!0,r=i)}return r},n.disable=function(t=!0){for(let r of n._getOptionsArray())r.setAttribute(`disabled`,t)},n},n.createColorPicker=function(n){let i=document.createElement(`input`),a;i.type=`color`,n?n instanceof t.Color?i.value=n.toString(`#rrggbb`):(this.push(),this.colorMode(`rgb`),i.value=this.color(n).toString(`#rrggbb`),this.pop()):i.value=`#000000`,a=r(i,this);let o=this;return a.color=function(){o.push(),n&&n.mode&&o.colorMode(n.mode,...n?.maxes&&n.maxes[n.mode]||[]);let t=o.color(this.elt.value);return o.pop(),t},a},n.createInput=function(t=``,n=`text`){let i=document.createElement(`input`);return i.setAttribute(`value`,t),i.setAttribute(`type`,n),r(i,this)},n.createFileInput=function(n,i=!1){let a=t=>n=>{n._isBlobUrl&&(this._blobFiles||=/* @__PURE__ */ new Set,this._blobFiles.add(n)),t(n)},o=function(t){for(let r of t.target.files)$i._load(r,a(n))};if(!(window.File&&window.FileReader&&window.FileList&&window.Blob)){t._friendlyError(`The File APIs are not fully supported in this browser. Cannot create element.`,`createFileInput`);return}let s=document.createElement(`input`);return s.setAttribute(`type`,`file`),i&&s.setAttribute(`multiple`,!0),s.addEventListener(`change`,o,!1),r(s,this)}}typeof p5<`u`&&f_(p5,p5.prototype);function p_(t){t.registerAddon(f_),t.registerAddon(na),t.registerAddon(so),t.registerAddon(ea)}function m_(t,n,r){r.presetup=function(){for(let t of[`deviceorientation`,`devicemotion`])window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal});this.deviceOrientation=typeof window<`u`&&window.innerWidth/window.innerHeight>1?`landscape`:`portrait`},n.deviceOrientation=`landscape`,n.accelerationX=0,n.accelerationY=0,n.accelerationZ=0,n.pAccelerationX=0,n.pAccelerationY=0,n.pAccelerationZ=0,n._updatePAccelerations=function(){this.pAccelerationX=this.accelerationX,this.pAccelerationY=this.accelerationY,this.pAccelerationZ=this.accelerationZ},n.rotationX=0,n.rotationY=0,n.rotationZ=0,n.pRotationX=0,n.pRotationY=0,n.pRotationZ=0;let i=0,a=0,o=0,s=`clockwise`,c=`clockwise`,l=`clockwise`;n.pRotateDirectionX=void 0,n.pRotateDirectionY=void 0,n.pRotateDirectionZ=void 0,n._updatePRotations=function(){this.pRotationX=this.rotationX,this.pRotationY=this.rotationY,this.pRotationZ=this.rotationZ},n.turnAxis=void 0;let u=.5,d=30;n.setMoveThreshold=function(t){u=t},n.setShakeThreshold=function(t){d=t},n._ondeviceorientation=function(t){this._updatePRotations(),this.rotationX=this._fromDegrees(t.beta),this.rotationY=this._fromDegrees(t.gamma),this.rotationZ=this._fromDegrees(t.alpha),this._handleMotion()},n._ondevicemotion=function(t){this._updatePAccelerations(),this.accelerationX=t.acceleration.x*2,this.accelerationY=t.acceleration.y*2,this.accelerationZ=t.acceleration.z*2,this._handleMotion()},n._handleMotion=function(){if(this.deviceOrientation=screen.orientation.type===`landscape-primary`||screen.orientation.type===`landscape-secondary`?`landscape`:screen.orientation.type===`portrait-primary`||screen.orientation.type===`portrait-secondary`?`portrait`:`undefined`,typeof this._customActions.deviceMoved==`function`&&(Math.abs(this.accelerationX-this.pAccelerationX)>u||Math.abs(this.accelerationY-this.pAccelerationY)>u||Math.abs(this.accelerationZ-this.pAccelerationZ)>u)&&this._customActions.deviceMoved(),typeof this._customActions.deviceTurned==`function`){let t=this._toDegrees(this.rotationX)+180,n=this._toDegrees(this.pRotationX)+180,r=i+180;t-n>0&&t-n<270||t-n<-270?s=`clockwise`:(t-n<0||t-n>270)&&(s=`counter-clockwise`),s!==this.pRotateDirectionX&&(r=t),Math.abs(t-r)>90&&Math.abs(t-r)<270&&(r=t,this.turnAxis=`X`,this._customActions.deviceTurned()),this.pRotateDirectionX=s,i=r-180;let u=this._toDegrees(this.rotationY)+180,d=this._toDegrees(this.pRotationY)+180,f=a+180;u-d>0&&u-d<270||u-d<-270?c=`clockwise`:(u-d<0||u-this.pRotationY>270)&&(c=`counter-clockwise`),c!==this.pRotateDirectionY&&(f=u),Math.abs(u-f)>90&&Math.abs(u-f)<270&&(f=u,this.turnAxis=`Y`,this._customActions.deviceTurned()),this.pRotateDirectionY=c,a=f-180;let p=this._toDegrees(this.rotationZ),m=this._toDegrees(this.pRotationZ);p-m>0&&p-m<270||p-m<-270?l=`clockwise`:(p-m<0||p-m>270)&&(l=`counter-clockwise`),l!==this.pRotateDirectionZ&&(o=p),Math.abs(p-o)>90&&Math.abs(p-o)<270&&(o=p,this.turnAxis=`Z`,this._customActions.deviceTurned()),this.pRotateDirectionZ=l,this.turnAxis=void 0}if(typeof this._customActions.deviceShaken==`function`){let t,n;this.pAccelerationX!==null&&(t=Math.abs(this.accelerationX-this.pAccelerationX),n=Math.abs(this.accelerationY-this.pAccelerationY)),t+n>d&&this._customActions.deviceShaken()}}}typeof p5<`u`&&m_(p5,p5.prototype);function h_(t){return[`Alt`,`Shift`,`Control`,`Meta`].includes(t)||typeof t!=`string`?!1:t.length>1}function g_(t,n,r){r.presetup=function(){for(let t of[`keydown`,`keyup`,`keypress`,`blur`])window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},n.keyIsPressed=!1,n.key=``,n.code=``,n.keyCode=0,n._onkeydown=function(t){this._downKeys[t.code]||(this.keyIsPressed=!0,this.keyCode=t.which,this.key=t.key,this.code=t.code,this._downKeyCodes[t.code]=!0,this._downKeys[t.key]=!0,typeof this._customActions.keyPressed==`function`&&!t.charCode&&this._customActions.keyPressed(t)===!1&&t.preventDefault())},n._onkeyup=function(t){if(typeof this._customActions.keyReleased==`function`&&this._customActions.keyReleased(t)===!1&&t.preventDefault(),delete this._downKeyCodes[t.code],delete this._downKeys[t.key],!this._areDownKeys())this.keyIsPressed=!1,this.key=``,this.code=``;else{let t=Object.keys(this._downKeyCodes).pop();this.code=t;let n=Object.keys(this._downKeys).pop();this.key=n}},n._onkeypress=function(t){t.which===this._lastKeyCodeTyped&&t.repeat||(this._lastKeyCodeTyped=t.which,this.key=t.key||String.fromCharCode(t.which)||t.which,typeof this._customActions.keyTyped==`function`&&this._customActions.keyTyped(t)===!1&&t.preventDefault())},n._onblur=function(t){this._downKeys={}},n.keyIsDown=function(t){return h_(t)?this._downKeyCodes[t]||this._downKeys[t]||!1:this._downKeys[t]||this._downKeyCodes[t]||!1},n._areDownKeys=function(){for(let t in this._downKeys)if(this._downKeys.hasOwnProperty(t)&&this._downKeys[t]===!0)return!0;return!1}}typeof p5<`u`&&g_(p5,p5.prototype);function __(t,n,r){r.presetup=function(){for(let t of[`pointerdown`,`pointerup`,`pointercancel`,`pointermove`,`dragend`,`dragover`,`click`,`dblclick`,`wheel`])window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal});window.addEventListener(`blur`,()=>{this.mouseIsPressed=!1},{signal:this._removeSignal})},n.movedX=0,n.movedY=0,n._hasMouseInteracted=!1,n.mouseX=0,n.mouseY=0,n.pmouseX=0,n.pmouseY=0,n.winMouseX=0,n.winMouseY=0,n.pwinMouseX=0,n.pwinMouseY=0,n.mouseButton={left:!1,right:!1,center:!1},n.touches=[],n._activePointers=/* @__PURE__ */ new Map,n.mouseIsPressed=!1,n._updatePointerCoords=function(t){if(this._curElement!==null){let n=this._curElement.elt,r=n.scrollWidth/this.width||1,o=n.scrollHeight/this.height||1;if(t.pointerType===`touch`){let t=[];for(let i of this._activePointers.values())t.push(a(n,r,o,i));this.touches=t}let s=i(n,r,o,t);this.movedX=t.movementX||0,this.movedY=t.movementY||0,this.mouseX=s.x,this.mouseY=s.y,this.winMouseX=s.winX,this.winMouseY=s.winY,this._hasMouseInteracted||=(this._updateMouseCoords(),!0)}},n._updateMouseCoords=function(){this.pmouseX=this.mouseX,this.pmouseY=this.mouseY,this.pwinMouseX=this.winMouseX,this.pwinMouseY=this.winMouseY,this._pmouseWheelDeltaY=this._mouseWheelDeltaY};function i(t,n,r,i){let a=t.getBoundingClientRect();return{x:(i.clientX-a.left)/n,y:(i.clientY-a.top)/r,winX:i.clientX,winY:i.clientY}}function a(t,n,r,i){let a=t.getBoundingClientRect();return{x:(i.clientX-a.left)/n,y:(i.clientY-a.top)/r,winX:i.clientX,winY:i.clientY,id:i.pointerId}}n._setMouseButton=function(t){this.mouseButton.left=Array.from(this._activePointers.values()).some(t=>!!(t.buttons&1)),this.mouseButton.center=Array.from(this._activePointers.values()).some(t=>!!(t.buttons&4)),this.mouseButton.right=Array.from(this._activePointers.values()).some(t=>!!(t.buttons&2))},n._onpointermove=function(t){let n;this._updatePointerCoords(t),this._activePointers.set(t.pointerId,t),this._setMouseButton(t),this.mouseIsPressed&&t.buttons===0&&this._onpointerup(t),!this.mouseIsPressed&&typeof this._customActions.mouseMoved==`function`?(n=this._customActions.mouseMoved(t),n===!1&&t.preventDefault()):this.mouseIsPressed&&typeof this._customActions.mouseDragged==`function`&&(n=this._customActions.mouseDragged(t),n===!1&&t.preventDefault())},n._onpointerdown=function(t){let n;this.mouseIsPressed=!0,this._activePointers.set(t.pointerId,t),this._setMouseButton(t),this._updatePointerCoords(t),typeof this._customActions.mousePressed==`function`&&(n=this._customActions.mousePressed(t),n===!1&&t.preventDefault())},n._onpointerup=function(t){let n;this.mouseIsPressed=!1,this._activePointers.delete(t.pointerId),this._setMouseButton(t),this._updatePointerCoords(t),typeof this._customActions.mouseReleased==`function`&&(n=this._customActions.mouseReleased(t),n===!1&&t.preventDefault())},n._ondragend=n._onpointerup,n._ondragover=n._onpointermove,n._onpointercancel=function(t){this._activePointers.delete(t.pointerId),this._setMouseButton(t),this._updatePointerCoords(t),this._activePointers.size===0&&(this.mouseIsPressed=!1)},n._onclick=function(t){typeof this._customActions.mouseClicked==`function`&&this._customActions.mouseClicked(t)===!1&&t.preventDefault()},n._ondblclick=function(t){typeof this._customActions.doubleClicked==`function`&&this._customActions.doubleClicked(t)===!1&&t.preventDefault()},n._mouseWheelDeltaY=0,n._pmouseWheelDeltaY=0,n._onwheel=function(t){this._mouseWheelDeltaY=t.deltaY,typeof this._customActions.mouseWheel==`function`&&(t.delta=t.deltaY,this._customActions.mouseWheel(t)===!1&&t.preventDefault())},n.requestPointerLock=function(){let n=this._curElement.elt;return n.requestPointerLock=n.requestPointerLock||n.mozRequestPointerLock,n.requestPointerLock?(n.requestPointerLock(),!0):(t._friendlyError(`requestPointerLock is not implemented in this browser`,`requestPointerLock`),!1)},n.exitPointerLock=function(){document.exitPointerLock()}}typeof p5<`u`&&__(p5,p5.prototype);function v_(t){t.registerAddon(m_),t.registerAddon(g_),t.registerAddon(__)}function y_(t){t.registerAddon(_o),t.registerAddon(Oo),t.registerAddon(ma),t.registerAddon(ko),t.registerAddon(bs),t.registerAddon(ks)}var b_=class{constructor(t){this.columns=[],this.rows=[]}toString(t=`,`){let n=this.rows.map(t=>t.arr);return this.columns.some(t=>t===null)||(n=[this.columns,...n]),yo(n,{separator:t})}addRow(t){let n=t||new p5.TableRow;if(n.arr===void 0||n.obj===void 0)throw Error(`invalid TableRow: ${n}`);return n.table=this,this.rows.push(n),n}removeRow(t){this.rows[t].table=null;let n=this.rows.splice(t+1,this.rows.length);this.rows.pop(),this.rows=this.rows.concat(n)}getRow(t){return this.rows[t]}getRows(){return this.rows}findRow(t,n){if(typeof n==`string`){for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(n)]===t)return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[n]===t)return this.rows[r];return null}findRows(t,n){let r=[];if(typeof n==`string`)for(let i=0;i<this.rows.length;i++)this.rows[i].obj[this.columns.indexOf(n)]===t&&r.push(this.rows[i]);else for(let i=0;i<this.rows.length;i++)this.rows[i].arr[n]===t&&r.push(this.rows[i]);return r}matchRow(t,n){if(typeof n==`number`){for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[n].match(t))return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(n)].match(t))return this.rows[r];return null}matchRows(t,n){let r=[];if(typeof n==`number`)for(let i=0;i<this.rows.length;i++)this.rows[i].arr[n].match(t)&&r.push(this.rows[i]);else for(let i=0;i<this.rows.length;i++)this.rows[i].obj[this.columns.indexOf(n)].match(t)&&r.push(this.rows[i]);return r}getColumn(t){let n=[];if(typeof t==`string`)for(let r=0;r<this.rows.length;r++)n.push(this.rows[r].obj[this.columns.indexOf(t)]);else for(let r=0;r<this.rows.length;r++)n.push(this.rows[r].arr[t]);return n}clearRows(){delete this.rows,this.rows=[]}addColumn(t){let n=t||null;this.columns.push(n)}getColumnCount(){return this.columns.length}getRowCount(){return this.rows.length}removeTokens(t,n){let r=t=>t.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`),i=[];for(let n=0;n<t.length;n++)i.push(r(t.charAt(n)));let a=new RegExp(i.join(`|`),`g`);if(n===void 0)for(let t=0;t<this.columns.length;t++)for(let n=0;n<this.rows.length;n++){let r=this.rows[n].arr[t];r=r.replace(a,``),this.rows[n].arr[t]=r,this.rows[n].obj[this.columns[t]]=r}else if(typeof n==`string`)for(let t=0;t<this.rows.length;t++){let r=this.rows[t].obj[n];r=r.replace(a,``),this.rows[t].obj[n]=r;let i=this.columns.indexOf(n);this.rows[t].arr[i]=r}else for(let t=0;t<this.rows.length;t++){let r=this.rows[t].arr[n];r=r.replace(a,``),this.rows[t].arr[n]=r,this.rows[t].obj[this.columns[n]]=r}}trim(t){let n=/* @__PURE__ */ RegExp(` `,`g`);if(t===void 0)for(let t=0;t<this.columns.length;t++)for(let r=0;r<this.rows.length;r++){let i=this.rows[r].arr[t];i=i.replace(n,``),this.rows[r].arr[t]=i,this.rows[r].obj[this.columns[t]]=i}else if(typeof t==`string`)for(let r=0;r<this.rows.length;r++){let i=this.rows[r].obj[t];i=i.replace(n,``),this.rows[r].obj[t]=i;let a=this.columns.indexOf(t);this.rows[r].arr[a]=i}else for(let r=0;r<this.rows.length;r++){let i=this.rows[r].arr[t];i=i.replace(n,``),this.rows[r].arr[t]=i,this.rows[r].obj[this.columns[t]]=i}}removeColumn(t){let n,r;typeof t==`string`?(n=t,r=this.columns.indexOf(t)):(r=t,n=this.columns[t]);let i=this.columns.splice(r+1,this.columns.length);this.columns.pop(),this.columns=this.columns.concat(i);for(let t=0;t<this.rows.length;t++){let i=this.rows[t].arr,a=i.splice(r+1,i.length);i.pop(),this.rows[t].arr=i.concat(a),delete this.rows[t].obj[n]}}set(t,n,r){this.rows[t].set(n,r)}setNum(t,n,r){this.rows[t].setNum(n,r)}setString(t,n,r){this.rows[t].setString(n,r)}get(t,n){return typeof n==`string`?this.rows[t].get(this.columns.indexOf(n)):this.rows[t].get(n)}getNum(t,n){return this.rows[t].getNum(n)}getString(t,n){return this.rows[t].getString(n)}getObject(t){let n={},r,i,a;for(let o=0;o<this.rows.length;o++)if(r=this.rows[o].obj,typeof t==`string`){if(i=this.columns.indexOf(t),i>=0)a=r[t],n[a]=r;else throw Error(`This table has no column named "${t}"`)}else n[o]=this.rows[o].obj;return n}getArray(){let t=[];for(let n=0;n<this.rows.length;n++)t.push(this.rows[n].arr);return t}};function x_(t,n){t.Table=b_}typeof p5<`u`&&x_(p5,p5.prototype);var S_=class{constructor(t=[]){let n=t;this.arr=n,this.obj=Object.fromEntries(n.entries()),this.table=null}set(t,n){if(typeof t==`string`){let r=this.table.columns.indexOf(t);if(r>=0)this.obj[t]=n,this.arr[r]=n;else throw Error(`This table has no column named "${t}"`)}else if(t<this.table.columns.length){this.arr[t]=n;let r=this.table.columns[t];this.obj[r]=n}else throw Error(`Column #${t} is out of the range of this table`)}setNum(t,n){let r=parseFloat(n);this.set(t,r)}setString(t,n){let r=n.toString();this.set(t,r)}get(t){return typeof t==`string`?this.obj[this.table.columns.indexOf(t)]:this.arr[t]}getNum(t){let n;if(n=parseFloat(typeof t==`string`?this.obj[this.table.columns.indexOf(t)]:this.arr[t]),n.toString()===`NaN`)throw`Error: ${this.obj[t]} is NaN (Not a Number)`;return n}getString(t){return typeof t==`string`?this.obj[this.table.columns.indexOf(t)].toString():this.arr[t].toString()}};function C_(t,n){t.TableRow=S_}typeof p5<`u`&&C_(p5,p5.prototype);function w_(t){t.registerAddon(Eo),t.registerAddon(x_),t.registerAddon(C_),t.registerAddon(Qi)}function T_(t,n){n.abs=Math.abs,n.ceil=Math.ceil,n.constrain=function(t,n,r){return Math.max(Math.min(t,r),n)},n.dist=function(...t){if(t.length===4)return Math.hypot(t[2]-t[0],t[3]-t[1]);if(t.length===6)return Math.hypot(t[3]-t[0],t[4]-t[1],t[5]-t[2])},n.exp=Math.exp,n.floor=Math.floor,n.lerp=function(t,n,r){return r*(n-t)+t},n.log=Math.log,n.mag=function(t,n){return Math.hypot(t,n)},n.map=function(t,n,r,i,a,o){let s=(t-n)/(r-n)*(a-i)+i;return o?i<a?this.constrain(s,i,a):this.constrain(s,a,i):s},n.max=function(...t){let n=t=>{let n=-1/0;for(let r of t)n=Math.max(n,r);return n};return t[0]instanceof Array?n(t[0]):n(t)},n.min=function(...t){let n=t=>{let n=1/0;for(let r of t)n=Math.min(n,r);return n};return t[0]instanceof Array?n(t[0]):n(t)},n.norm=function(t,n,r){return this.map(t,n,r,0,1)},n.pow=Math.pow,n.round=function(t,n){if(!n)return Math.round(t);let r=10**n;return Math.round(t*r)/r},n.sq=t=>t*t,n.sqrt=Math.sqrt,n.fract=function(t){let n=0,r=Number(t);if(isNaN(r)||Math.abs(r)===1/0)return r;if(r<0&&(r=-r,n=1),String(r).includes(`.`)&&!String(r).includes(`e`)){let t=String(r);return t=Number(`0`+t.slice(t.indexOf(`.`))),Math.abs(n-t)}return r<1?Math.abs(n-r):0}}typeof p5<`u`&&T_(p5,p5.prototype);function E_(t,n){let r=4095,i=4,a=.5,o=t=>.5*(1-Math.cos(t*Math.PI)),s;n.noise=function(t,n=0,c=0){if(s==null){s=Array(4096);for(let t=0;t<4096;t++)s[t]=Math.random()}t<0&&(t=-t),n<0&&(n=-n),c<0&&(c=-c);let l=Math.floor(t),u=Math.floor(n),d=Math.floor(c),f=t-l,p=n-u,m=c-d,h,g,_=0,v=.5,y,b,x;for(let t=0;t<i;t++){let t=l+(u<<4)+(d<<8);h=o(f),g=o(p),y=s[t&r],y+=h*(s[t+1&r]-y),b=s[t+16&r],b+=h*(s[t+16+1&r]-b),y+=g*(b-y),t+=256,b=s[t&r],b+=h*(s[t+1&r]-b),x=s[t+16&r],x+=h*(s[t+16+1&r]-x),b+=g*(x-b),y+=o(m)*(b-y),_+=y*v,v*=a,l<<=1,f*=2,u<<=1,p*=2,d<<=1,m*=2,f>=1&&(l++,f--),p>=1&&(u++,p--),m>=1&&(d++,m--)}return _},n.noiseDetail=function(t,n=.5){t>0&&(i=t),n>0&&(a=n)},n._getNoiseOctaves=function(){return i},n._getNoiseAmpFalloff=function(){return a},n.noiseSeed=function(t){let n=(()=>{let t=4294967296,n,r;return{setSeed(i){r=n=(i??Math.random()*t)>>>0},getSeed(){return n},rand(){return r=(1664525*r+1013904223)%t,r/t}}})();n.setSeed(t),s=Array(4096);for(let t=0;t<4096;t++)s[t]=n.rand()}}typeof p5<`u`&&E_(p5,p5.prototype);function D_(t,n){let r=`_lcg_random_state`,i=4294967296,a=0;n._lcg=function(t){return this[t]=(1664525*this[t]+1013904223)%i,this[t]/i},n._lcgSetSeed=function(t,n){this[t]=(n??Math.random()*i)>>>0},n.randomSeed=function(t){this._lcgSetSeed(r,t),this._gaussian_previous=!1},n.random=function(t,n){let i;if(i=this[r]==null?Math.random():this._lcg(r),t===void 0)return i;if(n===void 0)return t instanceof Array?t[Math.floor(i*t.length)]:i*t;if(t>n){let r=t;t=n,n=r}return i*(n-t)+t},n.randomGaussian=function(t,n=1){let r,i,o,s;if(this._gaussian_previous)r=a,this._gaussian_previous=!1;else{do i=this.random(2)-1,o=this.random(2)-1,s=i*i+o*o;while(s>=1);s=Math.sqrt(-2*Math.log(s)/s),r=i*s,a=o*s,this._gaussian_previous=!0}let c=t||0;return r*n+c}}typeof p5<`u`&&D_(p5,p5.prototype);function O_(t,n){n.createVector=function(...n){return this instanceof t?(this._boundFromRadians||(this._boundFromRadians=this._fromRadians.bind(this),this._boundToRadians=this._toRadians.bind(this)),new t.Vector(this._boundFromRadians,this._boundToRadians,...n)):new t.Vector(...n)},n.createMatrix=function(...n){return new t.Matrix(...n)}}typeof p5<`u`&&O_(p5,p5.prototype);function k_(t,n=`Requires valid arguments`){return t.friendlyErrorsDisabled()||t._friendlyError(n,`p5.Vector`),t}function A_(t){return function(...n){return n.length===0?(this.constructor._friendlyError(`In 1.x, createVector() was a shortcut for createVector(0, 0, 0). In 2.x, p5.js has vectors of any dimension, so you must provide your desired number of zeros. Use createVector(0, 0) for a 2D vector and createVector(0, 0, 0) for a 3D vector.`,`p5.createVector`),t.call(this,0,0,0)):(Array.isArray(n[0])&&(n=n[0]),t.call(this,...n))}}function j_(t,n=0,r){return function(i){return function(...a){let o=[];if(n>0){if(a.length===1&&(a[0]instanceof I||Array.isArray(a[0]))&&r)for(let t=0;t<r.length;t++)o.push(r[t]);else if(a.length<n)return r&&a.length===0?this:k_(this);else{for(let t=0;t<n;t++)o.unshift(a.pop());for(let t=0;t<o.length;t++){let n=o[t];if(typeof n!=`number`||!Number.isFinite(n))return k_(this,`Arguments contain non-finite numbers`)}if(a.length===0)return k_(this)}}else if(a.length===0)return this;if(a[0]instanceof I){if(n>0&&a.length>1)return k_(this);a=a[0].values}else if(Array.isArray(a[0])){if(n>0&&a.length>1)return k_(this);a=a[0]}else a.length===1&&t&&(a=a[0]);if(Array.isArray(a))for(let t=0;t<a.length;t++){let n=a[t];if(typeof n!=`number`||!Number.isFinite(n))return k_(this,`Arguments contain non-finite numbers`)}else if(typeof a!=`number`||!Number.isFinite(a))return k_(this,`Arguments contain non-finite numbers`);return i.call(this,a,...o)}}}function M_(t,n,r){t.registerDecorator(`p5.prototype.createVector`,A_),t.registerDecorator(`p5.Vector.prototype.mult`,j_(!0)),t.registerDecorator(`p5.Vector.prototype.rem`,j_(!0)),t.registerDecorator(`p5.Vector.prototype.div`,j_(!0)),t.registerDecorator(`p5.Vector.prototype.add`,j_(!1)),t.registerDecorator(`p5.Vector.prototype.sub`,j_(!1)),t.registerDecorator(`p5.Vector.prototype.lerp`,j_(!1,1,[0]))}function N_(t){t.registerAddon(T_),t.registerAddon(E_),t.registerAddon(D_),t.registerAddon(ws),t.registerAddon(O_),t.registerAddon(_a),t.registerAddon(M_)}function P_(t,n){n.float=function(t){return t instanceof Array?t.map(parseFloat):parseFloat(t)},n.int=function(t,r=10){if(t===1/0||t===`Infinity`)return 1/0;if(t===-1/0||t===`-Infinity`)return-1/0;if(typeof t==`string`)return parseInt(t,r);if(typeof t==`number`)return t|0;if(typeof t==`boolean`)return+!!t;if(t instanceof Array)return t.map(t=>n.int(t,r))},n.str=function(t){return t instanceof Array?t.map(n.str,this):String(t)},n.boolean=function(t){if(typeof t==`number`)return t!==0;if(typeof t==`string`)return t.toLowerCase()===`true`;if(typeof t==`boolean`)return t;if(t instanceof Array)return t.map(n.boolean,this)},n.byte=function(t){let r=n.int(t,10);if(typeof r==`number`)return(r+128)%256-128;if(r instanceof Array)return r.map(n.byte,this)},n.char=function(t){if(typeof t==`number`&&!isNaN(t))return String.fromCharCode(t);if(t instanceof Array)return t.map(n.char,this);if(typeof t==`string`)return n.char(parseInt(t,10))},n.unchar=function(t){if(typeof t==`string`&&t.length===1)return t.charCodeAt(0);if(t instanceof Array)return t.map(n.unchar,this)},n.hex=function(t,r){if(r??=r=8,t instanceof Array)return t.map(t=>n.hex(t,r));if(t===1/0||t===-1/0)return(t===1/0?`F`:`0`).repeat(r);if(typeof t==`number`){t<0&&(t=4294967295+t+1);let n=Number(t).toString(16).toUpperCase();for(;n.length<r;)n=`0${n}`;return n.length>=r&&(n=n.substring(n.length-r,n.length)),n}},n.unhex=function(t){return t instanceof Array?t.map(n.unhex,this):parseInt(`0x${t}`,16)}}typeof p5<`u`&&P_(p5,p5.prototype);function F_(t,n){n.nf=function(t,n,i){return t instanceof Array?t.map(t=>r(t,n,i)):Object.prototype.toString.call(t)===`[object Arguments]`?t.length===3?this.nf(t[0],t[1],t[2]):t.length===2?this.nf(t[0],t[1]):this.nf(t[0]):r(t,n,i)};function r(t,n,r){let i=t<0;t=Math.abs(t);let[a,o]=t.toString().split(`.`);if(r===void 0){a=a.padStart(n,`0`);let t=o?a+`.`+o:a;return i?`-`+t:t}{let s=t.toFixed(r);[a,o]=s.toString().split(`.`),a=a.padStart(n,`0`);let c=o===void 0?a:a+`.`+o;return i?`-`+c:c}}n.nfc=function(t,n){return t instanceof Array?t.map(t=>i(t,n)):i(t,n)};function i(t,n){t=t.toString();let r=t.indexOf(`.`),i=r===-1?``:t.substring(r),a=r===-1?t:t.substring(0,r);if(a=a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,`,`),n===0)i=``;else if(n!==void 0){if(n>i.length){i+=r===-1?`.`:``;let t=n-i.length+1;for(let n=0;n<t;n++)i+=`0`}else i=i.substring(0,n+1)}return a+i}n.nfp=function(...t){let r=n.nf.apply(this,t);return r instanceof Array?r.map(a):a(r)};function a(t){return parseFloat(t)>0?`+${t.toString()}`:t.toString()}n.nfs=function(...t){let r=n.nf.apply(this,t);return r instanceof Array?r.map(o):o(r)};function o(t){return parseFloat(t)>=0?` ${t.toString()}`:t.toString()}n.splitTokens=function(t,n){let r;if(n!==void 0){let t=n,i=/\]/g.exec(t),a=/\[/g.exec(t);a&&i?(t=t.slice(0,i.index)+t.slice(i.index+1),a=/\[/g.exec(t),t=t.slice(0,a.index)+t.slice(a.index+1),r=RegExp(`[\\[${t}\\]]`,`g`)):i?(t=t.slice(0,i.index)+t.slice(i.index+1),r=RegExp(`[${t}\\]]`,`g`)):a?(t=t.slice(0,a.index)+t.slice(a.index+1),r=RegExp(`[${t}\\[]`,`g`)):r=RegExp(`[${t}]`,`g`)}else r=/\s/g;return t.split(r).filter(t=>t)},n.shuffle=function(t,n){t=n?t:t.slice();let r,i,a=t.length;for(;a>1;)r=this.random(0,1)*a|0,i=t[--a],t[a]=t[r],t[r]=i;return t}}typeof p5<`u`&&F_(p5,p5.prototype);function I_(t,n){n.day=function(){return(/* @__PURE__ */ new Date()).getDate()},n.hour=function(){return(/* @__PURE__ */ new Date()).getHours()},n.minute=function(){return(/* @__PURE__ */ new Date()).getMinutes()},n.millis=function(){return this._millisStart===-1?0:window.performance.now()-this._millisStart},n.month=function(){return(/* @__PURE__ */ new Date()).getMonth()+1},n.second=function(){return(/* @__PURE__ */ new Date()).getSeconds()},n.year=function(){return(/* @__PURE__ */ new Date()).getFullYear()}}typeof p5<`u`&&I_(p5,p5.prototype);function L_(t){t.registerAddon(P_),t.registerAddon(F_),t.registerAddon(I_)}function R_(t,n){n.orbitControl=function(t,n,r,i){this._assert3d(`orbitControl`);let a=this._renderer.states.curCamera;t===void 0&&(t=1),n===void 0&&(n=t),r===void 0&&(r=1),typeof i!=`object`&&(i={}),this.contextMenuDisabled!==!0&&(this.canvas.oncontextmenu=()=>!1,this.contextMenuDisabled=!0),this.wheelDefaultDisabled!==!0&&(this.canvas.onwheel=()=>!1,this.wheelDefaultDisabled=!0);let{disableTouchActions:o=!0}=i;this.touchActionsDisabled!==!0&&o&&(this.canvas.style[`touch-action`]=`none`,this.touchActionsDisabled=!0);let{freeRotation:s=!1}=i,c=[];this.touches.forEach(t=>{this._renderer.prevTouches.forEach(n=>{if(t.id===n.id){let r={x:t.x,y:t.y,px:n.x,py:n.y};c.push(r)}})}),this._renderer.prevTouches=this.touches;let l=0,u=0,d=0,f=0,p=0,m=.85,h=.6,g=.15,_=this.height<this.width?this.height:this.width,v=!1;if(c.length>0){if(v=c[0].x>0&&c[0].x<this.width&&c[0].y>0&&c[0].y<this.height,c.length===1){let r=c[0];u=-t*(r.x-r.px)/_,d=n*(r.y-r.py)/_}else{let t=c[0],n=c[1];l=-(Math.hypot(t.x-n.x,t.y-n.y)-Math.hypot(t.px-n.px,t.py-n.py))*r*4e-4,f=.5*(t.x+n.x)-.5*(t.px+n.px),p=.5*(t.y+n.y)-.5*(t.py+n.py)}this.touches.length>0?v&&(this._renderer.executeRotateAndMove=!0,this._renderer.executeZoom=!0):(this._renderer.executeRotateAndMove=!1,this._renderer.executeZoom=!1)}else v=this.mouseX>0&&this.mouseX<this.width&&this.mouseY>0&&this.mouseY<this.height,this._mouseWheelDeltaY===0?this._renderer.executeZoom=!1:(l=Math.sign(this._mouseWheelDeltaY)*r,l*=.01,this._mouseWheelDeltaY=0,v&&(this._renderer.executeZoom=!0)),this.mouseIsPressed?(this.mouseButton.left?(u=-t*this.movedX/_,d=n*this.movedY/_):this.mouseButton.right&&(f=this.movedX,p=this.movedY*a.yScale),v&&(this._renderer.executeRotateAndMove=!0)):this._renderer.executeRotateAndMove=!1;if(l!==0&&this._renderer.executeZoom&&(this._renderer.zoomVelocity+=l),Math.abs(this._renderer.zoomVelocity)>.001?(s?a._orbitFree(0,0,this._renderer.zoomVelocity):a._orbit(0,0,this._renderer.zoomVelocity),a.projMatrix.mat4[15]!==0&&(a.projMatrix.mat4[0]*=10**-this._renderer.zoomVelocity,a.projMatrix.mat4[5]*=10**-this._renderer.zoomVelocity,this._renderer.states.setValue(`uPMatrix`,this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.mat4[0]=a.projMatrix.mat4[0],this._renderer.states.uPMatrix.mat4[5]=a.projMatrix.mat4[5]),this._renderer.zoomVelocity*=m):this._renderer.zoomVelocity=0,(u!==0||d!==0)&&this._renderer.executeRotateAndMove&&this._renderer.rotateVelocity.add(u*h,d*h,0),this._renderer.rotateVelocity.magSq()>1e-6?(s?a._orbitFree(-this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0):a._orbit(this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0),this._renderer.rotateVelocity.mult(m)):this._renderer.rotateVelocity.set(0,0,0),(f!==0||p!==0)&&this._renderer.executeRotateAndMove){let t=f*2/this.width,n=-p*2/this.height;this._renderer.moveVelocity.add(t*g,n*g)}if(this._renderer.moveVelocity.magSq()>1e-6){let t=a._getLocalAxes(),n=a.eyeX-a.centerX,r=a.eyeY-a.centerY,i=a.eyeZ-a.centerZ,o=Math.sqrt(n*n+r*r+i*i),s=new I(a.centerX,a.centerY,a.centerZ);s=a.cameraMatrix.multiplyPoint(s),s=this._renderer.states.uPMatrix.multiplyAndNormalizePoint(s),s.x-=this._renderer.moveVelocity.x,s.y-=this._renderer.moveVelocity.y;let c,l,u=this._renderer.states.uPMatrix.mat4;u[15]===0?(c=(u[8]+s.x)/u[0]*o,l=(u[9]+s.y)/u[5]*o):(c=(s.x-u[12])/u[0],l=(s.y-u[13])/u[5]),a.setPosition(a.eyeX+c*t.x[0]+l*t.y[0],a.eyeY+c*t.x[1]+l*t.y[1],a.eyeZ+c*t.x[2]+l*t.y[2]),this._renderer.moveVelocity.mult(m)}else this._renderer.moveVelocity.set(0,0);return this},n.debugMode=function(...n){this._assert3d(`debugMode`);for(let n=t.lifecycleHooks.postdraw.length-1;n>=0;n--)(t.lifecycleHooks.postdraw[n].toString()===this._grid().toString()||t.lifecycleHooks.postdraw[n].toString()===this._axesIcon().toString())&&t.lifecycleHooks.postdraw.splice(n,1);n[0]===`grid`?t.lifecycleHooks.postdraw.push(this._grid(n[1],n[2],n[3],n[4],n[5])):n[0]===`axes`?t.lifecycleHooks.postdraw.push(this._axesIcon(n[1],n[2],n[3],n[4])):(t.lifecycleHooks.postdraw.push(this._grid(n[0],n[1],n[2],n[3],n[4])),t.lifecycleHooks.postdraw.push(this._axesIcon(n[5],n[6],n[7],n[8])))},n.noDebugMode=function(){this._assert3d(`noDebugMode`);for(let n=t.lifecycleHooks.postdraw.length-1;n>=0;n--)(t.lifecycleHooks.postdraw[n].toString()===this._grid().toString()||t.lifecycleHooks.postdraw[n].toString()===this._axesIcon().toString())&&t.lifecycleHooks.postdraw.splice(n,1)},n._grid=function(t,n,r,i,a){t===void 0&&(t=this.width/2),n===void 0&&(n=Math.round(t/30)<4?4:Math.round(t/30)),r===void 0&&(r=0),i===void 0&&(i=0),a===void 0&&(a=0);let o=t/n,s=t/2;return function(){this.push(),this.stroke(this._renderer.states.curStrokeColor[0]*255,this._renderer.states.curStrokeColor[1]*255,this._renderer.states.curStrokeColor[2]*255),this._renderer.states.setValue(`uModelMatrix`,this._renderer.states.uModelMatrix.clone()),this._renderer.states.uModelMatrix.reset();for(let t=0;t<=n;t++)this.beginShape(this.LINES),this.vertex(-s+r,i,t*o-s+a),this.vertex(+s+r,i,t*o-s+a),this.endShape();for(let t=0;t<=n;t++)this.beginShape(this.LINES),this.vertex(t*o-s+r,i,-s+a),this.vertex(t*o-s+r,i,+s+a),this.endShape();this.pop()}},n._axesIcon=function(t,n,r,i){return t===void 0&&(t=this.width/20>40?this.width/20:40),n===void 0&&(n=-this.width/4),r===void 0&&(r=n),i===void 0&&(i=n),()=>{this.push(),this._renderer.states.setValue(`uModelMatrix`,this._renderer.states.uModelMatrix.clone()),this._renderer.states.uModelMatrix.reset(),this.strokeWeight(2),this.stroke(255,0,0),this.beginShape(this.LINES),this.vertex(n,r,i),this.vertex(n+t,r,i),this.endShape(),this.stroke(0,255,0),this.beginShape(this.LINES),this.vertex(n,r,i),this.vertex(n,r+t,i),this.endShape(),this.stroke(0,0,255),this.beginShape(this.LINES),this.vertex(n,r,i),this.vertex(n,r,i+t),this.endShape(),this.pop()}}}typeof p5<`u`&&R_(p5,p5.prototype);async function z_(t){try{return(await fetch(t,{method:`HEAD`})).ok}catch{return!1}}function B_(t){let n=null,r={},i=t.split(`
`);for(let t=0;t<i.length;++t){let a=i[t].trim().split(/\s+/);if(a[0]===`newmtl`)n=a[1],r[n]={};else if(!n)continue;else if(a[0]===`Kd`)r[n].diffuseColor=[parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])];else if(a[0]===`Ka`)r[n].ambientColor=[parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])];else if(a[0]===`Ks`)r[n].specularColor=[parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])];else if(a[0]===`Ns`)r[n].shininess=parseFloat(a[1]);else if(a[0]===`d`)r[n].opacity=parseFloat(a[1]);else if(a[0]===`Tr`)r[n].opacity=1-parseFloat(a[1]);else if(a[0]===`illum`)r[n].illuminationModel=parseInt(a[1]);else if(a[0]===`map_Kd`)r[n].texturePath=a[1];else if(a[0]===`map_Ka`)r[n].ambientTexturePath=a[1];else if(a[0]===`map_Ks`)r[n].specularTexturePath=a[1];else if(a[0]===`map_Ns`)r[n].shininessTexturePath=a[1];else if(a[0]===`map_Bump`||a[0]===`bump`){r[n].bumpTexturePath=a[a.length-1];let t=a.indexOf(`-bm`);if(t!==-1&&a[t+1]!==void 0){let i=parseFloat(a[t+1]);isNaN(i)||(r[n].bumpScale=i)}}else if(a[0]===`norm`){r[n].normalTexturePath=a[a.length-1];let t=a.indexOf(`-bm`);if(t!==-1&&a[t+1]!==void 0){let i=parseFloat(a[t+1]);isNaN(i)||(r[n].bumpScale=i)}}}return r}function V_(t){let n=Ro();return t&&(t.diffuseColor&&(n.fill=[...t.diffuseColor,t.opacity??1]),t.ambientColor&&(n.ambientColor=t.ambientColor),t.specularColor&&(n.specularColor=t.specularColor),t.shininess!==void 0&&(n.shininess=t.shininess),t.texture&&(n.texture=t.texture),t.specularTexture&&(n.specularTexture=t.specularTexture,n.specularColor||=[1,1,1]),t.ambientTexture&&(n.ambientTexture=t.ambientTexture,n.ambientColor||=[1,1,1]),t.shininessTexture&&(n.shininessTexture=t.shininessTexture,n.shininess??=1),(t.bumpTexture||t.normalTexture)&&(n.normalTexture=t.normalTexture||t.bumpTexture,n.normalMapMode=+!t.normalTexture,t.bumpScale!=null&&(n.normalScale=t.bumpScale))),n}const H_=[[`texturePath`,`texture`],[`specularTexturePath`,`specularTexture`],[`ambientTexturePath`,`ambientTexture`],[`shininessTexturePath`,`shininessTexture`],[`bumpTexturePath`,`bumpTexture`],[`normalTexturePath`,`normalTexture`]];async function U_(t,n,r){if(!r||typeof r.loadImage!=`function`)return;let i=n.lastIndexOf(`/`),a=i>=0?n.slice(0,i):``,o=t=>{let n=t.replace(/\\/g,`/`);return a?`${a}/${n}`:n},s=[];for(let n in t){let i=t[n];for(let[t,n]of H_){if(!i[t])continue;let a=o(i[t]);s.push(r.loadImage(a).then(t=>{i[n]=t}).catch(()=>{console.warn(`Texture not found, skipping: ${a}`)}))}}await Promise.all(s)}function W_(t,n,r){let i=[...new Set(n)];if(i.length===1&&i[0]!=null){Object.assign(t.partState,V_(r[i[0]]));return}if(i.filter(t=>t!=null).length<2)return;let a=t.uvs.length>0,o=t.vertexNormals.length>0,s=t.vertexTangents.length>0,c=[];for(let l of i){let i=new Bo(`${t.gid}|part${c.length}`,V_(r[l])),u=/* @__PURE__ */ new Map;for(let r=0;r<t.faces.length;r++){if(n[r]!==l)continue;let c=t.faces[r].map(n=>(u.has(n)||(u.set(n,i.vertices.length),i.vertices.push(t.vertices[n]),a&&i.uvs.push(t.uvs[n]),o&&i.vertexNormals.push(t.vertexNormals[n]),s&&i.vertexTangents.push(t.vertexTangents[n*4],t.vertexTangents[n*4+1],t.vertexTangents[n*4+2],t.vertexTangents[n*4+3])),u.get(n)));i.faces.push(c)}c.push(i)}t.parts=c}function G_(t,n){n.loadModel=async function(t,n,o,s,c){let l=!1,u=!1;typeof n==`object`?(o=n.normalize||!1,s=n.successCallback,c=n.failureCallback,n=n.fileType||n,l=n.flipU||!1,u=n.flipV||!1):(typeof arguments[arguments.length-1]==`function`&&(typeof arguments[arguments.length-2]==`function`?(s=arguments[arguments.length-2],c=arguments[arguments.length-1]):s=arguments[arguments.length-1]),typeof n==`string`?typeof o!=`boolean`&&(o=!1):typeof n==`boolean`?(o=n,n=t.slice(-4)):(n=t.slice(-4),o=!1)),n.toLowerCase()!==`.obj`&&n.toLowerCase()!==`.stl`&&(n=`.obj`);let d=new Vo(void 0,void 0,void 0,this._renderer);d.gid=`${t}|${o}`;async function f(n){let i=[];for(let a of n){let n=a.match(/^mtllib (.+)/);if(n){let a=``,o=n[1],s=t.split(`/`);s.length>1?(s.pop(),a=s.join(`/`)+`/`+o):a=o,i.push(z_(a).then(t=>t?r(a):(console.warn(`MTL file not found or error in parsing; proceeding without materials: ${a}`),{})).catch(t=>(console.warn(`Error loading MTL file: ${a}`,t),{})))}}try{let t=await Promise.all(i);return Object.assign({},...t)}catch{return{}}}try{if(n.match(/\.stl$/i)){let{data:n}=await To(t,`arrayBuffer`),r=()=>(a(d,n),o&&d.normalize(),l&&d.flipU(),u&&d.flipV(),d._makeTriangleEdges(),s?s(d):d);return this._internal?this._internal(r):r()}if(n.match(/\.obj$/i)){let{data:n}=await To(t,`text`),r=n.split(`
`),a=await f(r);await U_(a,t,this);let c=()=>(i(d,r,a),o&&d.normalize(),l&&d.flipU(),u&&d.flipV(),d._makeTriangleEdges(),s?s(d):d);return this._internal?this._internal(c):c()}}catch(t){if(c)return c(t);throw t}};async function r(t){let{data:n}=await To(t,`text`);return B_(n)}function i(t,n,r={}){let i={v:[],vt:[],vn:[]},a={},o=null,s=[],c=!1;for(let l=0;l<n.length;++l){let u=n[l].trim().split(/\b\s+/);if(u.length>0){if(u[0]===`usemtl`)o=u[1];else if(u[0]===`v`||u[0]===`vn`){let t=new I(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));i[u[0]].push(t)}else if(u[0]===`vt`){let t=[parseFloat(u[1]),1-parseFloat(u[2])];i[u[0]].push(t)}else if(u[0]===`f`)for(let n=3;n<u.length;++n){let l=[],d=[1,n-1,n];for(let n=0;n<d.length;++n){let s=u[d[n]],f=s.split(`/`);for(let t=0;t<f.length;t++){let n=parseInt(f[t]);n>0&&--n,f[t]=n}if(a[s]||(a[s]={}),a[s][o]===void 0){let n=t.vertices.length;if(t.vertices.push(i.v.at(f[0]).copy()),t.uvs.push(i.vt.at(f[1])?i.vt.at(f[1]).slice():[0,0]),t.vertexNormals.push(i.vn.at(f[2])?i.vn.at(f[2]).copy():new I(0,0,0)),a[s][o]=n,l.push(n),o&&r[o]&&r[o].diffuseColor){c=!0;let n=r[o].diffuseColor;t.vertexColors.push(n[0]),t.vertexColors.push(n[1]),t.vertexColors.push(n[2]),t.vertexColors.push(1)}else t.vertexColors.push(-1,-1,-1,-1)}else l.push(a[s][o])}l[0]!==l[1]&&l[0]!==l[2]&&l[1]!==l[2]&&(t.faces.push(l),s.push(o))}}}return t.vertexNormals.length===0&&t.computeNormals(),c||(t.vertexColors=[]),Object.values(r).some(t=>t&&(t.normalTexture||t.bumpTexture))&&t.computeTangents(),W_(t,s,r),t}function a(t,n){if(o(n))c(t,n);else{let r=new DataView(n);if(!(`TextDecoder`in window))return console.warn(`Sorry, ASCII STL loading only works in browsers that support TextDecoder (https://caniuse.com/#feat=textencoder)`),t;l(t,new TextDecoder(`utf-8`).decode(r).split(`
`))}return t}function o(t){let n=new DataView(t),r=[115,111,108,105,100];for(let t=0;t<5;t++)if(s(r,n,t))return!1;return!0}function s(t,n,r){for(let i=0,a=t.length;i<a;i++)if(t[i]!==n.getUint8(r+i,!1))return!1;return!0}function c(t,n){let r=new DataView(n),i=r.getUint32(80,!0),a,o,s,c=!1,l,u,d,f;for(let t=0;t<70;t++)r.getUint32(t,!1)===1129270351&&r.getUint8(t+4)===82&&r.getUint8(t+5)===61&&(c=!0,l=[],u=r.getUint8(t+6)/255,d=r.getUint8(t+7)/255,f=r.getUint8(t+8)/255);for(let n=0;n<i;n++){let i=84+n*50,p=r.getFloat32(i,!0),m=r.getFloat32(i+4,!0),h=r.getFloat32(i+8,!0);if(c){let t=r.getUint16(i+48,!0);t&32768?(a=u,o=d,s=f):(a=(t&31)/31,o=(t>>5&31)/31,s=(t>>10&31)/31)}let g=new I(p,m,h);for(let n=1;n<=3;n++){let u=i+n*12,d=new I(r.getFloat32(u,!0),r.getFloat32(u+4,!0),r.getFloat32(u+8,!0));t.vertices.push(d),t.vertexNormals.push(g),c&&l.push(a,o,s)}t.faces.push([3*n,3*n+1,3*n+2]),t.uvs.push([0,0],[0,0],[0,0])}return t}function l(t,n){let r=``,i=[],a,o;for(let s=0;s<n.length;++s){let c=n[s].trim(),l=c.split(` `);for(let t=0;t<l.length;++t)l[t]===``&&l.splice(t,1);if(l.length!==0)switch(r){case``:if(l[0]!==`solid`){console.error(c),console.error(`Invalid state "${l[0]}", should be "solid"`);return}r=`solid`;break;case`solid`:if(l[0]!==`facet`||l[1]!==`normal`){console.error(c),console.error(`Invalid state "${l[0]}", should be "facet normal"`);return}a=new I(parseFloat(l[2]),parseFloat(l[3]),parseFloat(l[4])),t.vertexNormals.push(a,a,a),r=`facet normal`;break;case`facet normal`:if(l[0]!==`outer`||l[1]!==`loop`){console.error(c),console.error(`Invalid state "${l[0]}", should be "outer loop"`);return}r=`vertex`;break;case`vertex`:if(l[0]===`vertex`)o=new I(parseFloat(l[1]),parseFloat(l[2]),parseFloat(l[3])),t.vertices.push(o),t.uvs.push([0,0]),i.push(t.vertices.indexOf(o));else if(l[0]===`endloop`)t.faces.push(i),i=[],r=`endloop`;else{console.error(c),console.error(`Invalid state "${l[0]}", should be "vertex" or "endloop"`);return}break;case`endloop`:if(l[0]!==`endfacet`){console.error(c),console.error(`Invalid state "${l[0]}", should be "endfacet"`);return}r=`endfacet`;break;case`endfacet`:if(l[0]!==`endsolid`){if(l[0]===`facet`&&l[1]===`normal`)a=new I(parseFloat(l[2]),parseFloat(l[3]),parseFloat(l[4])),t.vertexNormals.push(a,a,a),r=`facet normal`;else{console.error(c),console.error(`Invalid state "${l[0]}", should be "endsolid" or "facet normal"`);return}}break;default:console.error(`Invalid state "${r}"`)}}return t}n.model=function(t,n=1){this._assert3d(`model`),this._renderer.model(t,n)};let u=0;n.createModel=function(n,r=` `,o){let s=!1,c,l,d=!1,f=!1;o&&typeof o==`object`?(s=o.normalize||!1,c=o.successCallback,l=o.failureCallback,d=o.flipU||!1,f=o.flipV||!1):typeof o==`boolean`?(s=o,c=arguments[3],l=arguments[4]):(c=typeof arguments[2]==`function`?arguments[2]:void 0,l=arguments[3]);let p=new t.Geometry;if(p.gid=`${r}|${s}|${u++}`,r.match(/\.stl$/i))try{let t=new TextEncoder().encode(n).buffer;a(p,t)}catch(n){l?l(n):t.FES.log`Error during parsing: ${n.message}`();return}else if(r.match(/\.obj$/i))try{i(p,n.split(`
`))}catch(n){l?l(n):t.FES.log`Error during parsing: ${n.message}`();return}else l?l():t.FES.log`Sorry, the file type is invalid. Only OBJ and STL files are supported.`();return s&&p.normalize(),d&&p.flipU(),f&&p.flipV(),p._makeTriangleEdges(),typeof c==`function`&&c(p),p}}typeof p5<`u`&&G_(p5,p5.prototype);var K_=(/* @__PURE__ */ s((t=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnicodeRange=function(){function t(){}return t.parse=function(n){for(var r=/* @__PURE__ */ new Set,i=0,a=n;i<a.length;i++){var o=a[i];if(!t.REGEXP.test(o))throw TypeError(`"`+o+`" is invalid unicode-range.`);var s=o.match(t.REGEXP),c=s[1],l=s[2],u=s[3];if(c){if(/\?[^?]+$/.test(c))throw TypeError(`"`+o+`" is invalid unicode-range.`);if(c.includes(`?`))for(var d=c.replace(/\?/g,`0`),f=c.replace(/\?/g,`F`),p=t.parse([`U+`+d+`-`+f]),m=0,h=p;m<h.length;m++){var g=h[m];r.add(g)}else r.add(parseInt(c,16))}if(l&&u)for(var _=parseInt(l,16),v=parseInt(u,16),g=_;g<=v;g++)r.add(g)}return Array.from(r).sort(function(t,n){return t-n})},t.stringify=function(n){for(var r=Array.from(new Set(n)).sort(function(t,n){return t-n}),i=[],a,o=0;o<r.length;o++){var s=r[o],c=r[o-1];a&&s-c!==1&&(i.push(t.rangeString(a,c)),a=s),a||=s,o===r.length-1&&(a===s?i.push(t.rangeString(s)):i.push(t.rangeString(a,s)))}return i},t.rangeString=function(t,n){return!n||t===n?`U+`+t.toString(16):`U+`+t.toString(16)+`-`+n.toString(16)},t.REGEXP=/^u\+(?:([0-9a-f]?[0-9a-f?]{1,5})|([0-9a-f]{1,6})-([0-9a-f]{1,6}))?$/i,t}()})))();const q_=[{category:`control character`,hexrange:[`0000`,`001f`]},{category:`basic latin`,hexrange:[`0000`,`007f`]},{category:`latin-1 supplement`,hexrange:[`0080`,`00ff`]},{category:`latin extended-a`,hexrange:[`0100`,`017f`]},{category:`latin extended-b`,hexrange:[`0180`,`024f`]},{category:`ipa extensions`,hexrange:[`0250`,`02af`]},{category:`spacing modifier letters`,hexrange:[`02b0`,`02ff`]},{category:`combining diacritical marks`,hexrange:[`0300`,`036f`]},{category:`greek and coptic`,hexrange:[`0370`,`03ff`]},{category:`cyrillic`,hexrange:[`0400`,`04ff`]},{category:`cyrillic supplement`,hexrange:[`0500`,`052f`]},{category:`armenian`,hexrange:[`0530`,`058f`]},{category:`hebrew`,hexrange:[`0590`,`05ff`]},{category:`arabic`,hexrange:[`0600`,`06ff`]},{category:`syriac`,hexrange:[`0700`,`074f`]},{category:`arabic supplement`,hexrange:[`0750`,`077f`]},{category:`thaana`,hexrange:[`0780`,`07bf`]},{category:`nko`,hexrange:[`07c0`,`07ff`]},{category:`samaritan`,hexrange:[`0800`,`083f`]},{category:`mandaic`,hexrange:[`0840`,`085f`]},{category:`syriac supplement`,hexrange:[`0860`,`086f`]},{category:`arabic extended-b`,hexrange:[`0870`,`089f`]},{category:`arabic extended-a`,hexrange:[`08a0`,`08ff`]},{category:`devanagari`,hexrange:[`0900`,`097f`]},{category:`bengali`,hexrange:[`0980`,`09ff`]},{category:`gurmukhi`,hexrange:[`0a00`,`0a7f`]},{category:`gujarati`,hexrange:[`0a80`,`0aff`]},{category:`oriya`,hexrange:[`0b00`,`0b7f`]},{category:`tamil`,hexrange:[`0b80`,`0bff`]},{category:`telugu`,hexrange:[`0c00`,`0c7f`]},{category:`kannada`,hexrange:[`0c80`,`0cff`]},{category:`malayalam`,hexrange:[`0d00`,`0d7f`]},{category:`sinhala`,hexrange:[`0d80`,`0dff`]},{category:`thai`,hexrange:[`0e00`,`0e7f`]},{category:`lao`,hexrange:[`0e80`,`0eff`]},{category:`tibetan`,hexrange:[`0f00`,`0fff`]},{category:`myanmar`,hexrange:[`1000`,`109f`]},{category:`georgian`,hexrange:[`10a0`,`10ff`]},{category:`hangul jamo`,hexrange:[`1100`,`11ff`]},{category:`ethiopic`,hexrange:[`1200`,`137f`]},{category:`ethiopic supplement`,hexrange:[`1380`,`139f`]},{category:`cherokee`,hexrange:[`13a0`,`13ff`]},{category:`unified canadian aboriginal syllabics`,hexrange:[`1400`,`167f`]},{category:`ogham`,hexrange:[`1680`,`169f`]},{category:`runic`,hexrange:[`16a0`,`16ff`]},{category:`tagalog`,hexrange:[`1700`,`171f`]},{category:`hanunoo`,hexrange:[`1720`,`173f`]},{category:`buhid`,hexrange:[`1740`,`175f`]},{category:`tagbanwa`,hexrange:[`1760`,`177f`]},{category:`khmer`,hexrange:[`1780`,`17ff`]},{category:`mongolian`,hexrange:[`1800`,`18af`]},{category:`unified canadian aboriginal syllabics extended`,hexrange:[`18b0`,`18ff`]},{category:`limbu`,hexrange:[`1900`,`194f`]},{category:`tai le`,hexrange:[`1950`,`197f`]},{category:`new tai lue`,hexrange:[`1980`,`19df`]},{category:`khmer symbols`,hexrange:[`19e0`,`19ff`]},{category:`buginese`,hexrange:[`1a00`,`1a1f`]},{category:`tai tham`,hexrange:[`1a20`,`1aaf`]},{category:`combining diacritical marks extended`,hexrange:[`1ab0`,`1aff`]},{category:`balinese`,hexrange:[`1b00`,`1b7f`]},{category:`sundanese`,hexrange:[`1b80`,`1bbf`]},{category:`batak`,hexrange:[`1bc0`,`1bff`]},{category:`lepcha`,hexrange:[`1c00`,`1c4f`]},{category:`ol chiki`,hexrange:[`1c50`,`1c7f`]},{category:`cyrillic extended-c`,hexrange:[`1c80`,`1c8f`]},{category:`georgian extended`,hexrange:[`1c90`,`1cbf`]},{category:`sundanese supplement`,hexrange:[`1cc0`,`1ccf`]},{category:`vedic extensions`,hexrange:[`1cd0`,`1cff`]},{category:`phonetic extensions`,hexrange:[`1d00`,`1d7f`]},{category:`phonetic extensions supplement`,hexrange:[`1d80`,`1dbf`]},{category:`combining diacritical marks supplement`,hexrange:[`1dc0`,`1dff`]},{category:`latin extended additional`,hexrange:[`1e00`,`1eff`]},{category:`greek extended`,hexrange:[`1f00`,`1fff`]},{category:`general punctuation`,hexrange:[`2000`,`206f`]},{category:`superscripts and subscripts`,hexrange:[`2070`,`209f`]},{category:`currency symbols`,hexrange:[`20a0`,`20cf`]},{category:`combining diacritical marks for symbols`,hexrange:[`20d0`,`20ff`]},{category:`letterlike symbols`,hexrange:[`2100`,`214f`]},{category:`number forms`,hexrange:[`2150`,`218f`]},{category:`arrows`,hexrange:[`2190`,`21ff`]},{category:`mathematical operators`,hexrange:[`2200`,`22ff`]},{category:`miscellaneous technical`,hexrange:[`2300`,`23ff`]},{category:`control pictures`,hexrange:[`2400`,`243f`]},{category:`optical character recognition`,hexrange:[`2440`,`245f`]},{category:`enclosed alphanumerics`,hexrange:[`2460`,`24ff`]},{category:`box drawing`,hexrange:[`2500`,`257f`]},{category:`block elements`,hexrange:[`2580`,`259f`]},{category:`geometric shapes`,hexrange:[`25a0`,`25ff`]},{category:`miscellaneous symbols`,hexrange:[`2600`,`26ff`]},{category:`dingbats`,hexrange:[`2700`,`27bf`]},{category:`miscellaneous mathematical symbols-a`,hexrange:[`27c0`,`27ef`]},{category:`supplemental arrows-a`,hexrange:[`27f0`,`27ff`]},{category:`braille patterns`,hexrange:[`2800`,`28ff`]},{category:`supplemental arrows-b`,hexrange:[`2900`,`297f`]},{category:`miscellaneous mathematical symbols-b`,hexrange:[`2980`,`29ff`]},{category:`supplemental mathematical operators`,hexrange:[`2a00`,`2aff`]},{category:`miscellaneous symbols and arrows`,hexrange:[`2b00`,`2bff`]},{category:`glagolitic`,hexrange:[`2c00`,`2c5f`]},{category:`latin extended-c`,hexrange:[`2c60`,`2c7f`]},{category:`coptic`,hexrange:[`2c80`,`2cff`]},{category:`georgian supplement`,hexrange:[`2d00`,`2d2f`]},{category:`tifinagh`,hexrange:[`2d30`,`2d7f`]},{category:`ethiopic extended`,hexrange:[`2d80`,`2ddf`]},{category:`cyrillic extended-a`,hexrange:[`2de0`,`2dff`]},{category:`supplemental punctuation`,hexrange:[`2e00`,`2e7f`]},{category:`cjk radicals supplement`,hexrange:[`2e80`,`2eff`]},{category:`kangxi radicals`,hexrange:[`2f00`,`2fdf`]},{category:`ideographic description characters`,hexrange:[`2ff0`,`2fff`]},{category:`cjk symbols and punctuation`,hexrange:[`3000`,`303f`]},{category:`hiragana`,hexrange:[`3040`,`309f`]},{category:`katakana`,hexrange:[`30a0`,`30ff`]},{category:`bopomofo`,hexrange:[`3100`,`312f`]},{category:`hangul compatibility jamo`,hexrange:[`3130`,`318f`]},{category:`kanbun`,hexrange:[`3190`,`319f`]},{category:`bopomofo extended`,hexrange:[`31a0`,`31bf`]},{category:`cjk strokes`,hexrange:[`31c0`,`31ef`]},{category:`katakana phonetic extensions`,hexrange:[`31f0`,`31ff`]},{category:`enclosed cjk letters and months`,hexrange:[`3200`,`32ff`]},{category:`cjk compatibility`,hexrange:[`3300`,`33ff`]},{category:`cjk unified ideographs extension a`,hexrange:[`3400`,`4dbf`]},{category:`yijing hexagram symbols`,hexrange:[`4dc0`,`4dff`]},{category:`cjk unified ideographs`,hexrange:[`4e00`,`9fff`]},{category:`yi syllables`,hexrange:[`a000`,`a48f`]},{category:`yi radicals`,hexrange:[`a490`,`a4cf`]},{category:`lisu`,hexrange:[`a4d0`,`a4ff`]},{category:`vai`,hexrange:[`a500`,`a63f`]},{category:`cyrillic extended-b`,hexrange:[`a640`,`a69f`]},{category:`bamum`,hexrange:[`a6a0`,`a6ff`]},{category:`modifier tone letters`,hexrange:[`a700`,`a71f`]},{category:`latin extended-d`,hexrange:[`a720`,`a7ff`]},{category:`syloti nagri`,hexrange:[`a800`,`a82f`]},{category:`common indic number forms`,hexrange:[`a830`,`a83f`]},{category:`phags-pa`,hexrange:[`a840`,`a87f`]},{category:`saurashtra`,hexrange:[`a880`,`a8df`]},{category:`devanagari extended`,hexrange:[`a8e0`,`a8ff`]},{category:`kayah li`,hexrange:[`a900`,`a92f`]},{category:`rejang`,hexrange:[`a930`,`a95f`]},{category:`hangul jamo extended-a`,hexrange:[`a960`,`a97f`]},{category:`javanese`,hexrange:[`a980`,`a9df`]},{category:`myanmar extended-b`,hexrange:[`a9e0`,`a9ff`]},{category:`cham`,hexrange:[`aa00`,`aa5f`]},{category:`myanmar extended-a`,hexrange:[`aa60`,`aa7f`]},{category:`tai viet`,hexrange:[`aa80`,`aadf`]},{category:`meetei mayek extensions`,hexrange:[`aae0`,`aaff`]},{category:`ethiopic extended-a`,hexrange:[`ab00`,`ab2f`]},{category:`latin extended-e`,hexrange:[`ab30`,`ab6f`]},{category:`cherokee supplement`,hexrange:[`ab70`,`abbf`]},{category:`meetei mayek`,hexrange:[`abc0`,`abff`]},{category:`hangul syllables`,hexrange:[`ac00`,`d7af`]},{category:`hangul jamo extended-b`,hexrange:[`d7b0`,`d7ff`]},{category:`high surrogates`,hexrange:[`d800`,`db7f`]},{category:`high private use surrogates`,hexrange:[`db80`,`dbff`]},{category:`low surrogates`,hexrange:[`dc00`,`dfff`]},{category:`private use area`,hexrange:[`e000`,`f8ff`]},{category:`cjk compatibility ideographs`,hexrange:[`f900`,`faff`]},{category:`alphabetic presentation forms`,hexrange:[`fb00`,`fb4f`]},{category:`arabic presentation forms-a`,hexrange:[`fb50`,`fdff`]},{category:`variation selectors`,hexrange:[`fe00`,`fe0f`]},{category:`vertical forms`,hexrange:[`fe10`,`fe1f`]},{category:`combining half marks`,hexrange:[`fe20`,`fe2f`]},{category:`cjk compatibility forms`,hexrange:[`fe30`,`fe4f`]},{category:`small form variants`,hexrange:[`fe50`,`fe6f`]},{category:`arabic presentation forms-b`,hexrange:[`fe70`,`feff`]},{category:`halfwidth and fullwidth forms`,hexrange:[`ff00`,`ffef`]},{category:`specials`,hexrange:[`fff0`,`ffff`]},{category:`linear b syllabary`,hexrange:[`10000`,`1007f`]},{category:`linear b ideograms`,hexrange:[`10080`,`100ff`]},{category:`aegean numbers`,hexrange:[`10100`,`1013f`]},{category:`ancient greek numbers`,hexrange:[`10140`,`1018f`]},{category:`ancient symbols`,hexrange:[`10190`,`101cf`]},{category:`phaistos disc`,hexrange:[`101d0`,`101ff`]},{category:`lycian`,hexrange:[`10280`,`1029f`]},{category:`carian`,hexrange:[`102a0`,`102df`]},{category:`coptic epact numbers`,hexrange:[`102e0`,`102ff`]},{category:`old italic`,hexrange:[`10300`,`1032f`]},{category:`gothic`,hexrange:[`10330`,`1034f`]},{category:`old permic`,hexrange:[`10350`,`1037f`]},{category:`ugaritic`,hexrange:[`10380`,`1039f`]},{category:`old persian`,hexrange:[`103a0`,`103df`]},{category:`deseret`,hexrange:[`10400`,`1044f`]},{category:`shavian`,hexrange:[`10450`,`1047f`]},{category:`osmanya`,hexrange:[`10480`,`104af`]},{category:`osage`,hexrange:[`104b0`,`104ff`]},{category:`elbasan`,hexrange:[`10500`,`1052f`]},{category:`caucasian albanian`,hexrange:[`10530`,`1056f`]},{category:`vithkuqi`,hexrange:[`10570`,`105bf`]},{category:`linear a`,hexrange:[`10600`,`1077f`]},{category:`latin extended-f`,hexrange:[`10780`,`107bf`]},{category:`cypriot syllabary`,hexrange:[`10800`,`1083f`]},{category:`imperial aramaic`,hexrange:[`10840`,`1085f`]},{category:`palmyrene`,hexrange:[`10860`,`1087f`]},{category:`nabataean`,hexrange:[`10880`,`108af`]},{category:`hatran`,hexrange:[`108e0`,`108ff`]},{category:`phoenician`,hexrange:[`10900`,`1091f`]},{category:`lydian`,hexrange:[`10920`,`1093f`]},{category:`meroitic hieroglyphs`,hexrange:[`10980`,`1099f`]},{category:`meroitic cursive`,hexrange:[`109a0`,`109ff`]},{category:`kharoshthi`,hexrange:[`10a00`,`10a5f`]},{category:`old south arabian`,hexrange:[`10a60`,`10a7f`]},{category:`old north arabian`,hexrange:[`10a80`,`10a9f`]},{category:`manichaean`,hexrange:[`10ac0`,`10aff`]},{category:`avestan`,hexrange:[`10b00`,`10b3f`]},{category:`inscriptional parthian`,hexrange:[`10b40`,`10b5f`]},{category:`inscriptional pahlavi`,hexrange:[`10b60`,`10b7f`]},{category:`psalter pahlavi`,hexrange:[`10b80`,`10baf`]},{category:`old turkic`,hexrange:[`10c00`,`10c4f`]},{category:`old hungarian`,hexrange:[`10c80`,`10cff`]},{category:`hanifi rohingya`,hexrange:[`10d00`,`10d3f`]},{category:`rumi numeral symbols`,hexrange:[`10e60`,`10e7f`]},{category:`yezidi`,hexrange:[`10e80`,`10ebf`]},{category:`arabic extended-c`,hexrange:[`10ec0`,`10eff`]},{category:`old sogdian`,hexrange:[`10f00`,`10f2f`]},{category:`sogdian`,hexrange:[`10f30`,`10f6f`]},{category:`old uyghur`,hexrange:[`10f70`,`10faf`]},{category:`chorasmian`,hexrange:[`10fb0`,`10fdf`]},{category:`elymaic`,hexrange:[`10fe0`,`10fff`]},{category:`brahmi`,hexrange:[`11000`,`1107f`]},{category:`kaithi`,hexrange:[`11080`,`110cf`]},{category:`sora sompeng`,hexrange:[`110d0`,`110ff`]},{category:`chakma`,hexrange:[`11100`,`1114f`]},{category:`mahajani`,hexrange:[`11150`,`1117f`]},{category:`sharada`,hexrange:[`11180`,`111df`]},{category:`sinhala archaic numbers`,hexrange:[`111e0`,`111ff`]},{category:`khojki`,hexrange:[`11200`,`1124f`]},{category:`multani`,hexrange:[`11280`,`112af`]},{category:`khudawadi`,hexrange:[`112b0`,`112ff`]},{category:`grantha`,hexrange:[`11300`,`1137f`]},{category:`newa`,hexrange:[`11400`,`1147f`]},{category:`tirhuta`,hexrange:[`11480`,`114df`]},{category:`siddham`,hexrange:[`11580`,`115ff`]},{category:`modi`,hexrange:[`11600`,`1165f`]},{category:`mongolian supplement`,hexrange:[`11660`,`1167f`]},{category:`takri`,hexrange:[`11680`,`116cf`]},{category:`ahom`,hexrange:[`11700`,`1174f`]},{category:`dogra`,hexrange:[`11800`,`1184f`]},{category:`warang citi`,hexrange:[`118a0`,`118ff`]},{category:`dives akuru`,hexrange:[`11900`,`1195f`]},{category:`nandinagari`,hexrange:[`119a0`,`119ff`]},{category:`zanabazar square`,hexrange:[`11a00`,`11a4f`]},{category:`soyombo`,hexrange:[`11a50`,`11aaf`]},{category:`unified canadian aboriginal syllabics extended-a`,hexrange:[`11ab0`,`11abf`]},{category:`pau cin hau`,hexrange:[`11ac0`,`11aff`]},{category:`devanagari extended-a`,hexrange:[`11b00`,`11b5f`]},{category:`bhaiksuki`,hexrange:[`11c00`,`11c6f`]},{category:`marchen`,hexrange:[`11c70`,`11cbf`]},{category:`masaram gondi`,hexrange:[`11d00`,`11d5f`]},{category:`gunjala gondi`,hexrange:[`11d60`,`11daf`]},{category:`makasar`,hexrange:[`11ee0`,`11eff`]},{category:`kawi`,hexrange:[`11f00`,`11f5f`]},{category:`lisu supplement`,hexrange:[`11fb0`,`11fbf`]},{category:`tamil supplement`,hexrange:[`11fc0`,`11fff`]},{category:`cuneiform`,hexrange:[`12000`,`123ff`]},{category:`cuneiform numbers and punctuation`,hexrange:[`12400`,`1247f`]},{category:`early dynastic cuneiform`,hexrange:[`12480`,`1254f`]},{category:`cypro-minoan`,hexrange:[`12f90`,`12fff`]},{category:`egyptian hieroglyphs`,hexrange:[`13000`,`1342f`]},{category:`egyptian hieroglyph format controls`,hexrange:[`13430`,`1345f`]},{category:`anatolian hieroglyphs`,hexrange:[`14400`,`1467f`]},{category:`bamum supplement`,hexrange:[`16800`,`16a3f`]},{category:`mro`,hexrange:[`16a40`,`16a6f`]},{category:`tangsa`,hexrange:[`16a70`,`16acf`]},{category:`bassa vah`,hexrange:[`16ad0`,`16aff`]},{category:`pahawh hmong`,hexrange:[`16b00`,`16b8f`]},{category:`medefaidrin`,hexrange:[`16e40`,`16e9f`]},{category:`miao`,hexrange:[`16f00`,`16f9f`]},{category:`ideographic symbols and punctuation`,hexrange:[`16fe0`,`16fff`]},{category:`tangut`,hexrange:[`17000`,`187ff`]},{category:`tangut components`,hexrange:[`18800`,`18aff`]},{category:`khitan small script`,hexrange:[`18b00`,`18cff`]},{category:`tangut supplement`,hexrange:[`18d00`,`18d7f`]},{category:`kana extended-b`,hexrange:[`1aff0`,`1afff`]},{category:`kana supplement`,hexrange:[`1b000`,`1b0ff`]},{category:`kana extended-a`,hexrange:[`1b100`,`1b12f`]},{category:`small kana extension`,hexrange:[`1b130`,`1b16f`]},{category:`nushu`,hexrange:[`1b170`,`1b2ff`]},{category:`duployan`,hexrange:[`1bc00`,`1bc9f`]},{category:`shorthand format controls`,hexrange:[`1bca0`,`1bcaf`]},{category:`znamenny musical notation`,hexrange:[`1cf00`,`1cfcf`]},{category:`byzantine musical symbols`,hexrange:[`1d000`,`1d0ff`]},{category:`musical symbols`,hexrange:[`1d100`,`1d1ff`]},{category:`ancient greek musical notation`,hexrange:[`1d200`,`1d24f`]},{category:`kaktovik numerals`,hexrange:[`1d2c0`,`1d2df`]},{category:`mayan numerals`,hexrange:[`1d2e0`,`1d2ff`]},{category:`tai xuan jing symbols`,hexrange:[`1d300`,`1d35f`]},{category:`counting rod numerals`,hexrange:[`1d360`,`1d37f`]},{category:`mathematical alphanumeric symbols`,hexrange:[`1d400`,`1d7ff`]},{category:`sutton signwriting`,hexrange:[`1d800`,`1daaf`]},{category:`latin extended-g`,hexrange:[`1df00`,`1dfff`]},{category:`glagolitic supplement`,hexrange:[`1e000`,`1e02f`]},{category:`cyrillic extended-d`,hexrange:[`1e030`,`1e08f`]},{category:`nyiakeng puachue hmong`,hexrange:[`1e100`,`1e14f`]},{category:`toto`,hexrange:[`1e290`,`1e2bf`]},{category:`wancho`,hexrange:[`1e2c0`,`1e2ff`]},{category:`nag mundari`,hexrange:[`1e4d0`,`1e4ff`]},{category:`ethiopic extended-b`,hexrange:[`1e7e0`,`1e7ff`]},{category:`mende kikakui`,hexrange:[`1e800`,`1e8df`]},{category:`adlam`,hexrange:[`1e900`,`1e95f`]},{category:`indic siyaq numbers`,hexrange:[`1ec70`,`1ecbf`]},{category:`ottoman siyaq numbers`,hexrange:[`1ed00`,`1ed4f`]},{category:`arabic mathematical alphabetic symbols`,hexrange:[`1ee00`,`1eeff`]},{category:`mahjong tiles`,hexrange:[`1f000`,`1f02f`]},{category:`domino tiles`,hexrange:[`1f030`,`1f09f`]},{category:`playing cards`,hexrange:[`1f0a0`,`1f0ff`]},{category:`enclosed alphanumeric supplement`,hexrange:[`1f100`,`1f1ff`]},{category:`enclosed ideographic supplement`,hexrange:[`1f200`,`1f2ff`]},{category:`miscellaneous symbols and pictographs`,hexrange:[`1f300`,`1f5ff`]},{category:`emoticons (emoji)`,hexrange:[`1f600`,`1f64f`]},{category:`ornamental dingbats`,hexrange:[`1f650`,`1f67f`]},{category:`transport and map symbols`,hexrange:[`1f680`,`1f6ff`]},{category:`alchemical symbols`,hexrange:[`1f700`,`1f77f`]},{category:`geometric shapes extended`,hexrange:[`1f780`,`1f7ff`]},{category:`supplemental arrows-c`,hexrange:[`1f800`,`1f8ff`]},{category:`supplemental symbols and pictographs`,hexrange:[`1f900`,`1f9ff`]},{category:`chess symbols`,hexrange:[`1fa00`,`1fa6f`]},{category:`symbols and pictographs extended-a`,hexrange:[`1fa70`,`1faff`]},{category:`symbols for legacy computing`,hexrange:[`1fb00`,`1fbff`]},{category:`cjk unified ideographs extension b`,hexrange:[`20000`,`2a6df`]},{category:`cjk unified ideographs extension c`,hexrange:[`2a700`,`2b73f`]},{category:`cjk unified ideographs extension d`,hexrange:[`2b740`,`2b81f`]},{category:`cjk unified ideographs extension e`,hexrange:[`2b820`,`2ceaf`]},{category:`cjk unified ideographs extension f`,hexrange:[`2ceb0`,`2ebef`]},{category:`cjk unified ideographs extension i`,hexrange:[`2ebf0`,`2ee5f`]},{category:`cjk compatibility ideographs supplement`,hexrange:[`2f800`,`2fa1f`]},{category:`cjk unified ideographs extension g`,hexrange:[`30000`,`3134f`]},{category:`cjk unified ideographs extension h`,hexrange:[`31350`,`323af`]},{category:`tags`,hexrange:[`e0000`,`e007f`]},{category:`variation selectors supplement`,hexrange:[`e0100`,`e01ef`]},{category:`supplementary private use area-a`,hexrange:[`f0000`,`fffff`]},{category:`supplementary private use area-b`,hexrange:[`100000`,`10ffff`]}]
/*! pako 2.2.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
;function J_(t){let n=t.length;for(;--n>=0;)t[n]=0}const Y_=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),X_=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Z_=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Q_=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),$_=Array(576);J_($_);const ev=Array(60);J_(ev);const tv=Array(512);J_(tv);const nv=Array(256);J_(nv);const rv=Array(29);J_(rv);const iv=Array(30);J_(iv);function av(t,n,r,i,a){this.static_tree=t,this.extra_bits=n,this.extra_base=r,this.elems=i,this.max_length=a,this.has_stree=t&&t.length}let ov,sv,cv;function lv(t,n){this.dyn_tree=t,this.max_code=0,this.stat_desc=n}const uv=t=>t<256?tv[t]:tv[256+(t>>>7)],dv=(t,n)=>{t.pending_buf[t.pending++]=n&255,t.pending_buf[t.pending++]=n>>>8&255},fv=(t,n,r)=>{t.bi_valid>16-r?(t.bi_buf|=n<<t.bi_valid&65535,dv(t,t.bi_buf),t.bi_buf=n>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=n<<t.bi_valid&65535,t.bi_valid+=r)},pv=(t,n,r)=>{fv(t,r[n*2],r[n*2+1])},mv=(t,n)=>{let r=0;do r|=t&1,t>>>=1,r<<=1;while(--n>0);return r>>>1},hv=t=>{t.bi_valid===16?(dv(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=t.bi_buf&255,t.bi_buf>>=8,t.bi_valid-=8)},gv=(t,n)=>{let r=n.dyn_tree,i=n.max_code,a=n.stat_desc.static_tree,o=n.stat_desc.has_stree,s=n.stat_desc.extra_bits,c=n.stat_desc.extra_base,l=n.stat_desc.max_length,u,d,f,p,m,h,g=0;for(p=0;p<=15;p++)t.bl_count[p]=0;for(r[t.heap[t.heap_max]*2+1]=0,u=t.heap_max+1;u<573;u++)d=t.heap[u],p=r[r[d*2+1]*2+1]+1,p>l&&(p=l,g++),r[d*2+1]=p,!(d>i)&&(t.bl_count[p]++,m=0,d>=c&&(m=s[d-c]),h=r[d*2],t.opt_len+=h*(p+m),o&&(t.static_len+=h*(a[d*2+1]+m)));if(g!==0){do{for(p=l-1;t.bl_count[p]===0;)p--;t.bl_count[p]--,t.bl_count[p+1]+=2,t.bl_count[l]--,g-=2}while(g>0);for(p=l;p!==0;p--)for(d=t.bl_count[p];d!==0;)f=t.heap[--u],!(f>i)&&(r[f*2+1]!==p&&(t.opt_len+=(p-r[f*2+1])*r[f*2],r[f*2+1]=p),d--)}},_v=(t,n,r)=>{let i=Array(16),a=0,o,s;for(o=1;o<=15;o++)a=a+r[o-1]<<1,i[o]=a;for(s=0;s<=n;s++){let n=t[s*2+1];n!==0&&(t[s*2]=mv(i[n]++,n))}},vv=()=>{let t,n,r,i,a,o=Array(16);for(r=0,i=0;i<28;i++)for(rv[i]=r,t=0;t<1<<Y_[i];t++)nv[r++]=i;for(nv[r-1]=i,a=0,i=0;i<16;i++)for(iv[i]=a,t=0;t<1<<X_[i];t++)tv[a++]=i;for(a>>=7;i<30;i++)for(iv[i]=a<<7,t=0;t<1<<X_[i]-7;t++)tv[256+a++]=i;for(n=0;n<=15;n++)o[n]=0;for(t=0;t<=143;)$_[t*2+1]=8,t++,o[8]++;for(;t<=255;)$_[t*2+1]=9,t++,o[9]++;for(;t<=279;)$_[t*2+1]=7,t++,o[7]++;for(;t<=287;)$_[t*2+1]=8,t++,o[8]++;for(_v($_,287,o),t=0;t<30;t++)ev[t*2+1]=5,ev[t*2]=mv(t,5);ov=new av($_,Y_,257,286,15),sv=new av(ev,X_,0,30,15),cv=new av([],Z_,0,19,7)},yv=t=>{let n=0;for(;n<286;n++)t.dyn_ltree[n*2]=0;for(n=0;n<30;n++)t.dyn_dtree[n*2]=0;for(n=0;n<19;n++)t.bl_tree[n*2]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},bv=t=>{t.bi_valid>8?dv(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},xv=(t,n,r,i)=>{let a=n*2,o=r*2;return t[a]<t[o]||t[a]===t[o]&&i[n]<=i[r]},Sv=(t,n,r)=>{let i=t.heap[r],a=r<<1;for(;a<=t.heap_len&&(a<t.heap_len&&xv(n,t.heap[a+1],t.heap[a],t.depth)&&a++,!xv(n,i,t.heap[a],t.depth));)t.heap[r]=t.heap[a],r=a,a<<=1;t.heap[r]=i},Cv=(t,n,r)=>{let i,a,o=0,s,c;if(t.sym_next!==0)do i=t.pending_buf[t.sym_buf+o++]&255,i+=(t.pending_buf[t.sym_buf+o++]&255)<<8,a=t.pending_buf[t.sym_buf+o++],i===0?pv(t,a,n):(s=nv[a],pv(t,s+256+1,n),c=Y_[s],c!==0&&(a-=rv[s],fv(t,a,c)),i--,s=uv(i),pv(t,s,r),c=X_[s],c!==0&&(i-=iv[s],fv(t,i,c)));while(o<t.sym_next);pv(t,256,n)},wv=(t,n)=>{let r=n.dyn_tree,i=n.stat_desc.static_tree,a=n.stat_desc.has_stree,o=n.stat_desc.elems,s,c,l=-1,u;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)r[s*2]===0?r[s*2+1]=0:(t.heap[++t.heap_len]=l=s,t.depth[s]=0);for(;t.heap_len<2;)u=t.heap[++t.heap_len]=l<2?++l:0,r[u*2]=1,t.depth[u]=0,t.opt_len--,a&&(t.static_len-=i[u*2+1]);for(n.max_code=l,s=t.heap_len>>1;s>=1;s--)Sv(t,r,s);u=o;do s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Sv(t,r,1),c=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=c,r[u*2]=r[s*2]+r[c*2],t.depth[u]=(t.depth[s]>=t.depth[c]?t.depth[s]:t.depth[c])+1,r[s*2+1]=r[c*2+1]=u,t.heap[1]=u++,Sv(t,r,1);while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],gv(t,n),_v(r,l,t.bl_count)},Tv=(t,n,r)=>{let i,a=-1,o,s=n[1],c=0,l=7,u=4;for(s===0&&(l=138,u=3),n[(r+1)*2+1]=65535,i=0;i<=r;i++)o=s,s=n[(i+1)*2+1],!(++c<l&&o===s)&&(c<u?t.bl_tree[o*2]+=c:o===0?c<=10?t.bl_tree[34]++:t.bl_tree[36]++:(o!==a&&t.bl_tree[o*2]++,t.bl_tree[32]++),c=0,a=o,s===0?(l=138,u=3):o===s?(l=6,u=3):(l=7,u=4))},Ev=(t,n,r)=>{let i,a=-1,o,s=n[1],c=0,l=7,u=4;for(s===0&&(l=138,u=3),i=0;i<=r;i++)if(o=s,s=n[(i+1)*2+1],!(++c<l&&o===s)){if(c<u)do pv(t,o,t.bl_tree);while(--c!==0);else o===0?c<=10?(pv(t,17,t.bl_tree),fv(t,c-3,3)):(pv(t,18,t.bl_tree),fv(t,c-11,7)):(o!==a&&(pv(t,o,t.bl_tree),c--),pv(t,16,t.bl_tree),fv(t,c-3,2));c=0,a=o,s===0?(l=138,u=3):o===s?(l=6,u=3):(l=7,u=4)}},Dv=t=>{let n;for(Tv(t,t.dyn_ltree,t.l_desc.max_code),Tv(t,t.dyn_dtree,t.d_desc.max_code),wv(t,t.bl_desc),n=18;n>=3&&t.bl_tree[Q_[n]*2+1]===0;n--);return t.opt_len+=3*(n+1)+5+5+4,n},Ov=(t,n,r,i)=>{let a;for(fv(t,n-257,5),fv(t,r-1,5),fv(t,i-4,4),a=0;a<i;a++)fv(t,t.bl_tree[Q_[a]*2+1],3);Ev(t,t.dyn_ltree,n-1),Ev(t,t.dyn_dtree,r-1)},kv=t=>{let n=4093624447,r=0;for(;r<=31;r++,n>>>=1)if(n&1&&t.dyn_ltree[r*2]!==0)return 0;if(t.dyn_ltree[18]!==0||t.dyn_ltree[20]!==0||t.dyn_ltree[26]!==0)return 1;for(r=32;r<256;r++)if(t.dyn_ltree[r*2]!==0)return 1;return 0};let Av=!1;const jv=t=>{Av||=(vv(),!0),t.l_desc=new lv(t.dyn_ltree,ov),t.d_desc=new lv(t.dyn_dtree,sv),t.bl_desc=new lv(t.bl_tree,cv),t.bi_buf=0,t.bi_valid=0,yv(t)},Mv=(t,n,r,i)=>{fv(t,0+ +!!i,3),bv(t),dv(t,r),dv(t,~r),r&&t.pending_buf.set(t.window.subarray(n,n+r),t.pending),t.pending+=r};var Nv={_tr_init:jv,_tr_stored_block:Mv,_tr_flush_block:(t,n,r,i)=>{let a,o,s=0;t.level>0?(t.strm.data_type===2&&(t.strm.data_type=kv(t)),wv(t,t.l_desc),wv(t,t.d_desc),s=Dv(t),a=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=a&&(a=o)):a=o=r+5,r+4<=a&&n!==-1?Mv(t,n,r,i):t.strategy===4||o===a?(fv(t,2+ +!!i,3),Cv(t,$_,ev)):(fv(t,4+ +!!i,3),Ov(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Cv(t,t.dyn_ltree,t.dyn_dtree)),yv(t),i&&bv(t)},_tr_tally:(t,n,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=n,t.pending_buf[t.sym_buf+t.sym_next++]=n>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,n===0?t.dyn_ltree[r*2]++:(t.matches++,n--,t.dyn_ltree[(nv[r]+256+1)*2]++,t.dyn_dtree[uv(n)*2]++),t.sym_next===t.sym_end),_tr_align:t=>{fv(t,2,3),pv(t,256,$_),hv(t)}},Pv=(t,n,r,i)=>{let a=t&65535,o=t>>>16&65535,s=0;for(;r!==0;){s=r>2e3?2e3:r,r-=s;do a=a+n[i++]|0,o=o+a|0;while(--s);a%=65521,o%=65521}return a|o<<16};const Fv=new Uint32Array((()=>{let t,n=[];for(var r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;n[r]=t}return n})());var Iv=(t,n,r,i)=>{let a=Fv,o=i+r;t^=-1;for(let r=i;r<o;r++)t=t>>>8^a[(t^n[r])&255];return t^-1},Lv={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`},Rv={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:zv,_tr_stored_block:Bv,_tr_flush_block:Vv,_tr_tally:Hv,_tr_align:Uv}=Nv,{Z_NO_FLUSH:Wv,Z_PARTIAL_FLUSH:Gv,Z_FULL_FLUSH:Kv,Z_FINISH:qv,Z_BLOCK:Jv,Z_OK:Yv,Z_STREAM_END:Xv,Z_STREAM_ERROR:Zv,Z_DATA_ERROR:Qv,Z_BUF_ERROR:$v,Z_DEFAULT_COMPRESSION:ey,Z_FILTERED:ty,Z_HUFFMAN_ONLY:ny,Z_RLE:ry,Z_FIXED:iy,Z_DEFAULT_STRATEGY:ay,Z_UNKNOWN:oy,Z_DEFLATED:sy}=Rv,cy=(t,n)=>(t.msg=Lv[n],n),ly=t=>t*2-(t>4?9:0),uy=t=>{let n=t.length;for(;--n>=0;)t[n]=0},dy=t=>{let n,r,i,a=t.w_size;n=t.hash_size,i=n;do r=t.head[--i],t.head[i]=r>=a?r-a:0;while(--n);n=a,i=n;do r=t.prev[--i],t.prev[i]=r>=a?r-a:0;while(--n)};let fy=(t,n,r)=>(n<<t.hash_shift^r)&t.hash_mask;const py=(t,n)=>{let r;if(t.legacy_hash)r=t.ins_h=fy(t,t.ins_h,t.window[n+3-1]);else{let i=t.window,a=i[n]|i[n+1]<<8|i[n+2]<<16|i[n+3]<<24;r=t.ins_h=Math.imul(a,66521)+66521>>>16&t.hash_mask}let i=t.prev[n&t.w_mask]=t.head[r];return t.head[r]=n,i},my=t=>{let n=t.state,r=n.pending;r>t.avail_out&&(r=t.avail_out),r!==0&&(t.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+r),t.next_out),t.next_out+=r,n.pending_out+=r,t.total_out+=r,t.avail_out-=r,n.pending-=r,n.pending===0&&(n.pending_out=0))},hy=(t,n)=>{Vv(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,n),t.block_start=t.strstart,my(t.strm)},gy=(t,n)=>{t.pending_buf[t.pending++]=n},_y=(t,n)=>{t.pending_buf[t.pending++]=n>>>8&255,t.pending_buf[t.pending++]=n&255},vy=(t,n,r,i)=>{let a=t.avail_in;return a>i&&(a=i),a===0?0:(t.avail_in-=a,n.set(t.input.subarray(t.next_in,t.next_in+a),r),t.state.wrap===1?t.adler=Pv(t.adler,n,a,r):t.state.wrap===2&&(t.adler=Iv(t.adler,n,a,r)),t.next_in+=a,t.total_in+=a,a)},yy=(t,n)=>{let r=t.max_chain_length,i=t.strstart,a,o,s=t.prev_length,c=t.nice_match,l=t.strstart>t.w_size-262?t.strstart-(t.w_size-262):0,u=t.window,d=t.w_mask,f=t.prev,p=t.strstart+258,m=u[i+s-1],h=u[i+s];t.prev_length>=t.good_match&&(r>>=2),c>t.lookahead&&(c=t.lookahead);do if(a=n,u[a+s]===h&&u[a+s-1]===m&&u[a]===u[i]&&u[++a]===u[i+1]){i+=2,a++;do;while(u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&u[++i]===u[++a]&&i<p);if(o=258-(p-i),i=p-258,o>s){if(t.match_start=n,s=o,o>=c)break;m=u[i+s-1],h=u[i+s]}}while((n=f[n&d])>l&&--r!==0);return s<=t.lookahead?s:t.lookahead},by=t=>{let n=t.w_size,r,i,a;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=n+(n-262)&&(t.window.set(t.window.subarray(n,n+n-i),0),t.match_start-=n,t.strstart-=n,t.block_start-=n,t.insert>t.strstart&&(t.insert=t.strstart),dy(t),i+=n),t.strm.avail_in===0)break;if(r=vy(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=r,!t.legacy_hash){if(t.lookahead+t.insert>3)for(a=t.strstart-t.insert;t.insert&&(py(t,a),a++,t.insert--,!(t.lookahead+t.insert<=3)););}else if(t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=fy(t,t.ins_h,t.window[a+1]);t.insert&&(py(t,a),a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<262&&t.strm.avail_in!==0)},xy=(t,n)=>{let r=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,i,a,o,s=0,c=t.strm.avail_in;do{if(i=65535,o=t.bi_valid+42>>3,t.strm.avail_out<o||(o=t.strm.avail_out-o,a=t.strstart-t.block_start,i>a+t.strm.avail_in&&(i=a+t.strm.avail_in),i>o&&(i=o),i<r&&(i===0&&n!==qv||n===Wv||i!==a+t.strm.avail_in)))break;s=+(n===qv&&i===a+t.strm.avail_in),Bv(t,0,0,s),t.pending_buf[t.pending-4]=i,t.pending_buf[t.pending-3]=i>>8,t.pending_buf[t.pending-2]=~i,t.pending_buf[t.pending-1]=~i>>8,my(t.strm),a&&(a>i&&(a=i),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+a),t.strm.next_out),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a,t.block_start+=a,i-=a),i&&(vy(t.strm,t.strm.output,t.strm.next_out,i),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i)}while(s===0);return c-=t.strm.avail_in,c&&(c>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=c&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-c,t.strm.next_in),t.strstart),t.strstart+=c,t.insert+=c>t.w_size-t.insert?t.w_size-t.insert:c),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:n!==Wv&&n!==qv&&t.strm.avail_in===0&&t.strstart===t.block_start?2:(o=t.window_size-t.strstart,t.strm.avail_in>o&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,o+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),o>t.strm.avail_in&&(o=t.strm.avail_in),o&&(vy(t.strm,t.window,t.strstart,o),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.high_water<t.strstart&&(t.high_water=t.strstart),o=t.bi_valid+42>>3,o=t.pending_buf_size-o>65535?65535:t.pending_buf_size-o,r=o>t.w_size?t.w_size:o,a=t.strstart-t.block_start,(a>=r||(a||n===qv)&&n!==Wv&&t.strm.avail_in===0&&a<=o)&&(i=a>o?o:a,s=+(n===qv&&t.strm.avail_in===0&&i===a),Bv(t,t.block_start,i,s),t.block_start+=i,my(t.strm)),s?3:1)},Sy=(t,n)=>{let r,i;for(;;){if(t.lookahead<262){if(by(t),t.lookahead<262&&n===Wv)return 1;if(t.lookahead===0)break}if(r=0,t.lookahead>=3&&(r=py(t,t.strstart)),r!==0&&t.strstart-r<=t.w_size-262&&(t.match_length=yy(t,r)),t.match_length>=3){if(i=Hv(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do t.strstart++,r=py(t,t.strstart);while(--t.match_length!==0);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.legacy_hash&&(t.ins_h=t.window[t.strstart],t.ins_h=fy(t,t.ins_h,t.window[t.strstart+1]))}else i=Hv(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(hy(t,!1),t.strm.avail_out===0))return 1}return t.insert=t.strstart<2?t.strstart:2,n===qv?(hy(t,!0),t.strm.avail_out===0?3:4):t.sym_next&&(hy(t,!1),t.strm.avail_out===0)?1:2},Cy=(t,n)=>{let r,i,a;for(;;){if(t.lookahead<262){if(by(t),t.lookahead<262&&n===Wv)return 1;if(t.lookahead===0)break}if(r=0,t.lookahead>=3&&(r=py(t,t.strstart)),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,r!==0&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-262&&(t.match_length=yy(t,r),t.match_length<=5&&(t.strategy===ty||t.match_length===3&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){a=t.strstart+t.lookahead-3,i=Hv(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do++t.strstart<=a&&(r=py(t,t.strstart));while(--t.prev_length!==0);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(hy(t,!1),t.strm.avail_out===0))return 1}else if(t.match_available){if(i=Hv(t,0,t.window[t.strstart-1]),i&&hy(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&=(i=Hv(t,0,t.window[t.strstart-1]),0),t.insert=t.strstart<2?t.strstart:2,n===qv?(hy(t,!0),t.strm.avail_out===0?3:4):t.sym_next&&(hy(t,!1),t.strm.avail_out===0)?1:2},wy=(t,n)=>{let r,i,a,o,s=t.window;for(;;){if(t.lookahead<=258){if(by(t),t.lookahead<=258&&n===Wv)return 1;if(t.lookahead===0)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(a=t.strstart-1,i=s[a],i===s[++a]&&i===s[++a]&&i===s[++a])){o=t.strstart+258;do;while(i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&i===s[++a]&&a<o);t.match_length=258-(o-a),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Hv(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Hv(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(hy(t,!1),t.strm.avail_out===0))return 1}return t.insert=0,n===qv?(hy(t,!0),t.strm.avail_out===0?3:4):t.sym_next&&(hy(t,!1),t.strm.avail_out===0)?1:2},Ty=(t,n)=>{let r;for(;;){if(t.lookahead===0&&(by(t),t.lookahead===0)){if(n===Wv)return 1;break}if(t.match_length=0,r=Hv(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(hy(t,!1),t.strm.avail_out===0))return 1}return t.insert=0,n===qv?(hy(t,!0),t.strm.avail_out===0?3:4):t.sym_next&&(hy(t,!1),t.strm.avail_out===0)?1:2};function Ey(t,n,r,i,a){this.good_length=t,this.max_lazy=n,this.nice_length=r,this.max_chain=i,this.func=a}const Dy=[new Ey(0,0,0,0,xy),new Ey(4,4,8,4,Sy),new Ey(4,5,16,8,Sy),new Ey(4,6,32,32,Sy),new Ey(4,4,16,16,Cy),new Ey(8,16,32,32,Cy),new Ey(8,16,128,128,Cy),new Ey(8,32,128,256,Cy),new Ey(32,128,258,1024,Cy),new Ey(32,258,258,4096,Cy)],Oy=t=>{t.window_size=2*t.w_size,uy(t.head),t.max_lazy_match=Dy[t.level].max_lazy,t.good_match=Dy[t.level].good_length,t.nice_match=Dy[t.level].nice_length,t.max_chain_length=Dy[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0};function ky(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=sy,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=/* @__PURE__ */ new Uint16Array(1146),this.dyn_dtree=/* @__PURE__ */ new Uint16Array(122),this.bl_tree=/* @__PURE__ */ new Uint16Array(78),uy(this.dyn_ltree),uy(this.dyn_dtree),uy(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=/* @__PURE__ */ new Uint16Array(16),this.heap=/* @__PURE__ */ new Uint16Array(573),uy(this.heap),this.heap_len=0,this.heap_max=0,this.depth=/* @__PURE__ */ new Uint16Array(573),uy(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Ay=t=>{if(!t)return 1;let n=t.state;return+(!n||n.strm!==t||n.status!==42&&n.status!==57&&n.status!==69&&n.status!==73&&n.status!==91&&n.status!==103&&n.status!==113&&n.status!==666)},jy=t=>{if(Ay(t))return cy(t,Zv);t.total_in=t.total_out=0,t.data_type=oy;let n=t.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?57:n.wrap?42:113,t.adler=n.wrap===2?0:1,n.last_flush=-2,zv(n),Yv},My=t=>{let n=jy(t);return n===Yv&&Oy(t.state),n},Ny=(t,n)=>Ay(t)||t.state.wrap!==2?Zv:(t.state.gzhead=n,Yv),Py=(t,n,r,i,a,o,s)=>{if(!t)return Zv;let c=1;if(n===ey&&(n=6),i<0?(c=0,i=-i):i>15&&(c=2,i-=16),a<1||a>9||r!==sy||i<8||i>15||n<0||n>9||o<0||o>iy||i===8&&c!==1)return cy(t,Zv);i===8&&(i=9);let l=new ky;return t.state=l,l.strm=t,l.status=42,l.wrap=c,l.gzhead=null,l.w_bits=i,l.w_size=1<<l.w_bits,l.w_mask=l.w_size-1,l.legacy_hash=+!!s,l.hash_bits=a+7,!l.legacy_hash&&l.hash_bits<15&&(l.hash_bits=15),l.hash_size=1<<l.hash_bits,l.hash_mask=l.hash_size-1,l.hash_shift=~~((l.hash_bits+3-1)/3),l.window=new Uint8Array(l.w_size*2),l.head=new Uint16Array(l.hash_size),l.prev=new Uint16Array(l.w_size),l.lit_bufsize=1<<a+6,l.pending_buf_size=l.lit_bufsize*4,l.pending_buf=new Uint8Array(l.pending_buf_size),l.sym_buf=l.lit_bufsize,l.sym_end=(l.lit_bufsize-1)*3,l.level=n,l.strategy=o,l.method=r,My(t)};var Fy={deflateInit:(t,n)=>Py(t,n,sy,15,8,ay),deflateInit2:Py,deflateReset:My,deflateResetKeep:jy,deflateSetHeader:Ny,deflate:(t,n)=>{if(Ay(t)||n>Jv||n<0)return t?cy(t,Zv):Zv;let r=t.state;if(!t.output||t.avail_in!==0&&!t.input||r.status===666&&n!==qv)return cy(t,t.avail_out===0?$v:Zv);let i=r.last_flush;if(r.last_flush=n,r.pending!==0){if(my(t),t.avail_out===0)return r.last_flush=-1,Yv}else if(t.avail_in===0&&ly(n)<=ly(i)&&n!==qv)return cy(t,$v);if(r.status===666&&t.avail_in!==0)return cy(t,$v);if(r.status===42&&r.wrap===0&&(r.status=113),r.status===42){let n=sy+(r.w_bits-8<<4)<<8,i=-1;if(i=r.strategy>=ny||r.level<2?0:r.level<6?1:r.level===6?2:3,n|=i<<6,r.strstart!==0&&(n|=32),n+=31-n%31,_y(r,n),r.strstart!==0&&(_y(r,t.adler>>>16),_y(r,t.adler&65535)),t.adler=1,r.status=113,my(t),r.pending!==0)return r.last_flush=-1,Yv}if(r.status===57){if(t.adler=0,gy(r,31),gy(r,139),gy(r,8),r.gzhead)gy(r,+!!r.gzhead.text+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),gy(r,r.gzhead.time&255),gy(r,r.gzhead.time>>8&255),gy(r,r.gzhead.time>>16&255),gy(r,r.gzhead.time>>24&255),gy(r,r.level===9?2:r.strategy>=ny||r.level<2?4:0),gy(r,r.gzhead.os&255),r.gzhead.extra&&r.gzhead.extra.length&&(gy(r,r.gzhead.extra.length&255),gy(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=Iv(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(gy(r,0),gy(r,0),gy(r,0),gy(r,0),gy(r,0),gy(r,r.level===9?2:r.strategy>=ny||r.level<2?4:0),gy(r,3),r.status=113,my(t),r.pending!==0)return r.last_flush=-1,Yv}if(r.status===69){if(r.gzhead.extra){let n=r.pending,i=(r.gzhead.extra.length&65535)-r.gzindex;for(;r.pending+i>r.pending_buf_size;){let a=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+a),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex+=a,my(t),r.pending!==0)return r.last_flush=-1,Yv;n=0,i-=a}let a=new Uint8Array(r.gzhead.extra);r.pending_buf.set(a.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending+=i,r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=73}if(r.status===73){if(r.gzhead.name){let n=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n)),my(t),r.pending!==0)return r.last_flush=-1,Yv;n=0}i=r.gzindex<r.gzhead.name.length?r.gzhead.name.charCodeAt(r.gzindex++)&255:0,gy(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(r.status===91){if(r.gzhead.comment){let n=r.pending,i;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n)),my(t),r.pending!==0)return r.last_flush=-1,Yv;n=0}i=r.gzindex<r.gzhead.comment.length?r.gzhead.comment.charCodeAt(r.gzindex++)&255:0,gy(r,i)}while(i!==0);r.gzhead.hcrc&&r.pending>n&&(t.adler=Iv(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(r.status===103){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(my(t),r.pending!==0))return r.last_flush=-1,Yv;gy(r,t.adler&255),gy(r,t.adler>>8&255),t.adler=0}if(r.status=113,my(t),r.pending!==0)return r.last_flush=-1,Yv}if(t.avail_in!==0||r.lookahead!==0||n!==Wv&&r.status!==666){let i=r.level===0?xy(r,n):r.strategy===ny?Ty(r,n):r.strategy===ry?wy(r,n):Dy[r.level].func(r,n);if((i===3||i===4)&&(r.status=666),i===1||i===3)return t.avail_out===0&&(r.last_flush=-1),Yv;if(i===2&&(n===Gv?Uv(r):n!==Jv&&(Bv(r,0,0,!1),n===Kv&&(uy(r.head),r.lookahead===0&&(r.strstart=0,r.block_start=0,r.insert=0))),my(t),t.avail_out===0))return r.last_flush=-1,Yv}return n===qv?r.wrap<=0?Xv:(r.wrap===2?(gy(r,t.adler&255),gy(r,t.adler>>8&255),gy(r,t.adler>>16&255),gy(r,t.adler>>24&255),gy(r,t.total_in&255),gy(r,t.total_in>>8&255),gy(r,t.total_in>>16&255),gy(r,t.total_in>>24&255)):(_y(r,t.adler>>>16),_y(r,t.adler&65535)),my(t),r.wrap>0&&(r.wrap=-r.wrap),r.pending===0?Xv:Yv):Yv},deflateEnd:t=>{if(Ay(t))return Zv;let n=t.state.status;return t.state=null,n===113?cy(t,Qv):Yv},deflateSetDictionary:(t,n)=>{let r=n.length;if(Ay(t))return Zv;let i=t.state,a=i.wrap;if(a===2||a===1&&i.status!==42||i.lookahead)return Zv;if(a===1&&(t.adler=Pv(t.adler,n,r,0)),i.wrap=0,r>=i.w_size){a===0&&(uy(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(n.subarray(r-i.w_size,r),0),n=t,r=i.w_size}let o=t.avail_in,s=t.next_in,c=t.input;for(t.avail_in=r,t.next_in=0,t.input=n,by(i);i.lookahead>=3;){let t=i.strstart,n=i.lookahead-2;do py(i,t),t++;while(--n);i.strstart=t,i.lookahead=2,by(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=s,t.input=c,t.avail_in=o,i.wrap=a,Yv},deflateInfo:`pako deflate (from Nodeca project)`};const Iy=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);var Ly={assign:function(t){let n=Array.prototype.slice.call(arguments,1);for(;n.length;){let r=n.shift();if(r){if(typeof r!=`object`)throw TypeError(r+`must be non-object`);for(let n in r)Iy(r,n)&&(t[n]=r[n])}}return t},flattenChunks:t=>{let n=0;for(let r=0,i=t.length;r<i;r++)n+=t[r].length;let r=new Uint8Array(n);for(let n=0,i=0,a=t.length;n<a;n++){let a=t[n];r.set(a,i),i+=a.length}return r}};let Ry=!0;try{String.fromCharCode.apply(null,/* @__PURE__ */ new Uint8Array(1))}catch{Ry=!1}const zy=/* @__PURE__ */ new Uint8Array(256);for(let t=0;t<256;t++)zy[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;zy[254]=zy[255]=1;var By=t=>{if(typeof TextEncoder==`function`&&TextEncoder.prototype.encode)return new TextEncoder().encode(t);let n,r,i,a,o,s=t.length,c=0;for(a=0;a<s;a++)r=t.charCodeAt(a),(r&64512)==55296&&a+1<s&&(i=t.charCodeAt(a+1),(i&64512)==56320&&(r=65536+(r-55296<<10)+(i-56320),a++)),c+=r<128?1:r<2048?2:r<65536?3:4;for(n=new Uint8Array(c),o=0,a=0;o<c;a++)r=t.charCodeAt(a),(r&64512)==55296&&a+1<s&&(i=t.charCodeAt(a+1),(i&64512)==56320&&(r=65536+(r-55296<<10)+(i-56320),a++)),r<128?n[o++]=r:r<2048?(n[o++]=192|r>>>6,n[o++]=128|r&63):r<65536?(n[o++]=224|r>>>12,n[o++]=128|r>>>6&63,n[o++]=128|r&63):(n[o++]=240|r>>>18,n[o++]=128|r>>>12&63,n[o++]=128|r>>>6&63,n[o++]=128|r&63);return n};const Vy=(t,n)=>{if(n<65534&&t.subarray&&Ry)return String.fromCharCode.apply(null,t.length===n?t:t.subarray(0,n));let r=``;for(let i=0;i<n;i++)r+=String.fromCharCode(t[i]);return r};var Hy={string2buf:By,buf2string:(t,n)=>{let r=n||t.length;if(typeof TextDecoder==`function`&&TextDecoder.prototype.decode)return new TextDecoder().decode(t.subarray(0,n));let i,a,o=Array(r*2);for(a=0,i=0;i<r;){let n=t[i++];if(n<128){o[a++]=n;continue}let s=zy[n];if(s>4)o[a++]=65533,i+=s-1;else{for(n&=s===2?31:s===3?15:7;s>1&&i<r;)n=n<<6|t[i++]&63,s--;s>1?o[a++]=65533:n<65536?o[a++]=n:(n-=65536,o[a++]=55296|n>>10&1023,o[a++]=56320|n&1023)}}return Vy(o,a)},utf8border:(t,n)=>{n||=t.length,n>t.length&&(n=t.length);let r=n-1;for(;r>=0&&(t[r]&192)==128;)r--;return r<0||r===0?n:r+zy[t[r]]>n?r:n}};function Uy(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}var Wy=Uy;const Gy=Object.prototype.toString,{Z_NO_FLUSH:Ky,Z_SYNC_FLUSH:qy,Z_FULL_FLUSH:Jy,Z_FINISH:Yy,Z_OK:Xy,Z_STREAM_END:Zy,Z_DEFAULT_COMPRESSION:Qy,Z_DEFAULT_STRATEGY:$y,Z_DEFLATED:eb}=Rv,tb={level:Qy,method:eb,chunkSize:16384,windowBits:15,memLevel:8,strategy:$y,legacyHash:!0};function nb(t){this.options=Ly.assign({},tb,t||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new Wy,this.strm.avail_out=0;let r=Fy.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy,n.legacyHash);if(r!==Xy)throw Error(Lv[r]);if(n.header&&Fy.deflateSetHeader(this.strm,n.header),n.dictionary){let t;if(t=typeof n.dictionary==`string`?Hy.string2buf(n.dictionary):Gy.call(n.dictionary)===`[object ArrayBuffer]`?new Uint8Array(n.dictionary):n.dictionary,r=Fy.deflateSetDictionary(this.strm,t),r!==Xy)throw Error(Lv[r]);this._dict_set=!0}}nb.prototype.push=function(t,n){let r=this.strm,i=this.options.chunkSize,a,o;if(this.ended)return!1;for(o=n===~~n?n:n===!0?Yy:Ky,r.input=typeof t==`string`?Hy.string2buf(t):Gy.call(t)===`[object ArrayBuffer]`?new Uint8Array(t):t,r.next_in=0,r.avail_in=r.input.length;;)if(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),(o===qy||o===Jy)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(a=Fy.deflate(r,o),a===Zy)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),a=Fy.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Xy;if(r.avail_out===0)this.onData(r.output);else if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(r.avail_in===0)break}return!0},nb.prototype.onData=function(t){this.chunks.push(t)},nb.prototype.onEnd=function(t){t===Xy&&(this.result=Ly.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function rb(t,n){let r=new nb(n);if(r.push(t,!0),r.err)throw r.msg||Lv[r.err];return r.result}function ib(t,n){return n||={},n.raw=!0,rb(t,n)}function ab(t,n){return n||={},n.gzip=!0,rb(t,n)}var ob={Deflate:nb,deflate:rb,deflateRaw:ib,gzip:ab,constants:Rv};const sb=16209;var cb=function(t,n){let r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D=t.state;r=t.next_in,T=t.input,i=r+(t.avail_in-5),a=t.next_out,E=t.output,o=a-(n-t.avail_out),s=a+(t.avail_out-257),c=D.dmax,l=D.wsize,u=D.whave,d=D.wnext,f=D.window,p=D.hold,m=D.bits,h=D.lencode,g=D.distcode,_=(1<<D.lenbits)-1,v=(1<<D.distbits)-1;top:do{m<15&&(p+=T[r++]<<m,m+=8,p+=T[r++]<<m,m+=8),y=h[p&_];dolen:for(;;){if(b=y>>>24,p>>>=b,m-=b,b=y>>>16&255,b===0)E[a++]=y&65535;else if(b&16){x=y&65535,b&=15,b&&(m<b&&(p+=T[r++]<<m,m+=8),x+=p&(1<<b)-1,p>>>=b,m-=b),m<15&&(p+=T[r++]<<m,m+=8,p+=T[r++]<<m,m+=8),y=g[p&v];dodist:for(;;){if(b=y>>>24,p>>>=b,m-=b,b=y>>>16&255,b&16){if(S=y&65535,b&=15,m<b&&(p+=T[r++]<<m,m+=8,m<b&&(p+=T[r++]<<m,m+=8)),S+=p&(1<<b)-1,S>c){t.msg=`invalid distance too far back`,D.mode=sb;break top}if(p>>>=b,m-=b,b=a-o,S>b){if(b=S-b,b>u&&D.sane){t.msg=`invalid distance too far back`,D.mode=sb;break top}if(C=0,w=f,d===0){if(C+=l-b,b<x){x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}}else if(d<b){if(C+=l+d-b,b-=d,b<x){x-=b;do E[a++]=f[C++];while(--b);if(C=0,d<x){b=d,x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}}}else if(C+=d-b,b<x){x-=b;do E[a++]=f[C++];while(--b);C=a-S,w=E}for(;x>2;)E[a++]=w[C++],E[a++]=w[C++],E[a++]=w[C++],x-=3;x&&(E[a++]=w[C++],x>1&&(E[a++]=w[C++]))}else{C=a-S;do E[a++]=E[C++],E[a++]=E[C++],E[a++]=E[C++],x-=3;while(x>2);x&&(E[a++]=E[C++],x>1&&(E[a++]=E[C++]))}}else if(b&64){t.msg=`invalid distance code`,D.mode=sb;break top}else{y=g[(y&65535)+(p&(1<<b)-1)];continue dodist}break}}else if(!(b&64)){y=h[(y&65535)+(p&(1<<b)-1)];continue dolen}else if(b&32){D.mode=16191;break top}else{t.msg=`invalid literal/length code`,D.mode=sb;break top}break}}while(r<i&&a<s);x=m>>3,r-=x,m-=x<<3,p&=(1<<m)-1,t.next_in=r,t.next_out=a,t.avail_in=r<i?5+(i-r):5-(r-i),t.avail_out=a<s?257+(s-a):257-(a-s),D.hold=p,D.bits=m};const lb=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ub=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),db=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),fb=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var pb=(t,n,r,i,a,o,s,c)=>{let l=c.bits,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b,x,S,C,w,T=null,E,D=/* @__PURE__ */ new Uint16Array(16),O=/* @__PURE__ */ new Uint16Array(16),k=null,A,j,M;for(u=0;u<=15;u++)D[u]=0;for(d=0;d<i;d++)D[n[r+d]]++;for(m=l,p=15;p>=1&&D[p]===0;p--);if(m>p&&(m=p),p===0)return a[o++]=20971520,a[o++]=20971520,c.bits=1,0;for(f=1;f<p&&D[f]===0;f++);for(m<f&&(m=f),_=1,u=1;u<=15;u++)if(_<<=1,_-=D[u],_<0)return-1;if(_>0&&(t===0||p!==1))return-1;for(O[1]=0,u=1;u<15;u++)O[u+1]=O[u]+D[u];for(d=0;d<i;d++)n[r+d]!==0&&(s[O[n[r+d]]++]=d);if(t===0?(T=k=s,E=20):t===1?(T=lb,k=ub,E=257):(T=db,k=fb,E=0),y=0,d=0,u=f,w=o,h=m,g=0,S=-1,v=1<<m,C=v-1,t===1&&v>852||t===2&&v>592)return 1;for(;;){A=u-g,s[d]+1<E?(j=0,M=s[d]):s[d]>=E?(j=k[s[d]-E],M=T[s[d]-E]):(j=96,M=0),b=1<<u-g,x=1<<h,f=x;do x-=b,a[w+(y>>g)+x]=A<<24|j<<16|M;while(x!==0);for(b=1<<u-1;y&b;)b>>=1;if(b===0?y=0:(y&=b-1,y+=b),d++,--D[u]===0){if(u===p)break;u=n[r+s[d]]}if(u>m&&(y&C)!==S){for(g===0&&(g=m),w+=f,h=u-g,_=1<<h;h+g<p&&(_-=D[h+g],!(_<=0));)h++,_<<=1;if(v+=1<<h,t===1&&v>852||t===2&&v>592)return 1;S=y&C,a[S]=m<<24|h<<16|w-o}}return y!==0&&(a[w+y]=u-g<<24|4194304),c.bits=m,0};const{Z_FINISH:mb,Z_BLOCK:hb,Z_TREES:gb,Z_OK:_b,Z_STREAM_END:vb,Z_NEED_DICT:yb,Z_STREAM_ERROR:bb,Z_DATA_ERROR:xb,Z_MEM_ERROR:Sb,Z_BUF_ERROR:Cb,Z_DEFLATED:wb}=Rv,Tb=16180,Eb=16181,Db=16182,Ob=16183,kb=16184,Ab=16185,jb=16186,Mb=16187,Nb=16188,Pb=16189,Fb=16190,Ib=16191,Lb=16192,Rb=16193,zb=16194,Bb=16195,Vb=16196,Hb=16197,Ub=16198,Wb=16199,Gb=16200,Kb=16201,qb=16202,Jb=16203,Yb=16204,Xb=16205,Zb=16206,Qb=16207,$b=16208,ex=16209,tx=16210,nx=16211,rx=t=>(t>>>24&255)+(t>>>8&65280)+((t&65280)<<8)+((t&255)<<24);function ix(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=/* @__PURE__ */ new Uint16Array(320),this.work=/* @__PURE__ */ new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const ax=t=>{if(!t)return 1;let n=t.state;return+(!n||n.strm!==t||n.mode<Tb||n.mode>nx)},ox=t=>{if(ax(t))return bb;let n=t.state;return t.total_in=t.total_out=n.total=0,t.msg=``,n.wrap&&(t.adler=n.wrap&1),n.mode=Tb,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=/* @__PURE__ */ new Int32Array(852),n.distcode=n.distdyn=/* @__PURE__ */ new Int32Array(592),n.sane=1,n.back=-1,_b},sx=t=>{if(ax(t))return bb;let n=t.state;return n.wsize=0,n.whave=0,n.wnext=0,ox(t)},cx=(t,n)=>{let r;if(ax(t))return bb;let i=t.state;return n<0?(r=0,n=-n):(r=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?bb:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=r,i.wbits=n,sx(t))},lx=(t,n)=>{if(!t)return bb;let r=new ix;t.state=r,r.strm=t,r.window=null,r.mode=Tb;let i=cx(t,n);return i!==_b&&(t.state=null),i},ux=t=>lx(t,15);let dx=!0,fx,px;const mx=t=>{if(dx){fx=/* @__PURE__ */ new Int32Array(512),px=/* @__PURE__ */ new Int32Array(32);let n=0;for(;n<144;)t.lens[n++]=8;for(;n<256;)t.lens[n++]=9;for(;n<280;)t.lens[n++]=7;for(;n<288;)t.lens[n++]=8;for(pb(1,t.lens,0,288,fx,0,t.work,{bits:9}),n=0;n<32;)t.lens[n++]=5;pb(2,t.lens,0,32,px,0,t.work,{bits:5}),dx=!1}t.lencode=fx,t.lenbits=9,t.distcode=px,t.distbits=5},hx=(t,n,r,i)=>{let a,o=t.state;return o.window===null&&(o.window=new Uint8Array(1<<o.wbits)),o.wsize===0&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0),i>=o.wsize?(o.window.set(n.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(a=o.wsize-o.wnext,a>i&&(a=i),o.window.set(n.subarray(r-i,r-i+a),o.wnext),i-=a,i?(o.window.set(n.subarray(r-i,r),0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0};var gx={inflateReset:sx,inflateReset2:cx,inflateResetKeep:ox,inflateInit:ux,inflateInit2:lx,inflate:(t,n)=>{let r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=0,v,y,b,x,S,C,w,T,E=/* @__PURE__ */ new Uint8Array(4),D,O,k=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ax(t)||!t.output||!t.input&&t.avail_in!==0)return bb;r=t.state,r.mode===Ib&&(r.mode=Lb),s=t.next_out,a=t.output,l=t.avail_out,o=t.next_in,i=t.input,c=t.avail_in,u=r.hold,d=r.bits,f=c,p=l,T=_b;inf_leave:for(;;)switch(r.mode){case Tb:if(r.wrap===0){r.mode=Lb;break}for(;d<16;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(r.wrap&2&&u===35615){r.wbits===0&&(r.wbits=15),r.check=0,E[0]=u&255,E[1]=u>>>8&255,r.check=Iv(r.check,E,2,0),u=0,d=0,r.mode=Eb;break}if(r.head&&(r.head.done=!1),!(r.wrap&1)||(((u&255)<<8)+(u>>8))%31){t.msg=`incorrect header check`,r.mode=ex;break}if((u&15)!==wb){t.msg=`unknown compression method`,r.mode=ex;break}if(u>>>=4,d-=4,w=(u&15)+8,r.wbits===0&&(r.wbits=w),w>15||w>r.wbits){t.msg=`invalid window size`,r.mode=ex;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=u&512?Pb:Ib,u=0,d=0;break;case Eb:for(;d<16;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(r.flags=u,(r.flags&255)!==wb){t.msg=`unknown compression method`,r.mode=ex;break}if(r.flags&57344){t.msg=`unknown header flags set`,r.mode=ex;break}r.head&&(r.head.text=u>>8&1),r.flags&512&&r.wrap&4&&(E[0]=u&255,E[1]=u>>>8&255,r.check=Iv(r.check,E,2,0)),u=0,d=0,r.mode=Db;case Db:for(;d<32;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.head&&(r.head.time=u),r.flags&512&&r.wrap&4&&(E[0]=u&255,E[1]=u>>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=Iv(r.check,E,4,0)),u=0,d=0,r.mode=Ob;case Ob:for(;d<16;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.head&&(r.head.xflags=u&255,r.head.os=u>>8),r.flags&512&&r.wrap&4&&(E[0]=u&255,E[1]=u>>>8&255,r.check=Iv(r.check,E,2,0)),u=0,d=0,r.mode=kb;case kb:if(r.flags&1024){for(;d<16;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),r.flags&512&&r.wrap&4&&(E[0]=u&255,E[1]=u>>>8&255,r.check=Iv(r.check,E,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=Ab;case Ab:if(r.flags&1024&&(m=r.length,m>c&&(m=c),m&&(r.head&&(w=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(i.subarray(o,o+m),w)),r.flags&512&&r.wrap&4&&(r.check=Iv(r.check,i,m,o)),c-=m,o+=m,r.length-=m),r.length))break inf_leave;r.length=0,r.mode=jb;case jb:if(r.flags&2048){if(c===0)break inf_leave;m=0;do w=i[o+m++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w));while(w&&m<c);if(r.flags&512&&r.wrap&4&&(r.check=Iv(r.check,i,m,o)),c-=m,o+=m,w)break inf_leave}else r.head&&(r.head.name=null);r.length=0,r.mode=Mb;case Mb:if(r.flags&4096){if(c===0)break inf_leave;m=0;do w=i[o+m++],r.head&&w&&r.length<65536&&(r.head.comment+=String.fromCharCode(w));while(w&&m<c);if(r.flags&512&&r.wrap&4&&(r.check=Iv(r.check,i,m,o)),c-=m,o+=m,w)break inf_leave}else r.head&&(r.head.comment=null);r.mode=Nb;case Nb:if(r.flags&512){for(;d<16;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(r.wrap&4&&u!==(r.check&65535)){t.msg=`header crc mismatch`,r.mode=ex;break}u=0,d=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Ib;break;case Pb:for(;d<32;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}t.adler=r.check=rx(u),u=0,d=0,r.mode=Fb;case Fb:if(r.havedict===0)return t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=c,r.hold=u,r.bits=d,yb;t.adler=r.check=1,r.mode=Ib;case Ib:if(n===hb||n===gb)break inf_leave;case Lb:if(r.last){u>>>=d&7,d-=d&7,r.mode=Zb;break}for(;d<3;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}switch(r.last=u&1,u>>>=1,--d,u&3){case 0:r.mode=Rb;break;case 1:if(mx(r),r.mode=Wb,n===gb){u>>>=2,d-=2;break inf_leave}break;case 2:r.mode=Vb;break;case 3:t.msg=`invalid block type`,r.mode=ex}u>>>=2,d-=2;break;case Rb:for(u>>>=d&7,d-=d&7;d<32;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if((u&65535)!=(u>>>16^65535)){t.msg=`invalid stored block lengths`,r.mode=ex;break}if(r.length=u&65535,u=0,d=0,r.mode=zb,n===gb)break inf_leave;case zb:r.mode=Bb;case Bb:if(m=r.length,m){if(m>c&&(m=c),m>l&&(m=l),m===0)break inf_leave;a.set(i.subarray(o,o+m),s),c-=m,o+=m,l-=m,s+=m,r.length-=m;break}r.mode=Ib;break;case Vb:for(;d<14;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(r.nlen=(u&31)+257,u>>>=5,d-=5,r.ndist=(u&31)+1,u>>>=5,d-=5,r.ncode=(u&15)+4,u>>>=4,d-=4,r.nlen>286||r.ndist>30){t.msg=`too many length or distance symbols`,r.mode=ex;break}r.have=0,r.mode=Hb;case Hb:for(;r.have<r.ncode;){for(;d<3;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.lens[k[r.have++]]=u&7,u>>>=3,d-=3}for(;r.have<19;)r.lens[k[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,D={bits:r.lenbits},T=pb(0,r.lens,0,19,r.lencode,0,r.work,D),r.lenbits=D.bits,T){t.msg=`invalid code lengths set`,r.mode=ex;break}r.have=0,r.mode=Ub;case Ub:for(;r.have<r.nlen+r.ndist;){for(;_=r.lencode[u&(1<<r.lenbits)-1],v=_>>>24,y=_>>>16&255,b=_&65535,!(v<=d);){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(b<16)u>>>=v,d-=v,r.lens[r.have++]=b;else{if(b===16){for(O=v+2;d<O;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(u>>>=v,d-=v,r.have===0){t.msg=`invalid bit length repeat`,r.mode=ex;break}w=r.lens[r.have-1],m=3+(u&3),u>>>=2,d-=2}else if(b===17){for(O=v+3;d<O;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}u>>>=v,d-=v,w=0,m=3+(u&7),u>>>=3,d-=3}else{for(O=v+7;d<O;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}u>>>=v,d-=v,w=0,m=11+(u&127),u>>>=7,d-=7}if(r.have+m>r.nlen+r.ndist){t.msg=`invalid bit length repeat`,r.mode=ex;break}for(;m--;)r.lens[r.have++]=w}}if(r.mode===ex)break;if(r.lens[256]===0){t.msg=`invalid code -- missing end-of-block`,r.mode=ex;break}if(r.lenbits=9,D={bits:r.lenbits},T=pb(1,r.lens,0,r.nlen,r.lencode,0,r.work,D),r.lenbits=D.bits,T){t.msg=`invalid literal/lengths set`,r.mode=ex;break}if(r.distbits=6,r.distcode=r.distdyn,D={bits:r.distbits},T=pb(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,D),r.distbits=D.bits,T){t.msg=`invalid distances set`,r.mode=ex;break}if(r.mode=Wb,n===gb)break inf_leave;case Wb:r.mode=Gb;case Gb:if(c>=6&&l>=258){t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=c,r.hold=u,r.bits=d,cb(t,p),s=t.next_out,a=t.output,l=t.avail_out,o=t.next_in,i=t.input,c=t.avail_in,u=r.hold,d=r.bits,r.mode===Ib&&(r.back=-1);break}for(r.back=0;_=r.lencode[u&(1<<r.lenbits)-1],v=_>>>24,y=_>>>16&255,b=_&65535,!(v<=d);){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(y&&!(y&240)){for(x=v,S=y,C=b;_=r.lencode[C+((u&(1<<x+S)-1)>>x)],v=_>>>24,y=_>>>16&255,b=_&65535,!(x+v<=d);){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}u>>>=x,d-=x,r.back+=x}if(u>>>=v,d-=v,r.back+=v,r.length=b,y===0){r.mode=Xb;break}if(y&32){r.back=-1,r.mode=Ib;break}if(y&64){t.msg=`invalid literal/length code`,r.mode=ex;break}r.extra=y&15,r.mode=Kb;case Kb:if(r.extra){for(O=r.extra;d<O;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=qb;case qb:for(;_=r.distcode[u&(1<<r.distbits)-1],v=_>>>24,y=_>>>16&255,b=_&65535,!(v<=d);){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(!(y&240)){for(x=v,S=y,C=b;_=r.distcode[C+((u&(1<<x+S)-1)>>x)],v=_>>>24,y=_>>>16&255,b=_&65535,!(x+v<=d);){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}u>>>=x,d-=x,r.back+=x}if(u>>>=v,d-=v,r.back+=v,y&64){t.msg=`invalid distance code`,r.mode=ex;break}r.offset=b,r.extra=y&15,r.mode=Jb;case Jb:if(r.extra){for(O=r.extra;d<O;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg=`invalid distance too far back`,r.mode=ex;break}r.mode=Yb;case Yb:if(l===0)break inf_leave;if(m=p-l,r.offset>m){if(m=r.offset-m,m>r.whave&&r.sane){t.msg=`invalid distance too far back`,r.mode=ex;break}m>r.wnext?(m-=r.wnext,h=r.wsize-m):h=r.wnext-m,m>r.length&&(m=r.length),g=r.window}else g=a,h=s-r.offset,m=r.length;m>l&&(m=l),l-=m,r.length-=m;do a[s++]=g[h++];while(--m);r.length===0&&(r.mode=Gb);break;case Xb:if(l===0)break inf_leave;a[s++]=r.length,l--,r.mode=Gb;break;case Zb:if(r.wrap){for(;d<32;){if(c===0)break inf_leave;c--,u|=i[o++]<<d,d+=8}if(p-=l,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?Iv(r.check,a,p,s-p):Pv(r.check,a,p,s-p)),p=l,r.wrap&4&&(r.flags?u:rx(u))!==r.check){t.msg=`incorrect data check`,r.mode=ex;break}u=0,d=0}r.mode=Qb;case Qb:if(r.wrap&&r.flags){for(;d<32;){if(c===0)break inf_leave;c--,u+=i[o++]<<d,d+=8}if(r.wrap&4&&u!==(r.total|0)){t.msg=`incorrect length check`,r.mode=ex;break}u=0,d=0}r.mode=$b;case $b:T=vb;break inf_leave;case ex:T=xb;break inf_leave;case tx:return Sb;case nx:default:return bb}return t.next_out=s,t.avail_out=l,t.next_in=o,t.avail_in=c,r.hold=u,r.bits=d,(r.wsize||p!==t.avail_out&&r.mode<ex&&(r.mode<Zb||n!==mb))&&hx(t,t.output,t.next_out,p-t.avail_out),f-=t.avail_in,p-=t.avail_out,t.total_in+=f,t.total_out+=p,r.total+=p,r.wrap&4&&p&&(t.adler=r.check=r.flags?Iv(r.check,a,p,t.next_out-p):Pv(r.check,a,p,t.next_out-p)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ib?128:0)+(r.mode===Wb||r.mode===zb?256:0),(f===0&&p===0||n===mb)&&T===_b&&(T=Cb),T},inflateEnd:t=>{if(ax(t))return bb;let n=t.state;return n.window&&=null,t.state=null,_b},inflateGetHeader:(t,n)=>{if(ax(t))return bb;let r=t.state;return r.wrap&2?(r.head=n,n.done=!1,_b):bb},inflateSetDictionary:(t,n)=>{let r=n.length,i,a,o;return ax(t)||(i=t.state,i.wrap!==0&&i.mode!==Fb)?bb:i.mode===Fb&&(a=1,a=Pv(a,n,r,0),a!==i.check)?xb:(o=hx(t,n,r,r),o?(i.mode=tx,Sb):(i.havedict=1,_b))},inflateInfo:`pako inflate (from Nodeca project)`};function _x(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name=``,this.comment=``,this.hcrc=0,this.done=!1}var vx=_x;const yx=Object.prototype.toString,{Z_NO_FLUSH:bx,Z_FINISH:xx,Z_OK:Sx,Z_STREAM_END:Cx,Z_NEED_DICT:wx,Z_STREAM_ERROR:Tx,Z_DATA_ERROR:Ex,Z_MEM_ERROR:Dx,Z_BUF_ERROR:Ox}=Rv,kx={chunkSize:65536,windowBits:15,to:``};function Ax(t){this.options=Ly.assign({},kx,t||{});let n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(t&&t.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15||(n.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.chunks=[],this.strm=new Wy,this.strm.avail_out=0;let r=gx.inflateInit2(this.strm,n.windowBits);if(r!==Sx||(this.header=new vx,gx.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary==`string`?n.dictionary=Hy.string2buf(n.dictionary):yx.call(n.dictionary)===`[object ArrayBuffer]`&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(r=gx.inflateSetDictionary(this.strm,n.dictionary),r!==Sx))))throw Error(Lv[r])}Ax.prototype.push=function(t,n){let r=this.strm,i=this.options.chunkSize,a=this.options.dictionary,o,s,c;if(this.ended)return!1;for(s=n===~~n?n:n===!0?xx:bx,r.input=yx.call(t)===`[object ArrayBuffer]`?new Uint8Array(t):t,r.next_in=0,r.avail_in=r.input.length;;){for(r.avail_out===0&&(r.output=new Uint8Array(i),r.next_out=0,r.avail_out=i),o=gx.inflate(r,s),o===wx&&a&&(o=gx.inflateSetDictionary(r,a),o===Sx?o=gx.inflate(r,s):o===Ex&&(o=wx));r.avail_in>0&&o===Cx&&r.state.wrap&2&&r.state.flags!==0&&r.input[r.next_in]!==0;)gx.inflateReset(r),o=gx.inflate(r,s);switch(o){case Tx:case Ex:case wx:case Dx:return this.onEnd(o),this.ended=!0,!1}if(c=r.avail_out,r.next_out&&(r.avail_out===0||o===Cx||s>0)){if(this.options.to===`string`){let t=Hy.utf8border(r.output,r.next_out),n=r.next_out-t,a=Hy.buf2string(r.output,t);r.next_out=n,r.avail_out=i-n,n&&r.output.set(r.output.subarray(t,t+n),0),this.onData(a)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out)),r.avail_out=0,r.next_out=0}if(o!==Sx&&o!==Ox||c!==0){if(o===Cx)return o=gx.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(r.avail_in===0){if(s===xx)return o=gx.inflateEnd(this.strm),this.onEnd(o===Sx?Ox:o),this.ended=!0,!1;break}}}return!0},Ax.prototype.onData=function(t){this.chunks.push(t)},Ax.prototype.onEnd=function(t){t===Sx&&(this.result=this.options.to===`string`?this.chunks.join(``):Ly.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};function jx(t,n){let r=new Ax(n);if(r.push(t,!0),r.err)throw r.msg||Lv[r.err];return r.result}function Mx(t,n){return n||={},n.raw=!0,jx(t,n)}var Nx={Inflate:Ax,inflate:jx,inflateRaw:Mx,ungzip:jx,constants:Rv};const{Deflate:Px,deflate:Fx,deflateRaw:Ix,gzip:Lx}=ob,{Inflate:Rx,inflate:zx,inflateRaw:Bx,ungzip:Vx}=Nx,Hx={inflate:zx};var $={};$.parse=function(t){var n=$.B,r=function(t,n,r,i){var a=$.T,o={cmap:a.cmap,head:a.head,hhea:a.hhea,maxp:a.maxp,hmtx:a.hmtx,name:a.name,"OS/2":a.OS2,post:a.post,loca:a.loca,kern:a.kern,glyf:a.glyf,"CFF ":a.CFF,GSUB:a.GSUB,CBLC:a.CBLC,CBDT:a.CBDT,"SVG ":a.SVG,COLR:a.colr,CPAL:a.cpal,sbix:a.sbix,fvar:a.fvar,gvar:a.gvar,avar:a.avar,HVAR:a.HVAR},s={_data:t,_index:n,_offset:r};for(var c in o){var l=$.findTable(t,c,r);if(l){var u=l[0],d=i[u];d??=o[c].parseTab(t,u,l[1],s),s[c]=i[u]=d}}return s};function i(t){var r=n.readUshort(t,12),i=n.readUint(t,16),a=new Uint8Array(i),o=12+r*16;n.writeASCII(a,0,`OTTO`),n.writeUshort(a,4,r);for(var s=44,c=0;c<r;c++){var l=n.readASCII(t,s,4),u=n.readUint(t,s+4),d=n.readUint(t,s+8),f=n.readUint(t,s+12);s+=20;var p=t.slice(u,u+d);d!=f&&(p=Hx.inflate(p));var m=12+c*16;n.writeASCII(a,m,l),n.writeUint(a,m+8,o),n.writeUint(a,m+12,f),a.set(p,o),o+=f}return a}var a=new Uint8Array(t);let o;a[0]==119&&(o=a,a=i(a));var s={};if(n.readASCII(a,0,4)==`ttcf`){var c=4;n.readUshort(a,c),c+=2,n.readUshort(a,c),c+=2;var l=n.readUint(a,c);c+=4;for(var u=[],d=0;d<l;d++){var f=n.readUint(a,c);c+=4,u.push(r(a,d,f,s))}return u}var p=r(a,0,0,s);p._compressedData=o;var m=p.fvar;if(m){for(var h=[p],d=0;d<m[1].length;d++){var g=m[1][d],_={};for(var v in h.push(_),p)_[v]=p[v];_._index=d;var y=_.name=JSON.parse(JSON.stringify(_.name));y.fontSubfamily=g[0],g[3]??=(y.fontFamily+`-`+y.fontSubfamily).replaceAll(` `,``),y.postScriptName=g[3]}return h}return[p]},$.findTable=function(t,n,r){for(var i=$.B,a=i.readUshort(t,r+4),o=r+12,s=0;s<a;s++){var c=i.readASCII(t,o,4);i.readUint(t,o+4);var l=i.readUint(t,o+8),u=i.readUint(t,o+12);if(c==n)return[l,u];o+=16}return null},$.T={},$.B={readFixed:function(t,n){return(t[n]<<8|t[n+1])+(t[n+2]<<8|t[n+3])/65540},readF2dot14:function(t,n){return $.B.readShort(t,n)/16384},readInt:function(t,n){var r=$.B.t.uint8;return r[0]=t[n+3],r[1]=t[n+2],r[2]=t[n+1],r[3]=t[n],$.B.t.int32[0]},readInt8:function(t,n){var r=$.B.t.uint8;return r[0]=t[n],$.B.t.int8[0]},readShort:function(t,n){var r=$.B.t.uint16;return r[0]=t[n]<<8|t[n+1],$.B.t.int16[0]},readUshort:function(t,n){return t[n]<<8|t[n+1]},writeUshort:function(t,n,r){t[n]=r>>8&255,t[n+1]=r&255},readUshorts:function(t,n,r){for(var i=[],a=0;a<r;a++){var o=$.B.readUshort(t,n+a*2);i.push(o)}return i},readUint:function(t,n){var r=$.B.t.uint8;return r[3]=t[n],r[2]=t[n+1],r[1]=t[n+2],r[0]=t[n+3],$.B.t.uint32[0]},writeUint:function(t,n,r){t[n]=r>>24&255,t[n+1]=r>>16&255,t[n+2]=r>>8&255,t[n+3]=(r|0)&255},readUint64:function(t,n){return $.B.readUint(t,n)*4294967296+$.B.readUint(t,n+4)},readASCII:function(t,n,r){for(var i=``,a=0;a<r;a++)i+=String.fromCharCode(t[n+a]);return i},writeASCII:function(t,n,r){for(var i=0;i<r.length;i++)t[n+i]=r.charCodeAt(i)},readUnicode:function(t,n,r){for(var i=``,a=0;a<r;a++){var o=t[n++]<<8|t[n++];i+=String.fromCharCode(o)}return i},_tdec:globalThis.TextDecoder?new globalThis.TextDecoder:null,readUTF8:function(t,n,r){var i=$.B._tdec;return i&&n==0&&r==t.length?i.decode(t):$.B.readASCII(t,n,r)},readBytes:function(t,n,r){for(var i=[],a=0;a<r;a++)i.push(t[n+a]);return i},readASCIIArray:function(t,n,r){for(var i=[],a=0;a<r;a++)i.push(String.fromCharCode(t[n+a]));return i},t:(function(){var t=/* @__PURE__ */ new ArrayBuffer(8);return{buff:t,int8:new Int8Array(t),uint8:new Uint8Array(t),int16:new Int16Array(t),uint16:new Uint16Array(t),int32:new Int32Array(t),uint32:new Uint32Array(t)}})()},$.T.CFF={parseTab:function(t,n,r){var i=$.B,a=$.T.CFF;t=new Uint8Array(t.buffer,n,r),n=0,t[n],n++,t[n],n++,t[n],n++,t[n],n++;var o=[];n=a.readIndex(t,n,o);for(var s=[],c=0;c<o.length-1;c++)s.push(i.readASCII(t,n+o[c],o[c+1]-o[c]));n+=o[o.length-1];var l=[];n=a.readIndex(t,n,l);for(var u=[],c=0;c<l.length-1;c++)u.push(a.readDict(t,n+l[c],n+l[c+1]));n+=l[l.length-1];var d=u[0],f=[];n=a.readIndex(t,n,f);for(var p=[],c=0;c<f.length-1;c++)p.push(i.readASCII(t,n+f[c],f[c+1]-f[c]));if(n+=f[f.length-1],a.readSubrs(t,n,d),d.CharStrings&&=a.readBytes(t,d.CharStrings),d.ROS){n=d.FDArray;var m=[];n=a.readIndex(t,n,m),d.FDArray=[];for(var c=0;c<m.length-1;c++){var h=a.readDict(t,n+m[c],n+m[c+1]);a._readFDict(t,h,p),d.FDArray.push(h)}n+=m[m.length-1],n=d.FDSelect,d.FDSelect=[];var g=t[n];if(n++,g==3){var _=i.readUshort(t,n);n+=2;for(var c=0;c<_+1;c++)d.FDSelect.push(i.readUshort(t,n),t[n+2]),n+=3}else throw g}return d.charset&&=a.readCharset(t,d.charset,d.CharStrings.length),a._readFDict(t,d,p),d},_readFDict:function(t,n,r){var i=$.T.CFF,a;for(var o in n.Private&&(a=n.Private[1],n.Private=i.readDict(t,a,a+n.Private[0]),n.Private.Subrs&&i.readSubrs(t,a+n.Private.Subrs,n.Private)),n)[`FamilyName`,`FontName`,`FullName`,`Notice`,`version`,`Copyright`].indexOf(o)!=-1&&(n[o]=r[n[o]-426+35])},readSubrs:function(t,n,r){r.Subrs=$.T.CFF.readBytes(t,n);var i,a=r.Subrs.length+1;i=a<1240?107:a<33900?1131:32768,r.Bias=i},readBytes:function(t,n){$.B;var r=[];n=$.T.CFF.readIndex(t,n,r);for(var i=[],a=r.length-1,o=t.byteOffset+n,s=0;s<a;s++){var c=r[s];i.push(new Uint8Array(t.buffer,o+c,r[s+1]-c))}return i},tableSE:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],glyphByUnicode:function(t,n){for(var r=0;r<t.charset.length;r++)if(t.charset[r]==n)return r;return-1},glyphBySE:function(t,n){return n<0||n>255?-1:$.T.CFF.glyphByUnicode(t,$.T.CFF.tableSE[n])},readCharset:function(t,n,r){var i=$.B,a=[`.notdef`],o=t[n];if(n++,o==0)for(var s=0;s<r;s++){var c=i.readUshort(t,n);n+=2,a.push(c)}else if(o==1||o==2)for(;a.length<r;){var c=i.readUshort(t,n);n+=2;var l=0;o==1?(l=t[n],n++):(l=i.readUshort(t,n),n+=2);for(var s=0;s<=l;s++)a.push(c),c++}else throw`error: format: `+o;return a},readIndex:function(t,n,r){var i=$.B,a=i.readUshort(t,n)+1;n+=2;var o=t[n];if(n++,o==1)for(var s=0;s<a;s++)r.push(t[n+s]);else if(o==2)for(var s=0;s<a;s++)r.push(i.readUshort(t,n+s*2));else if(o==3)for(var s=0;s<a;s++)r.push(i.readUint(t,n+s*3-1)&16777215);else if(o==4)for(var s=0;s<a;s++)r.push(i.readUint(t,n+s*4));else if(a!=1)throw`unsupported offset size: `+o+`, count: `+a;return n+=a*o,n-1},getCharString:function(t,n,r){var i=$.B,a=t[n],o=t[n+1];t[n+2],t[n+3],t[n+4];var s=1,c=null,l=null;a<=20&&(c=a,s=1),a==12&&(c=a*100+o,s=2),21<=a&&a<=27&&(c=a,s=1),a==28&&(l=i.readShort(t,n+1),s=3),29<=a&&a<=31&&(c=a,s=1),32<=a&&a<=246&&(l=a-139,s=1),247<=a&&a<=250&&(l=(a-247)*256+o+108,s=2),251<=a&&a<=254&&(l=-(a-251)*256-o-108,s=2),a==255&&(l=i.readInt(t,n+1)/65535,s=5),r.val=l??`o`+c,r.size=s},readCharString:function(t,n,r){for(var i=n+r,a=$.B,o=[];n<i;){var s=t[n],c=t[n+1];t[n+2],t[n+3],t[n+4];var l=1,u=null,d=null;s<=20&&(u=s,l=1),s==12&&(u=s*100+c,l=2),(s==19||s==20)&&(u=s,l=2),21<=s&&s<=27&&(u=s,l=1),s==28&&(d=a.readShort(t,n+1),l=3),29<=s&&s<=31&&(u=s,l=1),32<=s&&s<=246&&(d=s-139,l=1),247<=s&&s<=250&&(d=(s-247)*256+c+108,l=2),251<=s&&s<=254&&(d=-(s-251)*256-c-108,l=2),s==255&&(d=a.readInt(t,n+1)/65535,l=5),o.push(d??`o`+u),n+=l}return o},readDict:function(t,n,r){for(var i=$.B,a={},o=[];n<r;){var s=t[n],c=t[n+1];t[n+2],t[n+3],t[n+4];var l=1,u=null,d=null;if(s==28&&(d=i.readShort(t,n+1),l=3),s==29&&(d=i.readInt(t,n+1),l=5),32<=s&&s<=246&&(d=s-139,l=1),247<=s&&s<=250&&(d=(s-247)*256+c+108,l=2),251<=s&&s<=254&&(d=-(s-251)*256-c-108,l=2),s==255)throw d=i.readInt(t,n+1)/65535,l=5,`unknown number`;if(s==30){var f=[];for(l=1;;){var p=t[n+l];l++;var m=p>>4,h=p&15;if(m!=15&&f.push(m),h!=15&&f.push(h),h==15)break}for(var g=``,_=[0,1,2,3,4,5,6,7,8,9,`.`,`e`,`e-`,`reserved`,`-`,`endOfNumber`],v=0;v<f.length;v++)g+=_[f[v]];d=parseFloat(g)}if(s<=21){var y=[`version`,`Notice`,`FullName`,`FamilyName`,`Weight`,`FontBBox`,`BlueValues`,`OtherBlues`,`FamilyBlues`,`FamilyOtherBlues`,`StdHW`,`StdVW`,`escape`,`UniqueID`,`XUID`,`charset`,`Encoding`,`CharStrings`,`Private`,`Subrs`,`defaultWidthX`,`nominalWidthX`];if(u=y[s],l=1,s==12){var y=/* @__PURE__ */ `Copyright.isFixedPitch.ItalicAngle.UnderlinePosition.UnderlineThickness.PaintType.CharstringType.FontMatrix.StrokeWidth.BlueScale.BlueShift.BlueFuzz.StemSnapH.StemSnapV.ForceBold...LanguageGroup.ExpansionFactor.initialRandomSeed.SyntheticBase.PostScript.BaseFontName.BaseFontBlend.......ROS.CIDFontVersion.CIDFontRevision.CIDFontType.CIDCount.UIDBase.FDArray.FDSelect.FontName`.split(`.`);u=y[c],l=2}}u==null?o.push(d):(a[u]=o.length==1?o[0]:o,o=[]),n+=l}return a}},$.T.cmap={parseTab:function(t,n,r){var i={tables:[],ids:{},off:n};t=new Uint8Array(t.buffer,n,r),n=0;var a=$.B,o=a.readUshort,s=$.T.cmap;o(t,n),n+=2;var c=o(t,n);n+=2;for(var l=[],u=0;u<c;u++){var d=o(t,n);n+=2;var f=o(t,n);n+=2;var p=a.readUint(t,n);n+=4;var m=`p`+d+`e`+f,h=l.indexOf(p);if(h==-1){h=i.tables.length;var g={};l.push(p);var _=g.format=o(t,p);_==0?g=s.parse0(t,p,g):_==4?g=s.parse4(t,p,g):_==6?g=s.parse6(t,p,g):_==12&&(g=s.parse12(t,p,g)),i.tables.push(g)}i.ids[m]!=null&&console.log(`multiple tables for one platform+encoding: `+m),i.ids[m]=h}return i},parse0:function(t,n,r){var i=$.B;n+=2;var a=i.readUshort(t,n);n+=2,i.readUshort(t,n),n+=2,r.map=[];for(var o=0;o<a-6;o++)r.map.push(t[n+o]);return r},parse4:function(t,n,r){var i=$.B,a=i.readUshort,o=i.readUshorts,s=n;n+=2;var c=a(t,n);n+=2,a(t,n),n+=2;var l=a(t,n);n+=2;var u=l>>>1;r.searchRange=a(t,n),n+=2,r.entrySelector=a(t,n),n+=2,r.rangeShift=a(t,n),n+=2,r.endCount=o(t,n,u),n+=u*2,n+=2,r.startCount=o(t,n,u),n+=u*2,r.idDelta=[];for(var d=0;d<u;d++)r.idDelta.push(i.readShort(t,n)),n+=2;return r.idRangeOffset=o(t,n,u),n+=u*2,r.glyphIdArray=o(t,n,s+c-n>>1),r},parse6:function(t,n,r){var i=$.B;n+=2,i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2,r.firstCode=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);n+=2,r.glyphIdArray=[];for(var o=0;o<a;o++)r.glyphIdArray.push(i.readUshort(t,n)),n+=2;return r},parse12:function(t,n,r){var i=$.B.readUint;n+=4,i(t,n),n+=4,i(t,n),n+=4;var a=i(t,n)*3;n+=4;for(var o=r.groups=new Uint32Array(a),s=0;s<a;s+=3)o[s]=i(t,n+(s<<2)),o[s+1]=i(t,n+(s<<2)+4),o[s+2]=i(t,n+(s<<2)+8);return r}},$.T.CBLC={parseTab:function(t,n,r){var i=$.B,a=n;i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2;var o=i.readUint(t,n);n+=4;for(var s=[],c=0;c<o;c++){var l=i.readUint(t,n);n+=4,i.readUint(t,n),n+=4,i.readUint(t,n),n+=4,n+=4,n+=24,i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2,n+=4;for(var u=a+l,d=0;d<3;d++){var f=i.readUshort(t,u);u+=2;var p=i.readUshort(t,u);u+=2;var m=i.readUint(t,u);u+=4;var h=p-f+1,g=a+l+m,_=i.readUshort(t,g);if(g+=2,_!=1)throw _;var v=i.readUshort(t,g);g+=2;var y=i.readUint(t,g);g+=4;for(var b=[],x=0;x<h;x++){var S=i.readUint(t,g+x*4);b.push(y+S)}s.push([f,p,v,b])}}return s}},$.T.CBDT={parseTab:function(t,n,r){return $.B,new Uint8Array(t.buffer,t.byteOffset+n,r)}},$.T.glyf={parseTab:function(t,n,r,i){for(var a=[],o=i.maxp.numGlyphs,s=0;s<o;s++)a.push(null);return a},_parseGlyf:function(t,n){var r=$.B,i=t._data,a=t.loca;if(a[n]==a[n+1])return null;var o=$.findTable(i,`glyf`,t._offset)[0]+a[n],s={};if(s.noc=r.readShort(i,o),o+=2,s.xMin=r.readShort(i,o),o+=2,s.yMin=r.readShort(i,o),o+=2,s.xMax=r.readShort(i,o),o+=2,s.yMax=r.readShort(i,o),o+=2,s.xMin>=s.xMax||s.yMin>=s.yMax)return null;if(s.noc>0){s.endPts=[];for(var c=0;c<s.noc;c++)s.endPts.push(r.readUshort(i,o)),o+=2;var l=r.readUshort(i,o);if(o+=2,i.length-o<l)return null;s.instructions=r.readBytes(i,o,l),o+=l;var u=s.endPts[s.noc-1]+1;s.flags=[];for(var c=0;c<u;c++){var d=i[o];if(o++,s.flags.push(d),d&8){var f=i[o];o++;for(var p=0;p<f;p++)s.flags.push(d),c++}}s.xs=[];for(var c=0;c<u;c++){var m=!!(s.flags[c]&2),h=!!(s.flags[c]&16);m?(s.xs.push(h?i[o]:-i[o]),o++):h?s.xs.push(0):(s.xs.push(r.readShort(i,o)),o+=2)}s.ys=[];for(var c=0;c<u;c++){var m=!!(s.flags[c]&4),h=!!(s.flags[c]&32);m?(s.ys.push(h?i[o]:-i[o]),o++):h?s.ys.push(0):(s.ys.push(r.readShort(i,o)),o+=2)}for(var g=0,_=0,c=0;c<u;c++)g+=s.xs[c],_+=s.ys[c],s.xs[c]=g,s.ys[c]=_}else{var v=1,y=2,b=8,x=32,S=64,C=128,w=256;s.parts=[];var T;do{T=r.readUshort(i,o),o+=2;var E={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(s.parts.push(E),E.glyphIndex=r.readUshort(i,o),o+=2,T&v){var D=r.readShort(i,o);o+=2;var O=r.readShort(i,o);o+=2}else{var D=r.readInt8(i,o);o++;var O=r.readInt8(i,o);o++}T&y?(E.m.tx=D,E.m.ty=O):(E.p1=D,E.p2=O),T&b?(E.m.a=E.m.d=r.readF2dot14(i,o),o+=2):T&S?(E.m.a=r.readF2dot14(i,o),o+=2,E.m.d=r.readF2dot14(i,o),o+=2):T&C&&(E.m.a=r.readF2dot14(i,o),o+=2,E.m.b=r.readF2dot14(i,o),o+=2,E.m.c=r.readF2dot14(i,o),o+=2,E.m.d=r.readF2dot14(i,o),o+=2)}while(T&x);if(T&w){var k=r.readUshort(i,o);o+=2,s.instr=[];for(var c=0;c<k;c++)s.instr.push(i[o]),o++}}return s}},$.T.head={parseTab:function(t,n,r){var i=$.B,a={};return i.readFixed(t,n),n+=4,a.fontRevision=i.readFixed(t,n),n+=4,i.readUint(t,n),n+=4,i.readUint(t,n),n+=4,a.flags=i.readUshort(t,n),n+=2,a.unitsPerEm=i.readUshort(t,n),n+=2,a.created=i.readUint64(t,n),n+=8,a.modified=i.readUint64(t,n),n+=8,a.xMin=i.readShort(t,n),n+=2,a.yMin=i.readShort(t,n),n+=2,a.xMax=i.readShort(t,n),n+=2,a.yMax=i.readShort(t,n),n+=2,a.macStyle=i.readUshort(t,n),n+=2,a.lowestRecPPEM=i.readUshort(t,n),n+=2,a.fontDirectionHint=i.readShort(t,n),n+=2,a.indexToLocFormat=i.readShort(t,n),n+=2,a.glyphDataFormat=i.readShort(t,n),n+=2,a}},$.T.hhea={parseTab:function(t,n,r){var i=$.B,a={};i.readFixed(t,n),n+=4;for(var o=[`ascender`,`descender`,`lineGap`,`advanceWidthMax`,`minLeftSideBearing`,`minRightSideBearing`,`xMaxExtent`,`caretSlopeRise`,`caretSlopeRun`,`caretOffset`,`res0`,`res1`,`res2`,`res3`,`metricDataFormat`,`numberOfHMetrics`],s=0;s<o.length;s++){var c=o[s];a[c]=(c==`advanceWidthMax`||c==`numberOfHMetrics`?i.readUshort:i.readShort)(t,n+s*2)}return a}},$.T.hmtx={parseTab:function(t,n,r,i){for(var a=$.B,o=[],s=[],c=i.maxp.numGlyphs,l=i.hhea.numberOfHMetrics,u=0,d=0,f=0;f<l;)u=a.readUshort(t,n+(f<<2)),d=a.readShort(t,n+(f<<2)+2),o.push(u),s.push(d),f++;for(;f<c;)o.push(u),s.push(d),f++;return{aWidth:o,lsBearing:s}}},$.T.kern={parseTab:function(t,n,r,i){var a=$.B,o=$.T.kern;if(a.readUshort(t,n)==1)return o.parseV1(t,n,r,i);var s=a.readUshort(t,n+2);n+=4;for(var c={glyph1:[],rval:[]},l=0;l<s;l++){n+=2;var r=a.readUshort(t,n);n+=2;var u=a.readUshort(t,n);n+=2;var d=u>>>8;d&=15,d==0&&(n=o.readFormat0(t,n,c))}return c},parseV1:function(t,n,r,i){var a=$.B,o=$.T.kern;a.readFixed(t,n);var s=a.readUint(t,n+4);n+=8;for(var c={glyph1:[],rval:[]},l=0;l<s;l++){a.readUint(t,n),n+=4;var u=a.readUshort(t,n);n+=2,a.readUshort(t,n),n+=2,u&255||(n=o.readFormat0(t,n,c))}return c},readFormat0:function(t,n,r){var i=$.B,a=i.readUshort,o=-1,s=a(t,n);a(t,n+2),a(t,n+4),a(t,n+6),n+=8;for(var c=0;c<s;c++){var l=a(t,n);n+=2;var u=a(t,n);n+=2;var d=i.readShort(t,n);n+=2,l!=o&&(r.glyph1.push(l),r.rval.push({glyph2:[],vals:[]}));var f=r.rval[r.rval.length-1];f.glyph2.push(u),f.vals.push(d),o=l}return n}},$.T.loca={parseTab:function(t,n,r,i){var a=$.B,o=[],s=i.head.indexToLocFormat,c=i.maxp.numGlyphs+1;if(s==0)for(var l=0;l<c;l++)o.push(a.readUshort(t,n+(l<<1))<<1);if(s==1)for(var l=0;l<c;l++)o.push(a.readUint(t,n+(l<<2)));return o}},$.T.maxp={parseTab:function(t,n,r){var i=$.B,a=i.readUshort,o={};return i.readUint(t,n),n+=4,o.numGlyphs=a(t,n),n+=2,o}},$.T.name={parseTab:function(t,n,r){var i=$.B,a={};i.readUshort(t,n),n+=2;var o=i.readUshort(t,n);n+=2;var s=i.readUshort(t,n);n+=2;for(var c=n-6+s,l=[`copyright`,`fontFamily`,`fontSubfamily`,`ID`,`fullName`,`version`,`postScriptName`,`trademark`,`manufacturer`,`designer`,`description`,`urlVendor`,`urlDesigner`,`licence`,`licenceURL`,`---`,`typoFamilyName`,`typoSubfamilyName`,`compatibleFull`,`sampleText`,`postScriptCID`,`wwsFamilyName`,`wwsSubfamilyName`,`lightPalette`,`darkPalette`],u=i.readUshort,d=0;d<o;d++){var f=u(t,n);n+=2;var p=u(t,n);n+=2;var m=u(t,n);n+=2;var h=u(t,n);n+=2;var g=u(t,n);n+=2;var _=u(t,n);n+=2;var v=c+_,y;f==0||f==3&&p==0||f==1&&p==25?y=i.readUnicode(t,v,g/2):p==0?y=i.readASCII(t,v,g):p==1||p==3||p==4||p==5||p==10?y=i.readUnicode(t,v,g/2):f==1?(y=i.readASCII(t,v,g),console.log(`reading unknown MAC encoding `+p+` as ASCII`)):(console.log(`unknown encoding `+p+`, platformID: `+f),y=i.readASCII(t,v,g));var b=`p`+f+`,`+m.toString(16);a[b]??(a[b]={});var x=l[h];x??=`_`+h,a[b][x]=y,a[b]._lang=m}var S=$.T.name.selectOne(a),C=`fontFamily`;if(S[C]==null)for(var w in a)a[w][C]!=null&&(S[C]=a[w][C]);return S},selectOne:function(t){var n=`postScriptName`;for(var r in t)if(t[r][n]!=null&&t[r]._lang==1033)return t[r];for(var r in t)if(t[r][n]!=null&&t[r]._lang==0)return t[r];for(var r in t)if(t[r][n]!=null&&t[r]._lang==3084)return t[r];for(var r in t)if(t[r][n]!=null)return t[r];var i;for(var r in t){i=t[r];break}return console.log(`returning name table with languageID `+i._lang),i[n]==null&&i.ID!=null&&(i[n]=i.ID),i}},$.T.OS2={parseTab:function(t,n,r){var i=$.B.readUshort(t,n);n+=2;var a=$.T.OS2,o={};if(i==0)a.version0(t,n,o);else if(i==1)a.version1(t,n,o);else if(i==2||i==3||i==4)a.version2(t,n,o);else if(i==5)a.version5(t,n,o);else throw`unknown OS/2 table version: `+i;return o},version0:function(t,n,r){var i=$.B;return r.xAvgCharWidth=i.readShort(t,n),n+=2,r.usWeightClass=i.readUshort(t,n),n+=2,r.usWidthClass=i.readUshort(t,n),n+=2,r.fsType=i.readUshort(t,n),n+=2,r.ySubscriptXSize=i.readShort(t,n),n+=2,r.ySubscriptYSize=i.readShort(t,n),n+=2,r.ySubscriptXOffset=i.readShort(t,n),n+=2,r.ySubscriptYOffset=i.readShort(t,n),n+=2,r.ySuperscriptXSize=i.readShort(t,n),n+=2,r.ySuperscriptYSize=i.readShort(t,n),n+=2,r.ySuperscriptXOffset=i.readShort(t,n),n+=2,r.ySuperscriptYOffset=i.readShort(t,n),n+=2,r.yStrikeoutSize=i.readShort(t,n),n+=2,r.yStrikeoutPosition=i.readShort(t,n),n+=2,r.sFamilyClass=i.readShort(t,n),n+=2,r.panose=i.readBytes(t,n,10),n+=10,r.ulUnicodeRange1=i.readUint(t,n),n+=4,r.ulUnicodeRange2=i.readUint(t,n),n+=4,r.ulUnicodeRange3=i.readUint(t,n),n+=4,r.ulUnicodeRange4=i.readUint(t,n),n+=4,r.achVendID=i.readASCII(t,n,4),n+=4,r.fsSelection=i.readUshort(t,n),n+=2,r.usFirstCharIndex=i.readUshort(t,n),n+=2,r.usLastCharIndex=i.readUshort(t,n),n+=2,r.sTypoAscender=i.readShort(t,n),n+=2,r.sTypoDescender=i.readShort(t,n),n+=2,r.sTypoLineGap=i.readShort(t,n),n+=2,r.usWinAscent=i.readUshort(t,n),n+=2,r.usWinDescent=i.readUshort(t,n),n+=2,n},version1:function(t,n,r){var i=$.B;return n=$.T.OS2.version0(t,n,r),r.ulCodePageRange1=i.readUint(t,n),n+=4,r.ulCodePageRange2=i.readUint(t,n),n+=4,n},version2:function(t,n,r){var i=$.B,a=i.readUshort;return n=$.T.OS2.version1(t,n,r),r.sxHeight=i.readShort(t,n),n+=2,r.sCapHeight=i.readShort(t,n),n+=2,r.usDefault=a(t,n),n+=2,r.usBreak=a(t,n),n+=2,r.usMaxContext=a(t,n),n+=2,n},version5:function(t,n,r){var i=$.B.readUshort;return n=$.T.OS2.version2(t,n,r),r.usLowerOpticalPointSize=i(t,n),n+=2,r.usUpperOpticalPointSize=i(t,n),n+=2,n}},$.T.post={parseTab:function(t,n,r){var i=$.B,a={};return a.version=i.readFixed(t,n),n+=4,a.italicAngle=i.readFixed(t,n),n+=4,a.underlinePosition=i.readShort(t,n),n+=2,a.underlineThickness=i.readShort(t,n),n+=2,a}},$.T.SVG={parseTab:function(t,n,r){var i=$.B,a={entries:[],svgs:[]},o=n;i.readUshort(t,n),n+=2;var s=i.readUint(t,n);n+=4,i.readUint(t,n),n+=4,n=s+o;var c=i.readUshort(t,n);n+=2;for(var l=0;l<c;l++){var u=i.readUshort(t,n);n+=2;var d=i.readUshort(t,n);n+=2;var f=i.readUint(t,n);n+=4;var p=i.readUint(t,n);n+=4;var m=new Uint8Array(t.buffer,o+f+s,p);m[0]==31&&m[1]==139&&m[2]==8&&(m=Hx.inflate(m));for(var h=i.readUTF8(m,0,m.length),g=u;g<=d;g++)a.entries[g]=a.svgs.length;a.svgs.push(h)}return a}},$.T.sbix={parseTab:function(t,n,r,i){for(var a=i.maxp.numGlyphs,o=n,s=$.B,c=s.readUint(t,n+4),l=[],u=c-1;u<c;u++)for(var d=o+s.readUint(t,n+8+u*4),f=0;f<a;f++){var p=s.readUint(t,d+4+f*4),m=s.readUint(t,d+4+f*4+4);if(p==m)l[f]=null;else{var h=d+p,g=s.readASCII(t,h+4,4);if(g!=`png `)throw g;l[f]=new Uint8Array(t.buffer,t.byteOffset+h+8,m-p-8)}}return l}},$.T.colr={parseTab:function(t,n,r){var i=$.B,a=n;n+=2;var o=i.readUshort(t,n);n+=2;var s=i.readUint(t,n);n+=4;var c=i.readUint(t,n);n+=4;var l=i.readUshort(t,n);n+=2;for(var u={},d=a+s,f=0;f<o;f++)u[`g`+i.readUshort(t,d)]=[i.readUshort(t,d+2),i.readUshort(t,d+4)],d+=6;var p=[];d=a+c;for(var f=0;f<l;f++)p.push(i.readUshort(t,d),i.readUshort(t,d+2)),d+=4;return[u,p]}},$.T.cpal={parseTab:function(t,n,r){var i=$.B,a=n,o=i.readUshort(t,n);if(n+=2,o==0){i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2;var s=i.readUshort(t,n);n+=2;var c=i.readUint(t,n);return n+=4,new Uint8Array(t.buffer,a+c,s*4)}throw o}},$.T.GSUB={parseTab:function(t,n,r,i){var a=$.B,o=a.readUshort;a.readUint;var s=n;o(t,s),s+=2,o(t,s),s+=2,o(t,s),s+=2;var c=o(t,s);s+=2,o(t,s),s+=2,s=n+c;var l={},u=o(t,s);s+=2;for(var d=0;d<u;d++){var f=a.readASCII(t,s,4);s+=4,o(t,s),s+=2,l[f]=!0}return l}},$.T.fvar={parseTab:function(t,n,r,i){var a=i.name,o=n,s=$.B,c=[],l=[];o+=8;var u=s.readUshort(t,o);o+=2,o+=2;var d=s.readUshort(t,o);o+=2;var f=s.readUshort(t,o);o+=2;for(var p=0;p<u;p++){var m=s.readASCII(t,o,4),h=s.readFixed(t,o+4),g=s.readFixed(t,o+8),_=s.readFixed(t,o+12),v=s.readUshort(t,o+16),y=s.readUshort(t,o+18);c.push([m,h,g,_,v,a[`_`+y]]),o+=20}for(var p=0;p<d;p++){for(var b=s.readUshort(t,o),x=null,v=s.readUshort(t,o+2),S=[],C=0;C<u;C++)S.push(s.readFixed(t,o+4+C*4));o+=4+u*4,(f&3)==2&&(x=s.readUshort(t,o),o+=2),l.push([a[`_`+b],v,S,x])}return[c,l]}},$.T.gvar=(function(){var t=16384,n=$.B;function r(t,r,i){for(var a=[],o=0;o<i;o++)a.push(n.readF2dot14(t,r+o*2));return a}function i(i,a,o,s,c){for(var l=[],u=0;u<o;u++){var d=n.readUshort(i,a);a+=2;var f=n.readUshort(i,a),p=f&61440;f&=4095,a+=2;var m=null,h=null,g=null;p&32768&&(m=r(i,a,s),a+=s*2),p&t&&(h=r(i,a,s),a+=s*2),p&t&&(g=r(i,a,s),a+=s*2),l.push([d,f,p,h,m,g])}return l}function a(t,r,i){var a=t[r];if(r++,a==0)return[[],r];127<a&&(a=(a&127)<<8|t[r++]);for(var o=[],s=0;o.length<a;){var c=t[r];r++;var l=!!(c&128);c=(c&127)+1;for(var u=0;u<c;u++){var d=0;l?(d=n.readUshort(t,r),r+=2):(d=t[r],r++),s+=d,o.push(s)}}return[o,r]}function o(t,o,s,c){var l=o+4,u=n.readUshort(t,l);l+=2;var d=n.readUshort(t,l);l+=2;var f=n.readUint(t,l);l+=4;var p=n.readUshort(t,l);l+=2,n.readUshort(t,l),l+=2;var m=n.readUint(t,l);l+=4;for(var h=[],g=0;g<p+1;g++)h.push(n.readUint(t,l+g*4));var _=[],v=[],y=[];l=o+f;for(var g=0;g<d;g++){var b=r(t,l+g*u*2,u),x=[],S=[];_.push(b),v.push(x),y.push(S);for(var C=0;C<u;C++)x[C]=Math.min(b[C],0),S[C]=Math.max(b[C],0)}for(var w=new Int8Array(t.buffer),T=[],g=0;g<p;g++){l=o+m+h[g];var E=n.readUshort(t,l);l+=2;var D=E&32768;E&=4095;var O=n.readUshort(t,l);l+=2;var k=i(t,l,E,u,o+m+h[g+1]),A=[];T.push(A),l=o+m+h[g]+O;var j=null;if(D){var M=a(t,l,g);j=M[0],l=M[1]}for(var ee=0;ee<E;ee++){var te=k[ee],N=l+te[0],ne=j;if(te[2]&8192){var M=a(t,l,g);ne=M[0],l=M[1]}for(var re=[];l<N;){var ie=t[l++],P=(ie&63)+1;if(ie&128)for(var C=0;C<P;C++)re.push(0);else if(ie&64){for(var C=0;C<P;C++)re.push(n.readShort(t,l+C*2));l+=P*2}else{for(var C=0;C<P;C++)re.push(w[l+C]);l+=P}}var ae=te[1];if(A.push([[te[3]?te[3]:v[ae],te[4]?te[4]:_[ae],te[5]?te[5]:y[ae]],re,ne.length==0?null:ne]),ne.length!=0&&ne.length*2!=re.length)throw`e`}}return T}return{parseTab:o}})(),$.T.avar={parseTab:function(t,n,r,i){var a=n,o=$.B,s=[];a+=6;var c=o.readUshort(t,a);a+=2;for(var l=0;l<c;l++){var u=o.readUshort(t,a);a+=2;var d=[];s.push(d);for(var f=0;f<u;f++){var p=o.readF2dot14(t,a),m=o.readF2dot14(t,a+2);a+=4,d.push(p,m)}}return s}},$.T.HVAR={parseTab:function(t,n,r,i){var a=n,o=n,s=$.B;a+=4;var c=s.readUint(t,a);a+=4;var l=s.readUint(t,a);a+=4;var u=s.readUint(t,a);a+=4;var d=s.readUint(t,a);if(a+=4,u!=0||d!=0)throw u;a=o+c;var f=a,p=s.readUshort(t,a);if(a+=2,p!=1)throw`e`;var m=s.readUint(t,a);a+=4;var h=s.readUshort(t,a);a+=2;for(var g=[],_=0;_<h;_++)g.push(s.readUint(t,a+_*4));a+=h*4,a=f+m;var v=s.readUshort(t,a);a+=2;var y=s.readUshort(t,a);a+=2;for(var b=[],_=0;_<y;_++){var x=[[],[],[]];b.push(x);for(var S=0;S<v;S++)x[0].push(s.readF2dot14(t,a+0)),x[1].push(s.readF2dot14(t,a+2)),x[2].push(s.readF2dot14(t,a+4)),a+=6}for(var C=new Int8Array(t.buffer),w=[],_=0;_<g.length;_++){a=o+c+g[_];var T=[];w.push(T);var E=s.readUshort(t,a);a+=2;var D=s.readUshort(t,a);if(a+=2,D&32768)throw`e`;var y=s.readUshort(t,a);a+=2;for(var O=[],S=0;S<y;S++)O.push(s.readUshort(t,a+S*2));a+=y*2;for(var k=0;k<E;k++){for(var A=[],j=0;j<y;j++)A.push(j<D?s.readShort(t,a):C[a]),a+=j<D?2:1;var M=Array(b.length);M.fill(0),T.push(M);for(var S=0;S<O.length;S++)M[O[S]]=A[S]}}a=o+l;var p=t[a++];if(p!=0)throw`e`;var ee=t[a++],te=s.readUshort(t,a);a+=2;for(var N=15,ne=((ee&48)>>4)+1,re=[],_=0;_<te;_++){var ie=0;ne==1?ie=t[a++]:(ie=s.readUshort(t,a),a+=2);var P=ie>>(ee&N)+1,ae=ie&(1<<(ee&N)+1)-1;re.push(w[P][ae])}return[b,re]}},$.U=(function(){var t={MoveTo:function(t,n,r){t.cmds.push(`M`),t.crds.push(n,r)},LineTo:function(t,n,r){t.cmds.push(`L`),t.crds.push(n,r)},CurveTo:function(t,n,r,i,a,o,s){t.cmds.push(`C`),t.crds.push(n,r,i,a,o,s)},qCurveTo:function(t,n,r,i,a){t.cmds.push(`Q`),t.crds.push(n,r,i,a)},ClosePath:function(t){t.cmds.push(`Z`)}};function n(t,n,r,i){var a=n[r],o=n[r+1],s=t.kern;if(s){var c=s.glyph1.indexOf(a);if(c!=-1){var l=s.rval[c].glyph2.indexOf(o);if(l!=-1)return[0,0,s.rval[c].vals[l],0]}}return[0,0,0,0]}function r(t,r,i){i??={};var a=i.ltr;i.fts;var o=i.axs;t.fvar&&o==null&&(o=t.fvar[1][t._index][2]);var s=t.HVAR;o&&s&&(o=p(t,o));for(var c=[],u=0;u<r.length;u++){var d=r.codePointAt(u);d>65535&&u++,c.push(l(t,d))}for(var m=[],h=0,u=0;u<c.length;u++){var g=n(t,c,u,a),_=c[u],v=t.hmtx.aWidth[_]+g[2];if(s&&s[1][_])for(var y=s[1][_],b=0;b<s[0].length;b++)v+=f(s[0][b],o)*y[b];m.push({g:_,cl:u,dx:0,dy:0,ax:v,ay:0}),h+=v}return m}function i(t,n,r){var i={cmds:[],crds:[]},a=0,o=0,s,c;r&&(s=r.clr,c=r.axs);for(var l=0;l<n.length;l++){for(var d=n[l],f=u(t,d.g,!1,c),p=f.crds,m=0;m<p.length;m+=2)i.crds.push(p[m]+a+d.dx),i.crds.push(p[m+1]+o+d.dy);s&&i.cmds.push(s);for(var m=0;m<f.cmds.length;m++)i.cmds.push(f.cmds[m]);var h=i.cmds.length;s&&h!=0&&i.cmds[h-1]!=`X`&&i.cmds.push(`X`),a+=d.ax,o+=d.ay}return{cmds:i.cmds,crds:i.crds}}function a(t,n,r){for(var i=0,a=~~(t.length/n);i+1!=a;){var o=i+(a-i>>>1);t[o*n]<=r?i=o:a=o}return i*n}for(var o=[9,10,11,12,13,32,133,160,5760,6158,8232,8233,8239,8288,12288,65279],s={},c=0;c<o.length;c++)s[o[c]]=1;for(var c=8192;c<=8205;c++)s[c]=1;function l(t,n){if(t._ctab==null){for(var r=t.cmap,i=-1,o=[`p3e10`,`p0e4`,`p3e1`,`p1e0`,`p0e3`,`p0e1`,`p3e0`,`p3e5`],c=0;c<o.length;c++)if(r.ids[o[c]]!=null){i=r.ids[o[c]];break}if(i==-1)throw`no familiar platform and encoding!`;t._ctab=r.tables[i]}var l=t._ctab,u=l.format,d=-1;if(u==0)d=n>=l.map.length?0:l.map[n];else if(u==4){var f=l.endCount;if(d=0,n<=f[f.length-1]){var p=a(f,1,n);if(f[p]<n&&p++,n>=l.startCount[p]){var m=0;m=l.idRangeOffset[p]==0?n+l.idDelta[p]:l.glyphIdArray[n-l.startCount[p]+(l.idRangeOffset[p]>>1)-(l.idRangeOffset.length-p)],d=m&65535}}}else if(u==6){var h=n-l.firstCode,g=l.glyphIdArray;d=h<0||h>=g.length?0:g[h]}else if(u==12){var _=l.groups;if(d=0,n<=_[_.length-2]){var c=a(_,3,n);_[c]<=n&&n<=_[c+1]&&(d=_[c+2]+(n-_[c]))}}else throw`unknown cmap table format `+l.format;var v=t[`SVG `],y=t.loca;return d!=0&&t[`CFF `]==null&&(v==null||v.entries[d]==null)&&y&&y[d]==y[d+1]&&s[n]==null&&(d=0),d}function u(t,n,r,i){var a={cmds:[],crds:[]};t.fvar&&(i??=t.fvar[1][t._index][2],i=p(t,i));var o=t[`SVG `],s=t[`CFF `],c=t.COLR,l=t.CBLC,f=t.CBDT,m=t.sbix,h=window.UPNG,g=null;if(l&&h)for(var _=0;_<l.length;_++)l[_][0]<=n&&n<=l[_][1]&&(g=l[_]);if(g||m&&m[n]){if(g&&g[2]!=17)throw`not a PNG`;t.__tmp??={};var v=t.__tmp[`g`+n];if(v==null){var y,b;if(m)y=m[n],b=y.length;else{var x=g[3][n-g[0]]+5;b=f[x+1]<<16|f[x+2]<<8|f[x+3],x+=4,y=new Uint8Array(f.buffer,f.byteOffset+x,b)}for(var S=``,_=0;_<b;_++)S+=String.fromCharCode(y[_]);v=t.__tmp[`g`+n]=`data:image/png;base64,`+btoa(S)}a.cmds.push(v);var w=t.head.unitsPerEm*1.15,T=Math.round(w),E=Math.round(w),D=Math.round(-E*.15);a.crds.push(0,E+D,T,E+D,T,D,0,D)}else if(o&&o.entries[n]){var O=o.entries[n];if(O!=null){if(typeof O==`number`){var k=o.svgs[O];if(typeof k==`string`){var A=new DOMParser().parseFromString(k,`image/svg+xml`);k=o.svgs[O]=A.getElementsByTagName(`svg`)[0]}O=$.U.SVG.toPath(k,n),o.entries[n]=O}a=O}}else if(r!=1&&c&&c[0][`g`+n]&&c[0][`g`+n][1]>1){function r(t){var n=t.toString(16);return(n.length==1?`0`:``)+n}for(var j=t.CPAL,M=c[0][`g`+n],_=0;_<M[1];_++){var ee=M[0]+_,te=c[1][2*ee],N=c[1][2*ee+1]*4,ne=u(t,te,te==n),re=`#`+r(j[N+2])+r(j[N+1])+r(j[N+0]);a.cmds.push(re),a.cmds=a.cmds.concat(ne.cmds),a.crds=a.crds.concat(ne.crds),a.cmds.push(`X`)}}else if(s){var ie=s.Private,P={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:ie?ie.defaultWidthX:0,open:!1};if(s.ROS){for(var ae=0;s.FDSelect[ae+2]<=n;)ae+=2;ie=s.FDArray[s.FDSelect[ae+1]].Private}C(s.CharStrings[n],P,s,ie,a)}else t.glyf&&d(n,t,a,i);return{cmds:a.cmds,crds:a.crds}}function d(t,n,r,i){var a=n.glyf[t];a??=n.glyf[t]=$.T.glyf._parseGlyf(n,t),a!=null&&(a.noc>-1?h(a,n,t,r,i):g(a,n,t,r,i))}function f(t,n){n.length;for(var r=1,i=t[0],a=t[1],o=t[2],s=0;s<n.length;s++){var c=1;c=i[s]>a[s]||a[s]>o[s]||i[s]<0&&o[s]>0&&a[s]!=0||a[s]==0?1:n[s]<i[s]||n[s]>o[s]?0:n[s]==a[s]?1:n[s]<a[s]?(n[s]-i[s])/(a[s]-i[s]):(o[s]-n[s])/(o[s]-a[s]),r*=c}return r}function p(t,n){for(var r=t.fvar,i=t.avar,a=r?r[0]:null,o=[],s=0;s<a.length;s++){var c=a[s][1],l=a[s][2],u=a[s][3],d=Math.max(c,Math.min(u,n[s]));if(d<l?o[s]=(l-d)/(c-l):d>l?o[s]=(d-l)/(u-l):o[s]=0,i&&o[s]!=-1){for(var f=i[s],p=0;p<f.length&&!(f[p]>=o[s]);p+=2);var m=(o[s]-f[p-2])/(f[p]-f[p-2]);o[s]=m*f[p+1]+(1-m)*f[p-1]}}return o}function m(t,n,r,i,a){var o=r.length,s=Array(o*2+8);s.fill(0);for(var c=0;c<o;c++){var l=0,u=0,d=n.indexOf(c);if(d!=-1)l=t[d],u=t[n.length+d];else{for(var f=0;a[f]<c;)f++;for(var p=f==0?0:a[f-1]+1,m=a[f],h=-1,g=-1,_=0;_<n.length;_++){var v=n[_];v<p||v>m||v>=o||(h=_,g==-1&&(g=_))}for(var _=0;_<n.length;_++){var v=n[_];if(!(v<p||v>m||v>=o)&&(v<c&&(h=_),c<v)){g=_;break}}for(var y=0;y<2;y++){var b=y==0?r:i,x=y*n.length,S=0,C=b[n[h]],w=b[n[g]],T=b[c],E=t[x+h],D=t[x+g];if(C==w)S=E==D?E:0;else if(T<=Math.min(C,w))S=C<w?E:D;else if(Math.max(C,w)<=T)S=C<w?D:E;else{var O=(T-C)/(w-C);S=O*D+(1-O)*E}y==0?l=S:u=S}}s[c]=l,s[o+4+c]=u}return s}function h(n,r,i,a,o){var s=n.xs,c=n.ys;if(r.fvar&&o){s=s.slice(0),c=c.slice(0);for(var l=r.gvar,u=l?l[i]:null,d=0;d<u.length;d++){var p=u[d][0],h=f(p,o);if(!(h<1e-9)){var g=u[d][1],_=u[d][2];if(_&&(g=u[d][1]=m(g,_,s,c,n.endPts),u[d][2]=null),g.length==s.length*2+8)for(var v=0;v<s.length;v++)s[v]+=h*g[v],c[v]+=h*g[v+s.length+4]}}}for(var y=0;y<n.noc;y++){for(var b=y==0?0:n.endPts[y-1]+1,x=n.endPts[y],v=b;v<=x;v++){var S=v==b?x:v-1,C=v==x?b:v+1,w=n.flags[v]&1,T=n.flags[S]&1,E=n.flags[C]&1,D=s[v],O=c[v];if(v==b){if(w){if(T)t.MoveTo(a,s[S],c[S]);else{t.MoveTo(a,D,O);continue}}else T?t.MoveTo(a,s[S],c[S]):t.MoveTo(a,Math.floor((s[S]+D)*.5),Math.floor((c[S]+O)*.5))}w?T&&t.LineTo(a,D,O):E?t.qCurveTo(a,D,O,s[C],c[C]):t.qCurveTo(a,D,O,Math.floor((D+s[C])*.5),Math.floor((O+c[C])*.5))}t.ClosePath(a)}}function g(t,n,r,i,a){var o=[0,0,0,0,0,0],s=[0,0,0,0,0,0],c=t.parts.length;if(n.fvar&&a)for(var l=n.gvar,u=l?l[r]:null,p=0;p<u.length;p++){var m=u[p][0],h=f(m,a);if(!(h<1e-6)){var g=u[p][1],_=u[p][2];if(_==null)for(var v=0;v<c;v++)o[v]+=h*g[v],s[v]+=h*g[v+c+4];else for(var y=0;y<_.length;y++){var v=_[y];o[v]+=h*g[0],s[v]+=h*g[0+c]}}}for(var y=0;y<c;y++){var b={cmds:[],crds:[]},x=t.parts[y];d(x.glyphIndex,n,b,a);for(var S=x.m,C=S.tx+o[y],w=S.ty+s[y],v=0;v<b.crds.length;v+=2){var T=b.crds[v],E=b.crds[v+1];i.crds.push(T*S.a+E*S.c+C),i.crds.push(T*S.b+E*S.d+w)}for(var v=0;v<b.cmds.length;v++)i.cmds.push(b.cmds[v])}}function _(t,n){var r=t.cmds,i=t.crds;n??=5;function a(t){return parseFloat(t.toFixed(n))}function o(t){for(var n=[],r=!1,i=``,a=0;a<t.length;a++){var o=t[a],s=typeof o==`number`;if(!s){if(o==i&&o.length==1&&o!=`m`)continue;i=o}r&&s&&o>=0&&n.push(` `),n.push(o),r=s}return n.join(``)}for(var s=[],c=0,l={M:2,L:2,Q:4,C:6},u=0,d=0,f=0,p=0,m=0,h=0,g=0;g<r.length;g++){var _=r[g],v=l[_]?l[_]:0,y=[],b,x,S,C;if(_==`L`)b=i[c]-u,x=i[c+1]-d,S=a(b+f),C=a(x+p),r[g+1]==`Z`&&i[c]==m&&i[c+1]==h?(S=b,C=x):S==0&&C==0||(S==0?y.push(`v`,C):C==0?y.push(`h`,S):y.push(`l`,S,C));else{y.push(_.toLowerCase());for(var w=0;w<v;w+=2)b=i[c+w]-u,x=i[c+w+1]-d,S=a(b+f),C=a(x+p),y.push(S,C)}v!=0&&(f+=b-S,p+=x-C);for(var T=y,w=0;w<T.length;w++)s.push(T[w]);v!=0&&(c+=v,u=i[c-2],d=i[c-1]),_==`M`&&(m=u,h=d),_==`Z`&&(u=m,d=h)}return o(s)}function v(t){var n={cmds:[],crds:[]};return $.U.SVG.svgToPath(t,n),{cmds:n.cmds,crds:n.crds}}function y(t,n,r,i){for(var a=n>>1,o=r>>1,s=i&&i.length==a*o*4?i:new Uint8Array(a*o*4),c=new Uint32Array(t.buffer),l=new Uint32Array(s.buffer),u=0;u<o;u++)for(var d=0;d<a;d++){var f=u*a+d,p=(u<<1)*n+(d<<1),m=c[p],h=c[p+1],g=c[p+n],_=c[p+n+1],v=m>>>24,y=h>>>24,b=g>>>24,x=_>>>24,S=v+y+b+x;if(S==1020){var C=(m>>>0&255)+(h>>>0&255)+(g>>>0&255)+(_>>>0&255)+2>>>2,w=(m>>>8&255)+(h>>>8&255)+(g>>>8&255)+(_>>>8&255)+2>>>2,T=(m>>>16&255)+(h>>>16&255)+(g>>>16&255)+(_>>>16&255)+2>>>2;l[f]=255<<24|T<<16|w<<8|C}else if(S==0)l[f]=0;else{var C=(m>>>0&255)*v+(h>>>0&255)*y+(g>>>0&255)*b+(_>>>0&255)*x,w=(m>>>8&255)*v+(h>>>8&255)*y+(g>>>8&255)*b+(_>>>8&255)*x,T=(m>>>16&255)*v+(h>>>16&255)*y+(g>>>16&255)*b+(_>>>16&255)*x,E=1/S;C=~~(C*E+.5),w=~~(w*E+.5),T=~~(T*E+.5),l[f]=S+2>>>2<<24|T<<16|w<<8|C}}return{buff:s,w:a,h:o}}var b,x;function S(t,n){for(var r=0,i=t.cmds,a=t.crds,o=0;o<i.length;o++){var s=i[o];if(s==`M`)n.moveTo(a[r],a[r+1]),r+=2;else if(s==`L`)n.lineTo(a[r],a[r+1]),r+=2;else if(s==`C`)n.bezierCurveTo(a[r],a[r+1],a[r+2],a[r+3],a[r+4],a[r+5]),r+=6;else if(s==`Q`)n.quadraticCurveTo(a[r],a[r+1],a[r+2],a[r+3]),r+=4;else if(s[0]==`d`){var c=window.UPNG,l=a[r],u=a[r+1],d=a[r+2],f=a[r+3],p=a[r+4],m=a[r+5],h=a[r+6],g=a[r+7];if(r+=8,c==null){n.moveTo(l,u),n.lineTo(d,f),n.lineTo(p,m),n.lineTo(h,g),n.closePath();continue}for(var _=d-l,v=f-u,S=h-l,C=g-u,w=atob(s.slice(22)),T=new Uint8Array(w.length),E=0;E<w.length;E++)T[E]=w.charCodeAt(E);for(var D=c.decode(T.buffer),O=D.width,k=D.height,A=new Uint8Array(c.toRGBA8(D)[0]),j=n.getTransform(),M=Math.sqrt(Math.abs(j.a*j.d-j.b*j.c))*Math.sqrt(S*S+C*C)/k;M<.5;){var ee=y(A,O,k);A=ee.buff,O=ee.w,k=ee.h,M*=2}b??(b=document.createElement(`canvas`),x=b.getContext(`2d`)),(b.width!=O||b.height!=k)&&(b.width=O,b.height=k),x.putImageData(new ImageData(new Uint8ClampedArray(A.buffer),O,k),0,0),n.save(),n.transform(_,v,S,C,l,u),n.scale(1/O,1/k),n.drawImage(b,0,0),n.restore()}else if(s.charAt(0)==`#`||s.charAt(0)==`r`)n.beginPath(),n.fillStyle=s;else if(s.charAt(0)==`O`&&s!=`OX`){n.beginPath();var te=s.split(`-`);n.lineWidth=parseFloat(te[2]),n.lineCap=[`butt`,`round`,`square`][parseFloat(te[3])],n.lineJoin=[`miter`,`round`,`bevel`][parseFloat(te[4])],n.miterLimit=parseFloat(te[5]),n.lineDashOffset=parseFloat(te[6]),n.setLineDash(te[7].split(`,`).map(parseFloat)),n.strokeStyle=te[1]}else s==`Z`?n.closePath():s==`X`?n.fill():s==`OX`&&n.stroke()}}function C(n,r,i,a,o){for(var s=r.stack,c=r.nStems,l=r.haveWidth,u=r.width,d=r.open,f=0,p=r.x,m=r.y,h=0,g=0,_=0,v=0,y=0,b=0,x=0,S=0,w=0,T=0,E=$.T.CFF,D=a.nominalWidthX,O={val:0,size:0};f<n.length;){E.getCharString(n,f,O);var k=O.val;if(f+=O.size,k==`o1`||k==`o18`){var A=s.length%2!=0;A&&!l&&(u=s.shift()+D),c+=s.length>>1,s.length=0,l=!0}else if(k==`o3`||k==`o23`){var A=s.length%2!=0;A&&!l&&(u=s.shift()+D),c+=s.length>>1,s.length=0,l=!0}else if(k==`o4`)s.length>1&&!l&&(u=s.shift()+D,l=!0),d&&t.ClosePath(o),m+=s.pop(),t.MoveTo(o,p,m),d=!0;else if(k==`o5`)for(;s.length>0;)p+=s.shift(),m+=s.shift(),t.LineTo(o,p,m);else if(k==`o6`||k==`o7`)for(var j=s.length,M=k==`o6`,ee=0;ee<j;ee++){var te=s.shift();M?p+=te:m+=te,M=!M,t.LineTo(o,p,m)}else if(k==`o8`||k==`o24`){for(var j=s.length,N=0;N+6<=j;)h=p+s.shift(),g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),p=_+s.shift(),m=v+s.shift(),t.CurveTo(o,h,g,_,v,p,m),N+=6;k==`o24`&&(p+=s.shift(),m+=s.shift(),t.LineTo(o,p,m))}else if(k==`o11`)break;else if(k==`o1234`||k==`o1235`||k==`o1236`||k==`o1237`)k==`o1234`&&(h=p+s.shift(),g=m,_=h+s.shift(),v=g+s.shift(),w=_+s.shift(),T=v,y=w+s.shift(),b=v,x=y+s.shift(),S=m,p=x+s.shift(),t.CurveTo(o,h,g,_,v,w,T),t.CurveTo(o,y,b,x,S,p,m)),k==`o1235`&&(h=p+s.shift(),g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),w=_+s.shift(),T=v+s.shift(),y=w+s.shift(),b=T+s.shift(),x=y+s.shift(),S=b+s.shift(),p=x+s.shift(),m=S+s.shift(),s.shift(),t.CurveTo(o,h,g,_,v,w,T),t.CurveTo(o,y,b,x,S,p,m)),k==`o1236`&&(h=p+s.shift(),g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),w=_+s.shift(),T=v,y=w+s.shift(),b=v,x=y+s.shift(),S=b+s.shift(),p=x+s.shift(),t.CurveTo(o,h,g,_,v,w,T),t.CurveTo(o,y,b,x,S,p,m)),k==`o1237`&&(h=p+s.shift(),g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),w=_+s.shift(),T=v+s.shift(),y=w+s.shift(),b=T+s.shift(),x=y+s.shift(),S=b+s.shift(),Math.abs(x-p)>Math.abs(S-m)?p=x+s.shift():m=S+s.shift(),t.CurveTo(o,h,g,_,v,w,T),t.CurveTo(o,y,b,x,S,p,m));else if(k==`o14`){if(s.length>0&&s.length!=4&&!l&&(u=s.shift()+i.nominalWidthX,l=!0),s.length==4){var ne=s.shift(),re=s.shift(),ie=s.shift(),P=s.shift(),ae=E.glyphBySE(i,ie),oe=E.glyphBySE(i,P);C(i.CharStrings[ae],r,i,a,o),r.x=ne,r.y=re,C(i.CharStrings[oe],r,i,a,o)}d&&=(t.ClosePath(o),!1)}else if(k==`o19`||k==`o20`){var A=s.length%2!=0;A&&!l&&(u=s.shift()+D),c+=s.length>>1,s.length=0,l=!0,f+=c+7>>3}else if(k==`o21`)s.length>2&&!l&&(u=s.shift()+D,l=!0),m+=s.pop(),p+=s.pop(),d&&t.ClosePath(o),t.MoveTo(o,p,m),d=!0;else if(k==`o22`)s.length>1&&!l&&(u=s.shift()+D,l=!0),p+=s.pop(),d&&t.ClosePath(o),t.MoveTo(o,p,m),d=!0;else if(k==`o25`){for(;s.length>6;)p+=s.shift(),m+=s.shift(),t.LineTo(o,p,m);h=p+s.shift(),g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),p=_+s.shift(),m=v+s.shift(),t.CurveTo(o,h,g,_,v,p,m)}else if(k==`o26`)for(s.length%2&&(p+=s.shift());s.length>0;)h=p,g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),p=_,m=v+s.shift(),t.CurveTo(o,h,g,_,v,p,m);else if(k==`o27`)for(s.length%2&&(m+=s.shift());s.length>0;)h=p+s.shift(),g=m,_=h+s.shift(),v=g+s.shift(),p=_+s.shift(),m=v,t.CurveTo(o,h,g,_,v,p,m);else if(k==`o10`||k==`o29`){var se=k==`o10`?a:i;if(s.length==0)console.log(`error: empty stack`);else{var ce=s.pop(),le=se.Subrs[ce+se.Bias];r.x=p,r.y=m,r.nStems=c,r.haveWidth=l,r.width=u,r.open=d,C(le,r,i,a,o),p=r.x,m=r.y,c=r.nStems,l=r.haveWidth,u=r.width,d=r.open}}else if(k==`o30`||k==`o31`){var j,ue=s.length,N=0,de=k==`o31`;for(j=ue&-3,N+=ue-j;N<j;)de?(h=p+s.shift(),g=m,_=h+s.shift(),v=g+s.shift(),m=v+s.shift(),j-N==5?(p=_+s.shift(),N++):p=_,de=!1):(h=p,g=m+s.shift(),_=h+s.shift(),v=g+s.shift(),p=_+s.shift(),j-N==5?(m=v+s.shift(),N++):m=v,de=!0),t.CurveTo(o,h,g,_,v,p,m),N+=4}else if((k+``).charAt(0)==`o`)throw console.log(`Unknown operation: `+k,n),k;else s.push(k)}r.x=p,r.y=m,r.nStems=c,r.haveWidth=l,r.width=u,r.open=d}function w(t,n){var r=function(t){var n=0;return t&4294967168?t&4294965248?t&4294901760?t&4292870144||(n=4):n=3:n=2:n=1,n};fetch(t).then(function(t){return t.arrayBuffer()}).then(function(t){return WebAssembly.instantiate(t)}).then(function(t){console.log(`HB ready`);var i=t.instance.exports,a=i.memory,o,s,c,l,u,d,f,p,m;$.U.shapeHB=(function(){var t=function(t){for(var n=i.hb_buffer_get_length(t),r=[],a=i.hb_buffer_get_glyph_infos(t,0)>>>2,o=i.hb_buffer_get_glyph_positions(t,0)>>>2,l=0;l<n;++l){var u=a+l*5,d=o+l*5;r.push({g:s[u+0],cl:s[u+2],ax:c[d+0],ay:c[d+1],dx:c[d+2],dy:c[d+3]})}return r},n;return function(h,g,_){var v=h._data,y=h.name.postScriptName,b=_.ltr,x=_.fts,S=_.axs;if(h.fvar&&S==null&&(S=h.fvar[1][h._index][2]),o=new Uint8Array(a.buffer),s=new Uint32Array(a.buffer),c=new Int32Array(a.buffer),l=new Float32Array(a.buffer),u!=y&&(d!=null&&(i.hb_blob_destroy(d),i.free(f),i.hb_face_destroy(p),i.hb_font_destroy(m)),f=i.malloc(v.byteLength),o.set(v,f),d=i.hb_blob_create(f,v.byteLength,2,0,0),p=i.hb_face_create(d,h._index),m=i.hb_font_create(p),u=y),window.TextEncoder==null)alert(`Your browser is too old. Please, update it.`);else{n??=new window.TextEncoder(`utf8`);var C=i.hb_buffer_create(),w=n.encode(g),T=w.length,E=i.malloc(T);o.set(w,E),i.hb_buffer_add_utf8(C,E,T,0,T),i.free(E);var D=$.B,O=0;if(x){O=i.malloc(16*x.length);for(var k=0;k<x.length;k++){var A=x[k],j=O+k*16,M=j>>>2;D.writeASCII(o,j,A[0].split(``).reverse().join(``)),s[M+1]=A[1],s[M+2]=A[2],s[M+3]=A[3]}}var ee=0;if(S&&h.fvar){var te=h.fvar[0];ee=i.malloc(8*S.length);for(var k=0;k<S.length;k++){var j=ee+k*8,M=j>>>2;D.writeASCII(o,j,te[k][0].split(``).reverse().join(``)),l[M+1]=S[k]}}S&&i.hb_font_set_variations(m,ee,S.length),i.hb_buffer_set_direction(C,b?4:5),i.hb_buffer_guess_segment_properties(C),i.hb_shape(m,C,O,x?x.length:0);var N=t(C);i.hb_buffer_destroy(C),x&&i.free(O),S&&i.free(ee);var ne=N.slice(0);b||ne.reverse();for(var re=0,ie=0,k=1;k<ne.length;k++){for(var P=ne[k],ae=P.cl;;){var oe=g.codePointAt(re),se=r(oe);if(ie+se<=ae)ie+=se,re+=oe<=65535?1:2;else break}P.cl=re}return N}}})(),n()})}return{shape:r,shapeToPath:i,codeToGlyph:l,glyphToPath:u,pathToSVG:_,SVGToPath:v,pathToContext:S,initHB:w}})();function Ux(t){let n=[];for(let r=0;r<t;r++)n.push(r);return n}var Wx=class t{constructor(t,n,r,i){this._totalLength=void 0,this.A=t,this.B=n,this.C=r,this.D=i}static sampleSpacing(){return 2}tangentAtParameter(t){let n=Math.max(0,Math.min(1,t));if(n===0||n===1){let t,r;n===0?this.A.x===this.B.x&&this.A.y===this.B.y?(t=this.C.x-this.A.x,r=this.C.y-this.A.y):(t=this.B.x-this.A.x,r=this.B.y-this.A.y):this.D.x===this.C.x&&this.D.y===this.C.y?(t=this.D.x-this.B.x,r=this.D.y-this.B.y):(t=this.D.x-this.C.x,r=this.D.y-this.C.y);let i=Math.hypot(t,r);return Math.abs(i)>1e-4&&(t/=i,r/=i),{x:t,y:r}}let r=1-n,i=3*this.D.x*n**2-3*this.C.x*n**2+6*this.C.x*r*n-6*this.B.x*r*n+3*this.B.x*r**2-3*this.A.x*r**2,a=3*this.D.y*n**2-3*this.C.y*n**2+6*this.C.y*r*n-6*this.B.y*r*n+3*this.B.y*r**2-3*this.A.y*r**2,o=Math.hypot(i,a);return Math.abs(o)>1e-4&&(i/=o,a/=o),{x:i,y:a}}isLinear(){return this.A.x===this.B.x&&this.A.y===this.B.y&&this.C.x===this.D.x&&this.C.y===this.D.y}pointAtParameter(t){let n=Math.max(0,Math.min(1,t));return{x:(1-n)**3*this.A.x+3*(1-n)**2*n*this.B.x+3*(1-n)*n**2*this.C.x+n**3*this.D.x,y:(1-n)**3*this.A.y+3*(1-n)**2*n*this.B.y+3*(1-n)*n**2*this.C.y+n**3*this.D.y}}getTotalLength(){if(this._totalLength===void 0){if(this.isLinear())this._totalLength=Math.hypot(this.D.x-this.A.x,this.D.y-this.A.y);else{let n=Math.max(10,Math.ceil((Math.hypot(this.B.x-this.A.x,this.B.y-this.A.y)+Math.hypot(this.C.x-this.B.x,this.C.y-this.B.y)+Math.hypot(this.D.x-this.C.x,this.D.y-this.C.y))/t.sampleSpacing())),r=Ux(n).map(t=>this.pointAtParameter(t/(n-1))),i=0;for(let t=1;t<r.length;t++)i+=Math.hypot(r[t].x-r[t-1].x,r[t].y-r[t-1].y);this._totalLength=i}}return this._totalLength}},Gx=class{constructor(t){this.samples=[],this.segments=t;let n=t.map(t=>t.getTotalLength()),r=[0];for(let t=1;t<n.length;t++)r.push(r[t-1]+n[t-1]);this._totalLength=r[r.length-1]+n[n.length-1];let i=t.map(t=>Math.max(4,Math.ceil(t.getTotalLength()/Wx.sampleSpacing()))),a=i.reduce((t,n)=>t+n),o=1/a/10,s=this._totalLength/a;this.samples.push({dist:0,pt:this.segments[0].A,tan:this.segments[0].tangentAtParameter(0),segIdx:0,t:0}),t.forEach((t,n)=>{let a=i[n],c=Ux(a+1).map(t=>t/a),l=c.map(n=>t.pointAtParameter(n)),u;for(let n=0;n<4;n++){u=Ux(a).map(t=>Math.hypot(l[t+1].x-l[t].x,l[t+1].y-l[t].y));let n=u.map(t=>t-s),r=0;for(let i=1;i<c.length-1;i++)r+=n[i-1],c[i]-=o*r,l[i]=t.pointAtParameter(c[i])}let d=0;l.slice(1).forEach((t,i)=>{d+=u[i],this.samples.push({dist:r[n]+d,pt:t,tan:this.segments[n].tangentAtParameter(c[i+1]),segIdx:n,t:c[i+1]})})}),this._jumps=[],this.segmentStartEnds=[{start:0,end:0}];for(let t=1;t<this.samples.length;t++){let n=this.samples[t-1],r=this.samples[t];if(r.segIdx===n.segIdx)this.segmentStartEnds[this.segmentStartEnds.length-1].end=r.dist;else{let i=r.dist-Math.hypot(this.segments[r.segIdx].A.x-r.pt.x,this.segments[r.segIdx].A.y-r.pt.y);if(this.segments[n.segIdx].D.x!==this.segments[r.segIdx].A.x||this.segments[n.segIdx].D.y!==this.segments[r.segIdx].A.y){let a={dist:i-1e-8,pt:this.segments[n.segIdx].D,tan:this.segments[n.segIdx].tangentAtParameter(1),segIdx:n.segIdx,t:1},o={dist:i+1e-8,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),segIdx:r.segIdx,t:0};this._jumps.push(i),this.samples.splice(t,0,a,o),this.segmentStartEnds[a.segIdx].end=a.dist,this.segmentStartEnds[o.segIdx]={start:o.dist,end:r.dist},t+=2}else if(r.t!==0){let n=Object.assign(Object.assign({},r),{t:0,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),dist:i});this.samples.splice(t,0,n),this.segmentStartEnds[r.segIdx]={start:n.dist,end:r.dist},t++}else this.segmentStartEnds[r.segIdx]={start:r.dist,end:r.dist}}}}jumps(){return[...this._jumps]}getTotalLength(){return this._totalLength}findClosestSampleIdx(t){let n=0,r=this.samples.length-1;for(;n<r;){let i=Math.floor((n+r)/2);if(this.samples[i].dist>t)r=i-1;else if(this.samples[i].dist<t)n=i+1;else return i}return Math.max(0,Math.min(this.samples.length-1,Math.floor((n+r)/2)))}getPointAtLength(t,n=!1){if(t<=0)return this.samples[0].pt;if(t>=this._totalLength)return this.samples[this.samples.length-1].pt;let r=this.findClosestSampleIdx(t),i=this.samples[r].dist<t?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),a=Math.abs(this.samples[i].dist-this.samples[r].dist)<1e-6?0:(t-this.samples[r].dist)/(this.samples[i].dist-this.samples[r].dist);if(n||this.samples[r].segIdx>this.samples[i].segIdx)return{x:(1-a)*this.samples[r].pt.x+a*this.samples[i].pt.x,y:(1-a)*this.samples[r].pt.y+a*this.samples[i].pt.y};if(this.samples[r].segIdx!==this.samples[i].segIdx){let t=1-this.samples[r].t+this.samples[i].t,n=t>0?(1-this.samples[r].t)/t:.5;if(a<n){let t=this.segments[this.samples[r].segIdx],i=a/n,o=(1-i)*this.samples[r].t+i;return t.pointAtParameter(o)}{let t=this.segments[this.samples[i].segIdx],r=(a-n)/(1-n)*this.samples[i].t;return t.pointAtParameter(r)}}{let t=this.segments[this.samples[r].segIdx],n=(1-a)*this.samples[r].t+a*this.samples[i].t;return t.pointAtParameter(n)}}getAngleAtLength(t,n=!1){let r=this.getTangentAtLength(t,n);return Math.atan2(r.y,r.x)}getTangentAtLength(t,n=!1){if(t<=0)return this.samples[0].tan;if(t>=this._totalLength)return this.samples[this.samples.length-1].tan;let r=this.findClosestSampleIdx(t),i=this.samples[r].dist<t?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),a=(t-this.samples[r].dist)/(this.samples[i].dist-this.samples[r].dist);if(n||this.samples[r].segIdx>this.samples[i].segIdx){let t=(1-a)*this.samples[r].tan.x+a*this.samples[i].tan.x,n=(1-a)*this.samples[r].tan.y+a*this.samples[i].tan.y,o=Math.max(Math.hypot(t,n),1e-4);return t/=o,n/=o,{x:t,y:n}}if(this.samples[r].segIdx!==this.samples[i].segIdx){if(a<.5){let t=this.segments[this.samples[r].segIdx],n=2*a,i=(1-n)*this.samples[r].t+n;return t.tangentAtParameter(i)}{let t=this.segments[this.samples[i].segIdx],n=2*(a-.5)*this.samples[i].t;return t.tangentAtParameter(n)}}{let t=this.segments[this.samples[r].segIdx],n=(1-a)*this.samples[r].t+a*this.samples[i].t;return t.tangentAtParameter(n)}}};const Kx=t=>{let n=t.slice();if(n.length<2)throw Error(`Path doesn't have enough commands: ${JSON.stringify(n)}`);if(n[0].type!==`M`)throw Error(`Path starts with ${n[0].type} instead of M!`);let r={x:n[0].x,y:n[0].y},i=Object.assign({},r),a=[];for(;n.length>0;){let t=n.shift();if(t.type===`M`)i={x:t.x,y:t.y},r=i;else if(t.type===`C`)a.push(new Wx(r,{x:t.x1,y:t.y1},{x:t.x2,y:t.y2},{x:t.x,y:t.y})),r={x:t.x,y:t.y};else if(t.type===`L`)(t.x!==r.x||t.y!==r.y)&&a.push(new Wx(r,r,{x:t.x,y:t.y},{x:t.x,y:t.y})),r={x:t.x,y:t.y};else if(t.type===`H`)t.x!==r.x&&a.push(new Wx(r,r,{x:t.x,y:r.y},{x:t.x,y:r.y})),r={x:t.x,y:r.y};else if(t.type===`V`)t.y!==r.y&&a.push(new Wx(r,r,{x:r.x,y:t.y},{x:r.x,y:t.y})),r={x:r.x,y:t.y};else if(t.type===`Q`)a.push(new Wx(r,{x:r.x+2/3*(t.x1-r.x),y:r.y+2/3*(t.y1-r.y)},{x:t.x+2/3*(t.x1-t.x),y:t.y+2/3*(t.y1-t.y)},{x:t.x,y:t.y})),r={x:t.x,y:t.y};else if(t.type===`Z`)Math.hypot(r.x-i.x,r.y-i.y)>0&&a.push(new Wx(r,r,i,i));else throw Error(`Unsupported path command ${t.type}; use only H, V, M, L, C, Z!`)}return new Gx(a)},qx={M:2,L:2,C:6,Q:4},Jx=[`ttf`,`otf`,`woff`],Yx=RegExp(`\\.(${Jx.join(`|`)})`,`i`),Xx=RegExp(`([^/]+)(\\.(?:${Jx.join(`|`)}))`,`i`),Zx=`Sorry, only TTF, OTF and WOFF files are supported.`,Qx=[`weight`,`stretch`,`style`];var $x=class{constructor(t,n,r,i,a){if(!(n instanceof FontFace))throw Error(`FontFace is required`);this._pInst=t,this.name=r,this.path=i,this.data=a,this.face=n}static hasGlyphData(t){let{font:n}=t;return typeof n==`object`&&n.data!==void 0}fontBounds(t,n,r,i,a,o){({width:i,height:a,options:o}=this._parseArgs(i,a,o));let s=o?.graphics?._renderer||this._pInst._renderer;if(!s)throw Error(`p5 or graphics required for fontBounds()`);return s.fontBounds(t,n,r,i,a)}textBounds(t,n,r,i,a,o){({width:i,height:a,options:o}=this._parseArgs(i,a,o));let s=o?.graphics?._renderer||this._pInst._renderer;if(!s)throw Error(`p5 or graphics required for fontBounds()`);return s.textBounds(t,n,r,i,a)}textToPaths(t,n,r,i,a,o){if({width:i,height:a,options:o}=this._parseArgs(i,a,o),!this.data)throw Error(`No font data available for "`+this.name+`"
Try downloading a local copy of the font file`);return this._lineateAndPathify(t,n,r,i,a,o).map(t=>t.glyphs).flat().map(t=>t.path.commands).flat()}textToPoints(t,n,r,i,a,o){return this.textToContours(t,n,r,i,a,o).reduce((t,n)=>(t.push(...n),t),[])}textToContours(t,n=0,r=0,i,a,o){({width:i,height:a,options:o}=this._parseArgs(i,a,o));let s=this.textToPaths(t,n,r,i,a,o),c=[];for(let t of s)t[0]===`M`&&c.push([]),c[c.length-1].push(t);return c.map(t=>iS(t,o,this))}textToModel(t,n,r,i,a,o){({width:i,height:a,options:o}=this._parseArgs(i,a,o));let s=o?.extrude||0,c=this.textToContours(t,n,r,i,a,o);if(!c||c.length===0)return new p5.Geometry;let l=this._pInst.buildGeometry(()=>{let t=this._pInst._renderer._validateFaces;this._pInst._renderer._validateFaces=!0,this._pInst.beginShape();for(let t of c){this._pInst.beginContour();for(let n of t)this._pInst.vertex(n.x,n.y,0);this._pInst.endContour(this._pInst.CLOSE)}this._pInst.endShape(this._pInst.CLOSE),this._pInst._renderer._validateFaces=t});if(s===0)return l;let u={},d=t=>`${t.x.toFixed(6)}-${t.y.toFixed(6)}-${t.z.toFixed(6)}`,f=[],p=[];for(let t of l.vertices){let n=d(t);n in u||(u[n]=f.length,f.push(t.copy())),p.push(u[n])}let m=l.faces.map(t=>t.map(t=>p[t])),h={};for(let t of m)for(let n=0;n<t.length;n++){let r=t[n],i=t[(n+1)%t.length],a=`${Math.min(r,i)}-${Math.max(r,i)}`;h[a]||(h[a]=[]),h[a].push([r,i])}let g=[];for(let t in h)h[t].length===1&&g.push(h[t][0]);let _=this._pInst.buildGeometry(()=>{}),v=s*.5;_.vertices=[],_.faces=[],_.edges=[];for(let[t,n]of g){let r=f[t],i=f[n],a=new I(i.x-r.x,i.y-r.y,i.z-r.z),o=new I(0,0,s),c=I.cross(a,o),l=a.mag();if(c.mag()<1e-4||l<1e-4)continue;let u=_.vertices.length;_.vertices.push(new I(r.x,r.y,r.z+v));let d=_.vertices.length;_.vertices.push(new I(i.x,i.y,i.z+v));let p=_.vertices.length;_.vertices.push(new I(r.x,r.y,r.z-v));let m=_.vertices.length;_.vertices.push(new I(i.x,i.y,i.z-v)),_.faces.push([u,p,m]),_.faces.push([u,m,d]),_.edges.push([u,d]),_.edges.push([p,m]),_.edges.push([u,p]),_.edges.push([d,m])}let y=_.vertices.length;for(let t of f)_.vertices.push(new I(t.x,t.y,t.z+v));for(let t of m){if(t.length<3)continue;let n=t.map(t=>t+y);_.faces.push(n);for(let t=0;t<n.length;t++){let r=(t+1)%n.length;_.edges.push([n[t],n[r]])}}let b=_.vertices.length;for(let t of f)_.vertices.push(new I(t.x,t.y,t.z-v));for(let t of m){if(t.length<3)continue;let n=[...t].reverse().map(t=>t+b);_.faces.push(n);for(let t=0;t<n.length;t++){let r=(t+1)%n.length;_.edges.push([n[t],n[r]])}}return _.computeNormals(),_}variations(){let t={};if(this.data){let n=this.face?.axes;n&&n.forEach(n=>{t[n.tag]=n.value})}return Qx.forEach(n=>{let r=this.face[n];r!==`normal`&&(t[n]=t[n]||r)}),t}metadata(){let t=this.data?.name||{};for(let n in this.face)/^load/.test(n)||(t[n]=t[n]||this.face[n]);return t}static async list(t=!1){if(t){console.log(`There are`,document.fonts.size,`font-faces
`);let t=0;for(let n of document.fonts.values()){console.log(`FontFace: {`);for(let t in n)console.log(`  `+t+`: `+n[t]);console.log(`}
`),n.status===`loaded`&&t++}console.log(t+` loaded`)}return await Array.from(document.fonts)}_lineateAndPathify(t,n,r,i,a,o={}){let s=o?.graphics?._renderer||this._pInst._renderer;s.push(),s.textFont(this);let{lines:c,bounds:l}=s._computeBounds(ns._FONT_BOUNDS,t,n,r,i,a,{ignoreRectMode:!0,...o});c=this._position(s,c,l,i,a);let u=this.data?.head?.unitsPerEm||1e3,d=s.states.textSize/u,f=this._currentAxes(s),p=c.map(t=>this._lineToGlyphs(t,{scale:d,axs:f}));return s.pop(),p}_currentAxes(t){let n;return(this.data?.fvar?.length??0)>0&&(n=this.data.fvar[0].map(([n,r,i,a,o,s])=>{if(!t)return i;if(n===`wght`)return t.states.fontWeight;if(n===`wdth`)return 100;if(t.textCanvas().style.fontVariationSettings){let r=RegExp(`\\b${n}s+(d+)`).exec(t.textCanvas().style.fontVariationSettings);return r?parseInt(r[1]):i}return i})),n}_textToPathPoints(t,n,r,i,a,o){({width:i,height:a,options:o}=this._parseArgs(i,a,o));let s=this.textToPaths(t,n,r,i,a,o),c=(t,n,r,i)=>{if(fn.dist(n.x,n.y,r.x,r.y)>i){let a={x:(n.x+r.x)/2,y:(n.y+r.y)/2};t.push(a),c(t,n,a,i),c(t,a,r,i)}},l=[],{textSize:u}=this._pInst._renderer.states,d=u/this.data.head.unitsPerEm*500;for(let t=0;t<s.length;t++){let{type:n,data:r}=s[t];if(n!==`Z`){let t={x:r[r.length-2],y:r[r.length-1]};n===`L`&&l.length&&!o?.nodivide>0&&c(l,l[l.length-1],t,d),l.push(t)}}return l}_parseArgs(t,n,r={}){return typeof t==`object`?(r=t,t=n=void 0):typeof n==`object`&&(r=n,n=void 0),{width:t,height:n,options:r}}_position(t,n,r,i,a){let{textAlign:o,textLeading:s}=t.states,c=this._measureTextDefault(t,`X`).fontBoundingBoxAscent;return n.map((n,l)=>{let u=r.x,d=r.y+l*s+c,f=t._fontWidthSingle(n);if(o===`center`?u+=(r.w-f)/2:o===`right`&&(u+=r.w-f),i!==void 0)switch(t.states.rectMode){case ie:u-=i/2,d-=a/2;break;case N:u-=i,d-=a}return{text:n,x:u,y:d}})}_lineToGlyphs(t,{scale:n=1,axs:r}={}){if(!this.data)throw Error(`No font data available for "`+this.name+`"
Try downloading a local copy of the font file`);let i=$.U.shape(this.data,t.text,{axs:r});return t.glyphShapes=i,t.glyphs=this._shapeToPaths(i,t,{scale:n,axs:r}),t}_positionGlyphs(t,n){let r=n?.graphics?._renderer||this._pInst._renderer,i=this._currentAxes(r),a=$.U.shape(this.data,t,{axs:i}),o=[],s=0;for(let t of a)o.push({x:s,index:t.g,shape:t}),s+=t.ax;return o}_singleShapeToPath(t,{scale:n=1,x:r=0,y:i=0,lineX:a=0,lineY:o=0,axs:s}={}){let c=this.data,l=0,{g:u,ax:d,ay:f,dx:p,dy:m}=t,{crds:h,cmds:g}=$.U.glyphToPath(c,u,!0,s),_={path:{commands:[]}};for(let t=0;t<g.length;t++){let s=g[t],c=[s];if(s in qx){let t=qx[s];for(let s=0;s<t;s+=2){let t=h[s+l]+r+p,u=h[s+l+1]+i+m,d=a+t*n,f=o+u*-n;c.push(d),c.push(f)}l+=t}_.path.commands.push(c)}return{glyph:_,ax:d,ay:f}}_shapeToPaths(t,n,{scale:r=1,axs:i}={}){let a=0,o=0,s=[];if(t.length!==n.text.length)throw Error(`Invalid shape data`);for(let c=0;c<t.length;c++){let{glyph:l,ax:u,ay:d}=this._singleShapeToPath(t[c],{scale:r,x:a,y:o,lineX:n.x,lineY:n.y,axs:i});s.push(l),a+=u,o+=d}return s}_measureTextDefault(t,n){let{textAlign:r,textBaseline:i}=t.states,a=t.textDrawingContext();a.textAlign=`left`,a.textBaseline=`alphabetic`;let o=a.measureText(n);return a.textAlign=r,a.textBaseline=i,o}drawPaths(t,n,r){t.strokeStyle=r?.stroke||t.strokeStyle,t.fillStyle=r?.fill||t.fillStyle,t.beginPath(),n.forEach(([n,...r])=>{n===`M`?t.moveTo(...r):n===`L`?t.lineTo(...r):n===`C`?t.bezierCurveTo(...r):n===`Q`?t.quadraticCurveTo(...r):n===`Z`&&t.closePath()}),r?.fill&&t.fill(),r?.stroke&&t.stroke()}_pathsToCommands(t,n){let r=[];for(let i=0;i<t.length;i++){let{x:a,y:o,path:s}=t[i],{crds:c,cmds:l}=s;for(let t=0,i=0;i<l.length;i++){let s=l[i],u={type:s,data:[]};if(s===`M`||s===`L`)u.data.push(a+c[t]*n,o+c[t+1]*-n),t+=2;else if(s===`C`){for(let r=0;r<6;r+=2)u.data.push(a+c[t+r]*n,o+c[t+r+1]*-n);t+=6}else if(s===`Q`){for(let r=0;r<4;r+=2)u.data.push(a+c[t+r]*n,o+c[t+r+1]*-n);t+=4}r.push(u)}}return r}};async function eS(t,n,r,i,a){let o=nS(n,r,i,a);return o.status!==`loaded`&&await o.load(),document.fonts.add(o),await document.fonts.ready,new $x(t,o,n,r,a)}function tS(t){return/^[A-Za-z][A-Za-z0-9_-]*$/.test(t)||(t=`'`+String(t).replace(/'/g,`\\'`)+`'`),t}function nS(t,n,r,i){t=tS(t);let a=i?._compressedData??i?._data;if(!a){if(!Yx.test(n))throw Error(Zx);n.startsWith(`url(`)||(n=`url(`+n+`)`),a=n}if((i?.fvar?.length??0)>0){r||={};for(let[t,n,,a]of i.fvar[0])t===`wght`?r.weight=`${n} ${a}`:t===`wdth`&&(r.stretch=`${n}% ${a}%`)}let o=new FontFace(t,a,r);if(o.status===`error`)throw Error(`Failed to create FontFace for "`+t+`"`);return o}function rS(t,n){let r,i=t?.name;if(i){if(i.fullName)return i.fullName;i.familyName&&(r=i.familyName)}if(!r){let t=Xx.exec(n);r=t&&t.length>=3?t[1]:n}return r.includes(` `)&&(r=r.replace(/ /g,`_`)),r}function iS(t,n,r){let i=(t,n)=>{if(typeof t!=`object`)t=n;else for(let r in n)t[r]===void 0&&(t[r]=n[r]);return t},a=(t,n)=>{let r=t.length;return t[n<0?n%r+r:n%r]},o=(t,n)=>{n||=0;let r=0;for(let i=t.length-1;t.length>3&&i>=0;--i)s(a(t,i-1),a(t,i),a(t,i+1),n)&&(t.splice(i%t.length,1),r++);return r},s=(t,n,r,i)=>{if(!i)return c(t,n,r)===0;s.tmpPoint1===void 0&&(s.tmpPoint1=[],s.tmpPoint2=[]);let a=s.tmpPoint1,o=s.tmpPoint2;a.x=n.x-t.x,a.y=n.y-t.y,o.x=r.x-n.x,o.y=r.y-n.y;let l=a.x*o.x+a.y*o.y,u=Math.sqrt(a.x*a.x+a.y*a.y),d=Math.sqrt(o.x*o.x+o.y*o.y);return Math.acos(l/(u*d))<i},c=(t,n,r)=>(n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1]),l=Kx(cS(t)),u=i(n,{sampleFactor:.1,simplifyThreshold:0}),d=Math.max(1,Math.ceil(l.getTotalLength()*u.sampleFactor)),f=[],p=r._pInst.angleMode(),m=r._pInst.DEGREES;for(let t=0;t<d;t++){let n=l.getTotalLength()*(d===1?0:t/(d-1));f.push({...l.getPointAtLength(n),get angle(){let t=l.getAngleAtLength(n);return p===m?t*180/Math.PI:t},get alpha(){return this.angle}})}return u.simplifyThreshold&&o(f,u.simplifyThreshold),f}function aS(t){return(t.startsWith(`"`)||t.startsWith(`'`))&&t.at(0)===t.at(-1)?t.slice(1,-1).replace(/\/(['"])/g,`$1`):t}function oS(...t){let n=t.shift();(typeof n!=`string`||n.length===0)&&p5._friendlyError(Zx,`p5.loadFont`);let r;typeof t[0]==`string`&&(r=t.shift());let i,a,o;for(let n=0;n<t.length;n++){let r=t[n];typeof r==`function`?i?a=r:i=r:typeof r==`object`&&(o=r)}return{path:n,name:r,success:i,error:a,options:o}}function sS(t,n){t.Font=$x,n.parseFontData=async function(t){let r=t instanceof Uint8Array?t:await n.loadBytes(t);if(!r)throw Error(`Failed to load font data`);let i=$.parse(r);if(i.length===0||i[0].cmap===void 0)throw Error(`parsing font data`);return i[0]},n.loadFont=async function(...t){let{path:r,name:i,success:a,error:o,options:{sets:s,...c}={}}=oS(...t),l=r.includes(`@font-face`);if(!l){let t;try{t=await fetch(r,{method:`HEAD`})}catch{t=await fetch(r)}t.headers.get(`content-type`)?.startsWith(`text/css`)&&(l=!0,r=await fetch(r).then(t=>t.text()))}if(l){let t=new CSSStyleSheet;await t.replace(r);let i=[];for(let r of t.cssRules)if(r instanceof CSSFontFaceRule){let t=r.style,a=aS(t.getPropertyValue(`font-family`)),o=t.getPropertyValue(`src`),s={...c||{}};for(let n of t){if(n===`font-family`||n===`src`)continue;let r=n.replace(/^font-/,``).split(`-`).map((t,n)=>n===0?t:`${t[0].toUpperCase()}${t.slice(1)}`).join(``);s[r]=t.getPropertyValue(n)}i.push({name:a,src:o,fontDescriptors:s,loadWithData:async()=>{let t;try{let r=/url\(([^)]+)\)/.exec(o);if(r){let i=r[1];/^['"]/.exec(i)&&i.at(0)===i.at(-1)&&(i=i.slice(1,-1)),t=await n.parseFontData(i)}}catch{}return eS(this,a,o,s,t)},loadWithoutData:()=>eS(this,a,o,s)})}s||=[`latin`];let a=(s instanceof Array?s:[s]).map(t=>t.toLowerCase()),o=q_.filter(t=>a.some(n=>t.category.includes(n)&&t.category.includes(`ext`)===n.includes(`ext`))),l=new Set(K_.UnicodeRange.parse(o.map(t=>`U+${t.hexrange[0]}-${t.hexrange[1]}`))),u=0,d=0,f;for(let t of i){if(!t.fontDescriptors.unicodeRange)continue;let n=[...new Set(K_.UnicodeRange.parse(t.fontDescriptors.unicodeRange.split(/,\s*/g))).values()].filter(t=>l.has(t)).length,r={style:`normal`,weight:400,...c},i=Object.keys(t.fontDescriptors).filter(n=>t.fontDescriptors[n]===r[n]).length;(i>d||i===d&&n>=u)&&(d=i,u=n,f=t)}let p=f||i.at(-1);for(let t of i)t!==p&&t.loadWithoutData();return p?.loadWithData()}let u;try{let t=await n.parseFontData(r);i||=rS(t,r),u=await eS(this,i,r,c,t)}catch{let t=i||r.substring(r.lastIndexOf(`/`)+1).replace(/\.[^/.]+$/,``);console.warn(`WARN: No glyph data for '${t}', retrying as FontFace`);try{u=await eS(this,t,r,c)}catch(t){if(o)return o(t);throw t}}let d=()=>a?a(u):u;return this._internal?this._internal(d):d()}}const cS=t=>t.map(t=>{let n=t[0];switch(n){case`Z`:return{type:n};case`M`:case`L`:{let[,r,i]=t;return{type:n,x:r,y:i}}case`Q`:{let[,r,i,a,o]=t;return{type:n,x1:r,y1:i,x:a,y:o}}case`C`:{let[,r,i,a,o,s,c]=t;return{type:n,x1:r,y1:i,x2:a,y2:o,x:s,y:c}}default:throw Error(`Unexpected path command: ${n}`)}});typeof p5<`u`&&sS(p5,p5.prototype);function lS(t,n){z.prototype.maxCachedGlyphs=function(){return 200},$x.prototype._getFontInfo=function(t){this._fontInfos=this._fontInfos||{};let n=JSON.stringify(t);if(this._fontInfos[n])return this._fontInfos[n];{let r=new o(this,{axs:t});return this._fontInfos[n]=r,r}};class r{constructor(t,n){this.width=t,this.height=n,this.infos=[]}findImage(t){let n=this.width*this.height;if(t>n)throw Error(`font is too complex to render in 3D`);let r,i;for(let a=this.infos.length-1;a>=0;--a){let o=this.infos[a];if(o.index+t<n){r=o,i=o.imageData;break}}if(!r){try{i=new ImageData(this.width,this.height)}catch{let t=document.getElementsByTagName(`canvas`)[0],n=!t;t||(t=document.createElement(`canvas`),t.style.display=`none`,document.body.appendChild(t));let r=t.getContext(`2d`);r&&(i=r.createImageData(this.width,this.height)),n&&document.body.removeChild(t)}r={index:0,imageData:i},this.infos.push(r)}let a=r.index;return r.index+=t,i._dirty=!0,{imageData:i,index:a}}}function i(t,n,r,i,a){let o=t.imageData.data,s=t.index++*4;o[s++]=n,o[s++]=r,o[s++]=i,o[s++]=a}let a=Math.sqrt(3);class o{constructor(t,{axs:n}={}){this.font=t,this.axs=n,this.strokeImageInfos=new r(64,64),this.colDimImageInfos=new r(64,64),this.rowDimImageInfos=new r(64,64),this.colCellImageInfos=new r(64,64),this.rowCellImageInfos=new r(64,64),this.glyphInfos={}}getGlyphInfo(t){let n=this.glyphInfos[t.index];if(n)return n;let r=this.axs,{glyph:{path:{commands:o}}}=this.font._singleShapeToPath(t.shape,{axs:r}),s=1/0,c=-1/0,l=1/0,u=-1/0;for(let t of o)for(let n=1;n<t.length;n+=2)s=Math.min(s,t[n]),c=Math.max(c,t[n]),l=Math.min(l,t[n+1]),u=Math.max(u,t[n+1]);if(s>=c||l>=u||!o.length)return this.glyphInfos[t.index]={};let d=c-s,f=u-l,p=cS(o),m,h=[],g=[],_=[];for(m=8;m>=0;--m)_.push([]);for(m=8;m>=0;--m)g.push([]);function v(t,n,r){let i=h.length;h.push(r);function a(t,n,r){for(let i=t.length;i-->0;){let a=t[i];n>a&&(n=a),r<a&&(r=a)}return{min:n,max:r}}let o=.5,s=a(t,1,0),c=Math.max(Math.floor(s.min*9-o),0),l=Math.min(Math.ceil(s.max*9+o),9);for(let t=c;t<l;++t)_[t].push(i);let u=a(n,1,0),d=Math.max(Math.floor(u.min*9-o),0),f=Math.min(Math.ceil(u.max*9+o),9);for(let t=d;t<f;++t)g[t].push(i)}function y(t,n,r){return t<n?n:t>r?r:t}function b(t){return y(255*t,0,255)}class x{constructor(t,n,r,i){this.p0=t,this.c0=n,this.c1=r,this.p1=i}toQuadratic(){return{x:this.p0.x,y:this.p0.y,x1:this.p1.x,y1:this.p1.y,cx:((this.c0.x+this.c1.x)*3-(this.p0.x+this.p1.x))/4,cy:((this.c0.y+this.c1.y)*3-(this.p0.y+this.p1.y))/4}}quadError(){return I.sub(I.sub(this.p1,this.p0),I.mult(I.sub(this.c1,this.c0),3)).mag()/2}split(t){let n=I.lerp(this.p0,this.c0,t),r=I.lerp(this.c0,this.c1,t),i=I.lerp(n,r,t);this.c1=I.lerp(this.c1,this.p1,t),this.c0=I.lerp(r,this.c1,t);let a=I.lerp(i,this.c0,t),o=new x(this.p0,n,i,a);return this.p0=a,o}splitInflections(){let t=I.sub(this.c0,this.p0),n=I.sub(I.sub(this.c1,this.c0),t),r=I.sub(I.sub(I.sub(this.p1,this.c1),t),I.mult(n,2)),i=[],a=n.x*r.y-n.y*r.x;if(a!==0){let o=t.x*r.y-t.y*r.x,s=t.x*n.y-t.y*n.x,c=o*o-4*a*s;if(c>=0){a<0&&(a=-a,o=-o,s=-s);let t=Math.sqrt(c),n=(-o-t)/(2*a),r=(-o+t)/(2*a);n>0&&n<1&&(i.push(this.split(n)),r=1-(1-r)/(1-n)),r>0&&r<1&&i.push(this.split(r))}}return i.push(this),i}}function S(t,n,r,i,o,s,c,l){let u=new x(new I(t,n),new I(r,i),new I(o,s),new I(c,l)).splitInflections(),d=[],f=30/a;for(let t of u){let n=[],r;for(;r=f/t.quadError(),!(r>=.125);){let i=r**(1/3),a=t.split(i),o=t.split(1-i/(1-i));d.push(a),n.push(t),t=o}r<1&&d.push(t.split(.5)),d.push(t),Array.prototype.push.apply(d,n.reverse())}return d}function C(t,n,r,i){let a=(t+r)/2,o=(n+i)/2;v([t,r],[n,i],{x:t,y:n,cx:a,cy:o})}function w(t,n,r,i){return Math.abs(r-t)<1e-5&&Math.abs(i-n)<1e-5}let T,E,D,O;for(let t of p){let n=(t.x-s)/d,r=(t.y-l)/f;if(!w(T,E,n,r)){switch(t.type){case`M`:D=n,O=r;break;case`L`:C(T,E,n,r);break;case`Q`:{let i=(t.x1-s)/d,a=(t.y1-l)/f;v([T,n,i],[E,r,a],{x:T,y:E,cx:i,cy:a});break}case`Z`:w(T,E,D,O)?h.push({x:T,y:E}):(C(T,E,D,O),h.push({x:D,y:O}));break;case`C`:{let i=(t.x1-s)/d,a=(t.y1-l)/f,o=(t.x2-s)/d,c=(t.y2-l)/f,u=S(T,E,i,a,o,c,n,r);for(let t=0;t<u.length;t++){let n=u[t].toQuadratic();v([n.x,n.x1,n.cx],[n.y,n.y1,n.cy],n)}break}default:throw Error(`unknown command type: ${t.type}`)}T=n,E=r}}let k=h.length,A=this.strokeImageInfos.findImage(k),j=A.index;for(let t=0;t<k;++t){let n=h[t];i(A,b(n.x),b(n.y),b(n.cx),b(n.cy))}function M(t,n,r){let a=t.length,o=n.findImage(a),s=o.index,c=0;for(let n=0;n<a;++n)c+=t[n].length;let l=r.findImage(c);for(let n=0;n<a;++n){let r=t[n],a=r.length,s=l.index;i(o,s>>7,s&127,a>>7,a&127);for(let t=0;t<a;++t){let n=r[t]+j;i(l,n>>7,n&127,0,0)}}return{cellImageInfo:l,dimOffset:s,dimImageInfo:o}}return n=this.glyphInfos[t.index]={glyph:t,uGlyphRect:[s,l,c,u],strokeImageInfo:A,strokes:h,colInfo:M(_,this.colDimImageInfos,this.colCellImageInfos),rowInfo:M(g,this.rowDimImageInfos,this.rowCellImageInfos)},n.uGridOffset=[n.colInfo.dimOffset,n.rowInfo.dimOffset],n}}z.prototype._renderText=function(n,r,i,a,o){if(!this.states.textFont||typeof this.states.textFont==`string`){console.log("WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont` for more details.");return}if(i>=a||!this.states.fillColor)return;if(!t.Font.hasGlyphData(this.states.textFont)){console.log(`WEBGL: only Opentype (.otf) and Truetype (.ttf) fonts with glyph data are supported. Make sure to set the font using textFont() before drawing text.`);return}this.push();let s=this.states.strokeColor,c=this.states.drawMode;this.states.setValue(`strokeColor`,null),this.states.setValue(`drawMode`,pt);let{font:l}=this.states.textFont;if(!l)throw Error(`In WebGL mode, textFont() needs to be given the result of loadFont() instead of a font family name.`);let u=l._currentAxes(this),d=l._getFontInfo(u),f={x:r,y:i},p=this.states.textSize/(l.data?.head?.unitsPerEm||1e3);this.translate(f.x,f.y,0),this.scale(p,p,1);let m=!this._defaultFontShader,h=this._getFontShader();h.init(),h.bindShader(`text`),m&&(h.setUniform(`uGridImageSize`,[64,64]),h.setUniform(`uCellsImageSize`,[64,64]),h.setUniform(`uStrokeImageSize`,[64,64]),h.setUniform(`uGridSize`,[9,9]));let g=this.states.fillSet?this.states.curFillColor:[0,0,0,1];this._setGlobalUniforms(h),this._applyColorBlend(g);let _=this.geometryBufferCache.getGeometryByID(`glyph`);_||(_=this._textGeom=new Vo(1,1,function(){for(let t=0;t<=1;t++)for(let n=0;n<=1;n++)this.vertices.push(new I(n,t,0)),this.uvs.push(n,t)},this),_.gid=`glyph`,_.computeFaces().computeNormals(),this.geometryBufferCache.ensureCached(_));for(let t of this.buffers.text)t._prepareBuffer(_,h);h.setUniform(`uMaterialColor`,g),this._disableRemainingAttributes(h),this._beforeDrawText(),this.glyphDataCache=this.glyphDataCache||/* @__PURE__ */ new Set;try{let t=l._positionGlyphs(n);for(let n of t){let t=d.getGlyphInfo(n);if(t.uGlyphRect){let r=t.rowInfo,i=t.colInfo,a=[t.strokeImageInfo.imageData,r.cellImageInfo.imageData,r.dimImageInfo.imageData,i.cellImageInfo.imageData,i.dimImageInfo.imageData];for(let t of a)this.glyphDataCache.delete(t),this.glyphDataCache.add(t);for(;this.glyphDataCache.size>this.maxCachedGlyphs();){let t=this.glyphDataCache.values().next().value;this.glyphDataCache.delete(t);let n=this.textures.get(t);n&&(n.remove(),this.textures.delete(t))}h.setUniform(`uSamplerStrokes`,t.strokeImageInfo.imageData),h.setUniform(`uSamplerRowStrokes`,r.cellImageInfo.imageData),h.setUniform(`uSamplerRows`,r.dimImageInfo.imageData),h.setUniform(`uSamplerColStrokes`,i.cellImageInfo.imageData),h.setUniform(`uSamplerCols`,i.dimImageInfo.imageData),h.setUniform(`uGridOffset`,t.uGridOffset),h.setUniform(`uGlyphRect`,t.uGlyphRect),h.setUniform(`uGlyphOffset`,n.x),h.bindTextures(),this._drawBuffers(_,{mode:4,count:1})}}}finally{h.unbindShader(),this.states.setValue(`strokeColor`,s),this.states.setValue(`drawMode`,c),this._afterDrawText(),this.pop()}}}var uS=`#define PI 3.141592

precision highp float;
precision highp int;

uniform mat4 uViewMatrix;
uniform mat3 uCameraNormalMatrix;

uniform bool uUseLighting;

uniform int uDirectionalLightCount;
uniform vec3 uLightingDirection[5];
uniform vec3 uDirectionalDiffuseColors[5];
uniform vec3 uDirectionalSpecularColors[5];

uniform int uPointLightCount;
uniform vec3 uPointLightLocation[5];
uniform vec3 uPointLightDiffuseColors[5];	
uniform vec3 uPointLightSpecularColors[5];

uniform int uSpotLightCount;
uniform float uSpotLightAngle[5];
uniform float uSpotLightConc[5];
uniform vec3 uSpotLightDiffuseColors[5];
uniform vec3 uSpotLightSpecularColors[5];
uniform vec3 uSpotLightLocation[5];
uniform vec3 uSpotLightDirection[5];

uniform bool uSpecular;
uniform float uShininess;
uniform float uMetallic;

uniform float uConstantAttenuation;
uniform float uLinearAttenuation;
uniform float uQuadraticAttenuation;

// setting from  _setImageLightUniforms()
// boolean to initiate the calculateImageDiffuse and calculateImageSpecular
uniform bool uUseImageLight;
// texture for use in calculateImageDiffuse
uniform sampler2D environmentMapDiffused;
// texture for use in calculateImageSpecular
uniform sampler2D environmentMapSpecular;

const float specularFactor = 2.0;
const float diffuseFactor = 0.73;

struct LightResult {
  float specular;
  float diffuse;
};

float _phongSpecular(
  vec3 lightDirection,
  vec3 viewDirection,
  vec3 surfaceNormal,
  float shininess) {

  vec3 R = reflect(lightDirection, surfaceNormal);
  return pow(max(0.0, dot(R, viewDirection)), shininess);
}

float _lambertDiffuse(vec3 lightDirection, vec3 surfaceNormal) {
  return max(0.0, dot(-lightDirection, surfaceNormal));
}

LightResult _light(vec3 viewDirection, vec3 normal, vec3 lightVector, float shininess, float metallic) {

  vec3 lightDir = normalize(lightVector);

  //compute our diffuse & specular terms
  LightResult lr;
  float specularIntensity = mix(1.0, 0.4, metallic);
  float diffuseIntensity = mix(1.0, 0.1, metallic);
  if (uSpecular)
    lr.specular = (_phongSpecular(lightDir, viewDirection, normal, shininess)) * specularIntensity;
    lr.diffuse = _lambertDiffuse(lightDir, normal) * diffuseIntensity;
  return lr;
}

// converts the range of "value" from [min1 to max1] to [min2 to max2]
float map(float value, float min1, float max1, float min2, float max2) {
  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}

vec2 mapTextureToNormal( vec3 v ){
  // x = r sin(phi) cos(theta)   
  // y = r cos(phi)  
  // z = r sin(phi) sin(theta)
  float phi = acos( v.y );
  // if phi is 0, then there are no x, z components
  float theta = 0.0;
  // else 
  theta = acos(v.x / sin(phi));
  float sinTheta = v.z / sin(phi);
  if (sinTheta < 0.0) {
    // Turn it into -theta, but in the 0-2PI range
    theta = 2.0 * PI - theta;
  }
  theta = theta / (2.0 * 3.14159);
  phi = phi / 3.14159 ;
  
  vec2 angles = vec2( fract(theta + 0.25), 1.0 - phi );
  return angles;
}


vec3 calculateImageDiffuse(vec3 vNormal, vec3 vViewPosition, float metallic){
  // make 2 seperate builds 
  vec3 worldCameraPosition =  vec3(0.0, 0.0, 0.0);  // hardcoded world camera position
  vec3 worldNormal = normalize(vNormal * uCameraNormalMatrix);
  vec2 newTexCoor = mapTextureToNormal( worldNormal );
  vec4 texture = TEXTURE( environmentMapDiffused, newTexCoor );
  // this is to make the darker sections more dark
  // png and jpg usually flatten the brightness so it is to reverse that
  return mix(smoothstep(vec3(0.0), vec3(1.0), texture.xyz), vec3(0.0), metallic);
}

vec3 calculateImageSpecular(vec3 vNormal, vec3 vViewPosition, float shininess, float metallic){
  vec3 worldCameraPosition =  vec3(0.0, 0.0, 0.0);
  vec3 worldNormal = normalize(vNormal);
  vec3 lightDirection = normalize( vViewPosition - worldCameraPosition );
  vec3 R = reflect(lightDirection, worldNormal) * uCameraNormalMatrix;
  vec2 newTexCoor = mapTextureToNormal( R );
#ifdef WEBGL2
  // In p5js the range of shininess is >= 1,
  // Therefore roughness range will be ([0,1]*8)*20 or [0, 160]
  // The factor of 8 is because currently the getSpecularTexture
  // only calculated 8 different levels of roughness
  // The factor of 20 is just to spread up this range so that,
  // [1, max] of shininess is converted to [0,160] of roughness
  float roughness = 20. / shininess;
  vec4 outColor = textureLod(environmentMapSpecular, newTexCoor, roughness * 8.);
#else
  vec4 outColor = TEXTURE(environmentMapSpecular, newTexCoor);
#endif
  // this is to make the darker sections more dark
  // png and jpg usually flatten the brightness so it is to reverse that
  return mix(
    pow(outColor.xyz, vec3(10)),
    pow(outColor.xyz, vec3(1.2)),
    metallic 
  );
}

void totalLight(
  vec3 modelPosition,
  vec3 normal,
  float shininess,
  float metallic,
  out vec3 totalDiffuse,
  out vec3 totalSpecular
) {

  totalSpecular = vec3(0.0);

  if (!uUseLighting) {
    totalDiffuse = vec3(1.0);
    return;
  }

  totalDiffuse = vec3(0.0);

  vec3 viewDirection = normalize(-modelPosition);

  for (int j = 0; j < 5; j++) {
    if (j < uDirectionalLightCount) {
      vec3 lightVector = (uViewMatrix * vec4(uLightingDirection[j], 0.0)).xyz;
      vec3 lightColor = uDirectionalDiffuseColors[j];
      vec3 specularColor = uDirectionalSpecularColors[j];
      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
      totalDiffuse += result.diffuse * lightColor;
      totalSpecular += result.specular * lightColor * specularColor;
    }

    if (j < uPointLightCount) {
      vec3 lightPosition = (uViewMatrix * vec4(uPointLightLocation[j], 1.0)).xyz;
      vec3 lightVector = modelPosition - lightPosition;
      //calculate attenuation
      float lightDistance = length(lightVector);
      float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);
      vec3 lightColor = lightFalloff * uPointLightDiffuseColors[j];
      vec3 specularColor = lightFalloff * uPointLightSpecularColors[j];

      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
      totalDiffuse += result.diffuse * lightColor;
      totalSpecular += result.specular * lightColor * specularColor;
    }

    if(j < uSpotLightCount) {
      vec3 lightPosition = (uViewMatrix * vec4(uSpotLightLocation[j], 1.0)).xyz;
      vec3 lightVector = modelPosition - lightPosition;
    
      float lightDistance = length(lightVector);
      float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);

      vec3 lightDirection = (uViewMatrix * vec4(uSpotLightDirection[j], 0.0)).xyz;
      float spotDot = dot(normalize(lightVector), normalize(lightDirection));
      float spotFalloff;
      if(spotDot < uSpotLightAngle[j]) {
        spotFalloff = 0.0;
      }
      else {
        spotFalloff = pow(spotDot, uSpotLightConc[j]);
      }
      lightFalloff *= spotFalloff;

      vec3 lightColor = uSpotLightDiffuseColors[j];
      vec3 specularColor = uSpotLightSpecularColors[j];
     
      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);
      
      totalDiffuse += result.diffuse * lightColor * lightFalloff;
      totalSpecular += result.specular * lightColor * specularColor * lightFalloff;
    }
  }

  if( uUseImageLight ){
    totalDiffuse += calculateImageDiffuse(normal, modelPosition, metallic);
    totalSpecular += calculateImageSpecular(normal, modelPosition, shininess, metallic);
  }

  totalDiffuse *= diffuseFactor;
  totalSpecular *= specularFactor;
}
`,dS=`IN vec3 aPosition;
IN vec3 aNormal;
IN vec2 aTexCoord;
IN vec4 aVertexColor;

#define HOOK_DEFINES

#ifdef AUGMENTED_HOOK_getWorldInputs
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat3 uModelNormalMatrix;
uniform mat3 uCameraNormalMatrix;
#else
uniform mat4 uModelViewMatrix;
uniform mat3 uNormalMatrix;
#endif
uniform mat4 uProjectionMatrix;

uniform vec4 uMaterialColor;
uniform bool uUseVertexColor;

OUT vec3 vVertexNormal;
OUT highp vec2 vVertTexCoord;
OUT vec4 vColor;

struct Vertex {
  vec3 position;
  vec3 normal;
  vec2 texCoord;
  vec4 color;
};

void main(void) {
  HOOK_beforeVertex();

  Vertex inputs;
  inputs.position = aPosition;
  inputs.normal = aNormal;
  inputs.texCoord = aTexCoord;
  inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;
#ifdef AUGMENTED_HOOK_getObjectInputs
  inputs = HOOK_getObjectInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uModelNormalMatrix * inputs.normal;
  inputs = HOOK_getWorldInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  // Already multiplied by the model matrix, just apply view
  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uCameraNormalMatrix * inputs.normal;
#else
  // Apply both at once
  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uNormalMatrix * inputs.normal;
#endif
#ifdef AUGMENTED_HOOK_getCameraInputs
  inputs = HOOK_getCameraInputs(inputs);
#endif

  // Pass varyings to fragment shader
  vVertTexCoord = inputs.texCoord;
  vVertexNormal = normalize(inputs.normal);
  vColor = inputs.color;

  gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);

  HOOK_afterVertex();
}
`,fS=`IN vec3 vVertexNormal;
IN highp vec2 vVertTexCoord;
void main(void) {
  HOOK_beforeFragment();
  OUT_COLOR = HOOK_getFinalColor(vec4(vVertexNormal, 1.0), vVertTexCoord);
  HOOK_afterFragment();
}`,pS=`IN vec4 vColor;
IN highp vec2 vVertTexCoord;
void main(void) {
  HOOK_beforeFragment();
  OUT_COLOR = HOOK_getFinalColor(vColor, vVertTexCoord);
  OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering
  HOOK_afterFragment();
}`,mS=`// include lighting.glgl

IN vec3 aPosition;
IN vec3 aNormal;
IN vec2 aTexCoord;
IN vec4 aVertexColor;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
uniform mat3 uNormalMatrix;

uniform bool uUseVertexColor;
uniform vec4 uMaterialColor;

OUT highp vec2 vVertTexCoord;
OUT vec3 vDiffuseColor;
OUT vec3 vSpecularColor;
OUT vec4 vColor;

void main(void) {

  vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);
  gl_Position = uProjectionMatrix * viewModelPosition;

  vec3 vertexNormal = normalize(uNormalMatrix * aNormal);
  vVertTexCoord = aTexCoord;

  totalLight(viewModelPosition.xyz, vertexNormal, vDiffuseColor, vSpecularColor);

  for (int i = 0; i < 8; i++) {
    if (i < uAmbientLightCount) {
      vDiffuseColor += uAmbientColor[i];
    }
  }
  
  vColor = ((uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor);
}
`,hS=`uniform vec4 uTint;
uniform sampler2D uSampler;
uniform bool isTexture;
uniform bool uEmissive;

IN highp vec2 vVertTexCoord;
IN vec3 vDiffuseColor;
IN vec3 vSpecularColor;
IN vec4 vColor;

void main(void) {
  if(uEmissive && !isTexture) {
    OUT_COLOR = vColor;
  }
  else {
    vec4 baseColor = isTexture
      // Textures come in with premultiplied alpha. To apply tint and still have
      // premultiplied alpha output, we need to multiply the RGB channels by the
      // tint RGB, and all channels by the tint alpha.
      ? TEXTURE(uSampler, vVertTexCoord) * vec4(uTint.rgb/255., 1.) * (uTint.a/255.)
      // Colors come in with unmultiplied alpha, so we need to multiply the RGB
      // channels by alpha to convert it to premultiplied alpha.
      : vec4(vColor.rgb * vColor.a, vColor.a);
    OUT_COLOR = vec4(baseColor.rgb * vDiffuseColor + vSpecularColor, baseColor.a);
  }
}
`,gS=`precision highp int;

#define HOOK_DEFINES

IN vec3 aPosition;
IN vec3 aNormal;
IN vec2 aTexCoord;
IN vec4 aVertexColor;
#ifdef USE_TEXTURE_MAPS
IN vec4 aTangent;
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
uniform mat3 uModelNormalMatrix;
uniform mat3 uCameraNormalMatrix;
#else
uniform mat4 uModelViewMatrix;
uniform mat3 uNormalMatrix;
#endif
uniform mat4 uProjectionMatrix;

uniform bool uUseVertexColor;
uniform vec4 uMaterialColor;

OUT vec3 vNormal;
OUT vec2 vTexCoord;
OUT vec3 vViewPosition;
OUT vec3 vAmbientColor;
OUT vec4 vColor;
#ifdef USE_TEXTURE_MAPS
OUT vec4 vTangent;
#endif

struct Vertex {
  vec3 position;
  vec3 normal;
  vec2 texCoord;
  vec4 color;
};

void main(void) {
  HOOK_beforeVertex();

  Vertex inputs;
  inputs.position = aPosition;
  inputs.normal = aNormal;
  inputs.texCoord = aTexCoord;
  inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;
#ifdef USE_TEXTURE_MAPS
  // transform the surface tangent alongside the normal so it ends up in the
  // same space; handedness (w) is passed through for rebuilding the bitangent.
  vec3 tangent = aTangent.xyz;
#endif
#ifdef AUGMENTED_HOOK_getObjectInputs
  inputs = HOOK_getObjectInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uModelNormalMatrix * inputs.normal;
#ifdef USE_TEXTURE_MAPS
  tangent = uModelNormalMatrix * tangent;
#endif
  inputs = HOOK_getWorldInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  // Already multiplied by the model matrix, just apply view
  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uCameraNormalMatrix * inputs.normal;
#ifdef USE_TEXTURE_MAPS
  tangent = uCameraNormalMatrix * tangent;
#endif
#else
  // Apply both at once
  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.normal = uNormalMatrix * inputs.normal;
#ifdef USE_TEXTURE_MAPS
  tangent = uNormalMatrix * tangent;
#endif
#endif
#ifdef AUGMENTED_HOOK_getCameraInputs
  inputs = HOOK_getCameraInputs(inputs);
#endif

  // Pass varyings to fragment shader
  vViewPosition = inputs.position;
  vTexCoord = inputs.texCoord;
  vNormal = inputs.normal;
  vColor = inputs.color;
#ifdef USE_TEXTURE_MAPS
  vTangent = vec4(tangent, aTangent.w);
#endif

  gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);
  HOOK_afterVertex();
}
`,_S=`// include lighting.glsl
precision highp int;

uniform bool uHasSetAmbient;
uniform vec3 uAmbientColor;
uniform vec4 uSpecularMatColor;
uniform vec4 uAmbientMatColor;
uniform vec4 uEmissiveMatColor;

uniform vec4 uTint;
uniform sampler2D uSampler;
uniform bool isTexture;

// the mtl texture maps only exist in the USE_TEXTURE_MAPS variant of this
// shader. models that don't use any map get the plain phong shader instead,
// so none of these samplers/branches are even compiled in for them. dave's
// call: separate variant rather than branching in one shader that everyone pays for.
#ifdef USE_TEXTURE_MAPS
uniform sampler2D uSpecularSampler;
uniform bool uHasSpecularTex;
uniform sampler2D uAmbientSampler;
uniform bool uHasAmbientTex;
uniform sampler2D uShininessSampler;
uniform bool uHasShininessTex;
uniform sampler2D uNormalSampler;
uniform bool uHasNormalMap;
uniform float uNormalScale;
uniform int uNormalMapMode;
uniform vec2 uNormalTexelSize;
#endif

IN vec3 vNormal;
IN vec2 vTexCoord;
IN vec3 vViewPosition;
IN vec4 vColor;
#ifdef USE_TEXTURE_MAPS
IN vec4 vTangent;
#endif

struct ColorComponents {
  vec3 baseColor;
  float opacity;
  vec3 ambientColor;
  vec3 specularColor;
  vec3 diffuse;
  vec3 ambient;
  vec3 specular;
  vec3 emissive;
};

struct Inputs {
  vec3 normal;
  vec2 texCoord;
  vec3 ambientLight;
  vec3 ambientMaterial;
  vec3 specularMaterial;
  vec3 emissiveMaterial;
  vec4 color;
  float shininess;
  float metalness;
};

void main(void) {
  HOOK_beforeFragment();

  Inputs inputs;
  vec3 N = normalize(vNormal);
#ifdef USE_TEXTURE_MAPS
  if (uHasNormalMap) {
    // rebuild the tangent basis (TBN) from the smooth per-vertex tangent and
    // perturb the normal by the map. gram-schmidt keeps T perpendicular to the
    // interpolated normal so the frame stays smooth across triangles (no facets).
    vec3 T = normalize(vTangent.xyz);
    T = normalize(T - N * dot(N, T));
    vec3 B = cross(N, T) * vTangent.w;
    vec3 mapN;
    if (uNormalMapMode == 1) {
      // bump map: brightness is height, so the tangent-space normal comes from
      // how fast that height changes between neighbouring texels. sampling both
      // sides keeps the slope right at the edges of the map, where reaching past
      // one side would otherwise clamp and read back the same texel.
      vec2 du = vec2(uNormalTexelSize.x, 0.0);
      vec2 dv = vec2(0.0, uNormalTexelSize.y);
      float hl = TEXTURE(uNormalSampler, vTexCoord - du).r;
      float hr = TEXTURE(uNormalSampler, vTexCoord + du).r;
      float hd = TEXTURE(uNormalSampler, vTexCoord - dv).r;
      float hu = TEXTURE(uNormalSampler, vTexCoord + dv).r;
      // the surface leans away from the direction height increases in
      mapN = normalize(vec3((hl - hr) * 0.5, (hd - hu) * 0.5, 1.0));
    } else {
      // normal map: rgb already holds the tangent-space normal
      mapN = TEXTURE(uNormalSampler, vTexCoord).rgb * 2.0 - 1.0;
    }
    // scale the tangent-space slope so the strength can be tuned (-bm)
    mapN.xy *= uNormalScale;
    N = normalize(mat3(T, B, N) * mapN);
  }
#endif
  inputs.normal = N;
  inputs.texCoord = vTexCoord;
  inputs.ambientLight = uAmbientColor;
  inputs.color = isTexture
      ? TEXTURE(uSampler, vTexCoord) * (vec4(uTint.rgb/255., 1.) * uTint.a/255.)
      : vColor;
  if (isTexture && inputs.color.a > 0.0) {
    // Textures come in with premultiplied alpha. Temporarily unpremultiply it
    // so hooks users don't have to think about premultiplied alpha.
    inputs.color.rgb /= inputs.color.a;
  }
  inputs.metalness = uMetallic;
#ifdef USE_TEXTURE_MAPS
  // map variant: shininess/ambient/specular can be modulated by their maps
  inputs.shininess = uHasShininessTex
      ? uShininess * TEXTURE(uShininessSampler, vTexCoord).r
      : uShininess;
  inputs.ambientMaterial = uHasAmbientTex
      ? TEXTURE(uAmbientSampler, vTexCoord).rgb * uAmbientMatColor.rgb
      : (uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb);
  inputs.specularMaterial = uHasSpecularTex
      ? TEXTURE(uSpecularSampler, vTexCoord).rgb * uSpecularMatColor.rgb
      : uSpecularMatColor.rgb;
#else
  // default variant: plain phong, exactly as before this feature existed
  inputs.shininess = uShininess;
  inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;
  inputs.specularMaterial = uSpecularMatColor.rgb;
#endif
  inputs.emissiveMaterial = uEmissiveMatColor.rgb;
  inputs = HOOK_getPixelInputs(inputs);

  vec3 diffuse;
  vec3 specular;
  totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);

  // Calculating final color as result of all lights (plus emissive term).

  vec4 baseColor = inputs.color;
  ColorComponents c;
  c.opacity = baseColor.a;
  c.baseColor = baseColor.rgb;
  c.ambientColor = inputs.ambientMaterial;
  c.specularColor = inputs.specularMaterial;
  c.diffuse = diffuse;
  c.ambient = inputs.ambientLight;
  c.specular = specular;
  c.emissive = inputs.emissiveMaterial;
  OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c), vTexCoord);
  OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering
  HOOK_afterFragment();
}
`,vS=`IN vec3 aPosition;
IN vec2 aTexCoord;
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;

uniform vec4 uGlyphRect;
uniform float uGlyphOffset;

OUT vec2 vTexCoord;

void main() {
  vec4 positionVec4 = vec4(aPosition, 1.0);

  // scale by the size of the glyph's rectangle
  positionVec4.xy *= uGlyphRect.zw - uGlyphRect.xy;

  // Expand glyph bounding boxes by 1px on each side to give a bit of room
  // for antialiasing
  vec3 newOrigin = (uModelViewMatrix * vec4(0., 0., 0., 1.)).xyz;
  vec3 newDX = (uModelViewMatrix * vec4(1., 0., 0., 1.)).xyz;
  vec3 newDY = (uModelViewMatrix * vec4(0., 1., 0., 1.)).xyz;
  vec2 pixelScale = vec2(
    1. / length(newOrigin - newDX),
    1. / length(newOrigin - newDY)
  );
  vec2 offset = pixelScale * normalize(aTexCoord - vec2(0.5, 0.5));
  vec2 textureOffset = offset * (1. / vec2(
    uGlyphRect.z - uGlyphRect.x,
    uGlyphRect.w - uGlyphRect.y
  ));

  // move to the corner of the glyph
  positionVec4.xy += uGlyphRect.xy;

  // move to the letter's line offset
  positionVec4.x += uGlyphOffset;

  positionVec4.xy += offset;
  
  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;
  vTexCoord = aTexCoord + textureOffset;
}
`,yS=`#ifndef WEBGL2
#extension GL_OES_standard_derivatives : enable
#endif

#if 0
  // simulate integer math using floats
	#define int float
	#define ivec2 vec2
	#define INT(x) float(x)

	int ifloor(float v) { return floor(v); }
	ivec2 ifloor(vec2 v) { return floor(v); }

#else
  // use native integer math
	precision highp int;
	#define INT(x) x

	int ifloor(float v) { return int(v); }
	int ifloor(int v) { return v; }
	ivec2 ifloor(vec2 v) { return ivec2(v); }

#endif

uniform sampler2D uSamplerStrokes;
uniform sampler2D uSamplerRowStrokes;
uniform sampler2D uSamplerRows;
uniform sampler2D uSamplerColStrokes;
uniform sampler2D uSamplerCols;

uniform ivec2 uStrokeImageSize;
uniform ivec2 uCellsImageSize;
uniform ivec2 uGridImageSize;

uniform ivec2 uGridOffset;
uniform ivec2 uGridSize;
uniform vec4 uMaterialColor;

IN vec2 vTexCoord;

// some helper functions
int ROUND(float v) { return ifloor(v + 0.5); }
ivec2 ROUND(vec2 v) { return ifloor(v + 0.5); }
float saturate(float v) { return clamp(v, 0.0, 1.0); }
vec2 saturate(vec2 v) { return clamp(v, 0.0, 1.0); }

int mul(float v1, int v2) {
  return ifloor(v1 * float(v2));
}

ivec2 mul(vec2 v1, ivec2 v2) {
  return ifloor(v1 * vec2(v2) + 0.5);
}

// unpack a 16-bit integer from a float vec2
int getInt16(vec2 v) {
  ivec2 iv = ROUND(v * 255.0);
  return iv.x * INT(128) + iv.y;
}

vec2 pixelScale;
vec2 coverage = vec2(0.0);
vec2 weight = vec2(0.5);
const float minDistance = 1.0/8192.0;
const float hardness = 1.05; // amount of antialias

// the maximum number of curves in a glyph
const int N = INT(250);

// retrieves an indexed pixel from a sampler
vec4 getTexel(sampler2D sampler, int pos, ivec2 size) {
  int width = size.x;
  int y = ifloor(pos / width);
  int x = pos - y * width;  // pos % width

  return TEXTURE(sampler, (vec2(x, y) + 0.5) / vec2(size));
}

void calulateCrossings(vec2 p0, vec2 p1, vec2 p2, out vec2 C1, out vec2 C2) {

  // get the coefficients of the quadratic in t
  vec2 a = p0 - p1 * 2.0 + p2;
  vec2 b = p0 - p1;
  vec2 c = p0 - vTexCoord;

  // found out which values of 't' it crosses the axes
  vec2 surd = sqrt(max(vec2(0.0), b * b - a * c));
  vec2 t1 = ((b - surd) / a).yx;
  vec2 t2 = ((b + surd) / a).yx;

  // approximate straight lines to avoid rounding errors
  if (abs(a.y) < 0.001)
    t1.x = t2.x = c.y / (2.0 * b.y);

  if (abs(a.x) < 0.001)
    t1.y = t2.y = c.x / (2.0 * b.x);

  // plug into quadratic formula to find the corrdinates of the crossings
  C1 = ((a * t1 - b * 2.0) * t1 + c) * pixelScale;
  C2 = ((a * t2 - b * 2.0) * t2 + c) * pixelScale;
}

void coverageX(vec2 p0, vec2 p1, vec2 p2) {

  vec2 C1, C2;
  calulateCrossings(p0, p1, p2, C1, C2);

  // determine on which side of the x-axis the points lie
  bool y0 = p0.y > vTexCoord.y;
  bool y1 = p1.y > vTexCoord.y;
  bool y2 = p2.y > vTexCoord.y;

  // could web be under the curve (after t1)?
  if (y1 ? !y2 : y0) {
    // add the coverage for t1
    coverage.x += saturate(C1.x + 0.5);
    // calculate the anti-aliasing for t1
    weight.x = min(weight.x, abs(C1.x));
  }

  // are we outside the curve (after t2)?
  if (y1 ? !y0 : y2) {
    // subtract the coverage for t2
    coverage.x -= saturate(C2.x + 0.5);
    // calculate the anti-aliasing for t2
    weight.x = min(weight.x, abs(C2.x));
  }
}

// this is essentially the same as coverageX, but with the axes swapped
void coverageY(vec2 p0, vec2 p1, vec2 p2) {

  vec2 C1, C2;
  calulateCrossings(p0, p1, p2, C1, C2);

  bool x0 = p0.x > vTexCoord.x;
  bool x1 = p1.x > vTexCoord.x;
  bool x2 = p2.x > vTexCoord.x;

  if (x1 ? !x2 : x0) {
    coverage.y -= saturate(C1.y + 0.5);
    weight.y = min(weight.y, abs(C1.y));
  }

  if (x1 ? !x0 : x2) {
    coverage.y += saturate(C2.y + 0.5);
    weight.y = min(weight.y, abs(C2.y));
  }
}

void main() {

  // calculate the pixel scale based on screen-coordinates
  pixelScale = hardness / fwidth(vTexCoord);

  // which grid cell is this pixel in?
  ivec2 gridCoord = ifloor(vTexCoord * vec2(uGridSize));

  // intersect curves in this row
  {
    // the index into the row info bitmap
    int rowIndex = gridCoord.y + uGridOffset.y;
    // fetch the info texel
    vec4 rowInfo = getTexel(uSamplerRows, rowIndex, uGridImageSize);
    // unpack the rowInfo
    int rowStrokeIndex = getInt16(rowInfo.xy);
    int rowStrokeCount = getInt16(rowInfo.zw);

    for (int iRowStroke = INT(0); iRowStroke < N; iRowStroke++) {
      if (iRowStroke >= rowStrokeCount)
        break;

      // each stroke is made up of 3 points: the start and control point
      // and the start of the next curve.
      // fetch the indices of this pair of strokes:
      vec4 strokeIndices = getTexel(uSamplerRowStrokes, rowStrokeIndex++, uCellsImageSize);

      // unpack the stroke index
      int strokePos = getInt16(strokeIndices.xy);

      // fetch the two strokes
      vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);
      vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);

      // calculate the coverage
      coverageX(stroke0.xy, stroke0.zw, stroke1.xy);
    }
  }

  // intersect curves in this column
  {
    int colIndex = gridCoord.x + uGridOffset.x;
    vec4 colInfo = getTexel(uSamplerCols, colIndex, uGridImageSize);
    int colStrokeIndex = getInt16(colInfo.xy);
    int colStrokeCount = getInt16(colInfo.zw);
    
    for (int iColStroke = INT(0); iColStroke < N; iColStroke++) {
      if (iColStroke >= colStrokeCount)
        break;

      vec4 strokeIndices = getTexel(uSamplerColStrokes, colStrokeIndex++, uCellsImageSize);

      int strokePos = getInt16(strokeIndices.xy);
      vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);
      vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);
      coverageY(stroke0.xy, stroke0.zw, stroke1.xy);
    }
  }

  weight = saturate(1.0 - weight * 2.0);
  float distance = max(weight.x + weight.y, minDistance); // manhattan approx.
  float antialias = abs(dot(coverage, weight) / distance);
  float cover = min(abs(coverage.x), abs(coverage.y));
  OUT_COLOR = vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a;
  OUT_COLOR *= saturate(max(antialias, cover));
}
`,bS=`/*
  Part of the Processing project - http://processing.org
  Copyright (c) 2012-15 The Processing Foundation
  Copyright (c) 2004-12 Ben Fry and Casey Reas
  Copyright (c) 2001-04 Massachusetts Institute of Technology
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation, version 2.1.
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA
*/

#define PROCESSING_LINE_SHADER

#define HOOK_DEFINES

precision highp int;
precision highp float;

#ifdef AUGMENTED_HOOK_getWorldInputs
uniform mat4 uModelMatrix;
uniform mat4 uViewMatrix;
#else
uniform mat4 uModelViewMatrix;
#endif

uniform mat4 uProjectionMatrix;
uniform float uStrokeWeight;

uniform bool uUseLineColor;
uniform bool uSimpleLines;
uniform vec4 uMaterialColor;

uniform vec4 uViewport;
uniform int uPerspective;
uniform int uStrokeJoin;

IN vec3 aPosition;
IN vec3 aTangentIn;
IN vec3 aTangentOut;
IN float aSide;
IN vec4 aVertexColor;

OUT vec4 vColor;
OUT vec2 vTangent;
OUT vec2 vCenter;
OUT vec2 vPosition;
OUT float vMaxDist;
OUT float vCap;
OUT float vJoin;
OUT float vStrokeWeight;

vec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {
  // Rotate and translate so a starts at the origin and goes out to the right
  bPoint -= aPoint;
  vec2 rotatedBFrom = vec2(
    bPoint.x*aDir.x + bPoint.y*aDir.y,
    bPoint.y*aDir.x - bPoint.x*aDir.y
  );
  vec2 bTo = bPoint + bDir;
  vec2 rotatedBTo = vec2(
    bTo.x*aDir.x + bTo.y*aDir.y,
    bTo.y*aDir.x - bTo.x*aDir.y
  );
  float intersectionDistance =
    rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /
    (rotatedBTo.y - rotatedBFrom.y);
  return aPoint + aDir * intersectionDistance;
}

struct StrokeVertex {
  vec3 position;
  vec3 tangentIn;
  vec3 tangentOut;
  vec4 color;
  float weight;
};

void main() {
  HOOK_beforeVertex();

  if (!uSimpleLines) {
      // Caps have one of either the in or out tangent set to 0
      vCap = (aTangentIn == vec3(0.)) != (aTangentOut == vec3(0.)) ? 1. : 0.;

      // Joins have two unique, defined tangents
      vJoin = (
          aTangentIn != vec3(0.) &&
          aTangentOut != vec3(0.) &&
          aTangentIn != aTangentOut
      ) ? 1. : 0.;
  }

  StrokeVertex inputs;
  inputs.position = aPosition.xyz;
  inputs.color = uUseLineColor ? aVertexColor : uMaterialColor;
  inputs.weight = uStrokeWeight;
  inputs.tangentIn = aTangentIn;
  inputs.tangentOut = aTangentOut;

#ifdef AUGMENTED_HOOK_getObjectInputs
  inputs = HOOK_getObjectInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.tangentIn = (uModelMatrix * vec4(aTangentIn, 0.)).xyz;
  inputs.tangentOut = (uModelMatrix * vec4(aTangentOut, 0.)).xyz;
  inputs = HOOK_getWorldInputs(inputs);
#endif

#ifdef AUGMENTED_HOOK_getWorldInputs
  // Already multiplied by the model matrix, just apply view
  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.tangentIn = (uViewMatrix * vec4(aTangentIn, 0.)).xyz;
  inputs.tangentOut = (uViewMatrix * vec4(aTangentOut, 0.)).xyz;
#else
  // Apply both at once
  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;
  inputs.tangentIn = (uModelViewMatrix * vec4(aTangentIn, 0.)).xyz;
  inputs.tangentOut = (uModelViewMatrix * vec4(aTangentOut, 0.)).xyz;
#endif
#ifdef AUGMENTED_HOOK_getCameraInputs
  inputs = HOOK_getCameraInputs(inputs);
#endif

  vec4 posp = vec4(inputs.position, 1.);
  vec4 posqIn = vec4(inputs.position + inputs.tangentIn, 1.);
  vec4 posqOut = vec4(inputs.position + inputs.tangentOut, 1.);
  vStrokeWeight = inputs.weight;

  float facingCamera = pow(
    // The word space tangent's z value is 0 if it's facing the camera
    abs(normalize(posqIn-posp).z),

    // Using pow() here to ramp \`facingCamera\` up from 0 to 1 really quickly
    // so most lines get scaled and don't get clipped
    0.25
  );

  // Moving vertices slightly toward the camera
  // to avoid depth-fighting with the fill triangles.
  // A mix of scaling and offsetting is used based on distance
  // Discussion here:
  // https://github.com/processing/p5.js/issues/7200 

  // using a scale <1 moves the lines towards nearby camera
  // in order to prevent popping effects due to half of
  // the line disappearing behind the geometry faces.
  float zDistance = -posp.z; 
  float distanceFactor = smoothstep(0.0, 800.0, zDistance); 
  
  // Discussed here:
  // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848  
  float scale = mix(1., 0.995, facingCamera);
  float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less

  posp.xyz = posp.xyz * dynamicScale;
  posqIn.xyz = posqIn.xyz * dynamicScale;
  posqOut.xyz = posqOut.xyz * dynamicScale;

  // Moving vertices slightly toward camera when far away 
  // https://github.com/processing/p5.js/issues/6956 
  float zOffset = mix(0., -1., facingCamera);
  float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more

  posp.z -= dynamicZAdjustment;
  posqIn.z -= dynamicZAdjustment;
  posqOut.z -= dynamicZAdjustment;
  
  vec4 p = uProjectionMatrix * posp;
  vec4 qIn = uProjectionMatrix * posqIn;
  vec4 qOut = uProjectionMatrix * posqOut;

  // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])
  // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw

  // prevent division by W by transforming the tangent formula (div by 0 causes
  // the line to disappear, see https://github.com/processing/processing/issues/5183)
  // t = screen_q - screen_p
  //
  // tangent is normalized and we don't care which aDirection it points to (+-)
  // t = +- normalize( screen_q - screen_p )
  // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )
  //
  // extract common factor, <1,1> - <1,1> cancels out
  // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )
  //
  // convert to common divisor
  // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )
  //
  // remove the common scalar divisor/factor, not needed due to normalize and +-
  // (keep uViewport - can't remove because it has different components for x and y
  //  and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)
  // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )

  vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);
  vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);

  vec2 curPerspScale;
  if(uPerspective == 1) {
    // Perspective ---
    // convert from world to clip by multiplying with projection scaling factor
    // to get the right thickness (see https://github.com/processing/processing/issues/5182)

    // The y value of the projection matrix may be flipped if rendering to a Framebuffer.
    // Multiplying again by its sign here negates the flip to get just the scale.
    curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;
  } else {
    // No Perspective ---
    // multiply by W (to cancel out division by W later in the pipeline) and
    // convert from screen to clip (derived from clip to screen above)
    curPerspScale = p.w / (0.5 * uViewport.zw);
  }

  vec2 offset;
  if (vJoin == 1. && !uSimpleLines) {
    vTangent = normalize(tangentIn + tangentOut);
    vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);
    vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);
    float side = sign(aSide);
    float sideEnum = abs(aSide);

    // We generate vertices for joins on either side of the centerline, but
    // the "elbow" side is the only one needing a join. By not setting the
    // offset for the other side, all its vertices will end up in the same
    // spot and not render, effectively discarding it.
    if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {
      // Side enums:
      //   1: the side going into the join
      //   2: the middle of the join
      //   3: the side going out of the join
      if (sideEnum == 2.) {
        // Calculate the position + tangent on either side of the join, and
        // find where the lines intersect to find the elbow of the join
        vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;
        vec2 intersection = lineIntersection(
          c + (side * normalIn * inputs.weight / 2.),
          tangentIn,
          c + (side * normalOut * inputs.weight / 2.),
          tangentOut
        );
        offset = (intersection - c);

        // When lines are thick and the angle of the join approaches 180, the
        // elbow might be really far from the center. We'll apply a limit to
        // the magnitude to avoid lines going across the whole screen when this
        // happens.
        float mag = length(offset);
        float maxMag = 3. * inputs.weight;
        if (mag > maxMag) {
          offset *= maxMag / mag;
        }
      } else if (sideEnum == 1.) {
        offset = side * normalIn * inputs.weight / 2.;
      } else if (sideEnum == 3.) {
        offset = side * normalOut * inputs.weight / 2.;
      }
    }
    if (uStrokeJoin == STROKE_JOIN_BEVEL) {
      vec2 avgNormal = vec2(-vTangent.y, vTangent.x);
      vMaxDist = abs(dot(avgNormal, normalIn * inputs.weight / 2.));
    } else {
      vMaxDist = inputs.weight / 2.;
    }
  } else {
    vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;

    vTangent = tangent;
    vec2 normal = vec2(-tangent.y, tangent.x);

    float normalOffset = sign(aSide);
    // Caps will have side values of -2 or 2 on the edge of the cap that
    // extends out from the line
    float tangentOffset = abs(aSide) - 1.;
    offset = (normal * normalOffset + tangent * tangentOffset) *
      inputs.weight * 0.5;
    vMaxDist = inputs.weight / 2.;
  }

  vCenter = p.xy;
  vPosition = vCenter + offset;
  vColor = inputs.color;

  gl_Position.xy = p.xy + offset.xy * curPerspScale;
  gl_Position.zw = p.zw;
  
  HOOK_afterVertex();
}
`,xS=`precision highp int;
precision highp float;

uniform vec4 uMaterialColor;
uniform int uStrokeCap;
uniform int uStrokeJoin;

IN vec4 vColor;
IN vec2 vTangent;
IN vec2 vCenter;
IN vec2 vPosition;
IN float vStrokeWeight;
IN float vMaxDist;
IN float vCap;
IN float vJoin;

float distSquared(vec2 a, vec2 b) {
  vec2 aToB = b - a;
  return dot(aToB, aToB);
}

struct Inputs {
  vec4 color;
  vec2 tangent;
  vec2 center;
  vec2 position;
  float strokeWeight;
};

void main() {
  HOOK_beforeFragment();

  Inputs inputs;
  inputs.color = vColor;
  inputs.tangent = vTangent;
  inputs.center = vCenter;
  inputs.position = vPosition;
  inputs.strokeWeight = vStrokeWeight;
  inputs = HOOK_getPixelInputs(inputs);

  if (vCap > 0.) {
    if (
      uStrokeCap == STROKE_CAP_ROUND &&
      HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)
    ) {
      discard;
    } else if (
      uStrokeCap == STROKE_CAP_SQUARE &&
      HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)
    ) {
      discard;
    // Use full area for PROJECT
    } else if (HOOK_shouldDiscard(false)) {
      discard;
    }
  } else if (vJoin > 0.) {
    if (
      uStrokeJoin == STROKE_JOIN_ROUND &&
      HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)
    ) {
      discard;
    } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {
      vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);
      if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {
        discard;
      }
    // Use full area for MITER
    } else if (HOOK_shouldDiscard(false)) {
      discard;
    }
  }
  OUT_COLOR = HOOK_getFinalColor(inputs.color, vec2(0.0, 0.0));
  OUT_COLOR.rgb *= OUT_COLOR.a;
  HOOK_afterFragment();
}
`,SS=`precision highp float;
IN vec3 aPosition;
IN vec3 aNormal;
IN vec2 aTexCoord;

OUT vec3 localPos;
OUT vec3 vWorldNormal;
OUT vec3 vWorldPosition;
OUT vec2 vTexCoord;

uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
uniform mat3 uNormalMatrix;

void main() {
  // Multiply the position by the matrix.
  vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);
  gl_Position = uProjectionMatrix * viewModelPosition;  
  
  // orient the normals and pass to the fragment shader
  vWorldNormal = uNormalMatrix * aNormal;
  
  // send the view position to the fragment shader
  vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;
  
  localPos = vWorldPosition;
  vTexCoord = aTexCoord;
}


/*
in the vertex shader we'll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings.
*/
`,CS=`precision highp float;
IN vec3 localPos;

// the HDR cubemap converted (can be from an equirectangular environment map.)
uniform sampler2D environmentMap;
IN vec2 vTexCoord;

const float PI = 3.14159265359;

vec2 nTOE( vec3 v ){
  // x = r sin(phi) cos(theta)   
  // y = r cos(phi)  
  // z = r sin(phi) sin(theta)
  float phi = acos( v.y );
  // if phi is 0, then there are no x, z components
  float theta = 0.0;
  // else 
  theta = acos(v.x / sin(phi));
  float sinTheta = v.z / sin(phi);
  if (sinTheta < 0.0) {
    // Turn it into -theta, but in the 0-2PI range
    theta = 2.0 * PI - theta;
  }
  theta = theta / (2.0 * 3.14159);
  phi = phi / 3.14159 ;
  
  vec2 angles = vec2( phi, theta );
  return angles;
}

float random(vec2 p) {
  vec3 p3  = fract(vec3(p.xyx) * .1031);
  p3 += dot(p3, p3.yzx + 33.33);
  return fract((p3.x + p3.y) * p3.z);
}

void main()
{   	 
	// the sample direction equals the hemisphere's orientation
  float phi = vTexCoord.x * 2.0 * PI;
  float theta = vTexCoord.y * PI;
  float x = sin(theta) * cos(phi);
  float y = sin(theta) * sin(phi);
  float z = cos(theta);
  vec3 normal = vec3( x, y, z);

	// Discretely sampling the hemisphere given the integral's
  // spherical coordinates translates to the following fragment code:
	vec3 irradiance = vec3(0.0);  
	vec3 up	= vec3(0.0, 1.0, 0.0);
	vec3 right = normalize(cross(up, normal));
	up = normalize(cross(normal, right));

	//  We specify a fixed sampleDelta delta value to traverse
  // the hemisphere; decreasing or increasing the sample delta
  // will increase or decrease the accuracy respectively.
	const float sampleDelta = 0.100;
	float nrSamples = 0.0;
  float randomOffset = random(gl_FragCoord.xy) * sampleDelta;
	for(float rawPhi = 0.0; rawPhi < 2.0 * PI; rawPhi += sampleDelta)
	{
    float phi = rawPhi + randomOffset;
    for(float rawTheta = 0.0; rawTheta < ( 0.5 ) * PI; rawTheta += sampleDelta)
    {
      float theta = rawTheta + randomOffset;
      // spherical to cartesian (in tangent space) // tangent space to world // add each sample result to irradiance
      float x = sin(theta) * cos(phi);
      float y = sin(theta) * sin(phi);
      float z = cos(theta);
      vec3 tangentSample = vec3( x, y, z);
      
      vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal;
        irradiance += (TEXTURE(environmentMap, nTOE(sampleVec)).xyz) * cos(theta) * sin(theta);
      nrSamples++;
    }
	}
	// divide by the total number of samples taken, giving us the average sampled irradiance.
	irradiance = PI * irradiance * (1.0 / float(nrSamples )) ;
  
 
	OUT_COLOR = vec4(irradiance, 1.0);
}`,wS=`precision highp float;\r
IN vec3 localPos;\r
IN vec2 vTexCoord;\r
\r
// our texture\r
uniform sampler2D environmentMap;\r
uniform float roughness;\r
\r
const float PI = 3.14159265359;\r
\r
float VanDerCorput(int bits);\r
vec2 HammersleyNoBitOps(int i, int N);\r
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);\r
\r
\r
vec2 nTOE( vec3 v ){\r
  // x = r sin(phi) cos(theta)   \r
  // y = r cos(phi)  \r
  // z = r sin(phi) sin(theta)\r
  float phi = acos( v.y );\r
  // if phi is 0, then there are no x, z components\r
  float theta = 0.0;\r
  // else \r
  theta = acos(v.x / sin(phi));\r
  float sinTheta = v.z / sin(phi);\r
  if (sinTheta < 0.0) {\r
    // Turn it into -theta, but in the 0-2PI range\r
    theta = 2.0 * PI - theta;\r
  }\r
  theta = theta / (2.0 * 3.14159);\r
  phi = phi / 3.14159 ;\r
  \r
  vec2 angles = vec2( phi, theta );\r
  return angles;\r
}\r
\r
\r
void main(){\r
  const int SAMPLE_COUNT = 400; // 4096\r
  int lowRoughnessLimit = int(pow(2.0,(roughness+0.1)*20.0));\r
  float totalWeight = 0.0;\r
  vec3 prefilteredColor = vec3(0.0);\r
  float phi = vTexCoord.x * 2.0 * PI;\r
  float theta = vTexCoord.y * PI;\r
  float x = sin(theta) * cos(phi);\r
  float y = sin(theta) * sin(phi);\r
  float z = cos(theta);\r
  vec3 N = vec3(x,y,z);\r
  vec3 V = N;\r
  for (int i = 0; i < SAMPLE_COUNT; ++i)\r
  {\r
    // break at smaller sample numbers for low roughness levels\r
    if(i == lowRoughnessLimit)\r
    {\r
      break;\r
    }\r
    vec2 Xi = HammersleyNoBitOps(i, SAMPLE_COUNT);\r
    vec3 H = ImportanceSampleGGX(Xi, N, roughness);\r
    vec3 L = normalize(2.0 * dot(V, H) * H - V);\r
\r
    float NdotL = max(dot(N, L), 0.0);\r
    if (NdotL > 0.0)\r
    {\r
      prefilteredColor += TEXTURE(environmentMap, nTOE(L)).xyz * NdotL;\r
      totalWeight += NdotL;\r
    }\r
  }\r
  prefilteredColor = prefilteredColor / totalWeight;\r
\r
 OUT_COLOR  = vec4(prefilteredColor, 1.0);\r
}\r
\r
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness){\r
  float a = roughness * roughness;\r
\r
  float phi = 2.0 * PI * Xi.x;\r
  float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));\r
  float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\r
  // from spherical coordinates to cartesian coordinates\r
  vec3 H;\r
  H.x = cos(phi) * sinTheta;\r
  H.y = sin(phi) * sinTheta;\r
  H.z = cosTheta;\r
\r
  // from tangent-space vector to world-space sample vector\r
  vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\r
  vec3 tangent = normalize(cross(up, N));\r
  vec3 bitangent = cross(N, tangent);\r
\r
  vec3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z;\r
  return normalize(sampleVec);\r
}\r
\r
\r
float VanDerCorput(int n, int base)\r
{\r
#ifdef WEBGL2\r
\r
    uint bits = uint(n);\r
    bits = (bits << 16u) | (bits >> 16u);\r
    bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\r
    bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\r
    bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\r
    bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\r
    return float(bits) * 2.3283064365386963e-10; // / 0x100000000\r
\r
#else\r
\r
  float invBase = 1.0 / float(base);\r
  float denom = 1.0;\r
  float result = 0.0;\r
\r
\r
  for (int i = 0; i < 32; ++i)\r
  {\r
        if (n > 0)\r
        {\r
        denom = mod(float(n), 2.0);\r
        result += denom * invBase;\r
        invBase = invBase / 2.0;\r
        n = int(float(n) / 2.0);\r
        }\r
  }\r
\r
\r
  return result;\r
\r
#endif\r
}\r
\r
vec2 HammersleyNoBitOps(int i, int N)\r
{\r
  return vec2(float(i) / float(N), VanDerCorput(i, 2));\r
}\r
`;const{lineDefs:TS}=as((t,n)=>`#define ${t} ${n}\n`),ES={normalVert:dS,normalFrag:fS,basicFrag:pS,lightVert:uS+mS,lightTextureFrag:hS,phongVert:gS,phongFrag:uS+_S,fontVert:vS,fontFrag:yS,lineVert:TS+bS,lineFrag:TS+xS,imageLightVert:SS,imageLightDiffusedFrag:CS,imageLightSpecularFrag:wS,filterBaseVert:Ks,filterBaseFrag:Gs};for(let t in ES)ES[t]=qs+ES[t];var DS=class t extends z{constructor(t,n,r,i,a){super(t,n,r,i,a),this.rendererType=h,this._pInst.rendererType=this.rendererType,this.blendExt=this.webglVersion===`webgl2`?this.GL:this.GL.getExtension(`EXT_blend_minmax`),this._userEnabledStencil=!1,this._internalEnable=this.drawingContext.enable,this._internalDisable=this.drawingContext.disable,this.drawingContext.enable=t=>(t===this.drawingContext.STENCIL_TEST&&(this._clipping||(this._userEnabledStencil=!0)),this._internalEnable.call(this.drawingContext,t)),this.drawingContext.disable=t=>(t===this.drawingContext.STENCIL_TEST&&(this._userEnabledStencil=!1),this._internalDisable.call(this.drawingContext,t)),this._cachedBlendMode=void 0,this.strandsBackend=ol}setupContext(){this._setAttributeDefaults(this._pInst),this._initContext(),this.GL=this.drawingContext}_applyBlendMode(){if(this._cachedBlendMode===this.states.curBlendMode)return;let t=this.GL;switch(this.states.curBlendMode){case F:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Ae:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE);break;case ke:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_ALPHA);break;case Ie:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA);break;case Le:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_COLOR);break;case Fe:t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE_MINUS_DST_COLOR,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE);break;case Re:t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ONE,t.ZERO);break;case Pe:t.blendEquationSeparate(t.FUNC_REVERSE_SUBTRACT,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case je:this.blendExt?(t.blendEquationSeparate(this.blendExt.MIN||this.blendExt.MIN_EXT,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):console.warn(`blendMode(DARKEST) does not work in your browser in WEBGL mode.`);break;case Me:this.blendExt?(t.blendEquationSeparate(this.blendExt.MAX||this.blendExt.MAX_EXT,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):console.warn(`blendMode(LIGHTEST) does not work in your browser in WEBGL mode.`);break;default:console.error(`Oops! Somehow Renderer3D set curBlendMode to an unsupported mode.`)}this._cachedBlendMode=this.states.curBlendMode}_shaderOptions(){}_restoreOriginalShaderNames(t,n){if(!t||!n?.internalToExternal)return t;let r=t;for(let[t,i]of Object.entries(n.internalToExternal)){let n=RegExp(`\\b${t}\\b`,`g`);r=r.replace(n,i)}return r}_useShader(t){this.GL.useProgram(t._glProgram)}_disableRemainingAttributes(t){for(let n of this.registerEnabled.values())Object.keys(t.attributes).some(r=>t.attributes[r].location===n)||(this.GL.disableVertexAttribArray(n),this.registerEnabled.delete(n))}_drawBuffers(t,{mode:n=4,count:r}){let i=this.GL,a=this.geometryBufferCache.getCached(t);if(a){if(this._curShader.shaderType===`stroke`){if(r===1)i.drawArrays(i.TRIANGLES,0,t.lineVertices.length/3);else try{i.drawArraysInstanced(i.TRIANGLES,0,t.lineVertices.length/3,r)}catch{console.log(`🌸 p5.js says: Instancing is only supported in WebGL2 mode`)}}else if(this._curShader.shaderType===`text`)this._bindBuffer(a.indexBuffer,i.ELEMENT_ARRAY_BUFFER),i.drawElements(i.TRIANGLES,6,i.UNSIGNED_SHORT,0);else if(a.indexBuffer){if(this._bindBuffer(a.indexBuffer,i.ELEMENT_ARRAY_BUFFER),this._pInst.webglVersion!==`webgl2`&&a.indexBufferType===i.UNSIGNED_INT&&!i.getExtension(`OES_element_index_uint`))throw Error(`Unable to render a 3d model with > 65535 triangles. Your web browser does not support the WebGL Extension OES_element_index_uint.`);if(r===1)i.drawElements(i.TRIANGLES,t.faces.length*3,a.indexBufferType,0);else try{i.drawElementsInstanced(i.TRIANGLES,t.faces.length*3,a.indexBufferType,0,r)}catch{console.log(`🌸 p5.js says: Instancing is only supported in WebGL2 mode`)}}else{let a;if(a=n===4?i.TRIANGLES:n===6?i.TRIANGLE_FAN:i.TRIANGLE_STRIP,r===1)i.drawArrays(a,0,t.vertices.length);else try{i.drawArraysInstanced(a,0,t.vertices.length,r)}catch{console.log(`🌸 p5.js says: Instancing is only supported in WebGL2 mode`)}}}}_beforeDrawText(){this.GL.pixelStorei(this.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}_afterDrawText(){this.GL.pixelStorei(this.GL.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}_setAttributeDefaults(t){let n={alpha:!0,depth:!0,stencil:!0,antialias:navigator.userAgent.toLowerCase().includes(`safari`),premultipliedAlpha:!0,preserveDrawingBuffer:!0,perPixelLighting:!0,version:2};t._glAttributes=t._glAttributes===null?n:Object.assign(n,t._glAttributes)}_setAttributes(n,r){if(this._pInst._glAttributes===void 0){console.log(`You are trying to use setAttributes on a p5.Graphics object that does not use a WEBGL renderer.`);return}let i=!0;r===void 0?n instanceof Object&&this._pInst._glAttributes!==n&&(this._pInst._glAttributes=n,i=!1):(this._pInst._glAttributes===null&&(this._pInst._glAttributes={}),this._pInst._glAttributes[n]!==r&&(this._pInst._glAttributes[n]=r,i=!1)),this.isP3D&&!i&&(!this._pInst._setupDone&&this.geometryBufferCache.numCached()>0?p5.FES.log`Sorry, Could not set the attributes, you need to call setAttributes() before calling the other drawing methods in setup()`():(this._resetContext(null,null,t),this.states.curCamera&&(this.states.curCamera._renderer=this._renderer)))}_initContext(){if(this._pInst._glAttributes?.version!==1&&(this.drawingContext=this.canvas.getContext(`webgl2`,this._pInst._glAttributes)),this.webglVersion=this.drawingContext?g:h,this._pInst.webglVersion=this.webglVersion,this.drawingContext||=this.canvas.getContext(`webgl`,this._pInst._glAttributes)||this.canvas.getContext(`experimental-webgl`,this._pInst._glAttributes),this.drawingContext===null)throw Error(`Error creating webgl context`);{let t=this.drawingContext;t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._viewport=this.drawingContext.getParameter(this.drawingContext.VIEWPORT)}}_updateSize(){}_getMaxTextureSize(){let t=this.drawingContext;return t.getParameter(t.MAX_TEXTURE_SIZE)}_adjustDimensions(t,n,r=this._pixelDensity){this._maxTextureSize||=this._getMaxTextureSize();let i=this._maxTextureSize,a=Math.floor(i/r),o=Math.min(t,a),s=Math.min(n,a);return(o!==t||s!==n)&&console.warn(`Warning: The requested width/height exceeds hardware limits. Adjusting dimensions to width: ${o}, height: ${s}.`),{adjustedWidth:o,adjustedHeight:s}}_resetBuffersBeforeDraw(){this.GL.clearStencil(0),this.GL.clear(this.GL.DEPTH_BUFFER_BIT|this.GL.STENCIL_BUFFER_BIT),this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST)}_applyClip(){let t=this.GL;t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),this._internalEnable.call(t,t.STENCIL_TEST),this._stencilTestOn=!0,t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.KEEP,t.KEEP,t.REPLACE),t.disable(t.DEPTH_TEST)}_unapplyClip(){let t=this.GL;t.stencilOp(t.KEEP,t.KEEP,t.KEEP),t.stencilFunc(this._clipInvert?t.EQUAL:t.NOTEQUAL,0,255),t.enable(t.DEPTH_TEST)}_clearClipBuffer(){this.GL.clearStencil(1),this.GL.clear(this.GL.STENCIL_BUFFER_BIT),this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST)}_getPixel(t,n){let r=this.GL;return js(r,null,t,n,r.RGBA,r.UNSIGNED_BYTE,this._pInst.height*this._pInst.pixelDensity())}loadPixels(){if(this._pInst._glAttributes.preserveDrawingBuffer!==!0){console.log(`loadPixels only works in WebGL when preserveDrawingBuffer is true.`);return}let t=this._pixelDensity,n=this.GL;this.pixels=As(this.pixels,n,null,0,0,this.width*t,this.height*t,n.RGBA,n.UNSIGNED_BYTE,this.height*t)}updatePixels(){let t=this._getTempFramebuffer();t.pixels=this.pixels,t.updatePixels(),this.push(),this.resetMatrix(),this.clear(),this.states.setValue(`imageMode`,ee),this.image(t,0,0,t.width,t.height,-t.width/2,-t.height/2,t.width,t.height),this.pop(),this.GL.clearDepth(1),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}zClipRange(){return[-1,1]}defaultNearScale(){return .1}defaultFarScale(){return 10}supportsTriangleFan(){return!0}supportsVideoUpload(){return!0}textureNeedsRecreating(t){return!1}viewport(t,n){this._viewport=[0,0,t,n],this.GL.viewport(0,0,t,n)}_updateViewport(){this._origViewport={width:this.GL.drawingBufferWidth,height:this.GL.drawingBufferHeight},this.viewport(this._origViewport.width,this._origViewport.height)}_createPixelsArray(){this.pixels=new Uint8Array(this.GL.drawingBufferWidth*this.GL.drawingBufferHeight*4)}clear(...t){let n=t[0]||0,r=t[1]||0,i=t[2]||0,a=t[3]||0,o=this.activeFramebuffer();o&&o.format===`unsigned-byte`&&!o.antialias&&a===0&&(a=1e-10),this.GL.clearColor(n*a,r*a,i*a,a),this.GL.clearDepth(1),this.GL.clear(this.GL.COLOR_BUFFER_BIT|this.GL.DEPTH_BUFFER_BIT)}clearDepth(t=1){this.GL.clearDepth(t),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}_applyStencilTestIfClipping(){let t=this.drawTarget();t._isClipApplied!==this._stencilTestOn&&(t._isClipApplied?(this._internalEnable.call(this.GL,this.GL.STENCIL_TEST),this._stencilTestOn=!0):(this._userEnabledStencil||this._internalDisable.call(this.GL,this.GL.STENCIL_TEST),this._stencilTestOn=!1))}baseMaterialShader(){if(!this._pInst._glAttributes.perPixelLighting)throw Error(`The material shader does not support hooks without perPixelLighting. Try turning it back on.`);return super.baseMaterialShader()}_getLightShader(t=!1){let n=t?`_defaultLightShaderWithMaps`:`_defaultLightShader`;if(!this[n]){if(this._pInst._glAttributes.perPixelLighting){let r=t?`#define USE_TEXTURE_MAPS
`:``;this[n]=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+r+ES.phongVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+r+ES.phongFrag,{vertex:{"void beforeVertex":`() {}`,"Vertex getObjectInputs":`(Vertex inputs) { return inputs; }`,"Vertex getWorldInputs":`(Vertex inputs) { return inputs; }`,"Vertex getCameraInputs":`(Vertex inputs) { return inputs; }`,"void afterVertex":`() {}`},fragment:{"void beforeFragment":`() {}`,"Inputs getPixelInputs":`(Inputs inputs) { return inputs; }`,"vec4 combineColors":`(ColorComponents components) {
                vec4 color = vec4(0.);
                color.rgb += components.diffuse * components.baseColor;
                color.rgb += components.ambient * components.ambientColor;
                color.rgb += components.specular * components.specularColor;
                color.rgb += components.emissive;
                color.a = components.opacity;
                return color;
              }`,"vec4 getFinalColor":`(vec4 color, vec2 texCoord) { return color; }`,"void afterFragment":`() {}`}})}else this[n]=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.lightVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.lightTextureFrag)}return this[n]}_getNormalShader(){return this._defaultNormalShader||=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.normalVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.normalFrag,{vertex:{"void beforeVertex":`() {}`,"Vertex getObjectInputs":`(Vertex inputs) { return inputs; }`,"Vertex getWorldInputs":`(Vertex inputs) { return inputs; }`,"Vertex getCameraInputs":`(Vertex inputs) { return inputs; }`,"void afterVertex":`() {}`},fragment:{"void beforeFragment":`() {}`,"vec4 getFinalColor":`(vec4 color, vec2 texCoord) { return color; }`,"void afterFragment":`() {}`}}),this._defaultNormalShader}_getColorShader(){return this._defaultColorShader||=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.normalVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.basicFrag,{vertex:{"void beforeVertex":`() {}`,"Vertex getObjectInputs":`(Vertex inputs) { return inputs; }`,"Vertex getWorldInputs":`(Vertex inputs) { return inputs; }`,"Vertex getCameraInputs":`(Vertex inputs) { return inputs; }`,"void afterVertex":`() {}`},fragment:{"void beforeFragment":`() {}`,"vec4 getFinalColor":`(vec4 color, vec2 texCoord) { return color; }`,"void afterFragment":`() {}`}}),this._defaultColorShader}_getLineShader(){return this._defaultLineShader||=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.lineVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.lineFrag,{vertex:{"void beforeVertex":`() {}`,"StrokeVertex getObjectInputs":`(StrokeVertex inputs) { return inputs; }`,"StrokeVertex getWorldInputs":`(StrokeVertex inputs) { return inputs; }`,"StrokeVertex getCameraInputs":`(StrokeVertex inputs) { return inputs; }`,"void afterVertex":`() {}`},fragment:{"void beforeFragment":`() {}`,"Inputs getPixelInputs":`(Inputs inputs) { return inputs; }`,"vec4 getFinalColor":`(vec4 color, vec2 texCoord) { return color; }`,"bool shouldDiscard":`(bool outside) { return outside; }`,"void afterFragment":`() {}`}}),this._defaultLineShader}_getFontShader(){return this._defaultFontShader||=(this.webglVersion===`webgl`&&this.GL.getExtension(`OES_standard_derivatives`),new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.fontVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.fontFrag)),this._defaultFontShader}baseFilterShader(){return this._baseFilterShader||=new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.filterBaseVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.filterBaseFrag,{vertex:{},fragment:{"vec4 getColor":`(FilterInputs inputs, in sampler2D canvasContent) {
              return getTexture(canvasContent, inputs.texCoord);
            }`},hookAliases:{getColor:[`filterColor`]}}),this._baseFilterShader}_webGL2CompatibilityPrefix(t,n){let r=``;return this.webglVersion===`webgl2`&&(r+=`#version 300 es
#define WEBGL2
`),t===`vert`?r+=`#define VERTEX_SHADER
`:t===`frag`&&(r+=`#define FRAGMENT_SHADER
`),n&&(r+=`precision ${n} float;\n`),r}_createImageLightShader(t){if(t===`diffused`)return new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.imageLightVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.imageLightDiffusedFrag);if(t===`specular`)return new ys(this,this._webGL2CompatibilityPrefix(`vert`,`highp`)+ES.imageLightVert,this._webGL2CompatibilityPrefix(`frag`,`highp`)+ES.imageLightSpecularFrag);throw Error(`Unknown imageLight shader type: ${t}`)}_createMipmapTexture(t){return new Os(this,t,{})}_prepareMipmapData(t,n){return{levels:[],size:t,mipLevels:n}}_accumulateMipLevel(t,n,r,i,a){let o=t.get().drawingContext.getImageData(0,0,i,a);n.levels.push(o)}_finalizeMipmapTexture(t){return new Os(this,t.levels,{minFilter:gt,magFilter:st})}createMipmapTextureHandle({levels:t,format:n,dataType:r,width:i,height:a}){let o=this.GL,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s);let c=o.RGBA,l=o.UNSIGNED_BYTE;for(let n=0;n<t.length;n++)o.texImage2D(o.TEXTURE_2D,n,c,c,l,t[n]);return o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR_MIPMAP_LINEAR),o.bindTexture(o.TEXTURE_2D,null),{texture:s,glFormat:c,glDataType:l}}_bindBuffer(t,n,r,i,a){let o=this.GL;if(n||=o.ARRAY_BUFFER,o.bindBuffer(n,t),r!==void 0){let t=this._normalizeBufferData(r,i);o.bufferData(n,t,a||o.STATIC_DRAW)}}_prepareBuffer(t,n,r){let i=r.attributes,a=this.GL,o=this._getOrMakeCachedBuffers(n),s=i[t.attr];if(!s)return;let c=o[t.dst],l=n[t.src];if(l&&l.length>0){let i=!c;if(i&&(o[t.dst]=c=a.createBuffer()),a.bindBuffer(a.ARRAY_BUFFER,c),i||n.dirtyFlags[t.src]!==!1){let r=t.map,i=r?r(l):l;this._bindBuffer(c,a.ARRAY_BUFFER,i),n.dirtyFlags[t.src]=!1}r.enableAttrib(s,t.size)}else{let t=s.location;if(t===-1||!this.registerEnabled.has(t))return;a.disableVertexAttribArray(t),this.registerEnabled.delete(t)}}_enableAttrib(t,n,r,i,a,o,s){let c=n.location,l=this.GL;this.registerEnabled.has(c)||(l.enableVertexAttribArray(c),this.registerEnabled.add(c)),l.vertexAttribPointer(c,r,i||l.FLOAT,a||!1,o||0,s||0)}_ensureGeometryBuffers(t,n,r){let i=this.GL;if(n){let a=t.indexBuffer;a||=i.createBuffer(),this._bindBuffer(a,i.ELEMENT_ARRAY_BUFFER,n,r),t.indexBuffer=a,t.indexBufferType=r===Uint32Array?i.UNSIGNED_INT:i.UNSIGNED_SHORT}else t.indexBuffer&&=(i.deleteBuffer(t.indexBuffer),null)}_freeBuffers(t){let n=this.GL;t.indexBuffer&&n.deleteBuffer(t.indexBuffer);function r(r){for(let i of r)t[i.dst]&&(n.deleteBuffer(t[i.dst]),t[i.dst]=null)}r(this.buffers.stroke),r(this.buffers.fill),r(this.buffers.user)}_initShader(t){let n=this.GL,r=t.hooks?.shaderNameMap,i=n.createShader(n.VERTEX_SHADER);if(n.shaderSource(i,t.vertSrc()),n.compileShader(i),!n.getShaderParameter(i,n.COMPILE_STATUS)){let a=this._restoreOriginalShaderNames(n.getShaderInfoLog(i),r),o=this._restoreOriginalShaderNames(t.vertSrc(),r);throw Error(`Yikes! An error occurred compiling the vertex shader: ${a} in:\n\n${o}`)}let a=n.createShader(n.FRAGMENT_SHADER);if(n.shaderSource(a,t.fragSrc()),n.compileShader(a),!n.getShaderParameter(a,n.COMPILE_STATUS)){let i=this._restoreOriginalShaderNames(n.getShaderInfoLog(a),r),o=this._restoreOriginalShaderNames(t.fragSrc(),r);throw Error(`Darn! An error occurred compiling the fragment shader: ${i} in:\n\n${o}`)}let o=n.createProgram();if(n.attachShader(o,i),n.attachShader(o,a),n.linkProgram(o),!n.getProgramParameter(o,n.LINK_STATUS))throw Error(`Snap! Error linking shader program: ${n.getProgramInfoLog(o)}`);t._compiled=!0,t._glProgram=o,t._vertShader=i,t._fragShader=a}_finalizeShader(){}_getShaderAttributes(t){return Fs(t,this.GL)}getUniformMetadata(t){return Ps(t,this.GL)}updateUniformValue(t,n,r){return Ns(t,n,r,t=>this.getTexture(t),this.GL)}_updateTexture(t,n){let r=this.GL;r.activeTexture(r.TEXTURE0+t.samplerIndex),n.bindTexture(),n.update(),r.uniform1i(t.location,t.samplerIndex)}bindTexture(t){this.GL.bindTexture(this.GL.TEXTURE_2D,t.getTexture().texture)}unbindTexture(){this.GL.bindTexture(this.GL.TEXTURE_2D,null)}_unbindFramebufferTexture(t){let n=this.GL,r=this._getEmptyTexture();n.activeTexture(n.TEXTURE0+t.samplerIndex),r.bindTexture(),n.uniform1i(t.location,t.samplerIndex)}createTexture({width:t,height:n,format:r,dataType:i}){let a=this.GL,o=a.createTexture();return a.bindTexture(a.TEXTURE_2D,o),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,t,n,0,a.RGBA,a.UNSIGNED_BYTE,null),{texture:o,glFormat:a.RGBA,glDataType:a.UNSIGNED_BYTE}}createFramebufferTextureHandle(t){return null}uploadTextureFromSource({texture:t,glFormat:n,glDataType:r},i){let a=this.GL;a.texImage2D(a.TEXTURE_2D,0,n,n,r,i)}uploadTextureFromData({texture:t,glFormat:n,glDataType:r},i,a,o){let s=this.GL;s.texImage2D(s.TEXTURE_2D,0,n,a,o,0,n,r,i)}getSampler(t){}bindTextureToShader({texture:t},n,r,i){let a=this.GL;a.activeTexture(a.TEXTURE0+i),a.bindTexture(a.TEXTURE_2D,t);let o=a.getUniformLocation(glProgram,r);a.uniform1i(o,i)}setTextureParams(t){return Ms(t,this.GL,this.webglVersion)}deleteTexture({texture:t}){this.GL.deleteTexture(t)}_applyColorBlend(t,n){let r=this.GL,i=this.states.drawMode===pt,a=n||this.states.userFillShader||this.states.userStrokeShader||i||this.states.curBlendMode!==`source-over`||t[t.length-1]<1||this._isErasing;return a!==this._isBlending&&(a||this.states.curBlendMode!==`source-over`&&this.states.curBlendMode!==`lighter`?r.enable(r.BLEND):r.disable(r.BLEND),r.depthMask(!0),this._isBlending=a),this._applyBlendMode(),t}uniformNameFromHookKey(t){return t.slice(t.indexOf(` `)+1)}populateHooks(t,n,r){return Is(t,n,r)}getShaderHookTypes(t,n){return sl(t,n)}defaultFramebufferAlpha(){return this._pInst._glAttributes.alpha}defaultFramebufferAntialias(){return this.supportsFramebufferAntialias()?this._pInst._glAttributes.antialias:!1}supportsFramebufferAntialias(){return this.webglVersion===g}createFramebufferResources(t){let n=this.GL;if(t.framebuffer=n.createFramebuffer(),!t.framebuffer)throw Error(`Unable to create a framebuffer`);if(t.antialias&&(t.aaFramebuffer=n.createFramebuffer(),!t.aaFramebuffer))throw Error(`Unable to create a framebuffer for antialiasing`)}validateFramebufferFormats(t){let n=this.GL;t.useDepth&&this.webglVersion===`webgl`&&!n.getExtension(`WEBGL_depth_texture`)&&(console.warn(`Unable to create depth textures in this environment. Falling back to a framebuffer without depth.`),t.useDepth=!1),t.useDepth&&this.webglVersion===`webgl`&&t.depthFormat===`float`&&(console.warn(`FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT.`),t.depthFormat=It),[`unsigned-byte`,`float`,`half-float`].includes(t.format)||(console.warn(`Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE.`),t.format=Ft),t.useDepth&&![`unsigned-int`,`float`].includes(t.depthFormat)&&(console.warn(`Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT.`),t.depthFormat=Lt);let r=Ls(this);!r.float&&t.format===`float`&&(console.warn(`This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE.`),t.format=Ft),t.useDepth&&!r.float&&t.depthFormat===`float`&&(console.warn(`This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT.`),t.depthFormat=It),!r.halfFloat&&t.format===`half-float`&&(console.warn(`This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE.`),t.format=Ft),t.channels===`rgb`&&[`float`,`half-float`].includes(t.format)&&(console.warn(`FLOAT and HALF_FLOAT formats do not work cross-platform with only RGB channels. Falling back to RGBA.`),t.channels=Ji)}recreateFramebufferTextures(t){let n=this.GL,r=n.getParameter(n.TEXTURE_BINDING_2D),i=n.getParameter(n.FRAMEBUFFER_BINDING),a=n.createTexture();if(!a)throw Error(`Unable to create color texture`);n.bindTexture(n.TEXTURE_2D,a);let o=this._getFramebufferColorFormat(t);if(n.texImage2D(n.TEXTURE_2D,0,o.internalFormat,t.width*t.density,t.height*t.density,0,o.format,o.type,null),t.colorTexture=a,n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,a,0),t.useDepth){let r=n.createTexture();if(!r)throw Error(`Unable to create depth texture`);let i=this._getFramebufferDepthFormat(t);n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,i.internalFormat,t.width*t.density,t.height*t.density,0,i.format,i.type,null),n.framebufferTexture2D(n.FRAMEBUFFER,t.useStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,n.TEXTURE_2D,r,0),t.depthTexture=r}if(t.antialias){if(t.colorRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,t.colorRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,Math.max(0,Math.min(t.antialiasSamples,n.getParameter(n.MAX_SAMPLES))),o.internalFormat,t.width*t.density,t.height*t.density),t.useDepth){let r=this._getFramebufferDepthFormat(t);t.depthRenderbuffer=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,t.depthRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,Math.max(0,Math.min(t.antialiasSamples,n.getParameter(n.MAX_SAMPLES))),r.internalFormat,t.width*t.density,t.height*t.density)}n.bindFramebuffer(n.FRAMEBUFFER,t.aaFramebuffer),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,t.colorRenderbuffer),t.useDepth&&n.framebufferRenderbuffer(n.FRAMEBUFFER,t.useStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,n.RENDERBUFFER,t.depthRenderbuffer)}n.bindTexture(n.TEXTURE_2D,r),n.bindFramebuffer(n.FRAMEBUFFER,i)}_getFramebufferColorFormat(t){let n,r,i,a=this.GL;return n=t.format===`float`?a.FLOAT:t.format===`half-float`?this.webglVersion===`webgl2`?a.HALF_FLOAT:a.getExtension(`OES_texture_half_float`).HALF_FLOAT_OES:a.UNSIGNED_BYTE,r=t.channels===`rgba`?a.RGBA:a.RGB,i=this.webglVersion===`webgl2`?{[a.FLOAT]:{[a.RGBA]:a.RGBA32F},[a.HALF_FLOAT]:{[a.RGBA]:a.RGBA16F},[a.UNSIGNED_BYTE]:{[a.RGBA]:a.RGBA8,[a.RGB]:a.RGB8}}[n][r]:t.format===`half-float`?a.RGBA:r,{internalFormat:i,format:r,type:n}}_getFramebufferDepthFormat(t){let n,r,i,a=this.GL;return n=t.useStencil?t.depthFormat===`float`?a.FLOAT_32_UNSIGNED_INT_24_8_REV:this.webglVersion===`webgl2`?a.UNSIGNED_INT_24_8:a.getExtension(`WEBGL_depth_texture`).UNSIGNED_INT_24_8_WEBGL:t.depthFormat===`float`?a.FLOAT:a.UNSIGNED_INT,r=t.useStencil?a.DEPTH_STENCIL:a.DEPTH_COMPONENT,i=t.useStencil?t.depthFormat===`float`?a.DEPTH32F_STENCIL8:this.webglVersion===`webgl2`?a.DEPTH24_STENCIL8:a.DEPTH_STENCIL:this.webglVersion===`webgl2`?t.depthFormat===`float`?a.DEPTH_COMPONENT32F:a.DEPTH_COMPONENT24:a.DEPTH_COMPONENT,{internalFormat:i,format:r,type:n}}_deleteFramebufferTexture(t){this.GL.deleteTexture(t.rawTexture().texture),this.textures.delete(t)}deleteFramebufferTextures(t){this._deleteFramebufferTexture(t.color),t.depth&&this._deleteFramebufferTexture(t.depth);let n=this.GL;t.colorRenderbuffer&&n.deleteRenderbuffer(t.colorRenderbuffer),t.depthRenderbuffer&&n.deleteRenderbuffer(t.depthRenderbuffer)}deleteFramebufferResources(t){let n=this.GL;n.deleteFramebuffer(t.framebuffer),t.aaFramebuffer&&n.deleteFramebuffer(t.aaFramebuffer),t.depthRenderbuffer&&n.deleteRenderbuffer(t.depthRenderbuffer),t.colorRenderbuffer&&n.deleteRenderbuffer(t.colorRenderbuffer)}getFramebufferToBind(t){return t.antialias?t.aaFramebuffer:t.framebuffer}updateFramebufferTexture(t,n){if(t.antialias){let r=this.GL;r.bindFramebuffer(r.READ_FRAMEBUFFER,t.aaFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,t.framebuffer);let i={colorTexture:[r.COLOR_BUFFER_BIT,t.colorP5Texture.magFilter===`linear`?r.LINEAR:r.NEAREST]};t.useDepth&&(i.depthTexture=[r.DEPTH_BUFFER_BIT,t.depthP5Texture.magFilter===`linear`?r.LINEAR:r.NEAREST]);let[a,o]=i[n];r.blitFramebuffer(0,0,t.width*t.density,t.height*t.density,0,0,t.width*t.density,t.height*t.density,a,o);let s=this.activeFramebuffer();this.bindFramebuffer(s)}}bindFramebuffer(t){let n=this.GL;n.bindFramebuffer(n.FRAMEBUFFER,t?this.getFramebufferToBind(t):null)}framebufferYScale(){return-1}readFramebufferPixels(t){let n=this.GL,r=this.activeFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer);let i=this._getFramebufferColorFormat(t),a=As(t.pixels,n,t.framebuffer,0,0,t.width*t.density,t.height*t.density,i.format,i.type);return this.bindFramebuffer(r),a}readFramebufferPixel(t,n,r){let i=this._getFramebufferColorFormat(t);return js(this.GL,t.framebuffer,n,r,i.format,i.type)}readFramebufferRegion(t,n,r,i,a){let o=this.GL,s=this._getFramebufferColorFormat(t),c=As(void 0,o,t.framebuffer,n*t.density,r*t.density,i*t.density,a*t.density,s.format,s.type),l=new Uint8ClampedArray(i*a*t.density*t.density*4);l.fill(255);let u=s.format===o.RGB?3:4;for(let n=0;n<a*t.density;n++)for(let r=0;r<i*t.density;r++)for(let a=0;a<4;a++){let o=(n*i*t.density+r)*4+a;a<u&&(l[o]=c[u===4?o:(n*i*t.density+r)*u+a])}let d=new fa(i*t.density,a*t.density);return d.imageData=d.canvas.getContext(`2d`).createImageData(d.width,d.height),d.imageData.data.set(l),d.pixels=d.imageData.data,d.updatePixels(),t.density!==1&&d.pixelDensity(t.density),d}updateFramebufferPixels(t){let n=this.GL;t.colorP5Texture.bindTexture();let r=this._getFramebufferColorFormat(t),i=r.format===n.RGBA?4:3,a=t.width*t.height*t.density*t.density*i,o=r.type===n.UNSIGNED_BYTE?Uint8Array:Float32Array;if(!(t.pixels instanceof o)||t.pixels.length!==a)throw Error(`The pixels array has not been set correctly. Please call loadPixels() before updatePixels().`);n.texImage2D(n.TEXTURE_2D,0,r.internalFormat,t.width*t.density,t.height*t.density,0,r.format,r.type,t.pixels),t.colorP5Texture.unbindTexture(),t.dirty.colorTexture=!1;let s=this.activeFramebuffer();t.antialias?(t.begin(),this.push(),this.states.setValue(`imageMode`,ee),this.setCamera(t.filterCamera),this.resetMatrix(),this.states.setValue(`strokeColor`,null),this.clear(),this._drawingFilter=!0,this.image(t,0,0,t.width,t.height,-this.width/2,-this.height/2,this.width,this.height),this._drawingFilter=!1,this.pop(),t.useDepth&&(n.clearDepth(1),n.clear(n.DEPTH_BUFFER_BIT)),t.end()):(n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer),t.useDepth&&(n.clearDepth(1),n.clear(n.DEPTH_BUFFER_BIT)),this.bindFramebuffer(s))}};function OS(t,n){t.RendererGL=DS,n.setAttributes=function(t,n){return this._renderer._setAttributes(t,n)},n._assert3d=function(t){if(!this._renderer.isP3D)throw Error(`${t}() is only supported in WEBGL mode. If you'd like to use 3D graphics and WebGL, see  https://p5js.org/examples/form-3d-primitives.html for more information.`)},t.renderers[h]=t.RendererGL,t.renderers[g]=t.RendererGL}typeof p5<`u`&&OS(p5,p5.prototype);function kS(t){t.registerAddon(hs),t.registerAddon(OS),t.registerAddon(gs),t.registerAddon(R_),t.registerAddon(_s),t.registerAddon(G_),t.registerAddon(Cs),t.registerAddon(lS),t.registerAddon(Xo),t.registerAddon(Go),t.registerAddon(Fo),t.registerAddon(Ho),t.registerAddon(qo),t.registerAddon(Hs),t.registerAddon(Lo),t.registerAddon(ks)}function AS(t){t.registerAddon(rs),t.registerAddon(sS)}var jS=/* @__PURE__ */ s((t=>{(function t(n){var r,i,a,o,s,c;function l(t){var n={},r,i;for(r in t)t.hasOwnProperty(r)&&(i=t[r],typeof i==`object`&&i?n[r]=l(i):n[r]=i);return n}function u(t,n){for(var r,i=t.length,a=0,o;i;)r=i>>>1,o=a+r,n(t[o])?i=r:(a=o+1,i-=r+1);return a}r={AssignmentExpression:`AssignmentExpression`,AssignmentPattern:`AssignmentPattern`,ArrayExpression:`ArrayExpression`,ArrayPattern:`ArrayPattern`,ArrowFunctionExpression:`ArrowFunctionExpression`,AwaitExpression:`AwaitExpression`,BlockStatement:`BlockStatement`,BinaryExpression:`BinaryExpression`,BreakStatement:`BreakStatement`,CallExpression:`CallExpression`,CatchClause:`CatchClause`,ChainExpression:`ChainExpression`,ClassBody:`ClassBody`,ClassDeclaration:`ClassDeclaration`,ClassExpression:`ClassExpression`,ComprehensionBlock:`ComprehensionBlock`,ComprehensionExpression:`ComprehensionExpression`,ConditionalExpression:`ConditionalExpression`,ContinueStatement:`ContinueStatement`,DebuggerStatement:`DebuggerStatement`,DirectiveStatement:`DirectiveStatement`,DoWhileStatement:`DoWhileStatement`,EmptyStatement:`EmptyStatement`,ExportAllDeclaration:`ExportAllDeclaration`,ExportDefaultDeclaration:`ExportDefaultDeclaration`,ExportNamedDeclaration:`ExportNamedDeclaration`,ExportSpecifier:`ExportSpecifier`,ExpressionStatement:`ExpressionStatement`,ForStatement:`ForStatement`,ForInStatement:`ForInStatement`,ForOfStatement:`ForOfStatement`,FunctionDeclaration:`FunctionDeclaration`,FunctionExpression:`FunctionExpression`,GeneratorExpression:`GeneratorExpression`,Identifier:`Identifier`,IfStatement:`IfStatement`,ImportExpression:`ImportExpression`,ImportDeclaration:`ImportDeclaration`,ImportDefaultSpecifier:`ImportDefaultSpecifier`,ImportNamespaceSpecifier:`ImportNamespaceSpecifier`,ImportSpecifier:`ImportSpecifier`,Literal:`Literal`,LabeledStatement:`LabeledStatement`,LogicalExpression:`LogicalExpression`,MemberExpression:`MemberExpression`,MetaProperty:`MetaProperty`,MethodDefinition:`MethodDefinition`,ModuleSpecifier:`ModuleSpecifier`,NewExpression:`NewExpression`,ObjectExpression:`ObjectExpression`,ObjectPattern:`ObjectPattern`,PrivateIdentifier:`PrivateIdentifier`,Program:`Program`,Property:`Property`,PropertyDefinition:`PropertyDefinition`,RestElement:`RestElement`,ReturnStatement:`ReturnStatement`,SequenceExpression:`SequenceExpression`,SpreadElement:`SpreadElement`,Super:`Super`,SwitchStatement:`SwitchStatement`,SwitchCase:`SwitchCase`,TaggedTemplateExpression:`TaggedTemplateExpression`,TemplateElement:`TemplateElement`,TemplateLiteral:`TemplateLiteral`,ThisExpression:`ThisExpression`,ThrowStatement:`ThrowStatement`,TryStatement:`TryStatement`,UnaryExpression:`UnaryExpression`,UpdateExpression:`UpdateExpression`,VariableDeclaration:`VariableDeclaration`,VariableDeclarator:`VariableDeclarator`,WhileStatement:`WhileStatement`,WithStatement:`WithStatement`,YieldExpression:`YieldExpression`},a={AssignmentExpression:[`left`,`right`],AssignmentPattern:[`left`,`right`],ArrayExpression:[`elements`],ArrayPattern:[`elements`],ArrowFunctionExpression:[`params`,`body`],AwaitExpression:[`argument`],BlockStatement:[`body`],BinaryExpression:[`left`,`right`],BreakStatement:[`label`],CallExpression:[`callee`,`arguments`],CatchClause:[`param`,`body`],ChainExpression:[`expression`],ClassBody:[`body`],ClassDeclaration:[`id`,`superClass`,`body`],ClassExpression:[`id`,`superClass`,`body`],ComprehensionBlock:[`left`,`right`],ComprehensionExpression:[`blocks`,`filter`,`body`],ConditionalExpression:[`test`,`consequent`,`alternate`],ContinueStatement:[`label`],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:[`body`,`test`],EmptyStatement:[],ExportAllDeclaration:[`source`],ExportDefaultDeclaration:[`declaration`],ExportNamedDeclaration:[`declaration`,`specifiers`,`source`],ExportSpecifier:[`exported`,`local`],ExpressionStatement:[`expression`],ForStatement:[`init`,`test`,`update`,`body`],ForInStatement:[`left`,`right`,`body`],ForOfStatement:[`left`,`right`,`body`],FunctionDeclaration:[`id`,`params`,`body`],FunctionExpression:[`id`,`params`,`body`],GeneratorExpression:[`blocks`,`filter`,`body`],Identifier:[],IfStatement:[`test`,`consequent`,`alternate`],ImportExpression:[`source`],ImportDeclaration:[`specifiers`,`source`],ImportDefaultSpecifier:[`local`],ImportNamespaceSpecifier:[`local`],ImportSpecifier:[`imported`,`local`],Literal:[],LabeledStatement:[`label`,`body`],LogicalExpression:[`left`,`right`],MemberExpression:[`object`,`property`],MetaProperty:[`meta`,`property`],MethodDefinition:[`key`,`value`],ModuleSpecifier:[],NewExpression:[`callee`,`arguments`],ObjectExpression:[`properties`],ObjectPattern:[`properties`],PrivateIdentifier:[],Program:[`body`],Property:[`key`,`value`],PropertyDefinition:[`key`,`value`],RestElement:[`argument`],ReturnStatement:[`argument`],SequenceExpression:[`expressions`],SpreadElement:[`argument`],Super:[],SwitchStatement:[`discriminant`,`cases`],SwitchCase:[`test`,`consequent`],TaggedTemplateExpression:[`tag`,`quasi`],TemplateElement:[],TemplateLiteral:[`quasis`,`expressions`],ThisExpression:[],ThrowStatement:[`argument`],TryStatement:[`block`,`handler`,`finalizer`],UnaryExpression:[`argument`],UpdateExpression:[`argument`],VariableDeclaration:[`declarations`],VariableDeclarator:[`id`,`init`],WhileStatement:[`test`,`body`],WithStatement:[`object`,`body`],YieldExpression:[`argument`]},o={},s={},c={},i={Break:o,Skip:s,Remove:c};function d(t,n){this.parent=t,this.key=n}d.prototype.replace=function(t){this.parent[this.key]=t},d.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)};function f(t,n,r,i){this.node=t,this.path=n,this.wrap=r,this.ref=i}function p(){}p.prototype.path=function(){var t,n,r,i,a,o;function s(t,n){if(Array.isArray(n))for(r=0,i=n.length;r<i;++r)t.push(n[r]);else t.push(n)}if(!this.__current.path)return null;for(a=[],t=2,n=this.__leavelist.length;t<n;++t)o=this.__leavelist[t],s(a,o.path);return s(a,this.__current.path),a},p.prototype.type=function(){return this.current().type||this.__current.wrap},p.prototype.parents=function(){var t,n,r=[];for(t=1,n=this.__leavelist.length;t<n;++t)r.push(this.__leavelist[t].node);return r},p.prototype.current=function(){return this.__current.node},p.prototype.__execute=function(t,n){var r,i=void 0;return r=this.__current,this.__current=n,this.__state=null,t&&(i=t.call(this,n.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,i},p.prototype.notify=function(t){this.__state=t},p.prototype.skip=function(){this.notify(s)},p.prototype.break=function(){this.notify(o)},p.prototype.remove=function(){this.notify(c)},p.prototype.__initialize=function(t,n){this.visitor=n,this.root=t,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,n.fallback===`iteration`?this.__fallback=Object.keys:typeof n.fallback==`function`&&(this.__fallback=n.fallback),this.__keys=a,n.keys&&(this.__keys=Object.assign(Object.create(this.__keys),n.keys))};function m(t){return typeof t==`object`&&!!t&&typeof t.type==`string`}function h(t,n){return(t===r.ObjectExpression||t===r.ObjectPattern)&&n===`properties`}function g(t,n){for(var r=t.length-1;r>=0;--r)if(t[r].node===n)return!0;return!1}p.prototype.traverse=function(t,n){var r,i,a,c,l,u,d,p,_,v,y,b;for(this.__initialize(t,n),b={},r=this.__worklist,i=this.__leavelist,r.push(new f(t,null,null,null)),i.push(new f(null,null,null,null));r.length;)if(a=r.pop(),a===b){if(a=i.pop(),u=this.__execute(n.leave,a),this.__state===o||u===o)return}else if(a.node){if(u=this.__execute(n.enter,a),this.__state===o||u===o)return;if(r.push(b),i.push(a),this.__state===s||u===s)continue;if(c=a.node,l=c.type||a.wrap,v=this.__keys[l],!v){if(this.__fallback)v=this.__fallback(c);else throw Error(`Unknown node type `+l+`.`)}for(p=v.length;--p>=0;)if(d=v[p],y=c[d],y){if(Array.isArray(y)){for(_=y.length;--_>=0;)if(y[_]&&!g(i,y[_])){if(h(l,v[p]))a=new f(y[_],[d,_],`Property`,null);else if(m(y[_]))a=new f(y[_],[d,_],null,null);else continue;r.push(a)}}else if(m(y)){if(g(i,y))continue;r.push(new f(y,d,null,null))}}}},p.prototype.replace=function(t,n){var r,i,a,l,u,p,g,_,v,y,b,x,S;function C(t){var n,i,a,o;if(t.ref.remove()){for(i=t.ref.key,o=t.ref.parent,n=r.length;n--;)if(a=r[n],a.ref&&a.ref.parent===o){if(a.ref.key<i)break;--a.ref.key}}}for(this.__initialize(t,n),b={},r=this.__worklist,i=this.__leavelist,x={root:t},p=new f(t,null,null,new d(x,`root`)),r.push(p),i.push(p);r.length;)if(p=r.pop(),p===b){if(p=i.pop(),u=this.__execute(n.leave,p),u!==void 0&&u!==o&&u!==s&&u!==c&&p.ref.replace(u),(this.__state===c||u===c)&&C(p),this.__state===o||u===o)return x.root}else{if(u=this.__execute(n.enter,p),u!==void 0&&u!==o&&u!==s&&u!==c&&(p.ref.replace(u),p.node=u),(this.__state===c||u===c)&&(C(p),p.node=null),this.__state===o||u===o)return x.root;if(a=p.node,a&&(r.push(b),i.push(p),this.__state!==s&&u!==s)){if(l=a.type||p.wrap,v=this.__keys[l],!v){if(this.__fallback)v=this.__fallback(a);else throw Error(`Unknown node type `+l+`.`)}for(g=v.length;--g>=0;)if(S=v[g],y=a[S],y){if(Array.isArray(y)){for(_=y.length;--_>=0;)if(y[_]){if(h(l,v[g]))p=new f(y[_],[S,_],`Property`,new d(y,_));else if(m(y[_]))p=new f(y[_],[S,_],null,new d(y,_));else continue;r.push(p)}}else m(y)&&r.push(new f(y,S,null,new d(a,S)))}}}return x.root};function _(t,n){return new p().traverse(t,n)}function v(t,n){return new p().replace(t,n)}function y(t,n){var r=u(n,function(n){return n.range[0]>t.range[0]});return t.extendedRange=[t.range[0],t.range[1]],r!==n.length&&(t.extendedRange[1]=n[r].range[0]),--r,r>=0&&(t.extendedRange[0]=n[r].range[1]),t}function b(t,n,r){var a=[],o,s,c,u;if(!t.range)throw Error(`attachComments needs range information`);if(!r.length){if(n.length){for(c=0,s=n.length;c<s;c+=1)o=l(n[c]),o.extendedRange=[0,t.range[0]],a.push(o);t.leadingComments=a}return t}for(c=0,s=n.length;c<s;c+=1)a.push(y(l(n[c]),r));return u=0,_(t,{enter:function(t){for(var n;u<a.length&&(n=a[u],!(n.extendedRange[1]>t.range[0]));)n.extendedRange[1]===t.range[0]?(t.leadingComments||=[],t.leadingComments.push(n),a.splice(u,1)):u+=1;if(u===a.length)return i.Break;if(a[u].extendedRange[0]>t.range[1])return i.Skip}}),u=0,_(t,{leave:function(t){for(var n;u<a.length&&(n=a[u],!(t.range[1]<n.extendedRange[0]));)t.range[1]===n.extendedRange[0]?(t.trailingComments||=[],t.trailingComments.push(n),a.splice(u,1)):u+=1;if(u===a.length)return i.Break;if(a[u].extendedRange[0]>t.range[1])return i.Skip}}),t}return n.Syntax=r,n.traverse=_,n.replace=v,n.attachComments=b,n.VisitorKeys=a,n.VisitorOption=i,n.Controller=p,n.cloneEnvironment=function(){return t({})},n})(t)})),MS=/* @__PURE__ */ s(((t,n)=>{(function(){function t(t){if(t==null)return!1;switch(t.type){case`ArrayExpression`:case`AssignmentExpression`:case`BinaryExpression`:case`CallExpression`:case`ConditionalExpression`:case`FunctionExpression`:case`Identifier`:case`Literal`:case`LogicalExpression`:case`MemberExpression`:case`NewExpression`:case`ObjectExpression`:case`SequenceExpression`:case`ThisExpression`:case`UnaryExpression`:case`UpdateExpression`:return!0}return!1}function r(t){if(t==null)return!1;switch(t.type){case`DoWhileStatement`:case`ForInStatement`:case`ForStatement`:case`WhileStatement`:return!0}return!1}function i(t){if(t==null)return!1;switch(t.type){case`BlockStatement`:case`BreakStatement`:case`ContinueStatement`:case`DebuggerStatement`:case`DoWhileStatement`:case`EmptyStatement`:case`ExpressionStatement`:case`ForInStatement`:case`ForStatement`:case`IfStatement`:case`LabeledStatement`:case`ReturnStatement`:case`SwitchStatement`:case`ThrowStatement`:case`TryStatement`:case`VariableDeclaration`:case`WhileStatement`:case`WithStatement`:return!0}return!1}function a(t){return i(t)||t!=null&&t.type===`FunctionDeclaration`}function o(t){switch(t.type){case`IfStatement`:return t.alternate==null?t.consequent:t.alternate;case`LabeledStatement`:case`ForStatement`:case`ForInStatement`:case`WhileStatement`:case`WithStatement`:return t.body}return null}function s(t){var n;if(t.type!==`IfStatement`||t.alternate==null)return!1;n=t.consequent;do{if(n.type===`IfStatement`&&n.alternate==null)return!0;n=o(n)}while(n);return!1}n.exports={isExpression:t,isStatement:i,isIterationStatement:r,isSourceElement:a,isProblematicIfStatement:s,trailingStatement:o}})()})),NS=/* @__PURE__ */ s(((t,n)=>{(function(){var t,r={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,NonAsciiIdentifierPart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/},i,a,o,s;t={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};function c(t){return 48<=t&&t<=57}function l(t){return 48<=t&&t<=57||97<=t&&t<=102||65<=t&&t<=70}function u(t){return t>=48&&t<=55}i=[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];function d(t){return t===32||t===9||t===11||t===12||t===160||t>=5760&&i.indexOf(t)>=0}function f(t){return t===10||t===13||t===8232||t===8233}function p(t){return t<=65535?String.fromCharCode(t):String.fromCharCode(Math.floor((t-65536)/1024)+55296)+String.fromCharCode((t-65536)%1024+56320)}for(a=Array(128),s=0;s<128;++s)a[s]=s>=97&&s<=122||s>=65&&s<=90||s===36||s===95;for(o=Array(128),s=0;s<128;++s)o[s]=s>=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||s===36||s===95;function m(t){return t<128?a[t]:r.NonAsciiIdentifierStart.test(p(t))}function h(t){return t<128?o[t]:r.NonAsciiIdentifierPart.test(p(t))}function g(n){return n<128?a[n]:t.NonAsciiIdentifierStart.test(p(n))}function _(n){return n<128?o[n]:t.NonAsciiIdentifierPart.test(p(n))}n.exports={isDecimalDigit:c,isHexDigit:l,isOctalDigit:u,isWhiteSpace:d,isLineTerminator:f,isIdentifierStartES5:m,isIdentifierPartES5:h,isIdentifierStartES6:g,isIdentifierPartES6:_}})()})),PS=/* @__PURE__ */ s(((t,n)=>{(function(){var t=NS();function r(t){switch(t){case`implements`:case`interface`:case`package`:case`private`:case`protected`:case`public`:case`static`:case`let`:return!0;default:return!1}}function i(t,n){return!n&&t===`yield`?!1:a(t,n)}function a(t,n){if(n&&r(t))return!0;switch(t.length){case 2:return t===`if`||t===`in`||t===`do`;case 3:return t===`var`||t===`for`||t===`new`||t===`try`;case 4:return t===`this`||t===`else`||t===`case`||t===`void`||t===`with`||t===`enum`;case 5:return t===`while`||t===`break`||t===`catch`||t===`throw`||t===`const`||t===`yield`||t===`class`||t===`super`;case 6:return t===`return`||t===`typeof`||t===`delete`||t===`switch`||t===`export`||t===`import`;case 7:return t==="default"||t===`finally`||t===`extends`;case 8:return t===`function`||t===`continue`||t===`debugger`;case 10:return t===`instanceof`;default:return!1}}function o(t,n){return t===`null`||t===`true`||t===`false`||i(t,n)}function s(t,n){return t===`null`||t===`true`||t===`false`||a(t,n)}function c(t){return t===`eval`||t===`arguments`}function l(n){var r,i,a;if(n.length===0||(a=n.charCodeAt(0),!t.isIdentifierStartES5(a)))return!1;for(r=1,i=n.length;r<i;++r)if(a=n.charCodeAt(r),!t.isIdentifierPartES5(a))return!1;return!0}function u(t,n){return(t-55296)*1024+(n-56320)+65536}function d(n){var r,i,a,o,s;if(n.length===0)return!1;for(s=t.isIdentifierStartES6,r=0,i=n.length;r<i;++r){if(a=n.charCodeAt(r),55296<=a&&a<=56319){if(++r,r>=i||(o=n.charCodeAt(r),!(56320<=o&&o<=57343)))return!1;a=u(a,o)}if(!s(a))return!1;s=t.isIdentifierPartES6}return!0}function f(t,n){return l(t)&&!o(t,n)}function p(t,n){return d(t)&&!s(t,n)}n.exports={isKeywordES5:i,isKeywordES6:a,isReservedWordES5:o,isReservedWordES6:s,isRestrictedWord:c,isIdentifierNameES5:l,isIdentifierNameES6:d,isIdentifierES5:f,isIdentifierES6:p}})()})),FS=/* @__PURE__ */ s((t=>{(function(){t.ast=MS(),t.code=NS(),t.keyword=PS()})()})),IS=/* @__PURE__ */ s((t=>{var n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``);t.encode=function(t){if(0<=t&&t<n.length)return n[t];throw TypeError(`Must be between 0 and 63: `+t)},t.decode=function(t){var n=65,r=90,i=97,a=122,o=48;return n<=t&&t<=r?t-n:i<=t&&t<=a?t-i+26:o<=t&&t<=57?t-o+52:t==43?62:t==47?63:-1}})),LS=/* @__PURE__ */ s((t=>{var n=IS(),r=5,i=1<<r,a=i-1,o=i;function s(t){return t<0?(-t<<1)+1:(t<<1)+0}function c(t){var n=(t&1)==1,r=t>>1;return n?-r:r}t.encode=function(t){var i=``,c,l=s(t);do c=l&a,l>>>=r,l>0&&(c|=o),i+=n.encode(c);while(l>0);return i},t.decode=function(t,i,s){var l=t.length,u=0,d=0,f,p;do{if(i>=l)throw Error(`Expected more digits in base 64 VLQ value.`);if(p=n.decode(t.charCodeAt(i++)),p===-1)throw Error(`Invalid base64 digit: `+t.charAt(i-1));f=!!(p&o),p&=a,u+=p<<d,d+=r}while(f);s.value=c(u),s.rest=i}})),RS=/* @__PURE__ */ s((t=>{function n(t,n,r){if(n in t)return t[n];if(arguments.length===3)return r;throw Error(`"`+n+`" is a required argument.`)}t.getArg=n;var r=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,i=/^data:.+\,.+$/;function a(t){var n=t.match(r);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}t.urlParse=a;function o(t){var n=``;return t.scheme&&(n+=t.scheme+`:`),n+=`//`,t.auth&&(n+=t.auth+`@`),t.host&&(n+=t.host),t.port&&(n+=`:`+t.port),t.path&&(n+=t.path),n}t.urlGenerate=o;function s(n){var r=n,i=a(n);if(i){if(!i.path)return n;r=i.path}for(var s=t.isAbsolute(r),c=r.split(/\/+/),l,u=0,d=c.length-1;d>=0;d--)l=c[d],l===`.`?c.splice(d,1):l===`..`?u++:u>0&&(l===``?(c.splice(d+1,u),u=0):(c.splice(d,2),u--));return r=c.join(`/`),r===``&&(r=s?`/`:`.`),i?(i.path=r,o(i)):r}t.normalize=s;function c(t,n){t===``&&(t=`.`),n===``&&(n=`.`);var r=a(n),c=a(t);if(c&&(t=c.path||`/`),r&&!r.scheme)return c&&(r.scheme=c.scheme),o(r);if(r||n.match(i))return n;if(c&&!c.host&&!c.path)return c.host=n,o(c);var l=n.charAt(0)===`/`?n:s(t.replace(/\/+$/,``)+`/`+n);return c?(c.path=l,o(c)):l}t.join=c,t.isAbsolute=function(t){return t.charAt(0)===`/`||r.test(t)};function l(t,n){t===``&&(t=`.`),t=t.replace(/\/$/,``);for(var r=0;n.indexOf(t+`/`)!==0;){var i=t.lastIndexOf(`/`);if(i<0||(t=t.slice(0,i),t.match(/^([^\/]+:\/)?\/*$/)))return n;++r}return Array(r+1).join(`../`)+n.substr(t.length+1)}t.relative=l;var u=function(){return!(`__proto__`in Object.create(null))}();function d(t){return t}function f(t){return m(t)?`$`+t:t}t.toSetString=u?d:f;function p(t){return m(t)?t.slice(1):t}t.fromSetString=u?d:p;function m(t){if(!t)return!1;var n=t.length;if(n<9||t.charCodeAt(n-1)!==95||t.charCodeAt(n-2)!==95||t.charCodeAt(n-3)!==111||t.charCodeAt(n-4)!==116||t.charCodeAt(n-5)!==111||t.charCodeAt(n-6)!==114||t.charCodeAt(n-7)!==112||t.charCodeAt(n-8)!==95||t.charCodeAt(n-9)!==95)return!1;for(var r=n-10;r>=0;r--)if(t.charCodeAt(r)!==36)return!1;return!0}function h(t,n,r){var i=_(t.source,n.source);return i!==0||(i=t.originalLine-n.originalLine,i!==0)||(i=t.originalColumn-n.originalColumn,i!==0||r)||(i=t.generatedColumn-n.generatedColumn,i!==0)||(i=t.generatedLine-n.generatedLine,i!==0)?i:_(t.name,n.name)}t.compareByOriginalPositions=h;function g(t,n,r){var i=t.generatedLine-n.generatedLine;return i!==0||(i=t.generatedColumn-n.generatedColumn,i!==0||r)||(i=_(t.source,n.source),i!==0)||(i=t.originalLine-n.originalLine,i!==0)||(i=t.originalColumn-n.originalColumn,i!==0)?i:_(t.name,n.name)}t.compareByGeneratedPositionsDeflated=g;function _(t,n){return t===n?0:t===null?1:n===null?-1:t>n?1:-1}function v(t,n){var r=t.generatedLine-n.generatedLine;return r!==0||(r=t.generatedColumn-n.generatedColumn,r!==0)||(r=_(t.source,n.source),r!==0)||(r=t.originalLine-n.originalLine,r!==0)||(r=t.originalColumn-n.originalColumn,r!==0)?r:_(t.name,n.name)}t.compareByGeneratedPositionsInflated=v;function y(t){return JSON.parse(t.replace(/^\)]}'[^\n]*\n/,``))}t.parseSourceMapInput=y;function b(t,n,r){if(n||=``,t&&(t[t.length-1]!==`/`&&n[0]!==`/`&&(t+=`/`),n=t+n),r){var i=a(r);if(!i)throw Error(`sourceMapURL could not be parsed`);if(i.path){var l=i.path.lastIndexOf(`/`);l>=0&&(i.path=i.path.substring(0,l+1))}n=c(o(i),n)}return s(n)}t.computeSourceURL=b})),zS=/* @__PURE__ */ s((t=>{var n=RS(),r=Object.prototype.hasOwnProperty,i=typeof Map<`u`;function a(){this._array=[],this._set=i?/* @__PURE__ */ new Map:Object.create(null)}a.fromArray=function(t,n){for(var r=new a,i=0,o=t.length;i<o;i++)r.add(t[i],n);return r},a.prototype.size=function(){return i?this._set.size:Object.getOwnPropertyNames(this._set).length},a.prototype.add=function(t,a){var o=i?t:n.toSetString(t),s=i?this.has(t):r.call(this._set,o),c=this._array.length;(!s||a)&&this._array.push(t),s||(i?this._set.set(t,c):this._set[o]=c)},a.prototype.has=function(t){if(i)return this._set.has(t);var a=n.toSetString(t);return r.call(this._set,a)},a.prototype.indexOf=function(t){if(i){var a=this._set.get(t);if(a>=0)return a}else{var o=n.toSetString(t);if(r.call(this._set,o))return this._set[o]}throw Error(`"`+t+`" is not in the set.`)},a.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw Error(`No element indexed by `+t)},a.prototype.toArray=function(){return this._array.slice()},t.ArraySet=a})),BS=/* @__PURE__ */ s((t=>{var n=RS();function r(t,r){var i=t.generatedLine,a=r.generatedLine,o=t.generatedColumn,s=r.generatedColumn;return a>i||a==i&&s>=o||n.compareByGeneratedPositionsInflated(t,r)<=0}function i(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}i.prototype.unsortedForEach=function(t,n){this._array.forEach(t,n)},i.prototype.add=function(t){r(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))},i.prototype.toArray=function(){return this._sorted||=(this._array.sort(n.compareByGeneratedPositionsInflated),!0),this._array},t.MappingList=i})),VS=/* @__PURE__ */ s((t=>{var n=LS(),r=RS(),i=zS().ArraySet,a=BS().MappingList;function o(t){t||={},this._file=r.getArg(t,`file`,null),this._sourceRoot=r.getArg(t,`sourceRoot`,null),this._skipValidation=r.getArg(t,`skipValidation`,!1),this._sources=new i,this._names=new i,this._mappings=new a,this._sourcesContents=null}o.prototype._version=3,o.fromSourceMap=function(t){var n=t.sourceRoot,i=new o({file:t.file,sourceRoot:n});return t.eachMapping(function(t){var a={generated:{line:t.generatedLine,column:t.generatedColumn}};t.source!=null&&(a.source=t.source,n!=null&&(a.source=r.relative(n,a.source)),a.original={line:t.originalLine,column:t.originalColumn},t.name!=null&&(a.name=t.name)),i.addMapping(a)}),t.sources.forEach(function(a){var o=a;n!==null&&(o=r.relative(n,a)),i._sources.has(o)||i._sources.add(o);var s=t.sourceContentFor(a);s!=null&&i.setSourceContent(a,s)}),i},o.prototype.addMapping=function(t){var n=r.getArg(t,`generated`),i=r.getArg(t,`original`,null),a=r.getArg(t,`source`,null),o=r.getArg(t,`name`,null);this._skipValidation||this._validateMapping(n,i,a,o),a!=null&&(a=String(a),this._sources.has(a)||this._sources.add(a)),o!=null&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:i!=null&&i.line,originalColumn:i!=null&&i.column,source:a,name:o})},o.prototype.setSourceContent=function(t,n){var i=t;this._sourceRoot!=null&&(i=r.relative(this._sourceRoot,i)),n==null?this._sourcesContents&&(delete this._sourcesContents[r.toSetString(i)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null)):(this._sourcesContents||=Object.create(null),this._sourcesContents[r.toSetString(i)]=n)},o.prototype.applySourceMap=function(t,n,a){var o=n;if(n==null){if(t.file==null)throw Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);o=t.file}var s=this._sourceRoot;s!=null&&(o=r.relative(s,o));var c=new i,l=new i;this._mappings.unsortedForEach(function(n){if(n.source===o&&n.originalLine!=null){var i=t.originalPositionFor({line:n.originalLine,column:n.originalColumn});i.source!=null&&(n.source=i.source,a!=null&&(n.source=r.join(a,n.source)),s!=null&&(n.source=r.relative(s,n.source)),n.originalLine=i.line,n.originalColumn=i.column,i.name!=null&&(n.name=i.name))}var u=n.source;u!=null&&!c.has(u)&&c.add(u);var d=n.name;d!=null&&!l.has(d)&&l.add(d)},this),this._sources=c,this._names=l,t.sources.forEach(function(n){var i=t.sourceContentFor(n);i!=null&&(a!=null&&(n=r.join(a,n)),s!=null&&(n=r.relative(s,n)),this.setSourceContent(n,i))},this)},o.prototype._validateMapping=function(t,n,r,i){if(n&&typeof n.line!=`number`&&typeof n.column!=`number`)throw Error(`original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.`);if(!(t&&`line`in t&&`column`in t&&t.line>0&&t.column>=0&&!n&&!r&&!i)&&!(t&&`line`in t&&`column`in t&&n&&`line`in n&&`column`in n&&t.line>0&&t.column>=0&&n.line>0&&n.column>=0&&r))throw Error(`Invalid mapping: `+JSON.stringify({generated:t,source:r,original:n,name:i}))},o.prototype._serializeMappings=function(){for(var t=0,i=1,a=0,o=0,s=0,c=0,l=``,u,d,f,p,m=this._mappings.toArray(),h=0,g=m.length;h<g;h++){if(d=m[h],u=``,d.generatedLine!==i)for(t=0;d.generatedLine!==i;)u+=`;`,i++;else if(h>0){if(!r.compareByGeneratedPositionsInflated(d,m[h-1]))continue;u+=`,`}u+=n.encode(d.generatedColumn-t),t=d.generatedColumn,d.source!=null&&(p=this._sources.indexOf(d.source),u+=n.encode(p-c),c=p,u+=n.encode(d.originalLine-1-o),o=d.originalLine-1,u+=n.encode(d.originalColumn-a),a=d.originalColumn,d.name!=null&&(f=this._names.indexOf(d.name),u+=n.encode(f-s),s=f)),l+=u}return l},o.prototype._generateSourcesContent=function(t,n){return t.map(function(t){if(!this._sourcesContents)return null;n!=null&&(t=r.relative(n,t));var i=r.toSetString(t);return Object.prototype.hasOwnProperty.call(this._sourcesContents,i)?this._sourcesContents[i]:null},this)},o.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t},o.prototype.toString=function(){return JSON.stringify(this.toJSON())},t.SourceMapGenerator=o})),HS=/* @__PURE__ */ s((t=>{t.GREATEST_LOWER_BOUND=1,t.LEAST_UPPER_BOUND=2;function n(r,i,a,o,s,c){var l=Math.floor((i-r)/2)+r,u=s(a,o[l],!0);return u===0?l:u>0?i-l>1?n(l,i,a,o,s,c):c==t.LEAST_UPPER_BOUND?i<o.length?i:-1:l:l-r>1?n(r,l,a,o,s,c):c==t.LEAST_UPPER_BOUND?l:r<0?-1:r}t.search=function(r,i,a,o){if(i.length===0)return-1;var s=n(-1,i.length,r,i,a,o||t.GREATEST_LOWER_BOUND);if(s<0)return-1;for(;s-1>=0&&a(i[s],i[s-1],!0)===0;)--s;return s}})),US=/* @__PURE__ */ s((t=>{function n(t,n,r){var i=t[n];t[n]=t[r],t[r]=i}function r(t,n){return Math.round(t+Math.random()*(n-t))}function i(t,a,o,s){if(o<s){var c=r(o,s),l=o-1;n(t,c,s);for(var u=t[s],d=o;d<s;d++)a(t[d],u)<=0&&(l+=1,n(t,l,d));n(t,l+1,d);var f=l+1;i(t,a,o,f-1),i(t,a,f+1,s)}}t.quickSort=function(t,n){i(t,n,0,t.length-1)}})),WS=/* @__PURE__ */ s((t=>{var n=RS(),r=HS(),i=zS().ArraySet,a=LS(),o=US().quickSort;function s(t,r){var i=t;return typeof t==`string`&&(i=n.parseSourceMapInput(t)),i.sections==null?new c(i,r):new u(i,r)}s.fromSourceMap=function(t,n){return c.fromSourceMap(t,n)},s.prototype._version=3,s.prototype.__generatedMappings=null,Object.defineProperty(s.prototype,"_generatedMappings",{configurable:!0,enumerable:!0,get:function(){return this.__generatedMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__generatedMappings}}),s.prototype.__originalMappings=null,Object.defineProperty(s.prototype,"_originalMappings",{configurable:!0,enumerable:!0,get:function(){return this.__originalMappings||this._parseMappings(this._mappings,this.sourceRoot),this.__originalMappings}}),s.prototype._charIsMappingSeparator=function(t,n){var r=t.charAt(n);return r===`;`||r===`,`},s.prototype._parseMappings=function(t,n){throw Error(`Subclasses must implement _parseMappings`)},s.GENERATED_ORDER=1,s.ORIGINAL_ORDER=2,s.GREATEST_LOWER_BOUND=1,s.LEAST_UPPER_BOUND=2,s.prototype.eachMapping=function(t,r,i){var a=r||null,o=i||s.GENERATED_ORDER,c;switch(o){case s.GENERATED_ORDER:c=this._generatedMappings;break;case s.ORIGINAL_ORDER:c=this._originalMappings;break;default:throw Error(`Unknown order of iteration.`)}var l=this.sourceRoot;c.map(function(t){var r=t.source===null?null:this._sources.at(t.source);return r=n.computeSourceURL(l,r,this._sourceMapURL),{source:r,generatedLine:t.generatedLine,generatedColumn:t.generatedColumn,originalLine:t.originalLine,originalColumn:t.originalColumn,name:t.name===null?null:this._names.at(t.name)}},this).forEach(t,a)},s.prototype.allGeneratedPositionsFor=function(t){var i=n.getArg(t,`line`),a={source:n.getArg(t,`source`),originalLine:i,originalColumn:n.getArg(t,`column`,0)};if(a.source=this._findSourceIndex(a.source),a.source<0)return[];var o=[],s=this._findMapping(a,this._originalMappings,`originalLine`,`originalColumn`,n.compareByOriginalPositions,r.LEAST_UPPER_BOUND);if(s>=0){var c=this._originalMappings[s];if(t.column===void 0)for(var l=c.originalLine;c&&c.originalLine===l;)o.push({line:n.getArg(c,`generatedLine`,null),column:n.getArg(c,`generatedColumn`,null),lastColumn:n.getArg(c,`lastGeneratedColumn`,null)}),c=this._originalMappings[++s];else for(var u=c.originalColumn;c&&c.originalLine===i&&c.originalColumn==u;)o.push({line:n.getArg(c,`generatedLine`,null),column:n.getArg(c,`generatedColumn`,null),lastColumn:n.getArg(c,`lastGeneratedColumn`,null)}),c=this._originalMappings[++s]}return o},t.SourceMapConsumer=s;function c(t,r){var a=t;typeof t==`string`&&(a=n.parseSourceMapInput(t));var o=n.getArg(a,`version`),s=n.getArg(a,`sources`),c=n.getArg(a,`names`,[]),l=n.getArg(a,`sourceRoot`,null),u=n.getArg(a,`sourcesContent`,null),d=n.getArg(a,`mappings`),f=n.getArg(a,`file`,null);if(o!=this._version)throw Error(`Unsupported version: `+o);l&&=n.normalize(l),s=s.map(String).map(n.normalize).map(function(t){return l&&n.isAbsolute(l)&&n.isAbsolute(t)?n.relative(l,t):t}),this._names=i.fromArray(c.map(String),!0),this._sources=i.fromArray(s,!0),this._absoluteSources=this._sources.toArray().map(function(t){return n.computeSourceURL(l,t,r)}),this.sourceRoot=l,this.sourcesContent=u,this._mappings=d,this._sourceMapURL=r,this.file=f}c.prototype=Object.create(s.prototype),c.prototype.consumer=s,c.prototype._findSourceIndex=function(t){var r=t;if(this.sourceRoot!=null&&(r=n.relative(this.sourceRoot,r)),this._sources.has(r))return this._sources.indexOf(r);for(var i=0;i<this._absoluteSources.length;++i)if(this._absoluteSources[i]==t)return i;return-1},c.fromSourceMap=function(t,r){var a=Object.create(c.prototype),s=a._names=i.fromArray(t._names.toArray(),!0),u=a._sources=i.fromArray(t._sources.toArray(),!0);a.sourceRoot=t._sourceRoot,a.sourcesContent=t._generateSourcesContent(a._sources.toArray(),a.sourceRoot),a.file=t._file,a._sourceMapURL=r,a._absoluteSources=a._sources.toArray().map(function(t){return n.computeSourceURL(a.sourceRoot,t,r)});for(var d=t._mappings.toArray().slice(),f=a.__generatedMappings=[],p=a.__originalMappings=[],m=0,h=d.length;m<h;m++){var g=d[m],_=new l;_.generatedLine=g.generatedLine,_.generatedColumn=g.generatedColumn,g.source&&(_.source=u.indexOf(g.source),_.originalLine=g.originalLine,_.originalColumn=g.originalColumn,g.name&&(_.name=s.indexOf(g.name)),p.push(_)),f.push(_)}return o(a.__originalMappings,n.compareByOriginalPositions),a},c.prototype._version=3,Object.defineProperty(c.prototype,"sources",{get:function(){return this._absoluteSources.slice()}});function l(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}c.prototype._parseMappings=function(t,r){for(var i=1,s=0,c=0,u=0,d=0,f=0,p=t.length,m=0,h={},g={},_=[],v=[],y,b,x,S,C;m<p;)if(t.charAt(m)===`;`)i++,m++,s=0;else if(t.charAt(m)===`,`)m++;else{for(y=new l,y.generatedLine=i,S=m;S<p&&!this._charIsMappingSeparator(t,S);S++);if(b=t.slice(m,S),x=h[b],x)m+=b.length;else{for(x=[];m<S;)a.decode(t,m,g),C=g.value,m=g.rest,x.push(C);if(x.length===2)throw Error(`Found a source, but no line and column`);if(x.length===3)throw Error(`Found a source and line, but no column`);h[b]=x}y.generatedColumn=s+x[0],s=y.generatedColumn,x.length>1&&(y.source=d+x[1],d+=x[1],y.originalLine=c+x[2],c=y.originalLine,y.originalLine+=1,y.originalColumn=u+x[3],u=y.originalColumn,x.length>4&&(y.name=f+x[4],f+=x[4])),v.push(y),typeof y.originalLine==`number`&&_.push(y)}o(v,n.compareByGeneratedPositionsDeflated),this.__generatedMappings=v,o(_,n.compareByOriginalPositions),this.__originalMappings=_},c.prototype._findMapping=function(t,n,i,a,o,s){if(t[i]<=0)throw TypeError(`Line must be greater than or equal to 1, got `+t[i]);if(t[a]<0)throw TypeError(`Column must be greater than or equal to 0, got `+t[a]);return r.search(t,n,o,s)},c.prototype.computeColumnSpans=function(){for(var t=0;t<this._generatedMappings.length;++t){var n=this._generatedMappings[t];if(t+1<this._generatedMappings.length){var r=this._generatedMappings[t+1];if(n.generatedLine===r.generatedLine){n.lastGeneratedColumn=r.generatedColumn-1;continue}}n.lastGeneratedColumn=1/0}},c.prototype.originalPositionFor=function(t){var r={generatedLine:n.getArg(t,`line`),generatedColumn:n.getArg(t,`column`)},i=this._findMapping(r,this._generatedMappings,`generatedLine`,`generatedColumn`,n.compareByGeneratedPositionsDeflated,n.getArg(t,`bias`,s.GREATEST_LOWER_BOUND));if(i>=0){var a=this._generatedMappings[i];if(a.generatedLine===r.generatedLine){var o=n.getArg(a,`source`,null);o!==null&&(o=this._sources.at(o),o=n.computeSourceURL(this.sourceRoot,o,this._sourceMapURL));var c=n.getArg(a,`name`,null);return c!==null&&(c=this._names.at(c)),{source:o,line:n.getArg(a,`originalLine`,null),column:n.getArg(a,`originalColumn`,null),name:c}}}return{source:null,line:null,column:null,name:null}},c.prototype.hasContentsOfAllSources=function(){return this.sourcesContent?this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(t){return t==null}):!1},c.prototype.sourceContentFor=function(t,r){if(!this.sourcesContent)return null;var i=this._findSourceIndex(t);if(i>=0)return this.sourcesContent[i];var a=t;this.sourceRoot!=null&&(a=n.relative(this.sourceRoot,a));var o;if(this.sourceRoot!=null&&(o=n.urlParse(this.sourceRoot))){var s=a.replace(/^file:\/\//,``);if(o.scheme==`file`&&this._sources.has(s))return this.sourcesContent[this._sources.indexOf(s)];if((!o.path||o.path==`/`)&&this._sources.has(`/`+a))return this.sourcesContent[this._sources.indexOf(`/`+a)]}if(r)return null;throw Error(`"`+a+`" is not in the SourceMap.`)},c.prototype.generatedPositionFor=function(t){var r=n.getArg(t,`source`);if(r=this._findSourceIndex(r),r<0)return{line:null,column:null,lastColumn:null};var i={source:r,originalLine:n.getArg(t,`line`),originalColumn:n.getArg(t,`column`)},a=this._findMapping(i,this._originalMappings,`originalLine`,`originalColumn`,n.compareByOriginalPositions,n.getArg(t,`bias`,s.GREATEST_LOWER_BOUND));if(a>=0){var o=this._originalMappings[a];if(o.source===i.source)return{line:n.getArg(o,`generatedLine`,null),column:n.getArg(o,`generatedColumn`,null),lastColumn:n.getArg(o,`lastGeneratedColumn`,null)}}return{line:null,column:null,lastColumn:null}},t.BasicSourceMapConsumer=c;function u(t,r){var a=t;typeof t==`string`&&(a=n.parseSourceMapInput(t));var o=n.getArg(a,`version`),c=n.getArg(a,`sections`);if(o!=this._version)throw Error(`Unsupported version: `+o);this._sources=new i,this._names=new i;var l={line:-1,column:0};this._sections=c.map(function(t){if(t.url)throw Error(`Support for url field in sections not implemented.`);var i=n.getArg(t,`offset`),a=n.getArg(i,`line`),o=n.getArg(i,`column`);if(a<l.line||a===l.line&&o<l.column)throw Error(`Section offsets must be ordered and non-overlapping.`);return l=i,{generatedOffset:{generatedLine:a+1,generatedColumn:o+1},consumer:new s(n.getArg(t,`map`),r)}})}u.prototype=Object.create(s.prototype),u.prototype.constructor=s,u.prototype._version=3,Object.defineProperty(u.prototype,"sources",{get:function(){for(var t=[],n=0;n<this._sections.length;n++)for(var r=0;r<this._sections[n].consumer.sources.length;r++)t.push(this._sections[n].consumer.sources[r]);return t}}),u.prototype.originalPositionFor=function(t){var i={generatedLine:n.getArg(t,`line`),generatedColumn:n.getArg(t,`column`)},a=r.search(i,this._sections,function(t,n){return t.generatedLine-n.generatedOffset.generatedLine||t.generatedColumn-n.generatedOffset.generatedColumn}),o=this._sections[a];return o?o.consumer.originalPositionFor({line:i.generatedLine-(o.generatedOffset.generatedLine-1),column:i.generatedColumn-(o.generatedOffset.generatedLine===i.generatedLine?o.generatedOffset.generatedColumn-1:0),bias:t.bias}):{source:null,line:null,column:null,name:null}},u.prototype.hasContentsOfAllSources=function(){return this._sections.every(function(t){return t.consumer.hasContentsOfAllSources()})},u.prototype.sourceContentFor=function(t,n){for(var r=0;r<this._sections.length;r++){var i=this._sections[r].consumer.sourceContentFor(t,!0);if(i)return i}if(n)return null;throw Error(`"`+t+`" is not in the SourceMap.`)},u.prototype.generatedPositionFor=function(t){for(var r=0;r<this._sections.length;r++){var i=this._sections[r];if(i.consumer._findSourceIndex(n.getArg(t,`source`))!==-1){var a=i.consumer.generatedPositionFor(t);if(a)return{line:a.line+(i.generatedOffset.generatedLine-1),column:a.column+(i.generatedOffset.generatedLine===a.line?i.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},u.prototype._parseMappings=function(t,r){this.__generatedMappings=[],this.__originalMappings=[];for(var i=0;i<this._sections.length;i++)for(var a=this._sections[i],s=a.consumer._generatedMappings,c=0;c<s.length;c++){var l=s[c],u=a.consumer._sources.at(l.source);u=n.computeSourceURL(a.consumer.sourceRoot,u,this._sourceMapURL),this._sources.add(u),u=this._sources.indexOf(u);var d=null;l.name&&(d=a.consumer._names.at(l.name),this._names.add(d),d=this._names.indexOf(d));var f={source:u,generatedLine:l.generatedLine+(a.generatedOffset.generatedLine-1),generatedColumn:l.generatedColumn+(a.generatedOffset.generatedLine===l.generatedLine?a.generatedOffset.generatedColumn-1:0),originalLine:l.originalLine,originalColumn:l.originalColumn,name:d};this.__generatedMappings.push(f),typeof f.originalLine==`number`&&this.__originalMappings.push(f)}o(this.__generatedMappings,n.compareByGeneratedPositionsDeflated),o(this.__originalMappings,n.compareByOriginalPositions)},t.IndexedSourceMapConsumer=u})),GS=/* @__PURE__ */ s((t=>{var n=VS().SourceMapGenerator,r=RS(),i=/(\r?\n)/,a=10,o=`$$$isSourceNode$$$`;function s(t,n,r,i,a){this.children=[],this.sourceContents={},this.line=t??null,this.column=n??null,this.source=r??null,this.name=a??null,this[o]=!0,i!=null&&this.add(i)}s.fromStringWithSourceMap=function(t,n,a){var o=new s,c=t.split(i),l=0,u=function(){return t()+(t()||``);function t(){return l<c.length?c[l++]:void 0}},d=1,f=0,p=null;return n.eachMapping(function(t){if(p!==null){if(d<t.generatedLine)m(p,u()),d++,f=0;else{var n=c[l]||``,r=n.substr(0,t.generatedColumn-f);c[l]=n.substr(t.generatedColumn-f),f=t.generatedColumn,m(p,r),p=t;return}}for(;d<t.generatedLine;)o.add(u()),d++;if(f<t.generatedColumn){var n=c[l]||``;o.add(n.substr(0,t.generatedColumn)),c[l]=n.substr(t.generatedColumn),f=t.generatedColumn}p=t},this),l<c.length&&(p&&m(p,u()),o.add(c.splice(l).join(``))),n.sources.forEach(function(t){var i=n.sourceContentFor(t);i!=null&&(a!=null&&(t=r.join(a,t)),o.setSourceContent(t,i))}),o;function m(t,n){if(t===null||t.source===void 0)o.add(n);else{var i=a?r.join(a,t.source):t.source;o.add(new s(t.originalLine,t.originalColumn,i,n,t.name))}}},s.prototype.add=function(t){if(Array.isArray(t))t.forEach(function(t){this.add(t)},this);else if(t[o]||typeof t==`string`)t&&this.children.push(t);else throw TypeError(`Expected a SourceNode, string, or an array of SourceNodes and strings. Got `+t);return this},s.prototype.prepend=function(t){if(Array.isArray(t))for(var n=t.length-1;n>=0;n--)this.prepend(t[n]);else if(t[o]||typeof t==`string`)this.children.unshift(t);else throw TypeError(`Expected a SourceNode, string, or an array of SourceNodes and strings. Got `+t);return this},s.prototype.walk=function(t){for(var n,r=0,i=this.children.length;r<i;r++)n=this.children[r],n[o]?n.walk(t):n!==``&&t(n,{source:this.source,line:this.line,column:this.column,name:this.name})},s.prototype.join=function(t){var n,r,i=this.children.length;if(i>0){for(n=[],r=0;r<i-1;r++)n.push(this.children[r]),n.push(t);n.push(this.children[r]),this.children=n}return this},s.prototype.replaceRight=function(t,n){var r=this.children[this.children.length-1];return r[o]?r.replaceRight(t,n):typeof r==`string`?this.children[this.children.length-1]=r.replace(t,n):this.children.push(``.replace(t,n)),this},s.prototype.setSourceContent=function(t,n){this.sourceContents[r.toSetString(t)]=n},s.prototype.walkSourceContents=function(t){for(var n=0,i=this.children.length;n<i;n++)this.children[n][o]&&this.children[n].walkSourceContents(t);for(var a=Object.keys(this.sourceContents),n=0,i=a.length;n<i;n++)t(r.fromSetString(a[n]),this.sourceContents[a[n]])},s.prototype.toString=function(){var t=``;return this.walk(function(n){t+=n}),t},s.prototype.toStringWithSourceMap=function(t){var r={code:``,line:1,column:0},i=new n(t),o=!1,s=null,c=null,l=null,u=null;return this.walk(function(t,n){r.code+=t,n.source!==null&&n.line!==null&&n.column!==null?((s!==n.source||c!==n.line||l!==n.column||u!==n.name)&&i.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:r.line,column:r.column},name:n.name}),s=n.source,c=n.line,l=n.column,u=n.name,o=!0):o&&=(i.addMapping({generated:{line:r.line,column:r.column}}),s=null,!1);for(var d=0,f=t.length;d<f;d++)t.charCodeAt(d)===a?(r.line++,r.column=0,d+1===f?(s=null,o=!1):o&&i.addMapping({source:n.source,original:{line:n.line,column:n.column},generated:{line:r.line,column:r.column},name:n.name})):r.column++}),this.walkSourceContents(function(t,n){i.setSourceContent(t,n)}),{code:r.code,map:i}},t.SourceNode=s})),KS=/* @__PURE__ */ s((t=>{t.SourceMapGenerator=VS().SourceMapGenerator,t.SourceMapConsumer=WS().SourceMapConsumer,t.SourceNode=GS().SourceNode})),qS=/* @__PURE__ */ s(((t,n)=>{n.exports={name:`escodegen`,description:`ECMAScript code generator`,homepage:`http://github.com/estools/escodegen`,main:`escodegen.js`,bin:{esgenerate:`./bin/esgenerate.js`,escodegen:`./bin/escodegen.js`},files:[`LICENSE.BSD`,`README.md`,`bin`,`escodegen.js`,`package.json`],version:`2.1.0`,engines:{node:`>=6.0`},maintainers:[{name:`Yusuke Suzuki`,email:`utatane.tea@gmail.com`,web:`http://github.com/Constellation`}],repository:{type:`git`,url:`http://github.com/estools/escodegen.git`},dependencies:{estraverse:`^5.2.0`,esutils:`^2.0.2`,esprima:`^4.0.1`},optionalDependencies:{"source-map":`~0.6.1`},devDependencies:{acorn:`^8.0.4`,bluebird:`^3.4.7`,"bower-registry-client":`^1.0.0`,chai:`^4.2.0`,"chai-exclude":`^2.0.2`,"commonjs-everywhere":`^0.9.7`,gulp:`^4.0.2`,"gulp-eslint":`^6.0.0`,"gulp-mocha":`^7.0.2`,minimist:`^1.2.5`,optionator:`^0.9.1`,semver:`^7.3.4`},license:`BSD-2-Clause`,scripts:{test:`gulp travis`,"unit-test":`gulp test`,lint:`gulp lint`,release:`node tools/release.js`,"build-min":`./node_modules/.bin/cjsify -ma path: tools/entry-point.js > escodegen.browser.min.js`,build:`./node_modules/.bin/cjsify -a path: tools/entry-point.js > escodegen.browser.js`}}})),JS=/* @__PURE__ */ u((/* @__PURE__ */ s((t=>{(function(){var n,r,i,a,o=jS(),s=FS(),c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D;n=o.Syntax;function O(t){return ze.Expression.hasOwnProperty(t.type)}function k(t){return ze.Statement.hasOwnProperty(t.type)}r={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,Coalesce:3,LogicalOR:4,LogicalAND:5,BitwiseOR:6,BitwiseXOR:7,BitwiseAND:8,Equality:9,Relational:10,BitwiseSHIFT:11,Additive:12,Multiplicative:13,Exponentiation:14,Await:15,Unary:15,Postfix:16,OptionalChaining:17,Call:18,New:19,TaggedTemplate:20,Member:21,Primary:22},i={"??":r.Coalesce,"||":r.LogicalOR,"&&":r.LogicalAND,"|":r.BitwiseOR,"^":r.BitwiseXOR,"&":r.BitwiseAND,"==":r.Equality,"!=":r.Equality,"===":r.Equality,"!==":r.Equality,is:r.Equality,isnt:r.Equality,"<":r.Relational,">":r.Relational,"<=":r.Relational,">=":r.Relational,in:r.Relational,instanceof:r.Relational,"<<":r.BitwiseSHIFT,">>":r.BitwiseSHIFT,">>>":r.BitwiseSHIFT,"+":r.Additive,"-":r.Additive,"*":r.Multiplicative,"%":r.Multiplicative,"/":r.Multiplicative,"**":r.Exponentiation};var A=1,j=2,M=4,ee=8,te=16,N=32,ne=64,re=j|M,ie=A|j,P=A|j|M,ae=A,oe=M,se=A|M,ce=A,le=A|N,ue=0,de=A|te,fe=A|ee;function pe(){return{indent:null,base:null,parse:null,comment:!1,format:{indent:{style:`    `,base:0,adjustMultilineComment:!1},newline:`
`,space:` `,json:!1,renumber:!1,hexadecimal:!1,quotes:`single`,escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1,preserveBlankLines:!1},moz:{comprehensionExpressionStartsWithAssignment:!1,starlessGenerator:!1},sourceMap:null,sourceMapRoot:null,sourceMapWithCode:!1,directive:!1,raw:!0,verbatim:null,sourceCode:null}}function me(t,n){var r=``;for(n|=0;n>0;n>>>=1,t+=t)n&1&&(r+=t);return r}function he(t){return/[\r\n]/g.test(t)}function ge(t){var n=t.length;return n&&s.code.isLineTerminator(t.charCodeAt(n-1))}function _e(t,n){for(var r in n)n.hasOwnProperty(r)&&(t[r]=n[r]);return t}function ve(t,n){var r,i;function a(t){return typeof t==`object`&&t instanceof Object&&!(t instanceof RegExp)}for(r in n)n.hasOwnProperty(r)&&(i=n[r],a(i)?a(t[r])?ve(t[r],i):t[r]=ve({},i):t[r]=i);return t}function ye(t){var n,r,i,a,o;if(t!==t)throw Error(`Numeric literal whose value is NaN`);if(t<0||t===0&&1/t<0)throw Error(`Numeric literal whose value is negative`);if(t===1/0)return u?`null`:d?`1e400`:`1e+400`;if(n=``+t,!d||n.length<3)return n;for(r=n.indexOf(`.`),!u&&n.charCodeAt(0)===48&&r===1&&(r=0,n=n.slice(1)),i=n,n=n.replace(`e+`,`e`),a=0,(o=i.indexOf(`e`))>0&&(a=+i.slice(o+1),i=i.slice(0,o)),r>=0&&(a-=i.length-r-1,i=+(i.slice(0,r)+i.slice(r+1))+``),o=0;i.charCodeAt(i.length+o-1)===48;)--o;return o!==0&&(a-=o,i=i.slice(0,o)),a!==0&&(i+=`e`+a),(i.length<n.length||f&&t>0xe8d4a51000&&Math.floor(t)===t&&(i=`0x`+t.toString(16)).length<n.length)&&+i===t&&(n=i),n}function be(t,n){return(t&-2)==8232?(n?`u`:`\\u`)+(t===8232?`2028`:`2029`):t===10||t===13?(n?``:`\\`)+(t===10?`n`:`r`):String.fromCharCode(t)}function xe(t){var n,r=t.toString(),i,a,o,s,c,l;if(t.source){if(n=r.match(/\/([^/]*)$/),!n)return r;for(i=n[1],r=``,c=!1,l=!1,a=0,o=t.source.length;a<o;++a)s=t.source.charCodeAt(a),l?(r+=be(s,l),l=!1):(c?s===93&&(c=!1):s===47?r+=`\\`:s===91&&(c=!0),r+=be(s,l),l=s===92);return`/`+r+`/`+i}return r}function Se(t,n){var r;return t===8?`\\b`:t===12?`\\f`:t===9?`\\t`:(r=t.toString(16).toUpperCase(),u||t>255?`\\u`+`0000`.slice(r.length)+r:t===0&&!s.code.isDecimalDigit(n)?`\\0`:t===11?`\\x0B`:`\\x`+`00`.slice(r.length)+r)}function Ce(t){if(t===92)return`\\\\`;if(t===10)return`\\n`;if(t===13)return`\\r`;if(t===8232)return`\\u2028`;if(t===8233)return`\\u2029`;throw Error(`Incorrectly classified character`)}function we(t){var n,r,i,a=p===`double`?`"`:`'`;for(n=0,r=t.length;n<r;++n){if(i=t.charCodeAt(n),i===39){a=`"`;break}if(i===34){a=`'`;break}i===92&&++n}return a+t+a}function Te(t){var n=``,r,i,a,o=0,c=0,l,d;for(r=0,i=t.length;r<i;++r){if(a=t.charCodeAt(r),a===39)++o;else if(a===34)++c;else if(a===47&&u)n+=`\\`;else if(s.code.isLineTerminator(a)||a===92){n+=Ce(a);continue}else if(!s.code.isIdentifierPartES5(a)&&(u&&a<32||!u&&!m&&(a<32||a>126))){n+=Se(a,t.charCodeAt(r+1));continue}n+=String.fromCharCode(a)}if(l=!(p===`double`||p===`auto`&&c<o),d=l?`'`:`"`,!(l?o:c))return d+n+d;for(t=n,n=d,r=0,i=t.length;r<i;++r)a=t.charCodeAt(r),(a===39&&l||a===34&&!l)&&(n+=`\\`),n+=String.fromCharCode(a);return n+d}function Ee(t){var n,r,i,a=``;for(n=0,r=t.length;n<r;++n)i=t[n],a+=Array.isArray(i)?Ee(i):i;return a}function De(t,n){if(!C)return Array.isArray(t)?Ee(t):t;if(n==null){if(t instanceof a)return t;n={}}return n.loc==null?new a(null,null,C,t,n.name||null):new a(n.loc.start.line,n.loc.start.column,C===!0?n.loc.source||null:C,t,n.name||null)}function Oe(){return g||` `}function F(t,n){var r=De(t).toString(),i,a,o;return r.length===0?[n]:(i=De(n).toString(),i.length===0?[t]:(a=r.charCodeAt(r.length-1),o=i.charCodeAt(0),(a===43||a===45)&&a===o||s.code.isIdentifierPartES5(a)&&s.code.isIdentifierPartES5(o)||a===47&&o===105?[t,Oe(),n]:s.code.isWhiteSpace(a)||s.code.isLineTerminator(a)||s.code.isWhiteSpace(o)||s.code.isLineTerminator(o)?[t,n]:[t,g,n]))}function ke(t){return[c,t]}function Ae(t){var n=c;c+=l,t(c),c=n}function je(t){for(var n=t.length-1;n>=0&&!s.code.isLineTerminator(t.charCodeAt(n));--n);return t.length-1-n}function Me(t,n){var r=t.split(/\r\n|[\r\n]/),i,a,o,l,u=Number.MAX_VALUE,d,f;for(i=1,a=r.length;i<a;++i){for(o=r[i],l=0;l<o.length&&s.code.isWhiteSpace(o.charCodeAt(l));)++l;u>l&&(u=l)}for(n===void 0?(u&1&&--u,d=c):(d=c,r[1][u]===`*`&&(n+=` `),c=n),i=1,a=r.length;i<a;++i)f=De(ke(r[i].slice(u))),r[i]=C?f.join(``):f;return c=d,r.join(`
`)}function Ne(t,n){if(t.type===`Line`){if(ge(t.value))return`//`+t.value;var r=`//`+t.value;return T||(r+=`
`),r}return x.format.indent.adjustMultilineComment&&/[\n\r]/.test(t.value)?Me(`/*`+t.value+`*/`,n):`/*`+t.value+`*/`}function Pe(t,r){var i,a,o,s,u,d,f,p,m,h,g,_,v,b;if(t.leadingComments&&t.leadingComments.length>0){if(s=r,T){for(o=t.leadingComments[0],r=[],p=o.extendedRange,m=o.range,g=w.substring(p[0],m[0]),b=(g.match(/\n/g)||[]).length,b>0?(r.push(me(`
`,b)),r.push(ke(Ne(o)))):(r.push(g),r.push(Ne(o))),h=m,i=1,a=t.leadingComments.length;i<a;i++)o=t.leadingComments[i],m=o.range,_=w.substring(h[1],m[0]),b=(_.match(/\n/g)||[]).length,r.push(me(`
`,b)),r.push(ke(Ne(o))),h=m;v=w.substring(m[1],p[1]),b=(v.match(/\n/g)||[]).length,r.push(me(`
`,b))}else for(o=t.leadingComments[0],r=[],y&&t.type===n.Program&&t.body.length===0&&r.push(`
`),r.push(Ne(o)),ge(De(r).toString())||r.push(`
`),i=1,a=t.leadingComments.length;i<a;++i)o=t.leadingComments[i],f=[Ne(o)],ge(De(f).toString())||f.push(`
`),r.push(ke(f));r.push(ke(s))}if(t.trailingComments){if(T)o=t.trailingComments[0],p=o.extendedRange,m=o.range,g=w.substring(p[0],m[0]),b=(g.match(/\n/g)||[]).length,b>0?(r.push(me(`
`,b)),r.push(ke(Ne(o)))):(r.push(g),r.push(Ne(o)));else for(u=!ge(De(r).toString()),d=me(` `,je(De([c,r,l]).toString())),i=0,a=t.trailingComments.length;i<a;++i)o=t.trailingComments[i],u?(r=i===0?[r,l]:[r,d],r.push(Ne(o,d))):r=[r,ke(Ne(o))],i!==a-1&&!ge(De(r).toString())&&(r=[r,`
`])}return r}function Fe(t,n,r){var i,a=0;for(i=t;i<n;i++)w[i]===`
`&&a++;for(i=1;i<a;i++)r.push(h)}function Ie(t,n,r){return n<r?[`(`,t,`)`]:t}function Le(t){var n,r,i=t.split(/\r\n|\n/);for(n=1,r=i.length;n<r;n++)i[n]=h+c+i[n];return i}function Re(t,n){var i=t[x.verbatim],a,o;return typeof i==`string`?a=Ie(Le(i),r.Sequence,n):(a=Le(i.content),o=i.precedence==null?r.Sequence:i.precedence,a=Ie(a,o,n)),De(a,t)}function ze(){}ze.prototype.maybeBlock=function(t,r){var i,a,o=this;return a=!x.comment||!t.leadingComments,t.type===n.BlockStatement&&a?[g,this.generateStatement(t,r)]:t.type===n.EmptyStatement&&a?`;`:(Ae(function(){i=[h,ke(o.generateStatement(t,r))]}),i)},ze.prototype.maybeBlockSuffix=function(t,r){var i=ge(De(r).toString());return t.type===n.BlockStatement&&(!x.comment||!t.leadingComments)&&!i?[r,g]:i?[r,c]:[r,h,c]};function Be(t){return De(t.name,t)}function Ve(t,n){return t.async?`async`+(n?Oe():g):``}function He(t){return t.generator&&!x.moz.starlessGenerator?`*`+g:``}function Ue(t){var n=t.value,r=``;return n.async&&(r+=Ve(n,!t.computed)),n.generator&&(r+=He(n)?`*`:``),r}ze.prototype.generatePattern=function(t,r,i){return t.type===n.Identifier?Be(t):this.generateExpression(t,r,i)},ze.prototype.generateFunctionParams=function(t){var i,a,o,s=!1;if(t.type===n.ArrowFunctionExpression&&!t.rest&&(!t.defaults||t.defaults.length===0)&&t.params.length===1&&t.params[0].type===n.Identifier)o=[Ve(t,!0),Be(t.params[0])];else{for(o=t.type===n.ArrowFunctionExpression?[Ve(t,!1)]:[],o.push(`(`),t.defaults&&(s=!0),i=0,a=t.params.length;i<a;++i)s&&t.defaults[i]?o.push(this.generateAssignment(t.params[i],t.defaults[i],`=`,r.Assignment,P)):o.push(this.generatePattern(t.params[i],r.Assignment,P)),i+1<a&&o.push(`,`+g);t.rest&&(t.params.length&&o.push(`,`+g),o.push(`...`),o.push(Be(t.rest))),o.push(`)`)}return o},ze.prototype.generateFunctionBody=function(t){var i=this.generateFunctionParams(t),a;return t.type===n.ArrowFunctionExpression&&(i.push(g),i.push(`=>`)),t.expression?(i.push(g),a=this.generateExpression(t.body,r.Assignment,P),a.toString().charAt(0)===`{`&&(a=[`(`,a,`)`]),i.push(a)):i.push(this.maybeBlock(t.body,fe)),i},ze.prototype.generateIterationForStatement=function(t,i,a){var o=[`for`+(i.await?Oe()+`await`:``)+g+`(`],s=this;return Ae(function(){i.left.type===n.VariableDeclaration?Ae(function(){o.push(i.left.kind+Oe()),o.push(s.generateStatement(i.left.declarations[0],ue))}):o.push(s.generateExpression(i.left,r.Call,P)),o=F(o,t),o=[F(o,s.generateExpression(i.right,r.Assignment,P)),`)`]}),o.push(this.maybeBlock(i.body,a)),o},ze.prototype.generatePropertyKey=function(t,n){var i=[];return n&&i.push(`[`),i.push(this.generateExpression(t,r.Assignment,P)),n&&i.push(`]`),i},ze.prototype.generateAssignment=function(t,n,i,a,o){return r.Assignment<a&&(o|=A),Ie([this.generateExpression(t,r.Call,o),g+i+g,this.generateExpression(n,r.Assignment,o)],r.Assignment,a)},ze.prototype.semicolon=function(t){return!v&&t&N?``:`;`},ze.Statement={BlockStatement:function(t,n){var r,i,a=[`{`,h],o=this;return Ae(function(){t.body.length===0&&T&&(r=t.range,r[1]-r[0]>2&&(i=w.substring(r[0]+1,r[1]-1),i[0]===`
`&&(a=[`{`]),a.push(i)));var s,c,l,u=ce;for(n&ee&&(u|=te),s=0,c=t.body.length;s<c;++s)T&&(s===0&&(t.body[0].leadingComments&&(r=t.body[0].leadingComments[0].extendedRange,i=w.substring(r[0],r[1]),i[0]===`
`&&(a=[`{`])),t.body[0].leadingComments||Fe(t.range[0],t.body[0].range[0],a)),s>0&&!t.body[s-1].trailingComments&&!t.body[s].leadingComments&&Fe(t.body[s-1].range[1],t.body[s].range[0],a)),s===c-1&&(u|=N),l=t.body[s].leadingComments&&T?o.generateStatement(t.body[s],u):ke(o.generateStatement(t.body[s],u)),a.push(l),ge(De(l).toString())||T&&s<c-1&&t.body[s+1].leadingComments||a.push(h),T&&s===c-1&&(t.body[s].trailingComments||Fe(t.body[s].range[1],t.range[1],a))}),a.push(ke(`}`)),a},BreakStatement:function(t,n){return t.label?`break `+t.label.name+this.semicolon(n):`break`+this.semicolon(n)},ContinueStatement:function(t,n){return t.label?`continue `+t.label.name+this.semicolon(n):`continue`+this.semicolon(n)},ClassBody:function(t,n){var i=[`{`,h],a=this;return Ae(function(n){for(var o=0,s=t.body.length;o<s;++o)i.push(n),i.push(a.generateExpression(t.body[o],r.Sequence,P)),o+1<s&&i.push(h)}),ge(De(i).toString())||i.push(h),i.push(c),i.push(`}`),i},ClassDeclaration:function(t,n){var i=[`class`],a;return t.id&&(i=F(i,this.generateExpression(t.id,r.Sequence,P))),t.superClass&&(a=F(`extends`,this.generateExpression(t.superClass,r.Unary,P)),i=F(i,a)),i.push(g),i.push(this.generateStatement(t.body,le)),i},DirectiveStatement:function(t,n){return x.raw&&t.raw?t.raw+this.semicolon(n):we(t.directive)+this.semicolon(n)},DoWhileStatement:function(t,n){var i=F(`do`,this.maybeBlock(t.body,ce));return i=this.maybeBlockSuffix(t.body,i),F(i,[`while`+g+`(`,this.generateExpression(t.test,r.Sequence,P),`)`+this.semicolon(n)])},CatchClause:function(t,n){var i,a=this;return Ae(function(){var n;t.param?(i=[`catch`+g+`(`,a.generateExpression(t.param,r.Sequence,P),`)`],t.guard&&(n=a.generateExpression(t.guard,r.Sequence,P),i.splice(2,0,` if `,n))):i=[`catch`]}),i.push(this.maybeBlock(t.body,ce)),i},DebuggerStatement:function(t,n){return`debugger`+this.semicolon(n)},EmptyStatement:function(t,n){return`;`},ExportDefaultDeclaration:function(t,n){var i=[`export`],a=n&N?le:ce;return i=F(i,`default`),i=k(t.declaration)?F(i,this.generateStatement(t.declaration,a)):F(i,this.generateExpression(t.declaration,r.Assignment,P)+this.semicolon(n)),i},ExportNamedDeclaration:function(t,i){var a=[`export`],o,s=this;return o=i&N?le:ce,t.declaration?F(a,this.generateStatement(t.declaration,o)):(t.specifiers&&(t.specifiers.length===0?a=F(a,`{`+g+`}`):t.specifiers[0].type===n.ExportBatchSpecifier?a=F(a,this.generateExpression(t.specifiers[0],r.Sequence,P)):(a=F(a,`{`),Ae(function(n){var i,o;for(a.push(h),i=0,o=t.specifiers.length;i<o;++i)a.push(n),a.push(s.generateExpression(t.specifiers[i],r.Sequence,P)),i+1<o&&a.push(`,`+h)}),ge(De(a).toString())||a.push(h),a.push(c+`}`)),t.source?a=F(a,[`from`+g,this.generateExpression(t.source,r.Sequence,P),this.semicolon(i)]):a.push(this.semicolon(i))),a)},ExportAllDeclaration:function(t,n){return[`export`+g,`*`+g,`from`+g,this.generateExpression(t.source,r.Sequence,P),this.semicolon(n)]},ExpressionStatement:function(t,i){var a,o;function c(t){var n;return t.slice(0,5)===`class`&&(n=t.charCodeAt(5),n===123||s.code.isWhiteSpace(n)||s.code.isLineTerminator(n))}function l(t){var n;return t.slice(0,8)===`function`&&(n=t.charCodeAt(8),n===40||s.code.isWhiteSpace(n)||n===42||s.code.isLineTerminator(n))}function u(t){var n,r,i;if(t.slice(0,5)!==`async`||!s.code.isWhiteSpace(t.charCodeAt(5)))return!1;for(r=6,i=t.length;r<i&&s.code.isWhiteSpace(t.charCodeAt(r));++r);return r===i||t.slice(r,r+8)!==`function`?!1:(n=t.charCodeAt(r+8),n===40||s.code.isWhiteSpace(n)||n===42||s.code.isLineTerminator(n))}return a=[this.generateExpression(t.expression,r.Sequence,P)],o=De(a).toString(),o.charCodeAt(0)===123||c(o)||l(o)||u(o)||b&&i&te&&t.expression.type===n.Literal&&typeof t.expression.value==`string`?a=[`(`,a,`)`+this.semicolon(i)]:a.push(this.semicolon(i)),a},ImportDeclaration:function(t,i){var a,o,s=this;return t.specifiers.length===0?[`import`,g,this.generateExpression(t.source,r.Sequence,P),this.semicolon(i)]:(a=[`import`],o=0,t.specifiers[o].type===n.ImportDefaultSpecifier&&(a=F(a,[this.generateExpression(t.specifiers[o],r.Sequence,P)]),++o),t.specifiers[o]&&(o!==0&&a.push(`,`),t.specifiers[o].type===n.ImportNamespaceSpecifier?a=F(a,[g,this.generateExpression(t.specifiers[o],r.Sequence,P)]):(a.push(g+`{`),t.specifiers.length-o===1?(a.push(g),a.push(this.generateExpression(t.specifiers[o],r.Sequence,P)),a.push(g+`}`+g)):(Ae(function(n){var i,c;for(a.push(h),i=o,c=t.specifiers.length;i<c;++i)a.push(n),a.push(s.generateExpression(t.specifiers[i],r.Sequence,P)),i+1<c&&a.push(`,`+h)}),ge(De(a).toString())||a.push(h),a.push(c+`}`+g)))),a=F(a,[`from`+g,this.generateExpression(t.source,r.Sequence,P),this.semicolon(i)]),a)},VariableDeclarator:function(t,n){var i=n&A?P:re;return t.init?[this.generateExpression(t.id,r.Assignment,i),g,`=`,g,this.generateExpression(t.init,r.Assignment,i)]:this.generatePattern(t.id,r.Assignment,i)},VariableDeclaration:function(t,n){var r,i,a,o,s,c=this;r=[t.kind],s=n&A?ce:ue;function l(){for(o=t.declarations[0],x.comment&&o.leadingComments?(r.push(`
`),r.push(ke(c.generateStatement(o,s)))):(r.push(Oe()),r.push(c.generateStatement(o,s))),i=1,a=t.declarations.length;i<a;++i)o=t.declarations[i],x.comment&&o.leadingComments?(r.push(`,`+h),r.push(ke(c.generateStatement(o,s)))):(r.push(`,`+g),r.push(c.generateStatement(o,s)))}return t.declarations.length>1?Ae(l):l(),r.push(this.semicolon(n)),r},ThrowStatement:function(t,n){return[F(`throw`,this.generateExpression(t.argument,r.Sequence,P)),this.semicolon(n)]},TryStatement:function(t,n){var r=[`try`,this.maybeBlock(t.block,ce)],i,a,o;if(r=this.maybeBlockSuffix(t.block,r),t.handlers)for(i=0,a=t.handlers.length;i<a;++i)r=F(r,this.generateStatement(t.handlers[i],ce)),(t.finalizer||i+1!==a)&&(r=this.maybeBlockSuffix(t.handlers[i].body,r));else{for(o=t.guardedHandlers||[],i=0,a=o.length;i<a;++i)r=F(r,this.generateStatement(o[i],ce)),(t.finalizer||i+1!==a)&&(r=this.maybeBlockSuffix(o[i].body,r));if(t.handler){if(Array.isArray(t.handler))for(i=0,a=t.handler.length;i<a;++i)r=F(r,this.generateStatement(t.handler[i],ce)),(t.finalizer||i+1!==a)&&(r=this.maybeBlockSuffix(t.handler[i].body,r));else r=F(r,this.generateStatement(t.handler,ce)),t.finalizer&&(r=this.maybeBlockSuffix(t.handler.body,r))}}return t.finalizer&&(r=F(r,[`finally`,this.maybeBlock(t.finalizer,ce)])),r},SwitchStatement:function(t,n){var i,a,o,s,c,l=this;if(Ae(function(){i=[`switch`+g+`(`,l.generateExpression(t.discriminant,r.Sequence,P),`)`+g+`{`+h]}),t.cases)for(c=ce,o=0,s=t.cases.length;o<s;++o)o===s-1&&(c|=N),a=ke(this.generateStatement(t.cases[o],c)),i.push(a),ge(De(a).toString())||i.push(h);return i.push(ke(`}`)),i},SwitchCase:function(t,i){var a,o,s,c,l,u=this;return Ae(function(){for(a=t.test?[F(`case`,u.generateExpression(t.test,r.Sequence,P)),`:`]:[`default:`],s=0,c=t.consequent.length,c&&t.consequent[0].type===n.BlockStatement&&(o=u.maybeBlock(t.consequent[0],ce),a.push(o),s=1),s!==c&&!ge(De(a).toString())&&a.push(h),l=ce;s<c;++s)s===c-1&&i&N&&(l|=N),o=ke(u.generateStatement(t.consequent[s],l)),a.push(o),s+1!==c&&!ge(De(o).toString())&&a.push(h)}),a},IfStatement:function(t,i){var a,o,s,c=this;return Ae(function(){a=[`if`+g+`(`,c.generateExpression(t.test,r.Sequence,P),`)`]}),s=i&N,o=ce,s&&(o|=N),t.alternate?(a.push(this.maybeBlock(t.consequent,ce)),a=this.maybeBlockSuffix(t.consequent,a),a=t.alternate.type===n.IfStatement?F(a,[`else `,this.generateStatement(t.alternate,o)]):F(a,F(`else`,this.maybeBlock(t.alternate,o)))):a.push(this.maybeBlock(t.consequent,o)),a},ForStatement:function(t,i){var a,o=this;return Ae(function(){a=[`for`+g+`(`],t.init?t.init.type===n.VariableDeclaration?a.push(o.generateStatement(t.init,ue)):(a.push(o.generateExpression(t.init,r.Sequence,re)),a.push(`;`)):a.push(`;`),t.test&&(a.push(g),a.push(o.generateExpression(t.test,r.Sequence,P))),a.push(`;`),t.update&&(a.push(g),a.push(o.generateExpression(t.update,r.Sequence,P))),a.push(`)`)}),a.push(this.maybeBlock(t.body,i&N?le:ce)),a},ForInStatement:function(t,n){return this.generateIterationForStatement(`in`,t,n&N?le:ce)},ForOfStatement:function(t,n){return this.generateIterationForStatement(`of`,t,n&N?le:ce)},LabeledStatement:function(t,n){return[t.label.name+`:`,this.maybeBlock(t.body,n&N?le:ce)]},Program:function(t,n){var r,i,a,o=t.body.length,s;for(r=[y&&o>0?`
`:``],s=de,a=0;a<o;++a)!y&&a===o-1&&(s|=N),T&&(a===0&&(t.body[0].leadingComments||Fe(t.range[0],t.body[a].range[0],r)),a>0&&!t.body[a-1].trailingComments&&!t.body[a].leadingComments&&Fe(t.body[a-1].range[1],t.body[a].range[0],r)),i=ke(this.generateStatement(t.body[a],s)),r.push(i),a+1<o&&!ge(De(i).toString())&&(T&&t.body[a+1].leadingComments||r.push(h)),T&&a===o-1&&(t.body[a].trailingComments||Fe(t.body[a].range[1],t.range[1],r));return r},FunctionDeclaration:function(t,n){return[Ve(t,!0),`function`,He(t)||Oe(),t.id?Be(t.id):``,this.generateFunctionBody(t)]},ReturnStatement:function(t,n){return t.argument?[F(`return`,this.generateExpression(t.argument,r.Sequence,P)),this.semicolon(n)]:[`return`+this.semicolon(n)]},WhileStatement:function(t,n){var i,a=this;return Ae(function(){i=[`while`+g+`(`,a.generateExpression(t.test,r.Sequence,P),`)`]}),i.push(this.maybeBlock(t.body,n&N?le:ce)),i},WithStatement:function(t,n){var i,a=this;return Ae(function(){i=[`with`+g+`(`,a.generateExpression(t.object,r.Sequence,P),`)`]}),i.push(this.maybeBlock(t.body,n&N?le:ce)),i}},_e(ze.prototype,ze.Statement),ze.Expression={SequenceExpression:function(t,n,i){var a,o,s;for(r.Sequence<n&&(i|=A),a=[],o=0,s=t.expressions.length;o<s;++o)a.push(this.generateExpression(t.expressions[o],r.Assignment,i)),o+1<s&&a.push(`,`+g);return Ie(a,r.Sequence,n)},AssignmentExpression:function(t,n,r){return this.generateAssignment(t.left,t.right,t.operator,n,r)},ArrowFunctionExpression:function(t,n,i){return Ie(this.generateFunctionBody(t),r.ArrowFunction,n)},ConditionalExpression:function(t,n,i){return r.Conditional<n&&(i|=A),Ie([this.generateExpression(t.test,r.Coalesce,i),g+`?`+g,this.generateExpression(t.consequent,r.Assignment,i),g+`:`+g,this.generateExpression(t.alternate,r.Assignment,i)],r.Conditional,n)},LogicalExpression:function(t,n,r){return t.operator===`??`&&(r|=ne),this.BinaryExpression(t,n,r)},BinaryExpression:function(t,n,a){var o,c,l,u=i[t.operator],d,f;return c=t.operator===`**`?r.Postfix:u,l=t.operator===`**`?u:u+1,u<n&&(a|=A),d=this.generateExpression(t.left,c,a),f=d.toString(),o=f.charCodeAt(f.length-1)===47&&s.code.isIdentifierPartES5(t.operator.charCodeAt(0))?[d,Oe(),t.operator]:F(d,t.operator),d=this.generateExpression(t.right,l,a),t.operator===`/`&&d.toString().charAt(0)===`/`||t.operator.slice(-1)===`<`&&d.toString().slice(0,3)===`!--`?(o.push(Oe()),o.push(d)):o=F(o,d),t.operator===`in`&&!(a&A)||(t.operator===`||`||t.operator===`&&`)&&a&ne?[`(`,o,`)`]:Ie(o,u,n)},CallExpression:function(t,n,i){var a=[this.generateExpression(t.callee,r.Call,ie)],o,s;for(t.optional&&a.push(`?.`),a.push(`(`),o=0,s=t.arguments.length;o<s;++o)a.push(this.generateExpression(t.arguments[o],r.Assignment,P)),o+1<s&&a.push(`,`+g);return a.push(`)`),i&j?Ie(a,r.Call,n):[`(`,a,`)`]},ChainExpression:function(t,n,i){return r.OptionalChaining<n&&(i|=j),Ie(this.generateExpression(t.expression,r.OptionalChaining,i),r.OptionalChaining,n)},NewExpression:function(t,n,i){var a,o=t.arguments.length,s,c,l=i&M&&!_&&o===0?se:ae;if(a=F(`new`,this.generateExpression(t.callee,r.New,l)),!(i&M)||_||o>0){for(a.push(`(`),s=0,c=o;s<c;++s)a.push(this.generateExpression(t.arguments[s],r.Assignment,P)),s+1<c&&a.push(`,`+g);a.push(`)`)}return Ie(a,r.New,n)},MemberExpression:function(t,i,a){var o=[this.generateExpression(t.object,r.Call,a&j?ie:ae)],c;return t.computed?(t.optional&&o.push(`?.`),o.push(`[`),o.push(this.generateExpression(t.property,r.Sequence,a&j?P:se)),o.push(`]`)):(!t.optional&&t.object.type===n.Literal&&typeof t.object.value==`number`&&(c=De(o).toString(),c.indexOf(`.`)<0&&!/[eExX]/.test(c)&&s.code.isDecimalDigit(c.charCodeAt(c.length-1))&&!(c.length>=2&&c.charCodeAt(0)===48)&&o.push(` `)),o.push(t.optional?`?.`:`.`),o.push(Be(t.property))),Ie(o,r.Member,i)},MetaProperty:function(t,n,i){var a=[];return a.push(typeof t.meta==`string`?t.meta:Be(t.meta)),a.push(`.`),a.push(typeof t.property==`string`?t.property:Be(t.property)),Ie(a,r.Member,n)},UnaryExpression:function(t,n,i){var a,o=this.generateExpression(t.argument,r.Unary,P),c,l,u;return g===``?a=F(t.operator,o):(a=[t.operator],t.operator.length>2?a=F(a,o):(l=De(a).toString(),u=l.charCodeAt(l.length-1),c=o.toString().charCodeAt(0),((u===43||u===45)&&u===c||s.code.isIdentifierPartES5(u)&&s.code.isIdentifierPartES5(c))&&a.push(Oe()),a.push(o))),Ie(a,r.Unary,n)},YieldExpression:function(t,n,i){var a=t.delegate?`yield*`:`yield`;return t.argument&&(a=F(a,this.generateExpression(t.argument,r.Yield,P))),Ie(a,r.Yield,n)},AwaitExpression:function(t,n,i){return Ie(F(t.all?`await*`:`await`,this.generateExpression(t.argument,r.Await,P)),r.Await,n)},UpdateExpression:function(t,n,i){return t.prefix?Ie([t.operator,this.generateExpression(t.argument,r.Unary,P)],r.Unary,n):Ie([this.generateExpression(t.argument,r.Postfix,P),t.operator],r.Postfix,n)},FunctionExpression:function(t,n,r){var i=[Ve(t,!0),`function`];return t.id?(i.push(He(t)||Oe()),i.push(Be(t.id))):i.push(He(t)||g),i.push(this.generateFunctionBody(t)),i},ArrayPattern:function(t,n,r){return this.ArrayExpression(t,n,r,!0)},ArrayExpression:function(t,n,i,a){var o,s,l=this;return t.elements.length?(s=!a&&t.elements.length>1,o=[`[`,s?h:``],Ae(function(n){for(var i=0,a=t.elements.length;i<a;++i)t.elements[i]?(o.push(s?n:``),o.push(l.generateExpression(t.elements[i],r.Assignment,P))):(s&&o.push(n),i+1===a&&o.push(`,`)),i+1<a&&o.push(`,`+(s?h:g))}),s&&!ge(De(o).toString())&&o.push(h),o.push(s?c:``),o.push(`]`),o):`[]`},RestElement:function(t,n,r){return`...`+this.generatePattern(t.argument)},ClassExpression:function(t,n,i){var a=[`class`],o;return t.id&&(a=F(a,this.generateExpression(t.id,r.Sequence,P))),t.superClass&&(o=F(`extends`,this.generateExpression(t.superClass,r.Unary,P)),a=F(a,o)),a.push(g),a.push(this.generateStatement(t.body,le)),a},MethodDefinition:function(t,n,r){return F(t.static?[`static`+g]:[],t.kind===`get`||t.kind===`set`?[F(t.kind,this.generatePropertyKey(t.key,t.computed)),this.generateFunctionBody(t.value)]:[Ue(t),this.generatePropertyKey(t.key,t.computed),this.generateFunctionBody(t.value)])},Property:function(t,n,i){return t.kind===`get`||t.kind===`set`?[t.kind,Oe(),this.generatePropertyKey(t.key,t.computed),this.generateFunctionBody(t.value)]:t.shorthand?t.value.type===`AssignmentPattern`?this.AssignmentPattern(t.value,r.Sequence,P):this.generatePropertyKey(t.key,t.computed):t.method?[Ue(t),this.generatePropertyKey(t.key,t.computed),this.generateFunctionBody(t.value)]:[this.generatePropertyKey(t.key,t.computed),`:`+g,this.generateExpression(t.value,r.Assignment,P)]},ObjectExpression:function(t,n,i){var a,o,s,l=this;return t.properties.length?(a=t.properties.length>1,Ae(function(){s=l.generateExpression(t.properties[0],r.Sequence,P)}),!a&&!he(De(s).toString())?[`{`,g,s,g,`}`]:(Ae(function(n){var i,c;if(o=[`{`,h,n,s],a)for(o.push(`,`+h),i=1,c=t.properties.length;i<c;++i)o.push(n),o.push(l.generateExpression(t.properties[i],r.Sequence,P)),i+1<c&&o.push(`,`+h)}),ge(De(o).toString())||o.push(h),o.push(c),o.push(`}`),o)):`{}`},AssignmentPattern:function(t,n,r){return this.generateAssignment(t.left,t.right,`=`,n,r)},ObjectPattern:function(t,i,a){var o,s,l,u,d,f=this;if(!t.properties.length)return`{}`;if(u=!1,t.properties.length===1)d=t.properties[0],d.type===n.Property&&d.value.type!==n.Identifier&&(u=!0);else for(s=0,l=t.properties.length;s<l;++s)if(d=t.properties[s],d.type===n.Property&&!d.shorthand){u=!0;break}return o=[`{`,u?h:``],Ae(function(n){for(var i=0,a=t.properties.length;i<a;++i)o.push(u?n:``),o.push(f.generateExpression(t.properties[i],r.Sequence,P)),i+1<a&&o.push(`,`+(u?h:g))}),u&&!ge(De(o).toString())&&o.push(h),o.push(u?c:``),o.push(`}`),o},ThisExpression:function(t,n,r){return`this`},Super:function(t,n,r){return`super`},Identifier:function(t,n,r){return Be(t)},ImportDefaultSpecifier:function(t,n,r){return Be(t.id||t.local)},ImportNamespaceSpecifier:function(t,n,r){var i=[`*`],a=t.id||t.local;return a&&i.push(g+`as`+Oe()+Be(a)),i},ImportSpecifier:function(t,n,r){var i=t.imported,a=[i.name],o=t.local;return o&&o.name!==i.name&&a.push(Oe()+`as`+Oe()+Be(o)),a},ExportSpecifier:function(t,n,r){var i=t.local,a=[i.name],o=t.exported;return o&&o.name!==i.name&&a.push(Oe()+`as`+Oe()+Be(o)),a},Literal:function(t,r,i){var a;if(t.hasOwnProperty(`raw`)&&S&&x.raw)try{if(a=S(t.raw).body[0].expression,a.type===n.Literal&&a.value===t.value)return t.raw}catch{}return t.regex?`/`+t.regex.pattern+`/`+t.regex.flags:typeof t.value==`bigint`?t.value.toString()+`n`:t.bigint?t.bigint+`n`:t.value===null?`null`:typeof t.value==`string`?Te(t.value):typeof t.value==`number`?ye(t.value):typeof t.value==`boolean`?t.value?`true`:`false`:xe(t.value)},GeneratorExpression:function(t,n,r){return this.ComprehensionExpression(t,n,r)},ComprehensionExpression:function(t,i,a){var o,s,c,l,u=this;return o=t.type===n.GeneratorExpression?[`(`]:[`[`],x.moz.comprehensionExpressionStartsWithAssignment&&(l=this.generateExpression(t.body,r.Assignment,P),o.push(l)),t.blocks&&Ae(function(){for(s=0,c=t.blocks.length;s<c;++s)l=u.generateExpression(t.blocks[s],r.Sequence,P),s>0||x.moz.comprehensionExpressionStartsWithAssignment?o=F(o,l):o.push(l)}),t.filter&&(o=F(o,`if`+g),l=this.generateExpression(t.filter,r.Sequence,P),o=F(o,[`(`,l,`)`])),x.moz.comprehensionExpressionStartsWithAssignment||(l=this.generateExpression(t.body,r.Assignment,P),o=F(o,l)),o.push(t.type===n.GeneratorExpression?`)`:`]`),o},ComprehensionBlock:function(t,i,a){var o=t.left.type===n.VariableDeclaration?[t.left.kind,Oe(),this.generateStatement(t.left.declarations[0],ue)]:this.generateExpression(t.left,r.Call,P);return o=F(o,t.of?`of`:`in`),o=F(o,this.generateExpression(t.right,r.Sequence,P)),[`for`+g+`(`,o,`)`]},SpreadElement:function(t,n,i){return[`...`,this.generateExpression(t.argument,r.Assignment,P)]},TaggedTemplateExpression:function(t,n,i){var a=ie;return i&j||(a=ae),Ie([this.generateExpression(t.tag,r.Call,a),this.generateExpression(t.quasi,r.Primary,oe)],r.TaggedTemplate,n)},TemplateElement:function(t,n,r){return t.value.raw},TemplateLiteral:function(t,n,i){for(var a=["`"],o=0,s=t.quasis.length;o<s;++o)a.push(this.generateExpression(t.quasis[o],r.Primary,P)),o+1<s&&(a.push("${"+g),a.push(this.generateExpression(t.expressions[o],r.Sequence,P)),a.push(g+`}`));return a.push("`"),a},ModuleSpecifier:function(t,n,r){return this.Literal(t,n,r)},ImportExpression:function(t,n,i){return Ie([`import(`,this.generateExpression(t.source,r.Assignment,P),`)`],r.Call,n)}},_e(ze.prototype,ze.Expression),ze.prototype.generateExpression=function(t,r,i){var a,o=t.type||n.Property;return x.verbatim&&t.hasOwnProperty(x.verbatim)?Re(t,r):(a=this[o](t,r,i),x.comment&&(a=Pe(t,a)),De(a,t))},ze.prototype.generateStatement=function(t,r){var i=this[t.type](t,r),a;return x.comment&&(i=Pe(t,i)),a=De(i).toString(),t.type===n.Program&&!y&&h===``&&a.charAt(a.length-1)===`
`&&(i=C?De(i).replaceRight(/\s+$/,``):a.replace(/\s+$/,``)),De(i,t)};function We(t){var n=new ze;if(k(t))return n.generateStatement(t,ce);if(O(t))return n.generateExpression(t,r.Sequence,P);throw Error(`Unknown node type: `+t.type)}function Ge(n,r){var i=pe(),o,s;return r==null?(r=i,l=r.format.indent.style,c=me(l,r.format.indent.base)):(typeof r.indent==`string`&&(i.format.indent.style=r.indent),typeof r.base==`number`&&(i.format.indent.base=r.base),r=ve(i,r),l=r.format.indent.style,c=typeof r.base==`string`?r.base:me(l,r.format.indent.base)),u=r.format.json,d=r.format.renumber,f=!u&&r.format.hexadecimal,p=u?`double`:r.format.quotes,m=r.format.escapeless,h=r.format.newline,g=r.format.space,r.format.compact&&(h=g=l=c=``),_=r.format.parentheses,v=r.format.semicolons,y=r.format.safeConcatenation,b=r.directive,S=u?null:r.parse,C=r.sourceMap,w=r.sourceCode,T=r.format.preserveBlankLines&&w!==null,x=r,C&&(a=t.browser?global.sourceMap.SourceNode:KS().SourceNode),o=We(n),C?(s=o.toStringWithSourceMap({file:r.file,sourceRoot:r.sourceMapRoot}),r.sourceContent&&s.map.setSourceContent(r.sourceMap,r.sourceContent),r.sourceMapWithCode?s:s.map.toString()):(s={code:o.toString(),map:null},r.sourceMapWithCode?s:s.code)}E={indent:{style:``,base:0},renumber:!0,hexadecimal:!0,quotes:`auto`,escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},D=pe().format,t.version=qS().version,t.generate=Ge,t.attachComments=o.attachComments,t.Precedence=ve({},r),t.browser=!1,t.FORMAT_MINIFY=E,t.FORMAT_DEFAULTS=D})()})))(),1);const YS=`_p5_strands_`;function XS(){return{externalToInternal:{},internalToExternal:{}}}function ZS(t=0){return{nextSuffix:t}}function QS(t){return typeof t==`string`&&(t.startsWith(`_p5_strands_`)||t.startsWith(`gl_`))}function $S(t){return typeof t==`string`&&/^[_A-Za-z][_A-Za-z0-9]*$/.test(t)&&!t.includes(`__`)&&!QS(t)}function eC(t,n,r){if(t.externalToInternal[r])return t.externalToInternal[r];if($S(r))return r;let i=`${YS}${n.nextSuffix++}`;return t.externalToInternal[r]=i,t.internalToExternal[i]=r,i}function tC(t,n){return n?.prototype?.[t]?.argTypes}let nC=0,rC=0;function iC(t){switch(t){case`+`:return`add`;case`-`:return`sub`;case`*`:return`mult`;case`/`:return`div`;case`%`:return`mod`;case`==`:case`===`:return`equalTo`;case`!=`:case`!==`:return`notEqual`;case`>`:return`greaterThan`;case`>=`:return`greaterEqual`;case`<`:return`lessThan`;case`<=`:return`lessEqual`;case`&&`:return`and`;case`||`:return`or`}}function aC(t){return t&&t.type===`CallExpression`&&(t.callee?.type===`Identifier`&&t.callee?.name.startsWith(`uniform`)||t.callee?.type===`MemberExpression`&&t.callee?.property.name.startsWith(`uniform`))}function oC(t,n){return n?.size?!!(t.type===`FunctionDeclaration`&&n.has(t.id?.name)||t.type===`VariableDeclarator`&&n.has(t.id?.name)&&(t.init?.type===`FunctionExpression`||t.init?.type===`ArrowFunctionExpression`)):!1}function sC(t){let n=/* @__PURE__ */ new Set;e_(t,{FunctionDeclaration(t){t.id&&n.add(t.id.name)},VariableDeclarator(t){t.id?.type===`Identifier`&&(t.init?.type===`FunctionExpression`||t.init?.type===`ArrowFunctionExpression`)&&n.add(t.id.name)}});let r=/* @__PURE__ */ new Set;return e_(t,{CallExpression(t){if(aC(t))for(let i of t.arguments)i.type===`Identifier`&&n.has(i.name)&&r.add(i.name)}}),r}function cC(t){return t&&t.type===`CallExpression`&&(t.callee?.type===`Identifier`&&(t.callee?.name.startsWith(`varying`)||t.callee?.name.startsWith(`shared`))||t.callee?.type===`MemberExpression`&&(t.callee?.property.name.startsWith(`varying`)||t.callee?.property.name.startsWith(`shared`)))}function lC(t){if(t?.type===`Identifier`)return t.name;if(t?.type!==`MemberExpression`||t.computed)return null;let n=lC(t.object),r=t.property?.name;return n&&r?`${n}.${r}`:null}function uC(t){if(t?.type!==`CallExpression`)return!1;let n=lC(t.callee);return n?n===`loopProtect.protect`||n.endsWith(`.loopProtect`)||n.endsWith(`.loopProtect.protect`):!1}function dC(t){let n=!1;e_(t,{CallExpression(t){uC(t)&&(n=!0)},LogicalExpression(t){t.right?.type===`CallExpression`&&uC(t.right)&&(n=!0)}}),n&&pc("loop protection error Loop protection code detected. Add `// noprotect` at the top of your sketch and run again.")}function fC(t){return t.type===`ConditionalExpression`||t.type===`LogicalExpression`&&(t.operator===`&&`||t.operator===`||`)}function pC(t){return{type:`BlockStatement`,body:t}}function mC(t){if(t.type!==`ExpressionStatement`)return[t];let n=t.expression,r=t=>({type:`ExpressionStatement`,expression:t});return n.type===`SequenceExpression`?n.expressions.some(fC)?n.expressions.flatMap(t=>mC(r(t))):[t]:n.type===`LogicalExpression`&&fC(n)?[{type:`IfStatement`,test:n.operator===`&&`?n.left:{type:`UnaryExpression`,operator:`!`,prefix:!0,argument:n.left},consequent:pC(mC(r(n.right))),alternate:null}]:n.type===`ConditionalExpression`?[{type:`IfStatement`,test:n.test,consequent:pC(mC(r(n.consequent))),alternate:pC(mC(r(n.alternate)))}]:[t]}function hC(t,n){let r=t=>t.some(t=>aC(t)||oC(t,n)),i=(t,n,i)=>{r(i)||(t.body=t.body.flatMap(mC))},a=(t,n,i)=>{if(!r(i))for(let n of[`consequent`,`alternate`,`body`]){let r=t[n];r?.type===`ExpressionStatement`&&(t[n]=pC(mC(r)))}};e_(t,{Program:i,BlockStatement:i,IfStatement:a,ForStatement:a,WhileStatement:a})}function gC(t){return t.type===`VariableDeclaration`&&t.declarations.some(t=>t.init?.type===`CallExpression`&&(t.init?.callee?.type===`MemberExpression`&&t.init?.callee?.object?.type===`Identifier`&&t.init?.callee?.object?.name===`__p5`&&(t.init?.callee?.property?.name===`strandsFor`||t.init?.callee?.property?.name===`strandsIf`)||t.init?.callee?.type===`Identifier`&&(t.init?.callee?.name===`__p5.strandsFor`||t.init?.callee?.name===`__p5.strandsIf`)))}function _C(t){return!t||typeof t!=`string`?!1:[[`x`,`y`,`z`,`w`],[`r`,`g`,`b`,`a`],[`s`,`t`,`p`,`q`]].some(n=>[...t].every(t=>n.includes(t)))}function vC(t){let n=[],r=t;for(;r.type===`MemberExpression`;){if(r.computed)return null;let t=r.property.name||r.property.value;_C(t)||n.unshift(t),r=r.object}if(r.type===`Identifier`)n.unshift(r.name);else return null;return n.join(`.`)}function yC(t,n){let r=t=>{if(t&&typeof t==`object`){if(t.type===`MemberExpression`){if(_C(t.property.name||t.property.value)){r(t.object);return}let i=vC(t);if(i&&n.has(i)){Object.assign(t,{type:`Identifier`,name:n.get(i)});return}}if(t.type===`Identifier`&&n.has(t.name)&&(t.name=n.get(t.name)),t.type===`AssignmentExpression`){let r=null;t.left.type===`Identifier`?r=t.left.name:t.left.type===`MemberExpression`&&(r=vC(t.left)),r&&n.has(r)&&(t.right.type===`Literal`||t.right.type===`ArrayExpression`)&&(t.right={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsNode`},arguments:[t.right]})}for(let n in t)if(t.hasOwnProperty(n)&&n!==`parent`){if(t.type===`MemberExpression`&&n===`property`&&!t.computed)continue;Array.isArray(t[n])?t[n].forEach(r):typeof t[n]==`object`&&r(t[n])}}};r(t)}function bC(t,n,r){if(!t||typeof t!=`object`)return t;let i=t=>{if(!t||typeof t!=`object`)return t;if(t.type===`Identifier`&&t.name===n)return{...t,name:r};let a={...t};for(let n in t)t.hasOwnProperty(n)&&n!==`parent`&&(Array.isArray(t[n])?a[n]=t[n].map(i):typeof t[n]==`object`&&(a[n]=i(t[n])));return a};return i(t)}function xC(t,n){return{type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsOperand`},arguments:[{type:`Literal`,value:t},{type:`ArrowFunctionExpression`,id:null,params:[],body:n,expression:!0,generator:!1,async:!1}]}}function SC(t,n,r){r.some(t=>aC(t)||oC(t,n.uniformCallbackNames))||(t.type===`LogicalExpression`&&(t.operator===`&&`||t.operator===`||`)&&(t.left=xC(t.operator,t.left),t.right=xC(t.operator,t.right)),t.left={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsNode`},arguments:[t.left]},t.type=`CallExpression`,t.callee={type:`MemberExpression`,object:t.left,property:{type:`Identifier`,name:iC(t.operator)}},t.arguments=[t.right])}function CC(t,n,r=null){if(t.type!==`BlockStatement`)return;let i=/* @__PURE__ */ new Map,a=[];for(let t of n){let n=t.split(`.`),o=`__copy_${n.join(`_`)}_${nC++}`;i.set(t,o);let s=r?{type:`MemberExpression`,object:{type:`Identifier`,name:r},property:{type:`Literal`,value:t},computed:!0}:{type:`Identifier`,name:n[0]},c=r?[]:n.slice(1);for(let t of c)s={type:`MemberExpression`,object:s,property:{type:`Identifier`,name:t},computed:!1};a.push({type:`VariableDeclaration`,declarations:[{type:`VariableDeclarator`,id:{type:`Identifier`,name:o},init:{type:`CallExpression`,callee:{type:`MemberExpression`,object:s,property:{type:`Identifier`,name:`copy`},computed:!1},arguments:[]}}],kind:`let`})}t.body.forEach(t=>yC(t,i)),t.body.unshift(...a);let o={type:`ObjectExpression`,properties:Array.from(n).map(t=>({type:`Property`,key:{type:`Literal`,value:t},value:{type:`Identifier`,name:i.get(t)},kind:`init`,computed:!1,shorthand:!1}))};t.body.push({type:`ReturnStatement`,argument:o})}function wC(t,n,r,i){delete t.operator,delete t.left,delete t.right,t.type=`CallExpression`,t.callee={type:`MemberExpression`,computed:!1,object:n,property:{type:`Identifier`,name:r}},t.arguments=i}const TC={UnaryExpression(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i=lc[t.operator],a=t=>{t.type=`CallExpression`,t.callee={type:`Identifier`,name:`__p5.${i}`},t.arguments=[t.argument]};if(t.type===`MemberExpression`){let n=t.argument.property.name;[[`x`,`y`,`z`,`w`],[`r`,`g`,`b`,`a`],[`s`,`t`,`p`,`q`]].some(t=>[...n].every(n=>t.includes(n)))&&t.argument.type===`MemberExpression`&&!t.argument.computed?(t.type=`MemberExpression`,t.object={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.${i}`},arguments:[t.argument.object]},t.property={type:`Identifier`,name:n}):a(t)}else a(t);delete t.argument,delete t.operator},BreakStatement(t,n,r){r.some(t=>aC(t)||oC(t,n.uniformCallbackNames))||(t.callee={type:`Identifier`,name:`__p5.break`},t.arguments=[],t.type=`CallExpression`)},MemberExpression(t,n,r){if(!r.some(t=>aC(t)||oC(t,n.uniformCallbackNames))&&(r.at(-2)?.type!==`AssignmentExpression`||r.at(-2).left!==t)&&t.computed){let n=t.object,r=t.property;t.computed=void 0,t.object=void 0,t.callee={type:`MemberExpression`,object:n,property:{type:`Identifier`,name:`get`}},t.arguments=[r],t.type=`CallExpression`}},VariableDeclarator(t,n,r){if(!r.some(t=>aC(t)||oC(t,n.uniformCallbackNames))){if(aC(t.init)&&(t.init.arguments.length===0||!(t.init.arguments[0].type===`Literal`&&typeof t.init.arguments[0].value==`string`||t.init.arguments[0].type===`TemplateLiteral`))){let r={type:`Literal`,value:eC(n.shaderNameMap,n.shaderNameState,t.id.name)};t.init.arguments.unshift(r)}if(cC(t.init)){if(t.init.arguments.length===0||t.init.arguments[0].type!==`Literal`||typeof t.init.arguments[0].value!=`string`){let r={type:`Literal`,value:eC(n.shaderNameMap,n.shaderNameState,t.id.name)};t.init.arguments.unshift(r),n.varyings[t.id.name]=r}else n.varyings[t.id.name]=t.init.arguments[0]}}},Identifier(t,n,r){r.some(t=>aC(t)||oC(t,n.uniformCallbackNames))||n.varyings[t.name]&&!r.some(n=>n.type===`AssignmentExpression`&&n.left===t)&&(t.type=`CallExpression`,t.callee={type:`MemberExpression`,object:{type:`Identifier`,name:t.name},property:{type:`Identifier`,name:`getValue`}},t.arguments=[])},ArrayExpression(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;for(let t=r.length-1;t>=0;t--){let i=r[t];if(i.type===`CallExpression`){let a=i.callee?.type===`Identifier`?i.callee.name:i.callee?.type===`MemberExpression`&&i.callee.property?.type===`Identifier`?i.callee.property.name:void 0,o=a&&tC(a,n.p5);if(o){let n=r.slice(t+1),a=i.arguments.indexOf(n[0]),s=a===-1?void 0:o[a];for(let t=1;t<n.length&&s;t++)s=s.subtype;if(s?.type===`Array`)return}break}}(t.elements.length<2||t.elements.length>4)&&G(`type error`,`Array literals in shader functions are transpiled to vectors and must have 2-4 elements (got ${t.elements.length}).`);let i=JSON.parse(JSON.stringify(t));t.type=`CallExpression`,t.callee={type:`Identifier`,name:`__p5.strandsNode`},t.arguments=[i]},AssignmentExpression(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i=[`Literal`,`ArrayExpression`,`Identifier`];if(t.operator!==`=`){let n=iC(t.operator.replace(`=`,``)),r=t.operator===`&&=`||t.operator===`||=`?xC(t.operator,t.right):t.right,a={type:`CallExpression`,callee:{type:`MemberExpression`,object:i.includes(t.left.type)?{type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsNode`},arguments:[t.left]}:t.left,property:{type:`Identifier`,name:n}},arguments:[r]};t.operator=`=`,t.right=a}if(n.varyings[t.left.name])wC(t,{type:`Identifier`,name:t.left.name},`bridge`,[t.right]);else if(t.left.type===`MemberExpression`){if(t.left.computed){let n=t.left,r=t.right,i=n.object,a=n.property;wC(t,i,`set`,[a,r]);return}let r=null;if(t.left.object.type===`Identifier`&&n.varyings[t.left.object.name]?r=t.left.object.name:t.left.object.type===`CallExpression`&&t.left.object.callee?.type===`MemberExpression`&&t.left.object.callee.property?.name===`getValue`&&t.left.object.callee.object?.type===`Identifier`&&n.varyings[t.left.object.callee.object.name]&&(r=t.left.object.callee.object.name),r){let n=t.left.property.name;wC(t,{type:`Identifier`,name:r},`bridgeSwizzle`,[{type:`Literal`,value:n},t.right])}}},BinaryExpression:SC,LogicalExpression:SC,ConditionalExpression(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i=t.test,a=xC(`?:`,t.consequent),o=xC(`?:`,t.alternate);t.type=`CallExpression`,t.callee={type:`Identifier`,name:`__p5.strandsTernary`},t.arguments=[i,a,o],delete t.test,delete t.consequent,delete t.alternate},IfStatement(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i=t.test,a={type:`ArrowFunctionExpression`,params:[],body:t.consequent.type===`BlockStatement`?t.consequent:{type:`BlockStatement`,body:[t.consequent]}},o={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsIf`},arguments:[i,a]},s;s=t.alternate?{type:`ArrowFunctionExpression`,params:[],body:t.alternate.type===`BlockStatement`?t.alternate:{type:`BlockStatement`,body:[t.alternate]}}:{type:`ArrowFunctionExpression`,params:[],body:{type:`BlockStatement`,body:[]}},o={type:`CallExpression`,callee:{type:`MemberExpression`,object:o,property:{type:`Identifier`,name:`Else`}},arguments:[s]};let c=/* @__PURE__ */ new Set,l=t=>{let n=/* @__PURE__ */ new Set;e_(t,{VariableDeclarator(t,r){r.some(gC)||t.id.type===`Identifier`&&n.add(t.id.name)}}),e_(t,{AssignmentExpression(t,r){if(r.some(gC))return;let i=t.left;if(i.type===`Identifier`)n.has(i.name)||c.add(i.name);else if(i.type===`MemberExpression`){let t=vC(i);if(t){let r=t.split(`.`)[0];n.has(r)||c.add(t)}}}})};if(l(a.body),l(s.body),c.size>0){CC(a.body,c),CC(s.body,c);let n=`__block_${nC++}`,r=[];for(let t of c){let n=t.split(`.`),i={type:`Identifier`,name:n[0]};for(let t=1;t<n.length;t++)i={type:`MemberExpression`,object:i,property:{type:`Identifier`,name:n[t]},computed:!1};let a={type:`Identifier`,name:n[0]};for(let t=1;t<n.length;t++)a={type:`MemberExpression`,object:a,property:{type:`Identifier`,name:n[t]},computed:!1};r.push({type:`ExpressionStatement`,expression:{type:`AssignmentExpression`,operator:`=`,left:i,right:{type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsNode`},arguments:[a]}}})}r.push({type:`VariableDeclaration`,declarations:[{type:`VariableDeclarator`,id:{type:`Identifier`,name:n},init:o}],kind:`const`});for(let t of c){let i=t.split(`.`),a={type:`Identifier`,name:i[0]};for(let t=1;t<i.length;t++)a={type:`MemberExpression`,object:a,property:{type:`Identifier`,name:i[t]},computed:!1};let o={type:`MemberExpression`,object:{type:`Identifier`,name:n},property:{type:`Literal`,value:t},computed:!0};r.push({type:`ExpressionStatement`,expression:{type:`AssignmentExpression`,operator:`=`,left:a,right:o}})}t.type=`BlockStatement`,t.body=r}else t.type=`ExpressionStatement`,t.expression=o;delete t.test,delete t.consequent,delete t.alternate},UpdateExpression(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i;if(t.operator===`++`)i=`+`;else if(t.operator===`--`)i=`-`;else return;let a={type:`AssignmentExpression`,operator:`=`,left:t.argument,right:{type:`BinaryExpression`,operator:i,left:t.argument,right:{type:`Literal`,value:1}}};Object.assign(t,a),delete t.prefix,TC.BinaryExpression(t.right,n,[...r,t]),TC.AssignmentExpression(t,n,r)},ForStatement(t,n,r){if(r.some(t=>aC(t)||oC(t,n.uniformCallbackNames)))return;let i=`loopVar${rC++}`,a;if(t.init&&t.init.type===`VariableDeclaration`){let n=t.init.declarations[0].init;n={type:`Program`,body:[{type:`ExpressionStatement`,expression:n}]}.body[0].expression,a={type:`ArrowFunctionExpression`,params:[],body:{type:`BlockStatement`,body:[{type:`ReturnStatement`,argument:n}]}}}else a={type:`ArrowFunctionExpression`,params:[],body:{type:`BlockStatement`,body:[{type:`ReturnStatement`,argument:{type:`Literal`,value:0}}]}};let o=t.test||{type:`Literal`,value:!0};if(t.init?.type===`VariableDeclaration`){let n=t.init.declarations[0].id.name;o=bC(o,n,i)}o={type:`Program`,body:[{type:`ExpressionStatement`,expression:o}]}.body[0].expression;let s={type:`ArrowFunctionExpression`,params:[{type:`Identifier`,name:i}],body:o},c;if(t.update){let n=t.update;if(t.init?.type===`VariableDeclaration`){let r=t.init.declarations[0].id.name;n=bC(n,r,i)}n={type:`Program`,body:[{type:`ExpressionStatement`,expression:n}]}.body[0].expression,c={type:`ArrowFunctionExpression`,params:[{type:`Identifier`,name:i}],body:{type:`BlockStatement`,body:[{type:`ReturnStatement`,argument:n}]}}}else c={type:`ArrowFunctionExpression`,params:[{type:`Identifier`,name:i}],body:{type:`BlockStatement`,body:[{type:`ReturnStatement`,argument:{type:`Identifier`,name:i}}]}};let l=t.body.type===`BlockStatement`?t.body:{type:`BlockStatement`,body:[t.body]};if(t.init?.type===`VariableDeclaration`){let n=t.init.declarations[0].id.name;l=bC(l,n,i)}let u={type:`ArrowFunctionExpression`,params:[{type:`Identifier`,name:i},{type:`Identifier`,name:`vars`}],body:l},d=EC(u.body);if(d.size>0){CC(u.body,d,`vars`);let n=`__block_${nC++}`,r=[],i={type:`ObjectExpression`,properties:Array.from(d).map(t=>{let n=t.split(`.`),r={type:`Identifier`,name:n[0]};for(let t=1;t<n.length;t++)r={type:`MemberExpression`,object:r,property:{type:`Identifier`,name:n[t]},computed:!1};return{type:`Property`,key:{type:`Literal`,value:t},value:{type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsNode`},arguments:[r]},kind:`init`,computed:!1,shorthand:!1}})},o={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsFor`},arguments:[a,s,c,u,i]};r.push({type:`VariableDeclaration`,declarations:[{type:`VariableDeclarator`,id:{type:`Identifier`,name:n},init:o}],kind:`const`});for(let t of d){let i=t.split(`.`),a={type:`Identifier`,name:i[0]};for(let t=1;t<i.length;t++)a={type:`MemberExpression`,object:a,property:{type:`Identifier`,name:i[t]},computed:!1};let o={type:`MemberExpression`,object:{type:`Identifier`,name:n},property:{type:`Literal`,value:t},computed:!0};r.push({type:`ExpressionStatement`,expression:{type:`AssignmentExpression`,operator:`=`,left:a,right:o}})}t.type=`BlockStatement`,t.body=r}else t.type=`ExpressionStatement`,t.expression={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsFor`},arguments:[a,s,c,u,{type:`ObjectExpression`,properties:[]}]};delete t.init,delete t.test,delete t.update}};function EC(t){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;return e_(t,{VariableDeclarator(t,n){n.some(gC)||t.id.type===`Identifier`&&r.add(t.id.name)}}),e_(t,{AssignmentExpression(t,i){if(i.some(gC))return;let a=t.left;if(a.type===`Identifier`)r.has(a.name)||n.add(a.name);else if(a.type===`MemberExpression`){let t=vC(a);if(t){let i=t.split(`.`)[0];r.has(i)||n.add(t)}}}}),n}function DC(t){let n=EC(t);e_(t,{CallExpression(t,r){t.callee.name===`__p5.break`&&(r.some(t=>t.type===`ForStatement`)||(t.arguments=[{type:`ObjectExpression`,properties:Array.from(n).map(t=>{let n=t.split(`.`),r={type:`Identifier`,name:n[0]};for(let t=1;t<n.length;t++)r={type:`MemberExpression`,object:r,property:{type:`Identifier`,name:n[t]},computed:!1};return{type:`Property`,key:{type:`Literal`,value:t},value:r,kind:`init`,computed:!1,shorthand:!1}})}]))}})}function OC(t){let n=!1,r=0;return t.body&&t.body.type===`BlockStatement`&&t_(t.body,{},{IfStatement(t,n,i){r++,t.test&&i(t.test,n),t.consequent&&i(t.consequent,n),t.alternate&&i(t.alternate,n),r--},ForStatement(t,n,i){r++,t.init&&i(t.init,n),t.test&&i(t.test,n),t.update&&i(t.update,n),t.body&&i(t.body,n),r--},ReturnStatement(t){r>0&&(n=!0)}}),n}function kC(t){let n=!1;return t&&t_(t,{},{ReturnStatement(){n=!0}}),n}function AC(t){let n={type:`VariableDeclaration`,declarations:[{type:`VariableDeclarator`,id:{type:`Identifier`,name:`__returnValue`},init:null}],kind:`let`};if(!t.body||t.body.type!==`BlockStatement`)return;t.body.body.unshift(n);function r(t){for(let n=0;n<t.length;n++){let i=t[n];if(i.type===`IfStatement`&&kC(i.consequent)&&!i.alternate){let a=t.slice(n+1);a.length>0&&(i.alternate={type:`BlockStatement`,body:a},t.splice(n+1),r(i.alternate.body))}i.type===`IfStatement`?(i.consequent&&i.consequent.type===`BlockStatement`&&r(i.consequent.body),i.alternate&&i.alternate.type===`BlockStatement`&&r(i.alternate.body)):i.type===`ForStatement`&&i.body&&i.body.type===`BlockStatement`?r(i.body.body):i.type===`BlockStatement`&&r(i.body)}}r(t.body.body),t_(t.body,{},{ReturnStatement(t){t.type=`ExpressionStatement`,t.expression={type:`AssignmentExpression`,operator:`=`,left:{type:`Identifier`,name:`__returnValue`},right:t.argument||{type:`Identifier`,name:`undefined`}},delete t.argument}}),t.body.body.push({type:`ReturnStatement`,argument:{type:`Identifier`,name:`__returnValue`}})}function jC(t){let n=!1,r=0;return t.body&&t.body.type===`BlockStatement`&&t_(t.body,{},{IfStatement(t,n,i){r++,t.test&&i(t.test,n),t.consequent&&i(t.consequent,n),t.alternate&&i(t.alternate,n),r--},ForStatement(t,n,i){r++,t.init&&i(t.init,n),t.test&&i(t.test,n),t.update&&i(t.update,n),t.body&&i(t.body,n),r--},CallExpression(t){r>0&&t.callee?.type===`MemberExpression`&&t.callee?.property?.name===`set`&&(n=!0)}}),n}function MC(t,n,r){return t.type===`ExpressionStatement`&&(t.expression?.type===`SequenceExpression`?t.expression.expressions:[t.expression]).some(t=>t?.type===`CallExpression`&&t.callee?.type===`MemberExpression`&&t.callee?.property?.name===n&&JS.generate(t.callee.object)===r)}function NC(t){if(!t.body||t.body.type!==`BlockStatement`)return;let n=/* @__PURE__ */ new Map;if(t_(t.body,{},{CallExpression(t){if(t.callee?.type===`MemberExpression`&&t.callee?.property?.name===`set`&&t.callee?.object){let r=t.callee.object,i=JS.generate(r);n.has(i)||n.set(i,r)}}}),n.size!==0)for(let[r,i]of n){let n=`__${r.replace(/[^a-zA-Z0-9_]/g,`_`)}_value`,a={type:`VariableDeclaration`,declarations:[{type:`VariableDeclarator`,id:{type:`Identifier`,name:n},init:null}],kind:`let`},o=-1;for(let n=0;n<t.body.body.length;n++)if(MC(t.body.body[n],`begin`,r)){o=n;break}o===-1?t.body.body.unshift(a):t.body.body.splice(o,0,a),e_(t.body,{CallExpression(t,i,a){if(t.callee?.type===`MemberExpression`&&t.callee?.property?.name===`set`&&t.callee?.object&&JS.generate(t.callee.object)===r&&t.arguments.length>0){let r=t.arguments[0];delete t.callee,delete t.arguments,t.type=`AssignmentExpression`,t.operator=`=`,t.left={type:`Identifier`,name:n},t.right=r}}});let s={type:`ExpressionStatement`,expression:{type:`CallExpression`,callee:{type:`MemberExpression`,object:JSON.parse(JSON.stringify(i)),property:{type:`Identifier`,name:`set`},computed:!1},arguments:[{type:`Identifier`,name:n}]}},c=-1;for(let n=0;n<t.body.body.length;n++)if(MC(t.body.body[n],`end`,r)){c=n;break}if(c!==-1)t.body.body.splice(c,0,s);else{let n=t.body.body[t.body.body.length-1];n&&n.type===`ReturnStatement`?t.body.body.splice(t.body.body.length-1,0,s):t.body.body.push(s)}}}function PC(t,n){let r=[];e_(t,{ArrowFunctionExpression(t,i){i.some(t=>aC(t)||oC(t,n))||jC(t)&&r.push(t)},FunctionExpression(t,i){i.some(t=>aC(t)||oC(t,n))||jC(t)&&r.push(t)},FunctionDeclaration(t,i){i.some(t=>aC(t)||oC(t,n))||jC(t)&&r.push(t)}});for(let t of r)NC(t)}function FC(t,n){let r=[];e_(t,{VariableDeclarator(t,i){if(i.some(t=>aC(t)||oC(t,n)))return;let a=t.init;a&&(a.type===`ArrowFunctionExpression`||a.type===`FunctionExpression`)&&OC(a)&&r.push(a)},FunctionDeclaration(t,i){i.some(t=>aC(t)||oC(t,n))||OC(t)&&r.push(t)},CallExpression(t,n){}});for(let t of r)AC(t)}function IC(t,n,r,i){let a={...TC};delete a.IfStatement,delete a.ForStatement;let o={varyings:{},uniformCallbackNames:n,shaderNameMap:XS(),shaderNameState:ZS(r?.nextSuffix||0),p5:i};return e_(t,a,void 0,o),{shaderNameMap:o.shaderNameMap,shaderNameState:o.shaderNameState}}function LC(t,n){t_(t,{varyings:{},inControlFlow:0,uniformCallbackNames:n},{CallExpression(t,n,r){if(!aC(t)){t.callee&&r(t.callee,n);for(let i of t.arguments)r(i,n)}},FunctionDeclaration(t,n,r){n.uniformCallbackNames?.has(t.id?.name)||t.body&&r(t.body,n)},VariableDeclarator(t,n,r){(!n.uniformCallbackNames?.has(t.id?.name)||t.init?.type!==`FunctionExpression`&&t.init?.type!==`ArrowFunctionExpression`)&&t.init&&r(t.init,n)},IfStatement(t,n,r){n.inControlFlow++,t.test&&r(t.test,n),t.consequent&&r(t.consequent,n),t.alternate&&r(t.alternate,n),TC.IfStatement(t,n,[]),n.inControlFlow--},ForStatement(t,n,r){n.inControlFlow++,t.init&&r(t.init,n),t.test&&r(t.test,n),t.update&&r(t.update,n),t.body&&(DC(t.body),r(t.body,n)),TC.ForStatement(t,n,[]),n.inControlFlow--},ReturnStatement(t,n,r){n.inControlFlow&&(t.type=`ExpressionStatement`,t.expression={type:`CallExpression`,callee:{type:`Identifier`,name:`__p5.strandsEarlyReturn`},arguments:t.argument?[t.argument]:[]},delete t.argument)}})}function RC(t,n,r){let i=Object.keys(r),a=n.body.length===1&&n.body[0].expression;if(!a||a.type!==`FunctionExpression`&&a.type!==`ArrowFunctionExpression`)throw console.log(JS.generate(n)),Error(`Could not parse p5.strands function!`);let o=a.params.map(t=>JS.generate(t)),s,c;o.length>0?(c=o,s=[r]):(c=i,s=i.map(t=>r[t]));let l=a.body.type===`BlockStatement`?a.body.body.map(t=>JS.generate(t)).join(`
`):`return ${JS.generate(a.body)};`;try{let n=Function(`__p5`,...c,l);return()=>n(t,...s)}catch(t){throw console.error(t),console.log(c),console.log(l),Error(`Error transpiling p5.strands callback!`)}}function zC(t,n,r,i,a){nC=0,rC=0;let o=Qg(n,{ecmaVersion:2021,locations:r});dC(o);let s=sC(o);hC(o,s),PC(o,s);let{shaderNameMap:c,shaderNameState:l}=IC(o,s,a,t);return FC(o,s),LC(o,s),{callback:RC(t,o,i),shaderNameMap:c,shaderNameState:l}}function BC(t){let{cfg:n,backend:r,vertexDeclarations:i,fragmentDeclarations:a,computeDeclarations:o}=t,s={uniforms:{},storageUniforms:{},varyingVariables:[],shaderNameMap:t.shaderNameMap,shaderNameState:t.shaderNameState};for(let{name:n,typeInfo:i,defaultValue:a}of t.uniforms)if(i.baseType===`storage`)a!=null&&(s.storageUniforms[n]=a);else{let t=r.generateHookUniformKey(n,i);t!==null&&(s.uniforms[t]=a)}r.addTextureBindingsToDeclarations&&r.addTextureBindingsToDeclarations(t),r.addStorageBufferBindingsToDeclarations&&r.addStorageBufferBindingsToDeclarations(t);for(let{hookType:i,rootNodeID:a,entryBlockID:o,shaderContext:c}of t.hooks){let l={indent:1,codeLines:[],write(t){this.codeLines.push(`  `.repeat(this.indent)+t)},tempNames:{},declarations:[],nextTempID:0,visitedNodes:/* @__PURE__ */ new Set,shaderContext:c,strandsContext:t},u=kc(n.outgoingEdges,o);for(let n of u)r.generateBlock(n,t,l);let d=r.hookEntry(i),f;f=i.returnType.properties?rc(i.returnType):!i.returnType.dataType||i.returnType.typeName?.trim()===`void`?null:i.returnType.dataType,a!==void 0&&r.generateReturnStatement(t,l,a,f),s[`${i.returnType.typeName} ${i.name}`]=[d,...l.codeLines,`}`].join(`
`)}if(t.sharedVariables)for(let[n,o]of t.sharedVariables)o.usedInVertex&&o.usedInFragment?s.varyingVariables.push(r.generateVaryingVariable(n,o.typeInfo)):o.usedInVertex?i.add(r.generateLocalDeclaration(n,o.typeInfo)):o.usedInFragment&&a.add(r.generateLocalDeclaration(n,o.typeInfo));return t._instanceIDUsedInFragment&&(s.instanceIDVarying=r.generateInstanceIDVarying()),s.vertexDeclarations=[...i].join(`
`),s.fragmentDeclarations=[...a].join(`
`),s.computeDeclarations=[...o].join(`
`),s}function VC(t,n,r){let i=n.filter(t=>t.value.id!==null);if(i.length===0)throw Error(`No valid inputs for phi node for variable ${r}`);let a=i.map(n=>_c(t.dag,n.value.id)),o=a.find(t=>t.baseType!==V.ASSIGN_ON_USE&&t.dimension)??a.find(t=>t.baseType!==V.ASSIGN_ON_USE);o||=a[0];let s=o.dimension,c=o.baseType;if(c!==V.ASSIGN_ON_USE)for(let n of a)n.baseType===V.ASSIGN_ON_USE&&yc(t.dag,n.id,c,s);let l={nodeType:B.PHI,dimension:s,baseType:c,dependsOn:n.map(t=>t.value.id).filter(t=>t!==null),phiBlocks:n.map(t=>t.blockId),phiInputs:n},u=K(t.dag,l);return Oc(t.cfg,t.cfg.currentBlock,u),{id:u,dimension:s,baseType:c}}var HC=class{constructor(t,n,r){this.branches=[{condition:n,branchCallback:r,blockType:fc.IF_BODY}],this.ctx=t}ElseIf(t,n){return this.branches.push({condition:t,branchCallback:n,blockType:fc.IF_BODY}),this}Else(t=()=>({})){this.branches.push({condition:null,branchCallback:t,blockType:fc.IF_BODY});let n=UC(this.ctx,this),r={};for(let[t,i]of Object.entries(n))r[t]=q(i.id,i.dimension,this.ctx);return r}};function UC(t,n){let r=t.cfg,i=n.branches,a=Ec(r,fc.MERGE),o=[],s=[],c=[],l={},u={},d=t.stateScope,f=d?.stack.length??0,p=/* @__PURE__ */ new Map,m=/* @__PURE__ */ new Map;for(let t of d?.records??[])for(let n of t.slots)p.set(n,n.valueId),m.set(n,[]);let h=Ec(r,fc.BRANCH);Dc(r,r.currentBlock,h),Dc(r,h,a);let g=h;for(let n=0;n<i.length;n++){let{condition:l,branchCallback:h,blockType:_}=i[n];if(l!==null){let t=Ec(r,fc.IF_COND);Dc(r,g,t),Cc(r,t),r.blockConditions[t]=l.id,g=t,wc(r)}else{let t=Ec(r,fc.ELSE_COND);Dc(r,g,t),g=t}let v=Ec(r,fc.SCOPE_START);Dc(r,g,v);let y=Ec(r,_);Dc(r,v,y),s.push(y),Cc(r,y);for(let[t,n]of p)t.valueId=n;let b=t.conditionalDepth,x=d?.stackFloor;t.conditionalDepth=b+1,d&&(d.stackFloor=f);let S;try{S=h()??{}}finally{t.conditionalDepth=b,d&&(d.stackFloor=x)}d&&d.stack.length!==f&&G(`scope error`,`push() and pop() must be balanced inside each if/else branch.`);for(let[n,r]of m)r.push({value:q(n.valueId,n.dimension,t),blockId:y});for(let n in S)S[n]=t.p5.strandsNode(S[n]);for(let t in S)u[t]?u[t].push({value:S[t],blockId:y}):u[t]=[{value:S[t],blockId:y}];o.push(S);let C=Ec(r,fc.DEFAULT);Dc(r,r.currentBlock,C),c.push(C),wc(r);let w=Ec(r,fc.SCOPE_END);Dc(r,C,w),Dc(r,w,a),g=v}Tc(r,h);for(let n in u)l[n]=VC(t,u[n],n);let _=/* @__PURE__ */ new Map;for(let[n,r]of m){let i=p.get(n);r.some(t=>t.value.id!==i)&&_.set(n,VC(t,r,n.name))}wc(r);for(let n=0;n<o.length;n++){let i=o[n],a=c[n];Tc(r,a);for(let n in i)if(l[n]){let o=l[n].id,s=i[n].id,c={nodeType:B.ASSIGNMENT,dependsOn:[o,s],phiBlocks:[]};Oc(r,a,K(t.dag,c))}for(let[i,o]of _)Oc(r,a,K(t.dag,{nodeType:B.ASSIGNMENT,dependsOn:[o.id,m.get(i)[n].value.id],phiBlocks:[]}));wc(r)}Cc(r,a);for(let[t,n]of p)t.valueId=_.get(t)?.id??n;return l}var WC=class{constructor(t,n,r,i,a,o){this.strandsContext=t,this.initialCb=n,this.conditionCb=r,this.updateCb=i,this.bodyCb=a,this.initialVars=o}build(){let t=this.strandsContext.cfg,n=Ec(t,fc.MERGE),r=Ec(t,fc.BRANCH);Dc(t,t.currentBlock,r),Dc(t,r,n);let{initialVar:i,phiNode:a}=this.initializeLoopVariable(t,r);Cc(t,t.currentBlock);let o=q(a.id,a.dimension,this.strandsContext),s=this.runInLoopPhase(`header`,()=>this.conditionCb(o)),c=this.runInLoopPhase(`header`,()=>this.updateCb(o));wc(t),this.loopIsBounded(i,s,c)?this.buildBoundedLoop(t,r,n,i,a,s,c):this.buildUnboundedLoop(t,r,n,i,a,s,c);let l=this.phiNodesForBody;Tc(t,r);for(let[t,n]of Object.entries(this.bodyResults))if(t!==`loopVar`&&l[t]){let r=l[t].id,i=_c(this.strandsContext.dag,r);i.dependsOn.length>1&&(i.dependsOn[1]=n.id),i.phiInputs&&i.phiInputs.length>1&&(i.phiInputs[1].value=n)}for(let[t,n]of this.stateUpdatedIds)_c(this.strandsContext.dag,this.statePhis.get(t).id).dependsOn[1]=n;wc(t),Tc(t,r);for(let[n,i]of Object.entries(this.initialVars))if(n!==`loopVar`&&l[n]){let a=l[n].id,o=i.id,s=gc({nodeType:B.ASSIGNMENT,dependsOn:[a,o],phiBlocks:[]});Oc(t,r,K(this.strandsContext.dag,s))}for(let[n,i]of this.statePhis)Oc(t,r,K(this.strandsContext.dag,gc({nodeType:B.ASSIGNMENT,dependsOn:[i.id,this.stateEntryIds.get(n)],phiBlocks:[]})));wc(t),Tc(t,this.finalBodyBlock);for(let[n,r]of Object.entries(this.bodyResults))if(n!==`loopVar`&&l[n]){let i=l[n].id,a=r.id,o=gc({nodeType:B.ASSIGNMENT,dependsOn:[i,a],phiBlocks:[]}),s=K(this.strandsContext.dag,o);Oc(t,this.finalBodyBlock,s)}for(let[n,r]of this.stateUpdatedIds){let i=K(this.strandsContext.dag,gc({nodeType:B.ASSIGNMENT,dependsOn:[this.statePhis.get(n).id,r],phiBlocks:[]}));Oc(t,this.finalBodyBlock,i)}wc(t);let u={};for(let[t,n]of Object.entries(l))u[t]=q(n.id,n.dimension,this.strandsContext);Cc(t,n);for(let[t,n]of this.statePhis)t.valueId=this.stateUpdatedIds.has(t)?n.id:this.stateEntryIds.get(t);return u}buildBoundedLoop(t,n,r,i,a,o,s){let c=Ec(t,fc.FOR);if(Dc(t,n,c),Cc(t,c),i){let n=gc({nodeType:B.ASSIGNMENT,dependsOn:[a.id,i.id],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,n))}let l=gc({nodeType:B.STATEMENT,statementType:tc.EXPRESSION,dependsOn:[o.id],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,l));let u=gc({nodeType:B.ASSIGNMENT,dependsOn:[a.id,s.id],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,u)),wc(t);let d=t.blockInstructions[c]||[],f=i?3:2;if(d.length!==f)throw Error(`FOR block must have exactly ${f} statements, got ${d.length}`);let p=Ec(t,fc.SCOPE_START);Dc(t,c,p);let m=Ec(t,fc.DEFAULT);this.bodyBlock=m,Dc(t,p,m),this.executeBodyCallback(t,n,m,a);let h=Ec(t,fc.SCOPE_END);Dc(t,m,h),Dc(t,h,r)}buildUnboundedLoop(t,n,r,i,a,o,s){let c=Ec(t,fc.FOR);if(Dc(t,n,c),Cc(t,c),i){let n=gc({nodeType:B.ASSIGNMENT,dependsOn:[a.id,i.id],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,n))}else{let n=gc({nodeType:B.STATEMENT,statementType:tc.EMPTY,dependsOn:[],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,n))}let l=gc({nodeType:B.STATEMENT,statementType:tc.EMPTY,dependsOn:[],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,l));let u=gc({nodeType:B.STATEMENT,statementType:tc.EMPTY,dependsOn:[],phiBlocks:[]});Oc(t,c,K(this.strandsContext.dag,u)),wc(t);let d=Ec(t,fc.SCOPE_START);Dc(t,c,d);let f=Ec(t,fc.DEFAULT);Dc(t,d,f),Cc(t,f);let p=o,m=this.createLogicalNotNode(p),h=Ec(t,fc.IF_COND);Dc(t,f,h),t.blockConditions[h]=m.id;let g=Ec(t,fc.SCOPE_START);Dc(t,h,g);let _=Ec(t,fc.DEFAULT);Dc(t,g,_),Cc(t,_);let v=gc({nodeType:B.STATEMENT,statementType:tc.BREAK,dependsOn:[],phiBlocks:[]});Oc(t,_,K(this.strandsContext.dag,v)),wc(t);let y=Ec(t,fc.SCOPE_END);Dc(t,_,y),Dc(t,y,r),wc(t);let b=Ec(t,fc.DEFAULT);this.bodyBlock=b,Dc(t,f,b),this.executeBodyCallback(t,n,b,a);let x=Ec(t,fc.DEFAULT);Dc(t,b,x),Cc(t,x);let S=gc({nodeType:B.ASSIGNMENT,dependsOn:[a.id,s.id],phiBlocks:[]});Oc(t,x,K(this.strandsContext.dag,S)),wc(t);let C=Ec(t,fc.SCOPE_END);Dc(t,x,C),Dc(t,C,r),Dc(t,f,r)}initializeLoopVariable(t,n){Cc(t,n);let r=this.runInLoopPhase(`header`,()=>this.initialCb());if(!r?.isStrandsNode){let{id:t,dimension:n}=qc(this.strandsContext,{baseType:V.FLOAT,dimension:1},r);r=q(t,n,this.strandsContext)}let i=VC(this.strandsContext,[{value:r,blockId:n},{value:r,blockId:n}],`loopVar`);return wc(t),{initialVar:r,phiNode:i}}runInLoopPhase(t,n){let r=this.strandsContext.loopPhase;this.strandsContext.loopPhase=t;try{return n()}finally{this.strandsContext.loopPhase=r}}createLogicalNotNode(t){let n=gc({nodeType:B.OPERATION,opCode:W.Unary.LOGICAL_NOT,baseType:V.BOOL,dimension:1,dependsOn:[t.id],phiBlocks:[],usedBy:[]});return q(K(this.strandsContext.dag,n),1,this.strandsContext)}executeBodyCallback(t,n,r,i){Cc(t,r);let a={};Tc(t,n);for(let[t,i]of Object.entries(this.initialVars))t!==`loopVar`&&(a[t]=VC(this.strandsContext,[{value:i,blockId:n},{value:i,blockId:r}],t));let o=this.strandsContext.stateScope;this.stateEntryIds=/* @__PURE__ */ new Map,this.statePhis=/* @__PURE__ */ new Map;for(let t of o?.records??[])for(let i of t.slots){let t=q(i.valueId,i.dimension,this.strandsContext);this.stateEntryIds.set(i,i.valueId),this.statePhis.set(i,VC(this.strandsContext,[{value:t,blockId:n},{value:t,blockId:r}],i.name))}wc(t);let s={};for(let[t,n]of Object.entries(a)){let{id:r,dimension:i}=Fc(this.strandsContext,n.id);s[t]=q(r,i,this.strandsContext)}let c=/* @__PURE__ */ new Map;for(let[t,n]of this.statePhis)t.valueId=Fc(this.strandsContext,n.id).id,c.set(t,t.valueId);let l=q(i.id,i.dimension,this.strandsContext),u=o?.stack.length??0,d=o?.stackFloor;o&&(o.stackFloor=u),this.phiNodesForBody=a;let f=this.strandsContext.activeLoop;this.strandsContext.activeLoop=this;try{this.bodyResults=this.runInLoopPhase(`body`,()=>this.bodyCb(l,s))||{}}finally{this.strandsContext.activeLoop=f,o&&(o.stackFloor=d)}o&&o.stack.length!==u&&G(`scope error`,`push() and pop() must be balanced inside a for loop body.`),this.stateUpdatedIds=/* @__PURE__ */ new Map;for(let[t,n]of c)t.valueId!==n&&this.stateUpdatedIds.set(t,t.valueId);for(let t in this.bodyResults)this.bodyResults[t]=this.strandsContext.p5.strandsNode(this.bodyResults[t]);this.finalBodyBlock=t.currentBlock,wc(t)}commitCarriedValues(t){let n=this.strandsContext.cfg;for(let[r,i]of Object.entries(t)){let t=this.phiNodesForBody[r];if(!t)continue;let a=K(this.strandsContext.dag,gc({nodeType:B.ASSIGNMENT,dependsOn:[t.id,this.strandsContext.p5.strandsNode(i).id],phiBlocks:[]}));Oc(n,n.currentBlock,a)}}loopIsBounded(t,n,r){if(!n)return!1;let i=_c(this.strandsContext.dag,n.id);if(i.nodeType!==B.OPERATION||!i.dependsOn||i.dependsOn.length!==2)return!1;let a=q(i.dependsOn[0],1,this.strandsContext),o=q(i.dependsOn[1],1,this.strandsContext),s=this.nodeUsesOnlyLiterals(a),c=this.nodeUsesOnlyLiterals(o);return s||c}nodeUsesOnlyLiterals(t){let n=_c(this.strandsContext.dag,t.id);switch(n.nodeType){case B.LITERAL:return!0;case B.VARIABLE:return!1;case B.PHI:return!1;case B.OPERATION:if(n.dependsOn)for(let t of n.dependsOn){let n=q(t,1,this.strandsContext);if(!this.nodeUsesOnlyLiterals(n))return!1}return!0;default:return!1}}};function GC(t,n,r,i){let{dag:a,cfg:o,p5:s}=t,c=n?.isStrandsNode?n:s.strandsNode(n),l=r?.isStrandsNode?r:s.strandsNode(r),u=i?.isStrandsNode?i:s.strandsNode(i),d=vc(a,l.id),f=vc(a,u.id);d.baseType===V.ASSIGN_ON_USE&&f.baseType!==V.ASSIGN_ON_USE?(yc(a,l.id,f.baseType,f.dimension),d=vc(a,l.id)):f.baseType===V.ASSIGN_ON_USE&&d.baseType!==V.ASSIGN_ON_USE&&(yc(a,u.id,d.baseType,d.dimension),f=vc(a,u.id)),d.baseType!==V.ASSIGN_ON_USE&&f.baseType!==V.ASSIGN_ON_USE&&(d.baseType!==f.baseType||d.dimension!==f.dimension)&&G(`type error`,`The true and false branches of a ternary expression must have the same type. Right now, the true branch is a ${d.baseType}${d.dimension}, and the false branch is a ${f.baseType}${f.dimension}.`);let p=d,m=K(a,gc({nodeType:B.OPERATION,opCode:W.Nary.TERNARY,dependsOn:[c.id,l.id,u.id],baseType:p.baseType,dimension:p.dimension}));return Oc(o,o.currentBlock,m),q(m,p.dimension,t)}function KC(t,n,r,i){let a=[[`mat2`,2],[`mat2x2`,2],[`transform2D`,3],[`mat3`,3],[`mat3x3`,3],[`transform3D`,4],[`mat4`,4],[`mat4x4`,4]],o=()=>r.experimentalFeaturesUsed.add(`p5.strands.transforms`);for(let[s,c]of a)i(n,t,s,function(...n){if(!r.active){t._friendlyError(`It looks like you've called ${s} outside of a shader's modify() function.`);return}o();let{id:i,dimension:a}=Kc(r,c,n);return q(i,a,r)});let s=t=>r.active&&!!t?.isStrandsNode&&t.typeInfo().baseType===V.MAT,c=(t,n,i)=>{s(t)||G(`type error`,`The first argument to a transform function (translate, rotate, scale, shearX, shearY) must be a transform created with transform2D() or transform3D().`);let a=t.dimension===4?i:n,o=Hc(r,t.dimension,a);return t.mult(q(o.id,o.dimension,r))},l=n.translate;i(n,t,`translate`,function(...t){let n=t[0];if(!s(n))return l.apply(this,t);o();let[r=0,i=0,a=0]=t.slice(1);return c(n,[1,0,0,0,1,0,r,i,1],[1,0,0,0,0,1,0,0,0,0,1,0,r,i,a,1])});let u=n.scale;i(n,t,`scale`,function(...t){let n=t[0];if(!s(n))return u.apply(this,t);o();let r=t.slice(1),i=r.length===1,a=r[0]??1,l=r[1]??(i?a:1),d=r[2]??(i?a:1);return c(n,[a,0,0,0,l,0,0,0,1],[a,0,0,0,0,l,0,0,0,0,d,0,0,0,0,1])});let d=n.rotate;i(n,t,`rotate`,function(...t){let n=t[0];if(!s(n))return d.apply(this,t);o();let r=t[1],i=this.cos(r),a=this.sin(r),l=a.mult(-1);return c(n,[i,a,0,l,i,0,0,0,1],[i,a,0,0,l,i,0,0,0,0,1,0,0,0,0,1])});let f=n.shearX;i(n,t,`shearX`,function(...t){let n=t[0];if(!s(n))return f.apply(this,t);o();let r=t[1],i=this.tan(r);return c(n,[1,0,0,i,1,0,0,0,1],[1,0,0,0,i,1,0,0,0,0,1,0,0,0,0,1])});let p=n.shearY;i(n,t,`shearY`,function(...t){let n=t[0];if(!s(n))return p.apply(this,t);o();let r=t[1],i=this.tan(r);return c(n,[1,i,0,0,1,0,0,0,1],[1,i,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}),i(n,t,`rotateAxisAngle`,function(...n){if(!r.active){t._friendlyError(`It looks like you've called rotateAxisAngle outside of a shader's modify() function.`);return}o();let[i,a,s]=n;(!i?.isStrandsNode||i.typeInfo().baseType!==V.MAT||i.dimension!==4)&&G(`type error`,`rotateAxisAngle() only works on a 3D transform created with transform3D().`);let c=this.normalize(a),l=c.x,u=c.y,d=c.z,f=this.cos(s),p=this.sin(s),m=t.strandsNode(1).sub(f),h=Hc(r,4,[l.mult(l).mult(m).add(f),u.mult(l).mult(m).add(d.mult(p)),d.mult(l).mult(m).sub(u.mult(p)),0,l.mult(u).mult(m).sub(d.mult(p)),u.mult(u).mult(m).add(f),d.mult(u).mult(m).add(l.mult(p)),0,l.mult(d).mult(m).add(u.mult(p)),u.mult(d).mult(m).sub(l.mult(p)),d.mult(d).mult(m).add(f),0,0,0,0,1]);return i.mult(q(h.id,h.dimension,r))});let m={rotateX:n.rotateX,rotateY:n.rotateY,rotateZ:n.rotateZ},h=(a,c)=>{let l=m[a];i(n,t,a,function(...t){let n=t[0];if(!s(n))return l?l.apply(this,t):void 0;o(),n.dimension!==4&&G(`type error`,`${a}() needs a 3D transform created with transform3D().`);let i=t[1],u=this.cos(i),d=this.sin(i),f=Hc(r,4,c(u,d,d.mult(-1)));return n.mult(q(f.id,f.dimension,r))})};h(`rotateX`,(t,n,r)=>[1,0,0,0,0,t,n,0,0,r,t,0,0,0,0,1]),h(`rotateY`,(t,n,r)=>[t,0,r,0,0,1,0,0,n,0,t,0,0,0,0,1]),h(`rotateZ`,(t,n,r)=>[t,n,0,0,r,t,0,0,0,0,1,0,0,0,0,1]),i(n,t,`transformPoint`,function(...i){if(!r.active){t._friendlyError(`It looks like you've called transformPoint outside of a shader's modify() function.`);return}o();let[a,s]=i;a?.isStrandsNode&&a.typeInfo().baseType===V.MAT||G(`type error`,`transformPoint(t, point): the first argument must be a transform from transform2D()/transform3D().`);let c=t.strandsNode(s);return a.dimension===4?a.mult(n.vec4(c,1)).xyz:a.mult(n.vec3(c,1)).xy}),i(n,t,`transformNormal`,function(...i){if(!r.active){t._friendlyError(`It looks like you've called transformNormal outside of a shader's modify() function.`);return}o();let[a,s]=i;a?.isStrandsNode&&a.typeInfo().baseType===V.MAT||G(`type error`,`transformNormal(t, normal): the first argument must be a transform from transform2D()/transform3D().`);let c=t.strandsNode(s),l=n[`mat${a.dimension-1}`](a);return n.normalize(n.transpose(n.inverse(l)).mult(c))})}const qC={width:{typeInfo:H.float1,get:t=>t.width},height:{typeInfo:H.float1,get:t=>t.height},mouseX:{typeInfo:H.float1,get:t=>t.mouseX},mouseY:{typeInfo:H.float1,get:t=>t.mouseY},pmouseX:{typeInfo:H.float1,get:t=>t.pmouseX},pmouseY:{typeInfo:H.float1,get:t=>t.pmouseY},winMouseX:{typeInfo:H.float1,get:t=>t.winMouseX},winMouseY:{typeInfo:H.float1,get:t=>t.winMouseY},pwinMouseX:{typeInfo:H.float1,get:t=>t.pwinMouseX},pwinMouseY:{typeInfo:H.float1,get:t=>t.pwinMouseY},frameCount:{typeInfo:H.float1,get:t=>t.frameCount},deltaTime:{typeInfo:H.float1,get:t=>t.deltaTime},displayWidth:{typeInfo:H.float1,get:t=>t.displayWidth},displayHeight:{typeInfo:H.float1,get:t=>t.displayHeight},windowWidth:{typeInfo:H.float1,get:t=>t.windowWidth},windowHeight:{typeInfo:H.float1,get:t=>t.windowHeight},mouseIsPressed:{typeInfo:H.bool1,get:t=>t.mouseIsPressed}};function JC(t){return(!t._builtinGlobals||t._builtinGlobals.dag!==t.dag)&&(t._builtinGlobals={dag:t.dag,nodes:/* @__PURE__ */ new Map,uniformsAdded:/* @__PURE__ */ new Set}),t._builtinGlobals}function YC(t,n,r,i){let a=JC(t),o=a.nodes.get(n);if(o)return o;a.uniformsAdded.has(n)||(a.uniformsAdded.add(n),t.uniforms.push({name:n,typeInfo:r,defaultValue:i}));let{id:s,dimension:c}=Nc(t,r,n),l=q(s,c,t);return a.nodes.set(n,l),l}function XC(t,n){let r=qC[n];if(!r)return null;let i=`_p5_global_${n}`,a=t.renderer?._pInst||t.p5?.instance,o=YC(t,i,r.typeInfo,()=>a?r.get(a):void 0);return o._originalBuiltinName=n,o}function ZC(t){if(t._builtinGlobalsAccessorsInstalled)return;let n=()=>t.renderer?._pInst||t.p5?.instance;for(let r of Object.keys(qC)){let i=qC[r],a=`_strands_${r}`;n()?._isGlobal&&Object.defineProperty(window,r,{get:()=>{if(t.active)return XC(t,r);let a=n();return i.get(a)},configurable:!0});let o=Object.getOwnPropertyDescriptor(t.p5.prototype,r);Object.defineProperty(t.p5.prototype,r,{get:function(){return t.active?XC(t,r):Object.prototype.hasOwnProperty.call(this,a)?this[a]:o?.get?o.get.call(this):o?.value},set:function(t){this[a]=t},configurable:!0});let s=t.p5?.Graphics?.prototype;if(s){let n=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(s,r,{get:function(){return t.active?XC(t,r):n?.get?n.get.call(this):this[a]},set:function(t){n?.set?n.set.call(this,t):this[a]=t},configurable:!0})}}t._builtinGlobalsAccessorsInstalled=!0}function QC(t){if(t._instanceIndexAccessorInstalled)return;let n=()=>t.renderer?._pInst||t.p5?.instance,r=function(){if(t.active){let n=Nc(t,{baseType:V.INT,dimension:1},t.backend.instanceIdReference());return q(n.id,n.dimension,t)}};n()?._isGlobal&&Object.defineProperty(window,"instanceIndex",{get:r,configurable:!0}),Object.defineProperty(t.p5.prototype,"instanceIndex",{get:r,configurable:!0});let i=t.p5?.Graphics?.prototype;i&&Object.defineProperty(i,"instanceIndex",{get:r,configurable:!0}),t._instanceIndexAccessorInstalled=!0}function $C(t,n,r,i){t[r]=i;let a=n?.Graphics?.prototype;a&&(a[r]=i)}function ew(t,n,r,i){tw(n,window,r,i),tw(n,t,r,i);let a=n.p5?.Graphics?.prototype;a&&tw(n,a,r,i)}function tw(t,n,r,i){let a=Object.getOwnPropertyDescriptor(n,r),o=a&&`value`in a&&a.writable;if(a&&!a.configurable&&!o)throw TypeError(`p5.strands can't temporarily replace "${String(r)}": the existing property can't be changed.`);t.tempProps.push({target:n,name:r,descriptor:a}),!a||a.configurable?Object.defineProperty(n,r,{value:i,writable:!0,enumerable:!a||a.enumerable,configurable:!0}):n[r]=i}function nw(t){let n=t.tempProps;t.tempProps=[];let r=[];for(let t=n.length-1;t>=0;t--){let{target:i,name:a,descriptor:o}=n[t];try{o?o.configurable?Object.defineProperty(i,a,o):i[a]=o.value:delete i[a]}catch(t){r.push(t)}}return r}function rw(t,n,r){typeof n==`string`&&(t.shaderNameMap?.internalToExternal?.[n]||QS(n)&&G(`parameter validation error`,`${r}("${n}") uses the reserved internal p5.strands prefix "${YS}". or the reserved "gl_" prefix. Please choose a different explicit shader name.`))}function iw(t,n,r){return typeof n!=`string`||t.shaderNameMap?.internalToExternal?.[n]?n:(rw(t,n,r),eC(t.shaderNameMap,t.shaderNameState,n))}function aw(t,n,r){for(let{name:n,arity:i,opCode:a}of sc)i===`binary`&&(Ac.prototype[n]=function(...t){let{id:n,dimension:i}=Rc(r,this,t,a);return q(n,i,r)}),i===`unary`&&(t[n]=function(t){let{id:n,dimension:i}=Pc(r,t,a);return q(n,i,r)});$C(n,t,`discard`,function(){Zc(r,tc.DISCARD)});function i(t){r.loopPhase===`body`&&r.stateScope?.records.length>0&&G(`scope error`,`${t} can't be used inside a for loop body while registered Strands helpers exist in this hook.`)}$C(n,t,`break`,function(t={}){i(`break`),r.activeLoop?.commitCarriedValues(t),Zc(r,tc.BREAK)}),t.break=n.break,$C(n,t,`instanceID`,function(){let t=Nc(r,{baseType:V.INT,dimension:1},r.backend.instanceIdReference());return q(t.id,t.dimension,r)}),t.strandsIf=function(t,n){return new HC(r,t,n)},$C(n,t,`strandsIf`,t.strandsIf),t.strandsFor=function(t,n,i,a,o){return new WC(r,t,n,i,a,o).build()},$C(n,t,`strandsFor`,t.strandsFor),t.strandsTernary=function(t,n,i){return GC(r,t,n,i)},$C(n,t,`strandsTernary`,t.strandsTernary),t.strandsOperand=function(t,n){let i=r.expressionOperand;r.expressionOperand=t;try{return n()}finally{r.expressionOperand=i}};function a(t){let n=r.expressionOperand;n&&G(`scope error`,`${t} can't be used inside ${n===`?:`?`a branch of a ?: expression`:`an operand of ${n}`}. Use it in its own statement before the expression.`)}t.strandsEarlyReturn=function(n){let{dag:a,cfg:o}=r;if(!r.activeHook)throw Error(`strandsEarlyReturn can only be used inside a hook callback`);i(`An early return`);let s=n?.isStrandsNode?n:t.strandsNode(n),c=Ec(o,fc.DEFAULT);Dc(o,o.currentBlock,c),Cc(o,c);let l=K(a,gc({nodeType:B.STATEMENT,statementType:tc.EARLY_RETURN,dependsOn:n===void 0?[]:[s.id]}));return Oc(o,o.currentBlock,l),r.activeHook.earlyReturns.push({earlyReturnID:l,valueNode:s}),wc(o),s},$C(n,t,`strandsEarlyReturn`,t.strandsEarlyReturn),t.strandsNode=function(...t){if(t.length===1&&t[0]instanceof Ac)return t[0];t.length>4&&G(`type error`,`It looks like you've tried to construct a p5.strands node implicitly, with more than 4 components. This is currently not supported.`);let n=t.flat().filter(t=>t!=null);if(n.length===0){let{id:t,dimension:n}=qc(r,{baseType:V.ASSIGN_ON_USE,dimension:null},[0]);return q(t,n,r)}let{id:i,dimension:a}=qc(r,{baseType:V.FLOAT,dimension:null},n);return q(i,a,r)},t.registerStrandsState=function(t,i){typeof t!=`string`&&G(`type error`,`registerStrandsState expects a string name.`);let o=t=>typeof t==`object`&&!!t&&!Array.isArray(t);(!o(i)||typeof i.init!=`function`)&&G(`type error`,`registerStrandsState expects an object with an init function.`);for(let t of[`update`,`read`]){let n=i[t];o(n)||G(`type error`,`registerStrandsState expects ${t} to be an object of functions.`);for(let[r,i]of Object.entries(n))typeof i!=`function`&&G(`type error`,`registerStrandsState ${t}.${r} must be a function.`)}for(let t of Object.keys(i.update))Object.prototype.hasOwnProperty.call(i.read,t)&&G(`type error`,`registerStrandsState cannot use "${t}" in both update and read.`);for(let t of[`update`,`read`]){Object.prototype.hasOwnProperty.call(i[t],`_installGlobal`)&&G(`type error`,`registerStrandsState reserves "_installGlobal" for every helper, so it cannot be a method name.`);for(let n of[`push`,`pop`])Object.prototype.hasOwnProperty.call(i[t],n)&&G(`type error`,`registerStrandsState reserves "${n}" for saving and restoring helper state, so it cannot be a method name.`);Object.prototype.hasOwnProperty.call(i[t],`set`)&&G(`type error`,`registerStrandsState reserves "set" because p5.strands treats .set() inside if and for as a hook setter, so it cannot be a method name.`)}let s=(t,n)=>[V.FLOAT,V.INT,V.BOOL].includes(t)?[1,2,3,4].includes(n):t===V.MAT&&[2,3,4].includes(n);function c(n,i){let a=o(n)?{scoped:n.scoped,global:n.global}:null;(!a||!o(a.scoped)||!o(a.global))&&G(`type error`,`${t} state must have scoped and global objects of fields.`);let c=[`scoped`,`global`].flatMap(t=>Object.entries(a[t]).map(([n,r])=>({group:t,field:n,value:r})));return c.length===0&&G(`type error`,`${t} state needs at least one scoped or global field.`),c.map(({group:n,field:a,value:o})=>{(!(o instanceof Ac)||o.strandsContext!==r)&&G(`type error`,`${t}.${n}.${a} must be a Strands node from this context.`);let{baseType:l,dimension:u}=vc(r.dag,o.id);s(l,u)||G(`type error`,`${t}.${n}.${a} must be a float, int or bool scalar or vector, or a mat2, mat3 or mat4.`);let d=i?.find(t=>t.group===n&&t.name===a);return i&&(!d||c.length!==i.length||l!==d.baseType||u!==d.dimension)&&G(`type error`,`${t} updates must return the same fields as init, with the same types and sizes.`),{group:n,name:a,baseType:l,dimension:u,valueId:o.id}})}let l=i.init,u=Object.entries(i.update),d=Object.entries(i.read);return function(...i){let s=r.stateScope;(!r.active||!s)&&G(`scope error`,`${t} must be created inside an active Strands hook.`),r.conditionalDepth>0&&G(`scope error`,`${t} must be created before an if/else, not inside one of its branches.`),r.loopPhase&&G(`scope error`,`${t} must be created before a for loop, not inside it.`),a(t);let f=this,p=l.call(f,...i);o(p)||G(`type error`,`${t} init must return an object containing config and state.`);let m={scope:s,config:p.config,slots:c(p.state)},h=Object.create(null);function g(){(!r.active||m.scope!==r.stateScope)&&G(`scope error`,`${t} helper must be used in the hook invocation that created it.`),r.loopPhase===`header`&&G(`scope error`,`${t} helper can only be used in a for loop's body, not its initializer, condition or update.`)}function _(){let t={scoped:Object.create(null),global:Object.create(null)};for(let n of m.slots)t[n.group][n.name]=q(n.valueId,n.dimension,r);return t}for(let[n,r]of u)h[n]=function(...n){g(),a(`${t} helper`);let i=c(r.call(f,_(),m.config,...n),m.slots);for(let t of m.slots)t.valueId=i.find(n=>n.group===t.group&&n.name===t.name).valueId;return h};for(let[t,n]of d)h[t]=function(...t){return g(),n.call(f,_(),m.config,...t)};return h._installGlobal=function(){g(),(r.conditionalDepth>0||r.loopPhase)&&G(`scope error`,`${t} helper's methods must be installed before an if/else or for loop, not inside one.`),a(`${t} helper`);for(let[t]of[...u,...d])ew(n,r,t,h[t]);return h},s.records.push(m),h}};function o(t){let n=r.stateScope;return(!r.active||!n)&&G(`scope error`,`${t}() must be called inside an active Strands hook.`),r.loopPhase===`header`&&G(`scope error`,`${t}() can only be used in a for loop's body, not its initializer, condition or update.`),a(`${t}()`),n}let s=n.push;$C(n,t,`push`,function(...t){if(!r.active)return s.apply(this,t);let n=o(`push`),i=/* @__PURE__ */ new Map;for(let t of n.records)for(let n of t.slots)n.group===`scoped`&&i.set(n,n.valueId);n.stack.push(i)});let c=n.pop;$C(n,t,`pop`,function(...t){if(!r.active)return c.apply(this,t);let n=o(`pop`);n.stack.length===0&&G(`scope error`,`pop() has no matching push().`),n.stack.length<=n.stackFloor&&G(`scope error`,`pop() can't pop a push() made outside the current if/else branch or for loop body.`);for(let[t,r]of n.stack.pop())t.valueId=r});for(let[i,a]of Object.entries(jc))if(a[0].isp5Function){let a=n[i];$C(n,t,i,function(...t){if(r.active){let{id:n,dimension:a}=Xc(r,i,t);return q(n,a,r)}return a.apply(this,t)})}else $C(n,t,i,function(...n){if(r.active){let{id:t,dimension:a}=Xc(r,i,n);return q(t,a,r)}t.FES.log`It looks like you've called ${i} outside of a shader's modify() function.`()});let l=n.lerp;$C(n,t,`lerp`,function(...t){return r.active?this.mix(...t):l.apply(this,t)});let u=n.map;$C(n,t,`map`,function(...n){if(!r.active)return u.apply(this,n);let[i,a,o,s,c,l]=n,d=t.strandsNode(i),f=t.strandsNode(a),p=t.strandsNode(o),m=d.sub(f).div(p.sub(f)),h=this.mix(s,c,m);return l?this.clamp(h,this.min(s,c),this.max(s,c)):h});let d=n.color;$C(n,t,`color`,function(...t){if(!r.active)return d.apply(this,t);let n=d.apply(this,t)._getRGBA(),{id:i,dimension:a}=qc(r,{baseType:V.FLOAT,dimension:null},n);return q(i,a,r)});let f=n.lerpColor;$C(n,t,`lerpColor`,function(...t){return r.active?this.mix(...t):f.apply(this,t)});let p=n.red;$C(n,t,`red`,function(...n){return r.active?t.strandsNode(n[0]).x:p.apply(this,n)});let m=n.green;$C(n,t,`green`,function(...n){return r.active?t.strandsNode(n[0]).y:m.apply(this,n)});let h=n.blue;$C(n,t,`blue`,function(...n){return r.active?t.strandsNode(n[0]).z:h.apply(this,n)});let g=n.alpha;$C(n,t,`alpha`,function(...n){return r.active?t.strandsNode(n[0]).w:g.apply(this,n)});let _=(n,r)=>{let i=r.x,a=r.y,o=r.z,s=n.vec4(0,-1/3,2/3,-1),c=n.mix(n.vec4(o,a,s.w,s.z),n.vec4(a,o,s.x,s.y),n.step(o,a)),l=n.mix(n.vec4(c.x,c.y,c.w,i),n.vec4(i,c.y,c.z,c.x),n.step(c.x,i)),u=l.x.sub(n.min(l.w,l.y)),d=t.strandsNode(1e-10),f=n.abs(l.z.add(l.w.sub(l.y).div(u.mult(6).add(d)))),p=u.div(l.x.add(d));return n.vec3(f,p,l.x)},v=(n,r)=>{let i=r.x,a=r.y,o=r.z,s=n.max(i,n.max(a,o)),c=n.min(i,n.min(a,o)),l=s.add(c).div(2),u=s.sub(c),d=t.strandsNode(1e-10),f=n.mix(t.strandsNode(0),u.div(t.strandsNode(1).sub(n.abs(l.mult(2).sub(1)))),n.step(d,u)),p=n.mod(a.sub(o).div(u.add(d)),t.strandsNode(6)).div(6),m=o.sub(i).div(u.add(d)).add(2).div(6),h=i.sub(a).div(u.add(d)).add(4).div(6),g=n.step(s.sub(d),i).mult(n.step(i.sub(d),s)),_=n.step(s.sub(d),a).mult(n.step(a.sub(d),s)),v=n.mix(n.mix(h,m,_),p,g);return n.vec3(v,f,l)},y=n.hue;$C(n,t,`hue`,function(...n){if(!r.active)return y.apply(this,n);let i=t.strandsNode(n[0]);return v(this,this.vec3(i.x,i.y,i.z)).x});let b=n.saturation;$C(n,t,`saturation`,function(...n){if(!r.active)return b.apply(this,n);let i=t.strandsNode(n[0]);return v(this,this.vec3(i.x,i.y,i.z)).y});let x=n.brightness;$C(n,t,`brightness`,function(...n){if(!r.active)return x.apply(this,n);let i=t.strandsNode(n[0]);return _(this,this.vec3(i.x,i.y,i.z)).z});let S=n.lightness;$C(n,t,`lightness`,function(...n){if(!r.active)return S.apply(this,n);let i=t.strandsNode(n[0]);return v(this,this.vec3(i.x,i.y,i.z)).z}),$C(n,t,`getTexture`,function(...n){if(r.active){let{id:t,dimension:i}=r.backend.createGetTextureCall(r,n);return q(t,i,r)}t.FES.log`It looks like you've called getTexture outside of a shader's modify() function.`()});let C=n.texture;$C(n,t,`texture`,function(...t){return r.active?this.getTexture(...t):C.apply(this,t)});let w=n.noise,T=n.noiseDetail,E=n.random,D=n.randomGaussian,O=n.randomSeed,k=n.millis;$C(n,t,`noiseDetail`,function(t,n=.5){if(!r.active)return T.apply(this,arguments);r._noiseOctaves=t,r._noiseAmpFalloff=n}),$C(n,t,`noise`,function(...i){if(!r.active)return w.apply(this,i);let a=r.backend.getNoiseShaderSnippet();r.vertexDeclarations.add(a),r.fragmentDeclarations.add(a),r.computeDeclarations.add(a);let o=i.flat().map(n=>t.strandsNode(n)),s;o.length===3?s=[n.vec3(o[0],o[1],o[2])]:o.length===2?s=[n.vec3(o[0],o[1],0)]:o.length===1&&o[0].dimension<=3?s=o[0].dimension===3?o:o[0].dimension===2?[n.vec3(o[0],0)]:[n.vec3(o[0],0,0)]:t.FES.log`It looks like you've called noise() with ${i.length} arguments. It only supports 1D to 3D input.`();let c=r._noiseOctaves===null?n._getNoiseOctaves():r._noiseOctaves,l=r._noiseAmpFalloff===null?n._getNoiseAmpFalloff():r._noiseAmpFalloff;s.push(c),s.push(l);let{id:u,dimension:d}=Xc(r,`noise`,s,{overloads:[{params:[H.float3,H.int1,H.float1],returnType:H.float1}]});return q(u,d,r)});let A=n.paletteLerp;$C(n,t,`paletteLerp`,function(i,a){if(!r.active)return A.apply(this,arguments);if(!Array.isArray(i))throw Error(`paletteLerp() first argument must be an array literal: [[color(...), pos], ...]`);let o=i.length;if(o<2||o>8)throw Error(`paletteLerp() requires 2–8 color stops, got ${o}.`);for(let t=0;t<o;t++)if(!Array.isArray(i[t])||i[t].length!==2)throw Error(`paletteLerp() stop ${t} must be a 2-element array: [color(...), position]`);let s=i.map(([n])=>t.strandsNode(n)),c=i.map(([,n])=>t.strandsNode(n)),l=t.strandsNode(a);function u(i,a,o,s){let c=t.strandsNode(0),u=t.strandsNode(1),d=l.sub(o),f=s.sub(o),p=n.clamp(d.div(f),c,u);return GC(r,o.equalTo(s),n.mix(i,a,t.strandsNode(.5)),n.mix(i,a,p))}let d=s[o-1];for(let t=o-2;t>=0;t--){let n=u(s[t],s[t+1],c[t],c[t+1]);d=GC(r,l.lessThan(c[t+1]),n,d)}return d=GC(r,l.greaterEqual(c[o-1]),s[o-1],d),d=GC(r,l.lessEqual(c[0]),s[0],d),d}),n.paletteLerp.argTypes=[{type:`Array`,subtype:{type:`Array`,subtype:`any`}},{type:`Number`}],$C(n,t,`randomSeed`,function(t){if(!r.active)return O.apply(this,arguments);r._randomSeed=t}),$C(n,t,`random`,function(...n){if(!r.active)return E.apply(this,n);let i=r.backend.getRandomVertexShaderSnippet(),a=r.backend.getRandomFragmentShaderSnippet();if(r.vertexDeclarations.add(i),r.fragmentDeclarations.add(a),r.backend.getRandomComputeShaderSnippet){let t=r.backend.getRandomComputeShaderSnippet();r.computeDeclarations.add(t)}let o;if(r._randomSeed!==null&&r._randomSeed.isStrandsNode)o=r._randomSeed;else{let t=r._randomSeed;o=YC(r,`_p5_randomSeed`,H.float1,t===null?()=>performance.now():()=>t)}let s=[o],c=[{params:[H.float1],returnType:H.float1}];if(n.length===0){let{id:t,dimension:n}=Xc(r,`random`,s,{overloads:c});return q(t,n,r)}if(n.length===1){let i=Xc(r,`random`,s,{overloads:c});return q(i.id,i.dimension,r).mult(t.strandsNode(n[0]))}if(n.length===2){let i=Xc(r,`random`,s,{overloads:c}),a=q(i.id,i.dimension,r),o=t.strandsNode(n[0]),l=t.strandsNode(n[1]);return a.mult(l.sub(o)).add(o)}t.FES.log`It looks like you've called random() with ${n.length} arguments. In strands, random() supports 0, 1, or 2 numeric arguments.`()}),$C(n,t,`randomGaussian`,function(...t){if(!r.active)return D.apply(this,t);let n=t.length>=1?t[0]:0,i=t.length>=2?t[1]:1,a=this.max(this.random(),1e-6),o=this.random();return this.sqrt(this.log(a).mult(-2)).mult(this.cos(o.mult(2*Math.PI))).mult(i).add(n)}),$C(n,t,`millis`,function(...t){if(!r.active)return k.apply(this,t);let n=r.renderer?._pInst||r.p5?.instance;return YC(r,`_p5_global_millis`,H.float1,()=>n?n.millis():void 0)});for(let i in H){if(i===V.DEFER||i===V.ASSIGN_ON_USE||i===`sampler`)continue;let a=H[i],o=[],s;/^[ib]vec/.test(a.fnName)?(s=a.fnName.slice(0,2).toUpperCase()+a.fnName.slice(2).toLowerCase(),o.push(s.replace(`Vec`,`Vector`))):(s=a.fnName.charAt(0).toUpperCase()+a.fnName.slice(1),s===`Sampler2D`?o.push(`Texture`):/^vec/.test(a.fnName)?o.push(s.replace(`Vec`,`Vector`)):/^mat\dx\d$/.test(a.fnName)&&o.push(s.slice(0,4))),$C(n,t,`uniform${s}`,function(t,n){let i=iw(r,t,`uniform${s}`),{id:o,dimension:c}=Nc(r,a,i);return r.uniforms.push({name:i,typeInfo:a,defaultValue:n}),q(o,c,r)}),$C(n,t,`shared${s}`,function(t){let n=iw(r,t,`shared${s}`),{id:i,dimension:o}=Nc(r,a,n);return r.sharedVariables.set(n,{typeInfo:a,usedInVertex:!1,usedInFragment:!1}),q(i,o,r)}),$C(n,t,`varying${s}`,n[`shared${s}`]);for(let r of o)$C(n,t,`uniform${r}`,n[`uniform${s}`]),$C(n,t,`varying${r}`,n[`varying${s}`]),$C(n,t,`shared${r}`,n[`shared${s}`]);let c=n[a.fnName];$C(n,t,a.fnName,function(...n){if(r.active){if(n.length===1&&n[0].dimension&&n[0].dimension===a.dimension){let{id:t,dimension:i}=Xc(r,r.backend.getTypeName(a.baseType,a.dimension),n,{overloads:[{params:[n[0].typeInfo()],returnType:a}]});return q(t,i,r)}{a.dimension>1&&n.length===1&&!Array.isArray(n[0])&&!(n[0]instanceof Ac&&n[0].dimension>1)&&(a.baseType===V.FLOAT||a.baseType===V.INT||a.baseType===V.BOOL)&&(n=Array(a.dimension).fill(n[0]));let{id:t,dimension:i}=qc(r,a,n);return q(t,i,r)}}if(c)return c.apply(this,n);t.FES.log`It looks like you've called ${a.fnName} outside of a shader's modify() function.`()})}KC(t,n,r,$C);function j(t,n,r,i){let{dag:a,cfg:o}=i;t.push=function(t){let s;if(r){let o=`${n}Element`,c=r.fields.map(n=>{let r=t&&typeof t==`object`&&!t.isStrandsNode?t[n.name]:t;if(r?.isStrandsNode)return r.id;let{id:a}=qc(i,{baseType:n.baseType,dimension:n.dim},r);return a}),l=gc({nodeType:B.OPERATION,opCode:W.Nary.FUNCTION_CALL,identifier:o,dependsOn:c,baseType:V.FLOAT,dimension:1});s=K(a,l)}else{let n=t;if(n?.isStrandsNode)s=_c(a,n.id).baseType===V.FLOAT?n.id:Jc(i,n).id;else{let{id:t}=qc(i,{baseType:V.FLOAT,dimension:1},n);s=t}}let c=gc({nodeType:B.OPERATION,opCode:W.Nary.FUNCTION_CALL,identifier:`_p5_push_${n}`,dependsOn:[s],baseType:V.FLOAT,dimension:1}),l=K(a,c),u=gc({nodeType:B.STATEMENT,statementType:tc.EXPRESSION,dependsOn:[l],phiBlocks:[]});Oc(o,o.currentBlock,K(a,u))},t.pop=function(){let t=gc({nodeType:B.OPERATION,opCode:W.Nary.FUNCTION_CALL,identifier:`_p5_pop_${n}`,dependsOn:[],baseType:V.FLOAT,dimension:1}),r=K(a,t);return Oc(o,o.currentBlock,r),q(r,1,i)},Object.defineProperty(t,"length",{get(){let t=gc({nodeType:B.OPERATION,opCode:W.Nary.FUNCTION_CALL,identifier:`_p5_length_${n}`,dependsOn:[],baseType:V.INT,dimension:1}),r=K(a,t);return Oc(o,o.currentBlock,r),q(r,1,i)},configurable:!0})}n.uniformStorage=function(t,n){let i=iw(r,t,`uniformStorage`),a=null,o=null,s=!1,c=0,l=n;typeof n==`function`&&(l=n(),l?._schema&&(o=n)),l?._isStorageList?(s=!0,c=l.maxCapacity,a=l._schema,o===null&&(o=l)):l?._schema?(a=l._schema,o===null&&(o=l)):l&&typeof l==`object`&&!l._isStorageBuffer?a=r.renderer?._inferStructSchema(l)??null:l?._isStorageBuffer&&(o=n);let{id:u,dimension:d}=Nc(r,{baseType:`storage`,dimension:1},i);r.uniforms.push({name:i,typeInfo:{baseType:`storage`,dimension:1,schema:a,isStorageList:s,maxCapacity:c},defaultValue:o});let f=q(u,d,r);return f._originalIdentifier=i,f._originalBaseType=`storage`,f._originalDimension=1,f._schema=a,s&&j(f,i,a,r),f}}function ow(t,n){let r=[],i=t.dag;for(let a of n)if(ic(a.type)){let n=rc(a),{id:o,dimension:s}=zc(t,n,`${Qs}${a.name}`,[]),c=q(o,s,t).withStructProperties(n.properties.map(t=>t.name));for(let r=0;r<n.properties.length;r++){let o=n.properties[r];Object.defineProperty(c,o.name,{get(){let o=_c(i,i.dependsOn[c.id][r]);return q(o.id,o.dimension,t,o=>{let s=i.dependsOn[c.id].slice();s[r]=o;let l=zc(t,n,`${Qs}${a.name}`,s);c.id=l.id})},set(s){let l=s?.isStrandsNode?s.dimension:Array.isArray(s)?s.length:1;l!==o.dataType.dimension&&l!==1&&mc(o.dataType.dimension,l,`${a.name}.${o.name}`);let u=[...i.dependsOn[c.id]],d;d=s?.isStrandsNode?s.id:qc(t,o.dataType,s).id,u[r]=d;let f=zc(t,n,`${Qs}${a.name}`,u);c.id=f.id}})}r.push(c)}else{if(a.type.typeName===`sampler`)continue;if(!a.type.dataType)throw Error(`Missing dataType for parameter ${a.name} of type ${a.type.typeName}`);let n=a.type.dataType,{id:i,dimension:o}=Nc(t,n,`${Qs}${a.name}`),s=q(i,o,t);r.push(s)}return r}function sw(t,n,r,i){if(!r?.isStrandsNode)return qc(t,n,r).id;let a=t.dag,o=r.id,s={baseType:a.baseTypes[o],dimension:a.dimensions[o]};return s.dimension===n.dimension?s.baseType!==n.baseType&&(o=qc(t,n,r).id):s.dimension===1?o=qc(t,n,r).id:G(`type error`,`You have returned a ${s.baseType+(s.dimension>1?s.dimension:``)} in ${i} when a ${n.baseType+n.dimension} was expected!\n\nMake sure your hook returns the correct type.`),o}function cw(t,n,r){ZC(t);let i=([t])=>t!==`declarations`;QC(t);let a=Object.fromEntries(Object.entries(r.hooks.vertex).filter(i).map(([t,n])=>[t,{...n,shaderContext:`vertex`}])),o=Object.fromEntries(Object.entries(r.hooks.fragment).filter(i).map(([t,n])=>[t,{...n,shaderContext:`fragment`}])),s=Object.fromEntries(Object.entries(r.hooks.compute).filter(i).map(([t,n])=>[t,{...n,shaderContext:`compute`}])),c={...a,...o,...s},l=Object.keys(c).map(t=>r.hookTypes(t)),{cfg:u,dag:d}=t;for(let r of l){let i=function(t){let n=l();try{i._result=t(...n)??i._result}catch(t){throw f(t),t}p()};i.set=function(t){i._active||G(`scope error`,`It looks like you're trying to call ${i._publicName}.set() outside of its begin()/end() block.`),i._result=t},i._active=!1;let a=r.parameters.filter(t=>t.type&&t.type.properties).length,o=-1;if(a===1&&(o=r.parameters.findIndex(t=>t.type&&t.type.properties)),o>=0){let t=r.parameters[o];if(t.type.properties){let n=/^get([A-Z0-9]\w*)$/.exec(r.name),a=n?n[1][0].toLowerCase()+n[1].slice(1):r.name;for(let n of t.type.properties){let t=n.name;Object.defineProperty(i,t,{get(){return this._active||G(`scope error`,`It looks like you're trying to access "${a}.${t}" outside of its begin()/end() block.\n\nProperties of ${a} are only available between ${a}.begin() and ${a}.end().\n\nTo share data between hooks, use sharedVec3() or sharedFloat() to pass values between them.`),this._args[this._argIdx][t]},set(n){this._active||G(`scope error`,`It looks like you're trying to set "${a}.${t}" outside of its begin()/end() block.`),this._args[this._argIdx][t]=n},enumerable:!0})}}}let s;function l(){try{t.activeHook=i,t.stateScope={records:[],stack:[],stackFloor:0},s=Ec(u,fc.FUNCTION),Dc(u,u.currentBlock,s),Cc(u,s);let n=ow(t,r.parameters);i._active=!0,i._args=n,i._argIdx=o,i._properties=[];for(let t=0;t<n.length;t++)if(t===o){for(let t of n[o].structProperties||[])i._properties.push(t);r.returnType?.typeName===r.parameters[o].type.typeName&&i.set(n[o])}else i._properties.push(r.parameters[t].name),i[r.parameters[t].name]=n[t];return n}catch(t){throw f(t),t}}function f(n){i._active=!1,t.activeHook=void 0,t.stateScope=null,t.failedHook===null&&(t.failedHook={hookName:r.name,thrown:n})}function p(){let n=t.stateScope?.stack.length>0;i._active=!1;let a=i._result;t.activeHook=void 0,t.stateScope=null;let o=r.returnType,l=ic(o)||o.dataType&&o.typeName?.trim()!==`void`,p=null,m=n=>{if(ic(o)){let i=rc(o);if(n?.isStrandsNode){let a=_c(t.dag,n.id);if(a.baseType!==i.typeName){let t=a.baseType||`undefined`,o=d.dimensions[n.id],s=o>1?`${t}${o}`:t,c=i.properties.map(t=>t.name).join(`, `);G(`type error`,`You have returned a ${s} from ${r.name} when a ${i.typeName} was expected.\n\nThe ${i.typeName} struct has these properties: { ${c} }\n\nInstead of returning a different type, you should modify and return the ${i.typeName} struct that was passed to your hook.\n\nFor example:\n${r.name}((inputs) => {\n  // Modify properties of inputs\n  inputs.someProperty = ...;\n  return inputs; // Return the modified struct\n})`)}let o=a.dependsOn.slice();for(let s=0;s<i.properties.length;s++){let c=i.properties[s].dataType,l=q(a.dependsOn[s],d.dependsOn[n.id],t);o[s]=sw(t,c,l,r.name)}return d.dependsOn[n.id]=o,n.id}{let a=i.properties,s=[];for(let c=0;c<a.length;c++){let l=a[c],u=n[l.name];if(u===void 0){let t=o.properties.map(t=>t.name).join(`, `),a=Object.keys(n).join(`, `);G(`type error`,`You've returned an incomplete ${i.typeName} struct from ${r.name}.\n\nExpected properties: { ${t} }\nReceived properties: { ${a} }\n\nAll properties are required! Make sure to include all properties in the returned struct.`)}let d=l.dataType,f=sw(t,d,u,r.name);s.push(f)}return Yc(t,i,s).id}}if(!o.dataType||o.typeName?.trim()===`void`)return null;{let i=o.dataType;return sw(t,i,n,r.name)}};try{n&&G(`scope error`,`push() needs a matching pop() before the hook ends.`),l&&a===void 0&&i.earlyReturns.length===0&&G(`scope error`,`${i._publicName} requires a value. Make sure to call ${i._publicName}.set(value) before ${i._publicName}.end().`);for(let{valueNode:t,earlyReturnID:n}of i.earlyReturns){let r=m(t);r===null?d.dependsOn[n]=[]:d.dependsOn[n]=[r]}p=a?m(a):void 0;let o=`${r.returnType.typeName} ${r.name}`,f=c[o];t.hooks.push({hookType:r,entryBlockID:s,rootNodeID:p,shaderContext:f?.shaderContext}),wc(u)}catch(t){throw f(t),t}}i.begin=l,i.end=p;let m=[r.name];t.baseShader?.hooks?.hookAliases?.[r.name]&&m.push(...t.baseShader.hooks.hookAliases[r.name]);let h=/^get([A-Z0-9]\w*)$/.exec(r.name);if(h){let t=h[1][0].toLowerCase()+h[1].slice(1);n[t]||m.push(t)}for(let r of m)ew(n,t,r,i);i._publicName=m[1]??r.name,i.earlyReturns=[]}}function lw(t,n){n._runStrandsInGlobalMode=!1;function r(n){n.p5=t,n._builtinGlobalsAccessorsInstalled=!1,o(n)}function i(t){return{dag:t,nodes:/* @__PURE__ */ new Map,uniformsAdded:/* @__PURE__ */ new Set}}function a(n,r,{active:a=!1,renderer:o=null,baseShader:s=null}={}){n.dag=hc(),n.cfg=Sc(),n.uniforms=[],n.shaderNameMap=XS(),n.shaderNameState=ZS(),n.vertexDeclarations=/* @__PURE__ */ new Set,n.fragmentDeclarations=/* @__PURE__ */ new Set,n.computeDeclarations=/* @__PURE__ */ new Set,n.hooks=[],n.backend=r,n.active=a,n.renderer=o,n.baseShader=s,n.previousFES=t.disableFriendlyErrors,n.tempProps=[],n._noiseOctaves=null,n._noiseAmpFalloff=null,n._randomSeed=null,n._builtinGlobals=i(n.dag),n.sharedVariables=/* @__PURE__ */ new Map,n.activeHook=void 0,n.stateScope=null,n.failedHook=null,n.conditionalDepth=0,n.loopPhase=null,n.activeLoop=null,n.expressionOperand=null,n._instanceIDUsedInFragment=!1,n.experimentalFeaturesUsed=/* @__PURE__ */ new Set,a&&(t.disableFriendlyErrors=!0)}function o(n){n.dag=hc(),n.cfg=Sc(),n.uniforms=[],n.shaderNameMap=XS(),n.shaderNameState=ZS(),n.vertexDeclarations=/* @__PURE__ */ new Set,n.fragmentDeclarations=/* @__PURE__ */ new Set,n.computeDeclarations=/* @__PURE__ */ new Set,n.hooks=[],n.backend=void 0,n.active=!1,n.renderer=null,n.baseShader=null,n.previousFES=t.disableFriendlyErrors,n.tempProps=[],n._noiseOctaves=null,n._noiseAmpFalloff=null,n._randomSeed=null,n._builtinGlobals=i(n.dag),n.sharedVariables=/* @__PURE__ */ new Map,n.activeHook=void 0,n.stateScope=null,n.failedHook=null,n.conditionalDepth=0,n.loopPhase=null,n.activeLoop=null,n.expressionOperand=null,n._instanceIDUsedInFragment=!1,n.experimentalFeaturesUsed=/* @__PURE__ */ new Set}function s(n){t.disableFriendlyErrors=n.previousFES;let r=nw(n);return o(n),r}let c={};r(c),aw(t,n,c);function l(t,r){if(t._isGlobal)return r();let i={};for(let r of Object.getOwnPropertyNames(n)){let a=Object.getOwnPropertyDescriptor(n,r);a&&!a.get&&typeof n[r]==`function`&&(i[r]=window[r],window[r]=n[r].bind(t))}try{r()}finally{for(let t in i)window[t]=i[t]}}let u=t.Shader.prototype.modify;t.Shader.prototype.modify=function(r,i={},o={}){c.active&&G(`scope error`,`modify() can't be called while a p5.strands shader is being built.`);let d,f=[];try{if(r instanceof Function||typeof r==`string`){a(c,this._renderer.strandsBackend,{active:!0,renderer:this._renderer,baseShader:this}),cw(c,n,this),o.parser=!0,o.srcLocations=!1;let s;if(o.parser){let n=zC(t,typeof r==`string`?`(${r})`:`(${r.toString()})`,o.srcLocations,i,this.hooks.shaderNameState);s=n.callback,c.shaderNameMap=n.shaderNameMap,c.shaderNameState=n.shaderNameState}else s=r;let f=Ec(c.cfg,fc.GLOBAL);if(Cc(c.cfg,f),o.hook){c.renderer._pInst[o.hook].begin();for(let r of c.renderer._pInst[o.hook]._properties){let i=c.renderer._pInst[o.hook][r];tw(c,n,r,i),tw(c,window,r,i),tw(c,t.Graphics.prototype,r,i)}if(o.globalInstance!==void 0){let t=typeof o.globalInstance==`function`?o.globalInstance.call(c.renderer._pInst):void 0;typeof t?._installGlobal!=`function`&&G(`type error`,`options.globalInstance must be a function that returns a helper made by a registerStrandsState() factory.`),t._installGlobal()}}else o.globalInstance!==void 0&&G(`type error`,`options.globalInstance needs options.hook, the hook its shared instance is created in.`);if(c.renderer?._pInst?._runStrandsInGlobalMode?l(c.renderer._pInst,s):s(),c.failedHook!==null)throw c.failedHook.thrown;o.hook&&c.renderer._pInst[o.hook].end(),c.activeHook&&G(`scope error`,`It looks like ${c.activeHook._publicName}.begin() was called without a matching ${c.activeHook._publicName}.end().`),wc(c.cfg);let p=BC(c);d=u.call(this,p)}else d=u.call(this,r)}finally{let n=[...c.experimentalFeaturesUsed];f=s(c);for(let r of n)us(t,this._renderer?._pInst,r)}if(f.length>0)throw f[0];return d}}typeof p5<`u`&&p5.registerAddon(lw);var uw=class{constructor(){this.children=[]}add(t){this.children.push(t)}},dw=class extends uw{constructor(){super(),this.type=`scope`}toSVGElement(t){t.visitScope(this)}},fw=class extends uw{constructor(t,n){super(),this.type=`shape`,this.shape=t,this.state=n}toSVGElement(t){t.currentState=this.state,t.currentPathElement=null,this.shape.accept(t),t.currentPathElement=null}},pw=class extends uw{constructor(t){super(),this.type=`background`,this.color=t}toSVGElement(t){t.addBackground(this)}},mw=class extends uw{constructor(){super(),this.type=`clear`}toSVGElement(t){t.clear()}},hw=class extends uw{constructor(t,n,r){super(),this.type=`image`,this.img=t,this.args=n,this.state=r}toSVGElement(t){t.currentState=this.state,t.visitImage(this)}},gw=class{constructor(){this.stack=[new DOMMatrix]}push(){this.stack.push(new DOMMatrix(this.current))}pop(){this.stack.length>1&&this.stack.pop()}translate(t,n){this.current.translateSelf(t,n)}rotate(t){this.current.rotateSelf(t*180/Math.PI)}scale(t,n){this.current.scaleSelf(t,n===void 0?t:n)}get current(){return this.stack[this.stack.length-1]}},_w=class{constructor(t,n={}){this.p5=t,this.active=!1,this.draw=n.draw??!1,this.root=new dw,this.scopeStack=[this.root],this.tStack=new gw,this.restores=[],this._isTransforming=!1}start(){this.active=!0,this.root=new dw,this.scopeStack=[this.root],this.restores=[],this._interceptTransforms();let t=this.p5._renderer,n=this.p5._svgCaptureAdapters();if(t)for(let r in n){let i=n[r].intercept(t,this);i&&this.restores.push(i)}}stop(){this.active=!1;for(let t of this.restores)t();this.restores=[]}addNode(t){this.scopeStack[this.scopeStack.length-1].add(t)}enterScope(){let t=new dw;return this.addNode(t),this.scopeStack.push(t),t}leaveScope(){this.scopeStack.length>1&&this.scopeStack.pop()}_interceptTransforms(){let t=this.p5,n=t._renderer,r={push:()=>{this.tStack.push(),this.enterScope()},pop:()=>{this.tStack.pop(),this.leaveScope()},translate:t=>{let n=t[0],r=t[1];typeof n==`object`&&n&&`x`in n&&`y`in n&&(r=n.y,n=n.x),this.tStack.translate(n||0,r||0)},rotate:t=>{this.tStack.rotate(t[0]||0)},scale:t=>{this.tStack.scale(t[0]||1,t[1])},applyMatrix:t=>{let[n,r,i,a,o,s]=t;this.tStack.current.multiplySelf(new DOMMatrix([n,r,i,a,o,s]))},resetMatrix:()=>{let t=this.tStack.stack;t[t.length-1]=new DOMMatrix}};Object.keys(r).forEach(i=>{let a=(t,n,a)=>{if(this._isTransforming)return t.apply(n,a);this._isTransforming=!0;try{return this.active&&r[i](a),t.apply(n,a)}finally{this._isTransforming=!1}},o=t[i];if(typeof o==`function`&&(t[i]=(...n)=>a(o,t,n),this.restores.push(()=>{t[i]=o})),n&&typeof n[i]==`function`){let t=n[i];n[i]=(...r)=>a(t,n,r),this.restores.push(()=>{n[i]=t})}})}getRecord(){return this.root}},vw=class{constructor(t){this.p5=t,this.recorder=void 0,this.data=null}begin(t={}){this.recorder=new _w(this.p5,{draw:t?t.draw??!1:!1}),this.p5.push(),this.recorder.start()}end(){this.recorder?(this.recorder.stop(),this.data=this.recorder.getRecord(),delete this.recorder,this.p5.pop()):console.warn(`end() called without a matching begin().`)}toSVGElement(t){this.data&&this.data.toSVGElement(t)}};function yw(t,n,r){t.ShapeCollection=vw,n.pendingExport=null,r&&(r.predraw=function(){this.pendingExport&&!this.pendingExport.shape&&(this.pendingExport.shape=this.createShape(),this.pendingExport.shape.begin({draw:!0}))},r.postdraw=function(){this.pendingExport&&this.pendingExport.shape&&(this.pendingExport.shape.end(),o(this,this.pendingExport.shape,this.pendingExport.filename),this.pendingExport=null)}),n._svgCaptureAdapters=function(){return{drawShape:{intercept(n,r){let i=n.drawShape;return i?(n.drawShape=function(a){if(!(r.active&&(r.addNode(new fw(a,r.p5._svgCaptureState(r))),t.Shape&&(n._currentShape=new t.Shape(n.getCommonVertexProperties())),!r.draw)))return i.call(n,a)},()=>{n.drawShape=i}):null}},background:{intercept(t,n){let r=t.background;return t.background=(...i)=>{if(n.active){let t=n.p5.color(...i);if(n.addNode(new pw(t)),!n.draw)return}return r.apply(t,i)},()=>{t.background=r}}},clear:{intercept(t,n){let r=t.clear;return r?(t.clear=(...i)=>{if(!(n.active&&(n.addNode(new mw),!n.draw)))return r.apply(t,i)},()=>{t.clear=r}):null}},image:{intercept(t,n){let r=t.image;return r?(t.image=function(i,a,o,s,c,l,u,d,f){if(i&&(i instanceof HTMLImageElement&&!i.elt&&(i.elt=i),i instanceof HTMLCanvasElement&&!i.canvas&&(i.canvas=i)),!(n.active&&(n.addNode(new hw(i,[a,o,s,c,l,u,d,f],n.p5._svgCaptureState(n))),!n.draw)))return r.call(t,i,a,o,s,c,l,u,d,f)},()=>{t.image=r}):null}}}},n._svgCaptureState=function(t){let n=this._renderer.states;return{transform:t?new DOMMatrix(t.tStack.current):new DOMMatrix,fill:n.fillColor,stroke:n.strokeColor,strokeWeight:this._renderer.states.strokeWeight,strokeCap:this._renderer.strokeCap()}};class i extends t.PrimitiveVisitor{constructor(t){super(),this.p5=t,this.width=t.width,this.height=t.height,this.svgElement=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this.svgElement.setAttribute(`width`,this.width),this.svgElement.setAttribute(`height`,this.height),this.svgElement.setAttribute(`viewBox`,`0 0 ${this.width} ${this.height}`),this.svgElement.setAttribute(`xmlns:xlink`,`http://www.w3.org/1999/xlink`),this.currentPathElement=null}_createElement(t,n={}){let r=document.createElementNS(`http://www.w3.org/2000/svg`,t);for(let[t,i]of Object.entries(n))r.setAttribute(t,i);return r}_getDefs(){return this.defsElement||(this.defsElement=this._createElement(`defs`),this.svgElement.insertBefore(this.defsElement,this.svgElement.firstChild)),this.defsElement}colorToSVG(t){if(!t)return this._currentOpacity=1,`none`;let[,,,n]=t._getRGBA([255,255,255,255]);return this._currentOpacity=n/255,t.toString(`#rrggbb`)}_applyStyle(t){let n=this.currentState;if(!n)return;this._currentOpacity=1;let r=this.colorToSVG(n.fill),i=this._currentOpacity;this._currentOpacity=1;let a=this.colorToSVG(n.stroke),o=this._currentOpacity;t.setAttribute(`fill`,r),t.setAttribute(`stroke`,a),i<1&&r!==`none`&&t.setAttribute(`fill-opacity`,i.toFixed(4)),o<1&&a!==`none`&&t.setAttribute(`stroke-opacity`,o.toFixed(4)),n.stroke&&n.strokeWeight!=null&&t.setAttribute(`stroke-width`,n.strokeWeight),n.strokeCap&&t.setAttribute(`stroke-linecap`,n.strokeCap)}_appendShapeElement(t){let n=this.currentState?.transform;if(n&&(n.a!==1||n.b!==0||n.c!==0||n.d!==1||n.e!==0||n.f!==0)){let r=this._createElement(`g`);r.setAttribute(`transform`,`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e} ${n.f})`),r.appendChild(t),this.svgElement.appendChild(r)}else this.svgElement.appendChild(t)}visitScope(t){for(let n of t.children)n.toSVGElement(this)}addBackground(t){this._currentOpacity=1;let n=this.colorToSVG(t.color),r=this._currentOpacity,i=this._createElement(`rect`,{x:0,y:0,width:this.width,height:this.height,fill:n});r<1&&n!==`none`&&i.setAttribute(`fill-opacity`,r.toFixed(4)),this.svgElement.appendChild(i)}clear(){for(;this.svgElement.firstChild;)this.svgElement.removeChild(this.svgElement.firstChild)}visitAnchor(t){let n=t.getEndVertex();if(this.currentPathElement){let t=this.currentPathElement.getAttribute(`d`);this.currentPathElement.setAttribute(`d`,`${t} M ${n.position.x} ${n.position.y}`)}else{let t=this._createElement(`path`,{d:`M ${n.position.x} ${n.position.y}`});this._applyStyle(t),this._appendShapeElement(t),this.currentPathElement=t}}visitLineSegment(t){if(!this.currentPathElement)return;let n=this.currentPathElement.getAttribute(`d`)||``;if(t.isClosing)n+=` Z`;else{let r=t.vertices;if(r&&r.length>0){let t=r.length;for(let i=0;i<t;i++){let t=r[i],a=t.position||t;n+=` L ${a.x} ${a.y}`}}else if(typeof t.getEndVertex==`function`){let r=t.getEndVertex();if(r){let t=r.position||r;n+=` L ${t.x} ${t.y}`}}}this.currentPathElement.setAttribute(`d`,n)}visitBezierSegment(t){if(!this.currentPathElement)return;let n=this.currentPathElement.getAttribute(`d`)||``,[r,i,a]=t.vertices;if(t.order===2){let t=r?.position||{x:0,y:0},a=i?.position||t;n+=` Q ${t.x} ${t.y} ${a.x} ${a.y}`}else if(t.order===3){let t=r?.position||{x:0,y:0},o=i?.position||t,s=a?.position||o;n+=` C ${t.x} ${t.y} ${o.x} ${o.y} ${s.x} ${s.y}`}this.currentPathElement.setAttribute(`d`,n)}visitSplineSegment(t){if(!this.currentPathElement)return;let n=t._shape,r=this.currentPathElement.getAttribute(`d`)||``;if(t._splineProperties.ends===this.p5.EXCLUDE&&!t._comesAfterSegment){let n=t._firstInterpolatedVertex?.position||{x:0,y:0},i=n.x===void 0?n[0]===void 0?n.values?n.values[0]:0:n[0]:n.x,a=n.y===void 0?n[1]===void 0?n.values?n.values[1]:0:n[1]:n.y;r+=` M ${i} ${a}`}let i=t.getControlPoints().map(t=>n.vertexToArray(t)),a=n.catmullRomToBezier(i,t._splineProperties.tightness);for(let t of a){let n=t.flatMap(t=>[t[0],t[1]]);r+=` C ${n[0]} ${n[1]} ${n[2]} ${n[3]} ${n[4]} ${n[5]}`}this.currentPathElement.setAttribute(`d`,r)}visitArcPrimitive(t){let n=t.x+t.w/2,r=t.y+t.h/2,i=t.w/2,a=t.h/2,o=t.stop-t.start;if(Math.abs(o%(2*Math.PI))<1e-5&&Math.abs(o)>1e-5){if(i===a){let t=this._createElement(`circle`,{cx:n,cy:r,r:i});this._applyStyle(t),this._appendShapeElement(t)}else{let t=this._createElement(`ellipse`,{cx:n,cy:r,rx:i,ry:a});this._applyStyle(t),this._appendShapeElement(t)}return}let s=n+i*Math.cos(t.start),c=r+a*Math.sin(t.start),l=n+i*Math.cos(t.stop),u=r+a*Math.sin(t.stop),d=`M ${s} ${c} A ${i} ${a} 0 ${+(Math.abs(o)%(2*Math.PI)>Math.PI)} ${+(o>0)} ${l} ${u}`,f=d,p=d,m=t.mode?t.mode.toLowerCase():void 0;if(m===`pie`?f=p=`${d} L ${n} ${r} Z`:m===`chord`?f=p=`${d} Z`:m===`open`?f=p=d:(f=`${d} L ${n} ${r} Z`,p=d),f===p){let t=this._createElement(`path`,{d:f});this._applyStyle(t),this._appendShapeElement(t)}else{let t=this.currentState,n=this.colorToSVG(t?.fill),r=this.colorToSVG(t?.stroke),i=n!==`none`,a=r!==`none`&&t?.strokeWeight!=null;if(i){let t=this._createElement(`path`,{d:f});this._applyStyle(t),t.setAttribute(`stroke`,`none`),this._appendShapeElement(t)}if(a){let t=this._createElement(`path`,{d:p});this._applyStyle(t),t.setAttribute(`fill`,`none`),this._appendShapeElement(t)}}}visitEllipsePrimitive(t){let n=t.x+t.w/2,r=t.y+t.h/2,i=t.w/2,a=t.h/2;if(t.w===t.h){let t=this._createElement(`circle`,{cx:n,cy:r,r:i});this._applyStyle(t),this._appendShapeElement(t)}else{let t=this._createElement(`ellipse`,{cx:n,cy:r,rx:i,ry:a});this._applyStyle(t),this._appendShapeElement(t)}}visitRectPrimitive(t){let n=t.x,r=t.y,i=t.w,a=t.h,o=t.tl,s=t.tr,c=t.br,l=t.bl,u={x:n,y:r,width:i,height:a};if(o!==void 0){if(s===void 0&&(s=o),c===void 0&&(c=s),l===void 0&&(l=c),o===s&&o===c&&o===l){u.rx=o,u.ry=o;let t=this._createElement(`rect`,u);this._applyStyle(t),this._appendShapeElement(t)}else{let t=Math.max(0,o),u=Math.max(0,s),d=Math.max(0,c),f=Math.max(0,l),p=`M ${n+t} ${r} L ${n+i-u} ${r} A ${u} ${u} 0 0 1 ${n+i} ${r+u} L ${n+i} ${r+a-d} A ${d} ${d} 0 0 1 ${n+i-d} ${r+a} L ${n+f} ${r+a} A ${f} ${f} 0 0 1 ${n} ${r+a-f} L ${n} ${r+t} A ${t} ${t} 0 0 1 ${n+t} ${r} Z`,m=this._createElement(`path`,{d:p});this._applyStyle(m),this._appendShapeElement(m)}}else{let t=this._createElement(`rect`,u);this._applyStyle(t),this._appendShapeElement(t)}}visitPoint(t){let{x:n,y:r}=t.vertices[0].position,i=this._createElement(`line`,{x1:n,y1:r,x2:n+1e-4,y2:r});this._applyStyle(i),i.setAttribute(`stroke-linecap`,`round`),this._appendShapeElement(i)}visitLine(t){let{x:n,y:r}=t.vertices[0].position,{x:i,y:a}=t.vertices[1].position,o=this._createElement(`line`,{x1:n,y1:r,x2:i,y2:a});this._applyStyle(o),this._appendShapeElement(o)}visitTriangle(t){let[n,r,i]=t.vertices,a=`${n.position.x},${n.position.y} ${r.position.x},${r.position.y} ${i.position.x},${i.position.y}`,o=this._createElement(`polygon`,{points:a});this._applyStyle(o),this._appendShapeElement(o)}visitQuad(t){let[n,r,i,a]=t.vertices,o=`${n.position.x},${n.position.y} ${r.position.x},${r.position.y} ${i.position.x},${i.position.y} ${a.position.x},${a.position.y}`,s=this._createElement(`polygon`,{points:o});this._applyStyle(s),this._appendShapeElement(s)}visitTriangleFan(t){if(t.vertices.length<3)return;let[n,...r]=t.vertices,i=``;for(let t=0;t<r.length-1;t++){let a=r[t],o=r[t+1];i+=`M ${n.position.x} ${n.position.y} L ${a.position.x} ${a.position.y} L ${o.position.x} ${o.position.y} Z `}let a=this._createElement(`path`,{d:i.trim()});this._applyStyle(a),this._appendShapeElement(a)}visitTriangleStrip(t){if(t.vertices.length<3)return;let n=``;for(let r=0;r<t.vertices.length-2;r++){let i=t.vertices[r],a=t.vertices[r+1],o=t.vertices[r+2];n+=`M ${i.position.x} ${i.position.y} L ${a.position.x} ${a.position.y} L ${o.position.x} ${o.position.y} Z `}let r=this._createElement(`path`,{d:n.trim()});this._applyStyle(r),this._appendShapeElement(r)}visitQuadStrip(t){if(t.vertices.length<4)return;let n=``;for(let r=0;r<t.vertices.length-3;r+=2){let i=t.vertices[r],a=t.vertices[r+1],o=t.vertices[r+2],s=t.vertices[r+3];n+=`M ${i.position.x} ${i.position.y} L ${a.position.x} ${a.position.y} L ${s.position.x} ${s.position.y} L ${o.position.x} ${o.position.y} Z `}let r=this._createElement(`path`,{d:n.trim()});this._applyStyle(r),this._appendShapeElement(r)}visitImage(t){let n=t.img,[r,i,a,o,s,c,l,u]=t.args,d=``;if(n){if(n.canvas&&typeof n.canvas.toDataURL==`function`)try{d=n.canvas.toDataURL()}catch{}if(!d&&n.elt){if(n.elt instanceof HTMLCanvasElement)try{d=n.elt.toDataURL()}catch{}else if(n.elt instanceof HTMLImageElement){if(n.elt.src&&n.elt.src.startsWith(`data:`))d=n.elt.src;else try{let t=document.createElement(`canvas`);t.width=n.elt.naturalWidth||n.width||n.elt.width,t.height=n.elt.naturalHeight||n.height||n.elt.height,t.getContext(`2d`).drawImage(n.elt,0,0),d=t.toDataURL()}catch{d=n.elt.src}}}if(!d&&n instanceof HTMLCanvasElement)try{d=n.toDataURL()}catch{}if(!d&&n instanceof HTMLImageElement){if(n.src&&n.src.startsWith(`data:`))d=n.src;else try{let t=document.createElement(`canvas`);t.width=n.naturalWidth||n.width,t.height=n.naturalHeight||n.height,t.getContext(`2d`).drawImage(n,0,0),d=t.toDataURL()}catch{d=n.src}}!d&&typeof n==`string`&&(d=n)}if(!d)return;let f=n.width||n.elt&&(n.elt.naturalWidth||n.elt.width)||0,p=n.height||n.elt&&(n.elt.naturalHeight||n.elt.height)||0,m=f>0&&p>0&&(r!==0||i!==0||Math.abs(a-f)>.1||Math.abs(o-p)>.1),h;if(m){this.clipPathCounter=(this.clipPathCounter||0)+1;let t=`clip-p5svg-${this.clipPathCounter}`,n=this._createElement(`clipPath`,{id:t}),d=this._createElement(`rect`,{x:s,y:c,width:l,height:u});n.appendChild(d),this._getDefs().appendChild(n);let m=l/a,g=u/o,_=f*m,v=p*g,y=s-r*m,b=c-i*g;h=this._createElement(`image`,{x:y,y:b,width:_,height:v,"clip-path":`url(#${t})`,preserveAspectRatio:`none`})}else h=this._createElement(`image`,{x:s,y:c,width:l,height:u,preserveAspectRatio:`none`});h.setAttribute(`href`,d),h.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,d),this._appendShapeElement(h)}buildSVG(){return new XMLSerializer().serializeToString(this.svgElement)}}class a{constructor(t){this.p5=t}replay(t){t&&(t instanceof vw?this.replayScope(t.data):this.replayScope(t))}replayScope(t){for(let n of t.children)switch(n.type){case`scope`:this.replayScope(n);break;case`shape`:this.replayShape(n);break;case`background`:this.replayBackground(n);break;case`clear`:this.replayClear(n);break;case`image`:this.replayImage(n)}}replayImage(t){let n=this.p5;n.push(),this.applyState(t.state);let[r,i,a,o,s,c,l,u]=t.args;n.image(t.img,s,c,l,u,r,i,a,o),n.pop()}replayShape(t){let n=this.p5;n.push(),this.applyState(t.state),n._renderer.drawShape(t.shape),n.pop()}replayClear(){this.p5.clear()}replayBackground(t){let n=this.p5;if(!t.color){n.clear();return}let[r,i,a,o]=t.color._getRGBA([255,255,255,255]);n.background(r,i,a,o)}applyState(t){let n=this.p5;if(t){if(t.transform){let r=t.transform;n.applyMatrix(r.a,r.b,r.c,r.d,r.e,r.f)}if(t.fill){let[r,i,a,o]=t.fill._getRGBA([255,255,255,255]);n.fill(r,i,a,o)}else n.noFill();if(t.stroke){let[r,i,a,o]=t.stroke._getRGBA([255,255,255,255]);n.stroke(r,i,a,o)}else n.noStroke();t.strokeWeight!=null&&n.strokeWeight(t.strokeWeight),t.strokeCap!=null&&n.strokeCap(t.strokeCap)}}}function o(t,n,r=`drawing.svg`){let i=t.getSVG(n),a=new Blob([i],{type:`image/svg+xml`}),o=URL.createObjectURL(a),s=document.createElement(`a`);s.href=o,s.download=r,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}n.createShape=function(){return new vw(this)},n.buildShape=function(t,n={}){let r=this.createShape();r.begin(n);try{typeof t==`function`&&t()}finally{r.end()}return r},n.getSVG=function(t){let n=new i(this);return t.toSVGElement(n),n.buildSVG()};let s=`corner`,c=`center`,l=`viewbox`;n.CORNER=n.CORNER||s,n.CENTER=n.CENTER||c,n.VIEWBOX=n.VIEWBOX||l,t&&(t.CORNER=t.CORNER||s,t.CENTER=t.CENTER||c,t.VIEWBOX=t.VIEWBOX||l);function u(t){return t?vw!==void 0&&t instanceof vw?t.data:t:null}function d(t){let n=u(t);if(!n)return null;if(n.coordinateBounds)return n.coordinateBounds;let r=n.viewBox||t?.viewBox;if(r&&typeof r.width==`number`&&typeof r.height==`number`&&!isNaN(r.width)&&!isNaN(r.height)&&r.width>0&&r.height>0)return{x:typeof r.x==`number`&&!isNaN(r.x)?r.x:0,y:typeof r.y==`number`&&!isNaN(r.y)?r.y:0,width:r.width,height:r.height};let i=n.width??t?.width,a=n.height??t?.height;return i!=null&&a!=null&&!isNaN(i)&&!isNaN(a)&&i>0&&a>0?{x:0,y:0,width:i,height:a}:null}let f={corner:t=>{let n=d(t);return n&&typeof n.x==`number`&&typeof n.y==`number`?{offsetX:-n.x,offsetY:-n.y}:{offsetX:0,offsetY:0}},center:t=>{let n=d(t);if(n&&typeof n.width==`number`&&typeof n.height==`number`){let t=typeof n.x==`number`?n.x:0,r=typeof n.y==`number`?n.y:0;return{offsetX:-(t+n.width/2),offsetY:-(r+n.height/2)}}return console.warn(`shape(): CENTER alignment requested, but shape record has no valid coordinate bounds metadata.`),{offsetX:0,offsetY:0}},viewbox:()=>({offsetX:0,offsetY:0})},p=[{key:`anchor`,resolve(t,n,r,i){return r===0&&i===0?null:{x:r,y:i}},apply(t,n){typeof t.translate==`function`?t.translate(n.x,n.y):typeof t.applyMatrix==`function`&&t.applyMatrix(1,0,0,1,n.x,n.y)}},{key:`scale`,resolve(t,n,r,i){if(!n||n.scale===void 0||n.scale===null)return null;let a=n.scale,o=1,s=1;if(typeof a==`number`){if(!Number.isFinite(a))return console.warn(`shape(): Invalid scale option. Ignoring.`),null;o=a,s=a}else if(typeof a==`object`&&a&&!Array.isArray(a)){if(typeof a.x!=`number`||!Number.isFinite(a.x)||typeof a.y!=`number`||!Number.isFinite(a.y))return console.warn(`shape(): Invalid scale option. Ignoring.`),null;o=a.x,s=a.y}else return console.warn(`shape(): Invalid scale option. Ignoring.`),null;return o===1&&s===1?null:{x:o,y:s}},apply(t,n){typeof t.scale==`function`?t.scale(n.x,n.y):typeof t.applyMatrix==`function`&&t.applyMatrix(n.x,0,0,n.y,0,0)}},{key:`align`,resolve(t,n,r,i){let a=n&&n.align!==void 0?n.align:s,o=String(a).trim().toLowerCase(),c=f[o],l;c?l=c(t,n):(console.warn(`shape(): Unknown alignment mode "${n.align}". Defaulting to CORNER.`),l=f.corner(t,n));let u=l?.offsetX||0,d=l?.offsetY||0;return u===0&&d===0?null:{x:u,y:d}},apply(t,n){typeof t.translate==`function`?t.translate(n.x,n.y):typeof t.applyMatrix==`function`&&t.applyMatrix(1,0,0,1,n.x,n.y)}}];function m(t,n,r,i={}){let a=[];for(let o of p){let s=o.resolve(t,i,n,r);s!==null&&a.push({stage:o,params:s})}return{resolved:a,hasTransform:a.length>0}}function h(t,n){if(t&&n&&n.resolved)for(let{stage:r,params:i}of n.resolved)r.apply(t,i)}n.shape=function(t,n=0,r=0,i={}){let o=new a(this),s=m(t,n,r,i);s.hasTransform?(typeof this.push==`function`&&this.push(),h(this,s),o.replay(t),typeof this.pop==`function`&&this.pop()):o.replay(t)},n.saveSVG=function(t,n=`drawing.svg`){t instanceof vw||t&&typeof t.toSVGElement==`function`?o(this,t,n):typeof t==`string`?this.pendingExport={filename:t,p5:this}:t===void 0&&(this.pendingExport={filename:n,p5:this})}}typeof p5<`u`&&p5.registerAddon(yw);const bw=Object.freeze({M:{args:[`x`,`y`],implicit:`L`},m:{args:[`dx`,`dy`],implicit:`l`},L:{args:[`x`,`y`],implicit:`L`},l:{args:[`dx`,`dy`],implicit:`l`},H:{args:[`x`],implicit:`H`},h:{args:[`dx`],implicit:`h`},V:{args:[`y`],implicit:`V`},v:{args:[`dy`],implicit:`v`},C:{args:[`x1`,`y1`,`x2`,`y2`,`x`,`y`],implicit:`C`},c:{args:[`dx1`,`dy1`,`dx2`,`dy2`,`dx`,`dy`],implicit:`c`},S:{args:[`x2`,`y2`,`x`,`y`],implicit:`S`},s:{args:[`dx2`,`dy2`,`dx`,`dy`],implicit:`s`},Q:{args:[`x1`,`y1`,`x`,`y`],implicit:`Q`},q:{args:[`dx1`,`dy1`,`dx`,`dy`],implicit:`q`},T:{args:[`x`,`y`],implicit:`T`},t:{args:[`dx`,`dy`],implicit:`t`},A:{args:[`rx`,`ry`,`rotation`,`largeArc`,`sweep`,`x`,`y`],implicit:`A`},a:{args:[`rx`,`ry`,`rotation`,`largeArc`,`sweep`,`dx`,`dy`],implicit:`a`},Z:{args:[],implicit:`Z`},z:{args:[],implicit:`z`}}),xw=/* @__PURE__ */ new Set;function Sw(t){xw.has(t)||(xw.add(t),console.warn(t))}var Cw=class{apply(t,n){if(!t.transform?.baseVal)return;let r=t.transform.baseVal;for(let t=0;t<r.numberOfItems;t++){let i=r.getItem(t).matrix;n.current.multiplySelf(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}}},ww=class{resolveNodeStyle(t,n){let r=n.clone(),i=t.getAttribute(`style`),a=i?this.parseInlineStyle(i):null;return this.resolveColor(r,t,a),this.resolveFill(r,t,a),this.resolveStroke(r,t,a,n),this.resolveOpacity(r,t,a,n),this.resolveDisplayAndVisibility(r,t,a,n),r}resolveColor(t,n,r){let i=this.getProp(n,r,`color`);i!==void 0&&i.trim().toLowerCase()!==`currentcolor`&&(t.color=i)}resolveDisplayAndVisibility(t,n,r,i){let a=this.getProp(n,r,`display`);t.display=i.display===`none`?`none`:a===void 0?`inline`:a;let o=this.getProp(n,r,`visibility`);o!==void 0&&(t.visibility=o)}resolveOpacity(t,n,r,i){let a=this.getProp(n,r,`opacity`);if(a!==void 0){let n=Ew(a);isNaN(n)||(t.opacity=i.opacity*n)}let o=this.getProp(n,r,`fill-opacity`,`fillOpacity`);if(o!==void 0){let n=Ew(o);isNaN(n)||(t.fillOpacity=n)}let s=this.getProp(n,r,`stroke-opacity`,`strokeOpacity`);if(s!==void 0){let n=Ew(s);isNaN(n)||(t.strokeOpacity=n)}}resolveStroke(t,n,r,i){let a=this.getProp(n,r,`stroke`);a!==void 0&&(t.stroke=a);let o=this.getProp(n,r,`stroke-width`,`strokeWidth`);o!==void 0&&(t.strokeWidth=Dw(o,i.strokeWidth));let s=this.getProp(n,r,`stroke-linecap`,`strokeLinecap`);s!==void 0&&(t.strokeCap=s)}resolveFill(t,n,r){let i=this.getProp(n,r,`fill`);i!==void 0&&(t.fill=i)}getProp(t,n,r,i){let a;if(n&&(a=n[r],a!==void 0&&a!==`inherit`))return a;if(this.styleCache){let n=this.styleCache.get(t);if(n&&(a=n[r],a!==void 0&&a!==`inherit`&&a!==``))return a}if(a=t.getAttribute(r),a!==null&&a!==`inherit`||i&&(a=t.getAttribute(i),a!==null&&a!==`inherit`))return a}parseInlineStyle(t){let n={};if(!t)return n;let r=t.split(`;`);for(let t of r){let r=t.indexOf(`:`);if(r===-1)continue;let i=t.slice(0,r).trim().toLowerCase(),a=t.slice(r+1).trim();i&&a&&(n[i]=a)}return n}preprocess(t){this.styleCache=/* @__PURE__ */ new WeakMap;let n=t.querySelectorAll(`style`),r=[];for(let t of n){let n=t.sheet;if(!n){console.warn(`SVG Importer Warning: CSS stylesheet could not be parsed via CSSOM (styleEl.sheet is null).`);continue}let i;try{i=n.cssRules}catch(t){console.warn(`SVG Importer Warning: Failed to access cssRules from stylesheet.`,t);continue}for(let t=0;t<i.length;t++){let n=i[t];if(n.type!==CSSRule.STYLE_RULE){console.warn(`SVG Importer Warning: Skipping non-style rule type ${n.type} (${n.cssText})`);continue}let a=n.style,o={};for(let t=0;t<a.length;t++){let n=a[t];o[n]=a.getPropertyValue(n).trim()}if(Object.keys(o).length>0){let t=n.selectorText;if(t){let n=t.split(`,`);for(let t of n){let n=t.trim();n&&r.push({selectorText:n,styles:o,specificity:this.getSpecificity(n)})}}}}}r.sort((t,n)=>t.specificity-n.specificity);for(let n of r){if(!this._isSupportedSelector(n.selectorText))continue;let r;try{r=t.querySelectorAll(n.selectorText)}catch{continue}for(let t of r){this.styleCache.has(t)||this.styleCache.set(t,{});let r=this.styleCache.get(t);for(let[t,i]of Object.entries(n.styles))r[t]=i}}}getSpecificity(t){let n=0,r=0,i=0,a=t.split(/[\s>+~]+/);for(let t of a){if(!t)continue;let a=t.match(/#[a-zA-Z0-9_-]+/g);a&&(n+=a.length);let o=t.match(/\.[a-zA-Z0-9_-]+/g);o&&(r+=o.length);let s=t.match(/\[[^\]]+\]/g);s&&(r+=s.length);let c=t.replace(/#[a-zA-Z0-9_-]+/g,``).replace(/\.[a-zA-Z0-9_-]+/g,``).replace(/\[[^\]]+\]/g,``);c&&/^[a-zA-Z]/.test(c)&&(i+=1)}return n*100+r*10+i}_isSupportedSelector(t){return t.split(`,`).every(t=>!t.includes(`:`))}},Tw=class t{constructor(t){t?(this.fill=t.fill,this.stroke=t.stroke,this.strokeWidth=t.strokeWidth,this.strokeCap=t.strokeCap,this.opacity=t.opacity,this.fillOpacity=t.fillOpacity,this.strokeOpacity=t.strokeOpacity,this.visibility=t.visibility,this.display=t.display===`none`?`none`:`inline`,this.color=t.color):(this.fill=`rgb(0, 0, 0)`,this.stroke=`none`,this.strokeWidth=1,this.strokeCap=`butt`,this.opacity=1,this.fillOpacity=1,this.strokeOpacity=1,this.visibility=`visible`,this.display=`inline`,this.color=`rgb(0, 0, 0)`)}clone(){return new t(this)}};function Ew(t){if(t==null||t===``)return NaN;let n=String(t).trim(),r=parseFloat(n);return isNaN(r)?NaN:(n.endsWith(`%`)&&(r/=100),Math.max(0,Math.min(1,r)))}function Dw(t,n){if(t==null||t===``)return n;let r=String(t).trim(),i=parseFloat(r);return isNaN(i)?n:i}function Ow(t,n){let r=t!=null&&!isNaN(t)&&t>=0,i=n!=null&&!isNaN(n)&&n>=0,a=t,o=n;return!r&&!i?(a=0,o=0):r&&!i?o=a:!r&&i&&(a=o),{rx:a,ry:o}}function kw(t,n,r){class i{constructor(t,n,r){this.p5=t,this.recorder=n,this.transformStack=r}makeColor(t,n,r){if(t&&t.startsWith(`url(`))return Sw(`SVG Importer Warning: Gradients and patterns (url(...)) are not supported yet.`),null;if(!t||t===`none`)return null;let i=t.trim();i.toLowerCase()===`currentcolor`&&(i=r.color||`rgb(0, 0, 0)`,i.toLowerCase()===`currentcolor`&&(i=`rgb(0, 0, 0)`));try{let t=this.p5.color(i).toString(`rgba`),r=this.p5.color(t);return r.setAlpha(this.p5.alpha(r)*n),r}catch{return Sw(`SVG Importer Warning: Failed to parse color: "${t}"`),null}}captureState(t){return{transform:new DOMMatrix(this.transformStack.current),fill:this.makeColor(t.fill,t.opacity*t.fillOpacity,t),stroke:this.makeColor(t.stroke,t.opacity*t.strokeOpacity,t),strokeWeight:t.strokeWidth,strokeCap:t.strokeCap,renderContext:t.clone(),fillOpacity:t.fillOpacity,strokeOpacity:t.strokeOpacity}}createShape(n){let r=new t.Shape({position:new t.Vector(0,0)});return r.beginShape(),n(r),r.endShape(),r}addPrimitive(t,n){if(t.visibility===`hidden`||t.visibility===`collapse`)return;let r=this.createShape(n),i=this.captureState(t);this.recorder.addNode(new fw(r,i))}emitShape(t,n){let r=this.captureState(n);this.recorder.addNode(new fw(t,r))}}class a{constructor(t){this.p5=t,this.recorder=new _w(t),this.tStack=new gw,this.renderContextStack=[new Tw],this.styleResolver=new ww,this.transformResolver=new Cw,this.shapeBuilder=new i(t,this.recorder,this.tStack),this.definitions=/* @__PURE__ */ new Map,this.activeRefs=/* @__PURE__ */ new Set}get currentRenderContext(){return this.renderContextStack[this.renderContextStack.length-1]}import(t){let n=document.createElement(`div`);n.style.position=`absolute`,n.style.left=`-99999px`,n.style.visibility=`hidden`,n.style.pointerEvents=`none`,document.body.appendChild(n);try{n.appendChild(t),this.styleResolver.preprocess(t),this.buildIdMap(t),this.visit(n.firstChild)}finally{n.remove()}let r=this.recorder.getRecord();r.sourceSVG=t.cloneNode(!0);let i;if(t.viewBox&&t.viewBox.baseVal)try{let n=t.viewBox.baseVal;typeof n.x==`number`&&typeof n.y==`number`&&typeof n.width==`number`&&typeof n.height==`number`&&n.width>0&&n.height>0&&(i={x:n.x,y:n.y,width:n.width,height:n.height})}catch{}if(!i&&t.hasAttribute&&t.hasAttribute(`viewBox`)){let n=t.getAttribute(`viewBox`).trim().split(/[\s,]+/).map(t=>parseFloat(t));n.length===4&&!n.some(t=>isNaN(t))&&n[2]>0&&n[3]>0&&(i={x:n[0],y:n[1],width:n[2],height:n[3]})}let a;if(t.width&&t.width.baseVal)try{let n=t.width.baseVal.value;typeof n==`number`&&!isNaN(n)&&n>0&&(a=n)}catch{}if(a===void 0&&t.hasAttribute&&t.hasAttribute(`width`)){let n=parseFloat(t.getAttribute(`width`));isNaN(n)||(a=n)}let o;if(t.height&&t.height.baseVal)try{let n=t.height.baseVal.value;typeof n==`number`&&!isNaN(n)&&n>0&&(o=n)}catch{}if(o===void 0&&t.hasAttribute&&t.hasAttribute(`height`)){let n=parseFloat(t.getAttribute(`height`));isNaN(n)||(o=n)}return r.width=a,r.height=o,r.viewBox=i,i?r.coordinateBounds={x:i.x,y:i.y,width:i.width,height:i.height}:a!=null&&o!=null&&(r.coordinateBounds={x:0,y:0,width:a,height:o}),r}buildIdMap(t){t.id&&!this.definitions.has(t.id)&&this.definitions.set(t.id,t);for(let n of t.children)this.buildIdMap(n)}visit(t){if(!t)return;let n=o[t.localName];if(!n)return;this.tStack.push(),this.transformResolver.apply(t,this.tStack);let r=this.currentRenderContext,i=this.styleResolver.resolveNodeStyle(t,r);this.renderContextStack.push(i),i.display===`none`?(this.renderContextStack.pop(),this.tStack.pop()):(n.call(this,t,i),this.renderContextStack.pop(),this.tStack.pop())}withRefGuard(t,n){if(!this.activeRefs.has(t)){this.activeRefs.add(t);try{n()}finally{this.activeRefs.delete(t)}}}num(t,n,r=0){return t.hasAttribute(n)?t[n]&&t[n].baseVal?t[n].baseVal.value:Dw(t.getAttribute(n),r):r}visitSVG(t){for(let n of t.children)n.localName!==`symbol`&&this.visit(n)}visitGroup(t){this.recorder.enterScope();for(let n of t.children)n.localName!==`symbol`&&this.visit(n);this.recorder.leaveScope()}visitDefs(){}visitUse(t){let n=t.getAttribute(`href`)||t.getAttribute(`xlink:href`);if(!n||!n.startsWith(`#`))return;let r=n.slice(1),i=this.definitions.get(r);i&&this.withRefGuard(r,()=>{let n=this.num(t,`x`),r=this.num(t,`y`);(n!==0||r!==0)&&this.tStack.current.translateSelf(n,r);let a=i.viewBox?.baseVal;if(a&&a.width&&a.height){let n=t.hasAttribute(`width`)?this.num(t,`width`):i.width?.baseVal?.value||a.width,r=t.hasAttribute(`height`)?this.num(t,`height`):i.height?.baseVal?.value||a.height,o=i.getAttribute(`preserveAspectRatio`);if(o?.trim()===`none`){let t=n/a.width,i=r/a.height;this.tStack.current.translateSelf(-a.x*t,-a.y*i),this.tStack.current.scaleSelf(t,i)}else{let t=Math.min(n/a.width,r/a.height),i=o?.trim().split(/\s+/)[0]||`xMidYMid`,s=i.startsWith(`xMin`)?0:i.startsWith(`xMax`)?1:.5,c=i.endsWith(`YMin`)?0:i.endsWith(`YMax`)?1:.5;this.tStack.current.translateSelf((n-a.width*t)*s-a.x*t,(r-a.height*t)*c-a.y*t),this.tStack.current.scaleSelf(t,t)}}this.visit(i)})}visitCircle(t,n){let r=this.num(t,`r`);r<=0||this.shapeBuilder.addPrimitive(n,n=>{n.ellipsePrimitive(this.num(t,`cx`)-r,this.num(t,`cy`)-r,r*2,r*2)})}visitEllipse(t,n){let{rx:r,ry:i}=Ow(this.num(t,`rx`,NaN),this.num(t,`ry`,NaN));r<=0||i<=0||this.shapeBuilder.addPrimitive(n,n=>{n.ellipsePrimitive(this.num(t,`cx`)-r,this.num(t,`cy`)-i,r*2,i*2)})}visitLine(t,n){this.shapeBuilder.addPrimitive(n,n=>{n.line(this.num(t,`x1`),this.num(t,`y1`),this.num(t,`x2`),this.num(t,`y2`))})}visitRect(t,n){let r=this.num(t,`width`),i=this.num(t,`height`);if(r<=0||i<=0)return;let{rx:a,ry:o}=Ow(this.num(t,`rx`,null),this.num(t,`ry`,null)),s=this.num(t,`x`),c=this.num(t,`y`),l=Math.max(0,Math.min(a,r/2)),u=Math.max(0,Math.min(o,i/2));(l===0||u===0)&&(l=0,u=0),l>0&&u>0&&l!==u?this.shapeBuilder.addPrimitive(n,t=>{this.buildRoundedRect(t,s,c,r,i,l,u)}):this.shapeBuilder.addPrimitive(n,t=>{this.buildSimpleRect(t,s,c,r,i,l)})}visitPolygon(n,r){let i=this.getNativePoints(n);this.shapeBuilder.addPrimitive(r,n=>{for(let r of i)n.vertex(new t.Vector(r.x,r.y));n.endShape(this.p5.CLOSE)})}visitPolyline(n,r){let i=this.getNativePoints(n);this.shapeBuilder.addPrimitive(r,n=>{for(let r of i)n.vertex(new t.Vector(r.x,r.y))})}visitPath(t,n){this.shapeBuilder.addPrimitive(n,n=>{if(typeof t.getPathData==`function`)this.buildFromPathData(n,t.getPathData());else{let r=t.getAttribute(`d`)||``;this.buildFromLegacyPath(n,r)}})}emitCubicSegments(t,n){for(let r of n)this.emitSingleCubic(t,r.cp1,r.cp2,r.end)}emitSingleCubic(n,r,i,a){n.bezierOrder(3),n.bezierVertex(new t.Vector(r.x,r.y)),n.bezierVertex(new t.Vector(i.x,i.y)),n.bezierVertex(new t.Vector(a.x,a.y))}buildRoundedRect(n,r,i,a,o,s,c){let l=.5523;n.vertex(new t.Vector(r+s,i)),n.vertex(new t.Vector(r+a-s,i)),this.emitSingleCubic(n,{x:r+a-s+s*l,y:i},{x:r+a,y:i+c-c*l},{x:r+a,y:i+c}),n.vertex(new t.Vector(r+a,i+o-c)),this.emitSingleCubic(n,{x:r+a,y:i+o-c+c*l},{x:r+a-s+s*l,y:i+o},{x:r+a-s,y:i+o}),n.vertex(new t.Vector(r+s,i+o)),this.emitSingleCubic(n,{x:r+s-s*l,y:i+o},{x:r,y:i+o-c+c*l},{x:r,y:i+o-c}),n.vertex(new t.Vector(r,i+c)),this.emitSingleCubic(n,{x:r,y:i+c-c*l},{x:r+s-s*l,y:i},{x:r+s,y:i}),n.endShape(this.p5.CLOSE)}buildSimpleRect(t,n,r,i,a,o){o>0?t.rectPrimitive(n,r,i,a,o,o,o,o):t.rectPrimitive(n,r,i,a)}parsePointsAttribute(t){let n=[],r=t.match(/-?[\d.]+/g);if(r)for(let t=0;t<r.length-1;t+=2){let i=parseFloat(r[t]),a=parseFloat(r[t+1]);!isNaN(i)&&!isNaN(a)&&n.push({x:i,y:a})}return n}getNativePoints(t){let n=t.points;if(n&&n.numberOfItems>0){let t=[];for(let r=0;r<n.numberOfItems;r++){let i=n.getItem(r);t.push({x:i.x,y:i.y})}return t}let r=t.getAttribute(`points`);return r?this.parsePointsAttribute(r):[]}parsePathData(t){let n=[],r=0,i=t.length,a=``,o=0,s=null,c=!1;function l(){for(;r<i;){let n=t[r];if(n===` `||n===`	`||n===`\r`||n===`
`||n===`,`)r++;else break}}function u(t){return`MmLlHhVvCcSsQqTtAaZz`.includes(t)}for(;r<i&&(l(),!(r>=i));){let i=t[r];if(u(i)){a=i,o=0,s={type:i};let t=bw[i];t&&t.args.length===0?(n.push(s),c=!0):c=!1,r++;continue}let l=bw[a]?.args[o];if(l===`largeArc`||l===`sweep`){if(i===`0`||i===`1`){let t=Number(i);if(s){c||=(n.push(s),!0);let r=bw[a].args[o];s[r]=t}o++,o>=7&&(o=0),r++}else{Sw(`SVG Importer Warning: Malformed SVG path data (invalid arc flag).`);break}}else{let i=t.substring(r).match(/^[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/);if(i){let t=i[0],l=Number(t);if(r+=t.length,s){c||=(n.push(s),!0);let t=bw[a].args[o];s[t]=l}if(a){let t=bw[a],n=t?t.args.length:0;n>0&&(o++,o>=n&&(a=t.implicit,o=0,s={type:a},c=!1))}}else Sw(`SVG Importer Warning: Malformed SVG path data (unrecognized character).`),r++}}return n}arcToBezier(t,n,r,i,a,o,s,c,l){if(t===c&&n===l)return[];if(r===0||i===0)return[{cp1:{x:t,y:n},cp2:{x:c,y:l},end:{x:c,y:l}}];r=Math.abs(r),i=Math.abs(i);let u=a*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=(t-c)/2,m=(n-l)/2,h=d*p+f*m,g=-f*p+d*m,_=r*r,v=i*i,y=h*h,b=g*g,x=y/_+b/v;x>1&&(r*=Math.sqrt(x),i*=Math.sqrt(x),_=r*r,v=i*i);let S=o===s?-1:1,C=(_*v-_*b-v*y)/(_*b+v*y),w=S*Math.sqrt(Math.max(0,C)),T=w*(r*g/i),E=w*-(i*h/r),D=d*T-f*E+(t+c)/2,O=f*T+d*E+(n+l)/2,k=(h-T)/r,A=(g-E)/i,j=(-h-T)/r,M=(-g-E)/i,ee=(t,n,r,i)=>{let a=t*r+n*i,o=Math.sqrt(t*t+n*n)*Math.sqrt(r*r+i*i),s=Math.acos(Math.max(-1,Math.min(1,a/o)));return t*i-n*r<0&&(s=-s),s},te=ee(1,0,k,A),N=ee(k,A,j,M);s===0&&N>0?N-=2*Math.PI:s===1&&N<0&&(N+=2*Math.PI);let ne=Math.ceil(Math.abs(N)/(Math.PI/2)),re=[],ie=te,P=N/ne;for(let t=0;t<ne;t++){let t=ie+P,n=Math.sin(P)*(Math.sqrt(4+3*Math.tan(P/2)*Math.tan(P/2))-1)/3,a=Math.cos(ie),o=Math.sin(ie),s=Math.cos(t),c=Math.sin(t),l=a-n*o,u=o+n*a,p=s+n*c,m=c-n*s,h=s,g=c,_=(t,n)=>{let a=r*t,o=i*n;return{x:d*a-f*o+D,y:f*a+d*o+O}},v=_(l,u),y=_(p,m),b=_(h,g);re.push({cp1:v,cp2:y,end:b}),ie=t}return re}handlePathM(n,r,i){let{x:a,y:o}=i;r.currentX=a,r.currentY=o,r.startX=r.currentX,r.startY=r.currentY,r.isFirstContour||n.beginContour(),r.isFirstContour=!1,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathm(n,r,i){let{dx:a,dy:o}=i;r.currentX+=a,r.currentY+=o,r.startX=r.currentX,r.startY=r.currentY,r.isFirstContour||n.beginContour(),r.isFirstContour=!1,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathL(n,r,i){let{x:a,y:o}=i;r.currentX=a,r.currentY=o,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathl(n,r,i){let{dx:a,dy:o}=i;r.currentX+=a,r.currentY+=o,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathH(n,r,i){let{x:a}=i;r.currentX=a,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathh(n,r,i){let{dx:a}=i;r.currentX+=a,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathV(n,r,i){let{y:a}=i;r.currentY=a,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathv(n,r,i){let{dy:a}=i;r.currentY+=a,n.vertex(new t.Vector(r.currentX,r.currentY)),r.lastControlX=r.currentX,r.lastControlY=r.currentY}handlePathC(n,r,i){let{x1:a,y1:o,x2:s,y2:c,x:l,y:u}=i;n.bezierOrder(3),n.bezierVertex(new t.Vector(a,o)),n.bezierVertex(new t.Vector(s,c)),n.bezierVertex(new t.Vector(l,u)),r.lastControlX=s,r.lastControlY=c,r.currentX=l,r.currentY=u}handlePathc(n,r,i){let{dx1:a,dy1:o,dx2:s,dy2:c,dx:l,dy:u}=i,d=a+r.currentX,f=o+r.currentY,p=s+r.currentX,m=c+r.currentY,h=l+r.currentX,g=u+r.currentY;n.bezierOrder(3),n.bezierVertex(new t.Vector(d,f)),n.bezierVertex(new t.Vector(p,m)),n.bezierVertex(new t.Vector(h,g)),r.lastControlX=p,r.lastControlY=m,r.currentX=h,r.currentY=g}handlePathS(n,r,i){let{x2:a,y2:o,x:s,y:c}=i,l=r.currentX,u=r.currentY;(r.lastCommand===`C`||r.lastCommand===`c`||r.lastCommand===`S`||r.lastCommand===`s`)&&(l=2*r.currentX-r.lastControlX,u=2*r.currentY-r.lastControlY),n.bezierOrder(3),n.bezierVertex(new t.Vector(l,u)),n.bezierVertex(new t.Vector(a,o)),n.bezierVertex(new t.Vector(s,c)),r.lastControlX=a,r.lastControlY=o,r.currentX=s,r.currentY=c}handlePaths(n,r,i){let{dx2:a,dy2:o,dx:s,dy:c}=i,l=a+r.currentX,u=o+r.currentY,d=s+r.currentX,f=c+r.currentY,p=r.currentX,m=r.currentY;(r.lastCommand===`C`||r.lastCommand===`c`||r.lastCommand===`S`||r.lastCommand===`s`)&&(p=2*r.currentX-r.lastControlX,m=2*r.currentY-r.lastControlY),n.bezierOrder(3),n.bezierVertex(new t.Vector(p,m)),n.bezierVertex(new t.Vector(l,u)),n.bezierVertex(new t.Vector(d,f)),r.lastControlX=l,r.lastControlY=u,r.currentX=d,r.currentY=f}handlePathQ(n,r,i){let{x1:a,y1:o,x:s,y:c}=i;n.bezierOrder(2),n.bezierVertex(new t.Vector(a,o)),n.bezierVertex(new t.Vector(s,c)),r.lastControlX=a,r.lastControlY=o,r.currentX=s,r.currentY=c}handlePathq(n,r,i){let{dx1:a,dy1:o,dx:s,dy:c}=i,l=a+r.currentX,u=o+r.currentY,d=s+r.currentX,f=c+r.currentY;n.bezierOrder(2),n.bezierVertex(new t.Vector(l,u)),n.bezierVertex(new t.Vector(d,f)),r.lastControlX=l,r.lastControlY=u,r.currentX=d,r.currentY=f}handlePathT(n,r,i){let{x:a,y:o}=i,s=r.currentX,c=r.currentY;(r.lastCommand===`Q`||r.lastCommand===`q`||r.lastCommand===`T`||r.lastCommand===`t`)&&(s=2*r.currentX-r.lastControlX,c=2*r.currentY-r.lastControlY),n.bezierOrder(2),n.bezierVertex(new t.Vector(s,c)),n.bezierVertex(new t.Vector(a,o)),r.lastControlX=s,r.lastControlY=c,r.currentX=a,r.currentY=o}handlePatht(n,r,i){let{dx:a,dy:o}=i,s=a+r.currentX,c=o+r.currentY,l=r.currentX,u=r.currentY;(r.lastCommand===`Q`||r.lastCommand===`q`||r.lastCommand===`T`||r.lastCommand===`t`)&&(l=2*r.currentX-r.lastControlX,u=2*r.currentY-r.lastControlY),n.bezierOrder(2),n.bezierVertex(new t.Vector(l,u)),n.bezierVertex(new t.Vector(s,c)),r.lastControlX=l,r.lastControlY=u,r.currentX=s,r.currentY=c}handlePathA(t,n,r){let{rx:i,ry:a,rotation:o,largeArc:s,sweep:c,x:l,y:u}=r,d=this.arcToBezier(n.currentX,n.currentY,i,a,o,s,c,l,u);this.emitCubicSegments(t,d),n.lastControlX=n.currentX=l,n.lastControlY=n.currentY=u}handlePatha(t,n,r){let{rx:i,ry:a,rotation:o,largeArc:s,sweep:c,dx:l,dy:u}=r,d=l+n.currentX,f=u+n.currentY,p=this.arcToBezier(n.currentX,n.currentY,i,a,o,s,c,d,f);this.emitCubicSegments(t,p),n.lastControlX=n.currentX=d,n.lastControlY=n.currentY=f}buildFromCommands(t,n){let r={currentX:0,currentY:0,lastControlX:0,lastControlY:0,startX:0,startY:0,lastCommand:``,isFirstContour:!0};for(let i of n){let n=i.type;if(n===`Z`||n===`z`){t.endContour(this.p5.CLOSE),r.currentX=r.startX,r.currentY=r.startY,r.lastControlX=r.currentX,r.lastControlY=r.currentY,r.lastCommand=n;continue}let a=s[n];a&&a.call(this,t,r,i),r.lastCommand=n}}buildFromLegacyPath(t,n){let r=this.parsePathData(n);this.buildFromCommands(t,r)}buildFromPathData(t,n){let r=n.map(t=>{let n={type:t.type};return bw[t.type].args.forEach((r,i)=>{n[r]=t.values[i]}),n});this.buildFromCommands(t,r)}}let o=Object.freeze({svg:a.prototype.visitSVG,g:a.prototype.visitGroup,symbol:a.prototype.visitGroup,circle:a.prototype.visitCircle,ellipse:a.prototype.visitEllipse,line:a.prototype.visitLine,rect:a.prototype.visitRect,polygon:a.prototype.visitPolygon,polyline:a.prototype.visitPolyline,path:a.prototype.visitPath,defs:a.prototype.visitDefs,use:a.prototype.visitUse}),s=Object.freeze({M:a.prototype.handlePathM,m:a.prototype.handlePathm,L:a.prototype.handlePathL,l:a.prototype.handlePathl,H:a.prototype.handlePathH,h:a.prototype.handlePathh,V:a.prototype.handlePathV,v:a.prototype.handlePathv,C:a.prototype.handlePathC,c:a.prototype.handlePathc,S:a.prototype.handlePathS,s:a.prototype.handlePaths,Q:a.prototype.handlePathQ,q:a.prototype.handlePathq,T:a.prototype.handlePathT,t:a.prototype.handlePatht,A:a.prototype.handlePathA,a:a.prototype.handlePatha});function c(t,n){let r;r=typeof n==`string`?new DOMParser().parseFromString(n,`image/svg+xml`).documentElement:n;let i=new a(t).import(r);if(t?.createShape){let n=t.createShape();return n.data=i,n.sourceSVG=i.sourceSVG,n}return i}n.createSVG=function(t){return c(this,t)},n.loadSVG=async function(n,r,i){try{let t;if(typeof request==`function`){let{data:r}=await request(n,`text`);t=r}else{let r=await fetch(n);if(!r.ok)throw Error(`Failed to load SVG: ${n}`);t=await r.text()}let i=c(this,t),a=()=>r?r(i):i;return this._internal?this._internal(a):a()}catch(r){if(typeof t._friendlyFileLoadError==`function`&&t._friendlyFileLoadError(1,n),typeof i==`function`)return i(r);throw r}}}typeof p5<`u`&&p5.registerAddon(kw);function Aw(t,n,r){yw(t,n,r),kw(t,n,r);for(let r of[`createSVG`,`loadSVG`,`createShape`,`buildShape`,`getSVG`,`shape`,`saveSVG`])n[r]&&t.registerDecorator(`p5.prototype.${r}`,ds(`p5.svg`,t))}xl(_l),Ol(_l),kl(_l),typeof IS_MINIFIED>`u`&&l_(_l),d_(_l),p_(_l),v_(_l),y_(_l),w_(_l),N_(_l),L_(_l),kS(_l),AS(_l),_l.registerAddon(bs),_l.registerAddon(lw),_l.registerAddon(Aw),(()=>{if(typeof document<`u`)return new Promise((t,n)=>{document.readyState===`complete`?t():window.addEventListener(`load`,t,!1)})})().then(()=>{if(typeof window<`u`){if(window._setupDone!==void 0)console.warn(`p5.js seems to have been imported multiple times. Please remove the duplicate import`);else if(!window.mocha){let t=new Event(`p5Ready`);window.dispatchEvent(t),(window.setup&&typeof window.setup==`function`||window.draw&&typeof window.draw==`function`)&&!_l.instance&&new _l}}});var jw=_l;export{jw as default};